zookeeper集群安裝
(集群安裝測(cè)試時(shí)以ip為例說(shuō)明偷厦,正式上線(xiàn)后可以配主機(jī)名稱(chēng))
1)解壓zookeeper安裝包
tar -zxvfzookeeper-3.4.5.tar.gz
2)進(jìn)入zookeeper-3.4.5文件夾,創(chuàng)建data和log
創(chuàng)建目錄并賦于寫(xiě)權(quán)限
指定zookeeper的數(shù)據(jù)存放目錄和日志目錄
3)拷貝zookeeper配制文件zoo_sample.cfg
拷貝zookeeper配制文件zoo_sample.cfg并重命名zoo.cfg
cp /solrcloud/zookeeper-3.4.5/conf/zoo_sample.cfg/solrcloud/zookerper-3.4.5/conf/zoo.cfg
4)修改zoo.cfg
加入dataDir=/solrcloud/zookeeper-3.4.5/data
dataLogDir=/solrcloud/zookeeper-3.4.5/log
server.1=192.168.56.11:2888:3888
server.2=192.168.56.12:2888:3888
server.3=192.168.56.13:2888:3888
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=/solrcloud/zookeeper-3.4.5/data
dataLogDir=/solrcloud/zookeeper-3.4.5/log
# the port at which the clients will connect
clientPort=2181
#
# 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=192.168.56.11:2888:3888
server.2=192.168.56.12:2888:3888
server.3=192.168.56.13:2888:3888
5)進(jìn)入data文件夾建立對(duì)應(yīng)的myid文件
例如server.1=192.168.56.11 data文件夾下的myid文件內(nèi)容為1
6)制zookeeper-3.4.5文件夾到其他機(jī)器
將data文件夾下的myid修改為對(duì)應(yīng)的server.【序號(hào)】
7)開(kāi)啟zookeeper的端口
/sbin/iptables -I INPUT -p tcp --dport 2181-j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 2888-j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 3888-j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 8080
-j ACCEPT--順便啟用tomcat 8080端口
/etc/rc.d/init.d/iptables save#將更改進(jìn)行保存
/etc/init.d/iptables restart#重啟防火墻以便改動(dòng)生效
8)啟動(dòng)zookeeper
進(jìn)入bin
./zkServer.sh start
查看集群狀態(tài)
./zkServer.sh status剛啟動(dòng)可能會(huì)有錯(cuò)誤,集群中其他節(jié)點(diǎn)一并起來(lái)后就正常了
./zkCli.sh?
ls /等命令可以查看zookeeper上面的文件穆趴。
例如: ls /live_nodes 查看各節(jié)點(diǎn)存活情況
rmr 可以刪除文件