安裝包放置在 /usr/myapp
cd /usr/myApp/
tar -zxf zookeeper-3.4.9.tar.gz
cd /usr/myApp/zookeeper-3.4.9
1.3 配置
在主目錄下創(chuàng)建data和logs兩個(gè)目錄用于存儲(chǔ)數(shù)據(jù)和日志:
cd /usr/myApp/zookeeper-3.4.9
mkdir data
mkdir logs
3.1 conf/zoo.cfg文件修改
三個(gè)zookeeper的conf/zoo.cfg修改如下:
The number of milliseconds of each tick
tickTime=2000
The number of ticks that the initial
synchronization phase can take
initLimit=10
The number of ticks that can pass between
sending a request and getting an acknowledgement
syncLimit=5
the directory where the snapshot is stored.
do not use /tmp for storage, /tmp here is just
example sakes.
dataDir=/usr/myapp/zookeeper-3.4.9/data
dataLogDir=/usr/myapp/zookeeper-3.4.9/logs
the port at which the clients will connect
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
server.1=ip1:2888:3888
server.2=ip2:2888:3888
server.3=ip3:2888:3888
cd /usr/myApp/zookeeper-3.4.9
機(jī)器1echo '1' > data/myid
機(jī)器2echo '2' > data/myid
機(jī)器3echo '3' > data/myid
進(jìn)入bin目錄更米,啟動(dòng)撒轮、停止浇揩、重啟分和查看當(dāng)前節(jié)點(diǎn)狀態(tài)(包括集群中是何角色)別執(zhí)行:
sh ./zkServer.sh start /usr/myApp/zookeeper-3.4.9/conf/zoo.cfg
./zkServer.sh stop
./zkServer.sh restart
./zkServer.sh status