# 需要修改的文件
dataDir=/opt/zookeeper-3.4.14/data
dataLogDir=/opt/zookeeper-3.4.14/log
server.1=192.168.129.200:2888:3888
server.2=192.168.129.201:2888:3888
server.3=192.168.129.202:2888:3888
使用scp将修改完的zoo.cfg文件赋值到其它两台主机conf目录下
scp zoo.cfg root@node1:/opt/zookeeper-3.4.14/conf/
zookeeper
环境变量
ZOOKEEPER_HOME=/opt/zookeeper-3.4.14 PATH=$PATH:$ZOOKEEPER_HOME/bin# 三台都需要执行
/opt/zookeeper-3.4.14/bin
zkServer.sh status # 查看状态
zkServer.sh start # 启动zookeeper服务
####################################
zkCli.sh # 启动zookeeper工具,任意一台机器执行
# DEMO
[root@hservice bin]# zkServer.sh
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.14/bin/../conf/zoo.cfg
Usage: /opt/zookeeper-3.4.14/bin/zkServer.sh {start|start-foreground|stop|restart|status|upgrade|print-cmd}
[root@hservice bin]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.14/bin/../conf/zoo.cfg
Mode: follower
[root@hservice bin]# zkCli.sh
Connecting to localhost:2181
2019-09-29 20:24:46,132 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.14-4c25d480e66aadd371de8bd2fd8da255ac140bcf, built on 03/06/2019 16:18 GMT
2019-09-29 20:24:46,136 [myid:] - INFO [main:Environment@100] - Client environment:host.name=hservice
2019-09-29 20:24:46,136 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_181
2019-09-29 20:24:46,138 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2019-09-29 20:24:46,138 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/opt/jdk1.8.0_181/jre
2019-09-29 20:24:46,138 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/opt/zookeeper-3.4.14/bin/../zookeeper-server/target/classes:/opt/zookeeper-3.4.14/bin/../build/classes:/opt/zookeeper-3.4.14/bin/../zookeeper-server/target/lib/*.jar:/opt/zookeeper-3.4.14/bin/../build/lib/*.jar:/opt/zookeeper-3.4.14/bin/../lib/slf4j-log4j12-1.7.25.jar:/opt/zookeeper-3.4.14/bin/../lib/slf4j-api-1.7.25.jar:/opt/zookeeper-3.4.14/bin/../lib/netty-3.10.6.Final.jar:/opt/zookeeper-3.4.14/bin/../lib/log4j-1.2.17.jar:/opt/zookeeper-3.4.14/bin/../lib/jline-0.9.94.jar:/opt/zookeeper-3.4.14/bin/../lib/audience-annotations-0.5.0.jar:/opt/zookeeper-3.4.14/bin/../zookeeper-3.4.14.jar:/opt/zookeeper-3.4.14/bin/../zookeeper-server/src/main/resources/lib/*.jar:/opt/zookeeper-3.4.14/bin/../conf:.:/opt/jdk1.8.0_181/lib/tools.jar:/opt/jdk1.8.0_181/jre/rt.jar
2019-09-29 20:24:46,138 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2019-09-29 20:24:46,138 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2019-09-29 20:24:46,139 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=<NA>
2019-09-29 20:24:46,139 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux
2019-09-29 20:24:46,141 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64
2019-09-29 20:24:46,142 [myid:] - INFO [main:Environment@100] - Client environment:os.version=3.10.0-862.el7.x86_64
2019-09-29 20:24:46,142 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root
2019-09-29 20:24:46,142 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root
2019-09-29 20:24:46,142 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/opt/zookeeper-3.4.14/bin
2019-09-29 20:24:46,143 [myid:] - INFO [main:ZooKeeper@442] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@255316f2
2019-09-29 20:24:46,175 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1025] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
Welcome to ZooKeeper!
JLine support is enabled
2019-09-29 20:24:46,440 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@879] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2019-09-29 20:24:46,458 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x6d7c4873940004, negotiated timeout = 30000
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0] ls /
[zookeeper, hbase]
[zk: localhost:2181(CONNECTED) 1]