cookeem / kubernetes-zookeeper-cluster

How to deploy zookeeper cluster on kubernetes
21 stars 24 forks source link

Unable to connect to server: zk2:2181 #1

Open mrhjx2 opened 6 years ago

mrhjx2 commented 6 years ago

2018-06-29 02:46:47,330 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/usr/lib/jvm/java-1.8-openjdk/jre 2018-06-29 02:46:47,331 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/zookeeper-3.4.12/bin/../build/classes:/zookeeper-3.4.12/bin/../build/lib/.jar:/zookeeper-3.4.12/bin/../lib/slf4j-log4j12-1.7.25.jar:/zookeeper-3.4.12/bin/../lib/slf4j-api-1.7.25.jar:/zookeeper-3.4.12/bin/../lib/netty-3.10.6.Final.jar:/zookeeper-3.4.12/bin/../lib/log4j-1.2.17.jar:/zookeeper-3.4.12/bin/../lib/jline-0.9.94.jar:/zookeeper-3.4.12/bin/../lib/audience-annotations-0.5.0.jar:/zookeeper-3.4.12/bin/../zookeeper-3.4.12.jar:/zookeeper-3.4.12/bin/../src/java/lib/.jar:/conf: 2018-06-29 02:46:47,331 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64:/usr/lib/jvm/java-1.8-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 2018-06-29 02:46:47,331 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp 2018-06-29 02:46:47,331 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler= 2018-06-29 02:46:47,331 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux 2018-06-29 02:46:47,331 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64 2018-06-29 02:46:47,331 [myid:] - INFO [main:Environment@100] - Client environment:os.version=3.10.0-693.21.1.el7.x86_64 2018-06-29 02:46:47,331 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root 2018-06-29 02:46:47,331 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root 2018-06-29 02:46:47,332 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/zookeeper-3.4.12 2018-06-29 02:46:47,334 [myid:] - INFO [main:ZooKeeper@441] - Initiating client connection, connectString=zk2:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@446cdf90 2018-06-29 02:46:47,343 [myid:] - ERROR [main:StaticHostProvider@83] - Unable to connect to server: zk2:2181 java.net.UnknownHostException: zk2: Name does not resolve at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method) at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928) at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323) at java.net.InetAddress.getAllByName0(InetAddress.java:1276) at java.net.InetAddress.getAllByName(InetAddress.java:1192) at java.net.InetAddress.getAllByName(InetAddress.java:1126) at org.apache.zookeeper.client.StaticHostProvider.(StaticHostProvider.java:62) at org.apache.zookeeper.ZooKeeper.(ZooKeeper.java:449) at org.apache.zookeeper.ZooKeeperMain.connectToZK(ZooKeeperMain.java:283) at org.apache.zookeeper.ZooKeeperMain.(ZooKeeperMain.java:297) at org.apache.zookeeper.ZooKeeperMain.main(ZooKeeperMain.java:290) Exception in thread "main" java.lang.IllegalArgumentException: A HostProvider may not be empty! at org.apache.zookeeper.client.StaticHostProvider.(StaticHostProvider.java:88) at org.apache.zookeeper.ZooKeeper.(ZooKeeper.java:449) at org.apache.zookeeper.ZooKeeperMain.connectToZK(ZooKeeperMain.java:283) at org.apache.zookeeper.ZooKeeperMain.(ZooKeeperMain.java:297) at org.apache.zookeeper.ZooKeeperMain.main(ZooKeeperMain.java:290)

I get a error logs but nodes is runing

cookeem commented 6 years ago

The service name should be zk-2 not zk2.

2018-06-29 02:46:47,343 [myid:] - ERROR [main:StaticHostProvider@83] - Unable to connect to server: zk2:2181
mrhjx2 commented 6 years ago

I try to find zk2 in my config but there's no zk2 word in my deployment and service config file zk-service.yaml kind: Service apiVersion: v1 metadata: name: zk-1 labels: app: zk node: node1 spec: type: LoadBalancer ports:


kind: Service apiVersion: v1 metadata: name: zk-2 labels: app: zk node: node2 spec: type: LoadBalancer ports:


kind: Deployment apiVersion: extensions/v1beta1 metadata: name: zk-1 spec: replicas: 1 template: metadata: labels: app: zk node: node1 spec: hostname: zk-1 volumes:


kind: Deployment apiVersion: extensions/v1beta1 metadata: name: zk-2 spec: replicas: 1 template: metadata: labels: app: zk node: node2 spec: hostname: zk-2 volumes: