我要在我的集装箱上安装Zookeeper。
我所做的是:
root@46966b33c3a1:/opt:> wget https://downloads.apache.org/zookeeper/zookeeper-3.6.2/apache-zookeeper-3.6.2-bin.tar.gz
root@46966b33c3a1:/opt:> tar zxf apache-zookeeper-3.6.2-bin.tar.gz
root@46966b33c3a1:/opt:> cd apache-zookeeper-3.6.2-bin
root@46966b33c3a1:/opt/apache-zookeeper-3.6.2-bin:> cp conf/zoo_sample.cfg conf/zoo.cfg
root@46966b33c3a1:/opt/apache-zookeeper-3.6.2-bin:> vi conf/zoo.cfg
root@46966b33c3a1:/opt/apache-zookeeper-3.6.2-bin:> ./bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/apache-zookeeper-3.6.2-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
zoo.cfg
tickTime=2000
dataDir=/opt/apache-zookeeper-3.6.2-bin/data
clientPort=2181
initLimit=5
syncLimit=2
看起来zk服务器启动没有问题。
但是,当我尝试连接到zk CLI时,出现错误:
2021-02-09 22:59:16,920 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1167] - Opening socket connection to server localhost/127.0.0.1:2181.
2021-02-09 22:59:16,921 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1169] - SASL config status: Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2021-02-09 22:59:17,001 [myid:localhost:2181] - WARN [main-SendThread(localhost:2181):ClientCnxn$SendThread@1285] - Session 0x0 for sever localhost/127.0.0.1:2181, Closing socket connection. Attempting reconnect except it is a SessionExpiredException.
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:344)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1275)
所以,我检查了2181端口的连接。
root@46966b33c3a1:/opt/apache-zookeeper-3.6.2-bin:> telnet localhost 2181
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
Trying ::1...
telnet: connect to address ::1: Network is unreachable
root@46966b33c3a1:/opt/apache-zookeeper-3.6.2-bin:> hostname -i
172.17.0.2
root@46966b33c3a1:/opt/apache-zookeeper-3.6.2-bin:> telnet 172.17.0.2 2181
Trying 172.17.0.2...
telnet: connect to address 172.17.0.2: Connection refused
连接被拒绝。
如何解决此问题?
1条答案
按热度按时间swvgeqrz1#
您可以使用zookeeper official docker image。您可以使用docker-compose代替在docker中手动安装zookeeper。以下是一个docker-compose文件示例。您可以根据需要修改文档中的其他配置。