问题描述
我是Docker和nosql的新手,我在Windows机器上创建了一个Oracle Linux VM(ipAddr 192.168.10.2)。
I am new to Docker and nosql, I created a Oracle Linux VM (ipAddr 192.168.10.2) on my windows machine.
此外,我创建了docker容器这个VM)用于kvlite并运行我的nosql-container,如下所示:
Further I created docker container (on this VM ) for kvlite and run my nosql-container as below:
$ docker run --name nosql-container -p 5000:5000 -d kvlite:最新
后面是以下命令:
$ docker exec -it nosql-容器bash
#java -jar lib / kvcli.jar -host localhost -port 5000
kv-> connect store -host localhost -port 5000 -name kvstore;
我相信我的Docker容器可以正常运行。
This works fine till here and I believe my Docker container for kvlite is up and running fine.
现在我需要从我的Windows机器创建一个客户端Java程序来访问这个kvlite(在docker运行VM上的容器)
要完成我下载的 kvclient.jar 文件,并将其放在我的类路径中。
Now I need to create a Client Java program from my windows machine to access this kvlite (running in docker container on a VM)To accomplish I downloaded kvclient.jar file and put that in my classpath.
下面的Java代码片段:
The Java code-snippet below:
KVStore store = KVStoreFactory.getStore(new KVStoreConfig("kvstore", "192.168.10.2:5000"));
这会引发一个例外:
oracle.kv.FaultException:无法联系任何RepNode:[192.168.10.2:5000](12.1.4.0.9)
oracle.kv.FaultException: Could not contact any RepNode at: [192.168.10.2:5000] (12.1.4.0.9)
....
导致:java.rmi.UnknownHostException:未知主机:ecfe59938ea4;嵌套异常是:
Caused by: java.rmi.UnknownHostException: Unknown host: ecfe59938ea4; nested exception is:
任何帮助都提前感谢。
推荐答案
我通过在运行nosql-container
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
现在,而不是IPAddress,您可以使用Java Client代码中的VM主机名来访问kvlite DB。
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"));
这篇关于Docker - oracle.kv.FaultException:无法联系任何RepNode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!