1.zookeeper下载地址
https://archive.apache.org/dist/zookeeper/
# 解压
[root@localhost soft]# tar -zxvf zookeeper-3.4.9.tar.gz
# 移动到自己以为合适的位置
# 环境变量配置
[root@localhost soft]# vi /etc/profile
# zookeeper
export ZOOKEEPER_HOME=/home/test/soft/zookeeper
export PATH=$PATH:${ZOOKEEPER_HOME}/bin
# 配置文件生效
[root@localhost soft]# source /etc/profile
# 修改zookeeper配置文件
[root@localhost zookeeper]# cd conf/
[root@localhost conf]# ll
总用量 12
-rw-rw-r--. 1 1001 1001 535 8月 23 2016 configuration.xsl
-rw-rw-r--. 1 1001 1001 2161 8月 23 2016 log4j.properties
-rw-rw-r--. 1 1001 1001 922 8月 23 2016 zoo_sample.cfg
[root@localhost conf]# mv zoo_sample.cfg zoo.cfg
# The number of milliseconds of each tick
# 用于计算的时间单元,以毫秒为单位,例如session超时:N*tickTime
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
# 用于集群,运行从节点链接并同步到master节点的初始化连接时间,已tickTime的倍数来表示
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
# 用于集群,master节点与从节点之间发送消息,请求和答应时间长度(心跳机制)
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
# 存放数据文件夹
dataDir=/home/test/soft/zookeeper/data
# 存放日志文件夹,事务日志目录,不配置则和dataDir共用
dataLogDir=/home/test/soft/zookeeper/dataLog
# the port at which the clients will connect
# 连接服务器的端口,默认2181
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
# zookeeper服务管理
zkServer.sh start|stop|restart|status
[root@localhost bin]# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /home/test/soft/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@localhost bin]#
# 测试连接
[root@localhost bin]# ./zkCli.sh -server 192.168.2.3:2181
Connecting to 192.168.2.3:2181
2022-06-12 10:31:29,136 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.9-1757313, built on 08/23/2016 06:50 GMT
2022-06-12 10:31:29,138 [myid:] - INFO [main:Environment@100] - Client environment:host.name=localhost
2022-06-12 10:31:29,138 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_202
2022-06-12 10:31:29,139 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2022-06-12 10:31:29,139 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/usr/local/jdk1.8.0_202/jre
2022-06-12 10:31:29,139 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/home/test/soft/zookeeper/bin/../build/classes:/home/test/soft/zookeeper/bin/../build/lib/*.jar:/home/test/soft/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/home/test/soft/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/home/test/soft/zookeeper/bin/../lib/netty-3.10.5.Final.jar:/home/test/soft/zookeeper/bin/../lib/log4j-1.2.16.jar:/home/test/soft/zookeeper/bin/../lib/jline-0.9.94.jar:/home/test/soft/zookeeper/bin/../zookeeper-3.4.9.jar:/home/test/soft/zookeeper/bin/../src/java/lib/*.jar:/home/test/soft/zookeeper/bin/../conf:.:/usr/local/jdk1.8.0_202/jre/lib/rt.jar:/usr/local/jdk1.8.0_202/lib/dt.jar:/usr/local/jdk1.8.0_202/lib/tools.jar
2022-06-12 10:31:29,139 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2022-06-12 10:31:29,139 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2022-06-12 10:31:29,139 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=<NA>
2022-06-12 10:31:29,139 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux
2022-06-12 10:31:29,139 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64
2022-06-12 10:31:29,139 [myid:] - INFO [main:Environment@100] - Client environment:os.version=3.10.0-1127.el7.x86_64
2022-06-12 10:31:29,140 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root
2022-06-12 10:31:29,140 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root
2022-06-12 10:31:29,140 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/home/test/soft/zookeeper/bin
2022-06-12 10:31:29,140 [myid:] - INFO [main:ZooKeeper@438] - Initiating client connection, connectString=192.168.2.3:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@506c589e
Welcome to ZooKeeper!
2022-06-12 10:31:29,185 [myid:] - INFO [main-SendThread(192.168.2.3:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server 192.168.2.3/192.168.2.3:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2022-06-12 10:31:29,274 [myid:] - INFO [main-SendThread(192.168.2.3:2181):ClientCnxn$SendThread@876] - Socket connection established to 192.168.2.3/192.168.2.3:2181, initiating session
[zk: 192.168.2.3:2181(CONNECTING) 0] 2022-06-12 10:31:29,411 [myid:] - INFO [main-SendThread(192.168.2.3:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server 192.168.2.3/192.168.2.3:2181, sessionid = 0x18155bf16b00000, negotiated timeout = 30000
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
# 退出
CTRL+c