Skip to Main Content

NoSQL Database

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

java -jar lib/kvstore.jar ping - ConnectException when using IPAddress

714047Oct 21 2016 — edited Oct 26 2016

0down votefavori

I created a Oracle Linux VM (ipAddr 192.168.10.2) on my windows machine.

On this VM I further created a kvlite docker container.

In Dockerfile following is CMD issued:

CMD ["java", "-jar", "lib/kvstore.jar", "kvlite"] 

Once kvlite docker container was created I ran following commands on my VM:

$ docker run --name nosql-container -d kvlite:latest

$ docker exec -it nosql-container bash

On the container bash prompt I try to ping my client using following command (but using VM IpAddress and not localhost):

# java -jar lib/kvstore.jar ping -port 5000 -host 192.168.10.2 

This however throws an exception

Picked up _JAVA_OPTIONS: -Djava.security.egd=file:/dev/./urandom

Could not connect to registry at 192.168.10.2:5000 Unable to connect to the storage node agent at host 192.168.10.2, port 5000, which may not be running; nested exception is:

java.rmi.ConnectException: Connection refused to host: 192.168.10.2; nested exception is:

java.net.ConnectException: Connection refused

Can't find store topology: Could not contact any RepNode at: [192.168.10.2:5000]

But, things works fine when I use -host as localhost instead i.e.,

# java -jar lib/kvstore.jar ping -port 5000 -host localhost 

To resolve this issue I tried following:

  • I stopped my kvlite docker container
  • Changed config.xml ($KVROOT/config.xml) for value hostname to IpAddress
  • Re-Started my kvlite docker container, but this didn't helped, container couldn't start

Next I tried to re-create a new docker image for kvlite issuing below CMD:

CMD ["java", "-jar", "lib/kvstore.jar", "kvlite", "-host", "192.168.10.2", "-port", "5000"] 

But here also when I tried starting kvlite docker container, it didn't start.

I even verified my /etc/hosts file for entry of IpAddress-192.168.10.2.

Any help appreciated in advance.

This post has been answered by 714047 on Oct 26 2016
Jump to Answer

Comments

Preetam Shetty-Oracle

The IP address for the docker container running the store is different. To get the container ip address, do the following:

Get the docker container ip address. Issue this command immediately after creating the container : docker inspect nosql-container | grep -i ipadd

You can then ping the store using the container IP address:

docker run --name nosql-container -d kvlite:latest

docker exec -it nosql-container bash

On the docker bash prompt, issue the following command:

java -jar lib/kvstore.jar ping -port 5000 -host <container_ip_address>

714047

Thanks for this info. Container IP Address is 172.17.0.2
But further I need to access this NoSQL db remotely from a Java Client (on my windows desktop).

The Java code-snippet below:

KVStore store = KVStoreFactory.getStore(new KVStoreConfig("kvstore", "192.168.10.2:5000"));

This throws an exception:
oracle.kv.FaultException: Could not contact any RepNode at: 192.168.10.2:5000
....
Caused by: java.rmi.UnknownHostException: Unknown host: ecfe59938ea4; nested exception is:

When I use container ip 172.17.0.2 instead, I still get UnknownHostException

Any help appreciated.

Preetam Shetty-Oracle

Can you ping the docker container (172.17.0.2) from your windows desktop?

714047

No I can't (172.17.0.2), but can ping "Gateway" i.e., "172.17.0.1",

$ ifconfig

docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

       inet 172.17.0.1  netmask 255.255.0.0  broadcast 0.0.0.0

        inet6 fe80::42:66ff:fe2d:1ad6  prefixlen 64  scopeid 0x20<link>

        ether 02:42:66:2d:1a:d6  txqueuelen 0  (Ethernet)

        RX packets 254  bytes 11787 (11.5 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 311  bytes 21929 (21.4 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

714047
Answer

I resolved the issue by adding a param --net=host when running nosql-container
$ docker run --name nosql-container --net=host -p 5000:5000 -d kvlite:latest

Now instead of IPAddress you can use VM hostname in Java Client code to access kvlite DB.
KVStore store = KVStoreFactory.getStore(new KVStoreConfig("kvstore", "VMHostname:5000"));

Marked as Answer by 714047 · Sep 27 2020
1 - 5
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 23 2016
Added on Oct 21 2016
5 comments
1,174 views