1.需求
安装ZooKeeper
2.下载
http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.8/
当前stable版是zookeeper-3.4.8
3.解压
上传到/usr/local路径下
tar –xf zookeeper-3.4.8.tar.gz
解压文件到"/usr/local/zookeeper-3.4.8".
4.复制conf目录下的zoo_sample.cfg,并命名为zoo.cfg
5.修改zoo.cfg配置文件
# The number of millisecondsof each tick
tickTime=2000
# The number of ticks thatthe initial
# synchronization phase cantake
initLimit=10
# The number of ticks thatcan pass between
# sending a request andgetting an acknowledgement
syncLimit=5
# the directory where thesnapshot is stored.
# do not use /tmp forstorage, /tmp here is just
# example sakes.
dataDir=/data/zookeeper/data
dataLogDir=/data/zookeeper/logs
# the port at which theclients will connect
clientPort=2181
# the maximum number ofclient connections.
# increase this if you needto handle more clients
#maxClientCnxns=60
#
# Be sure to read themaintenance section of the
# administrator guide beforeturning on autopurge.
#
#http://zookeeper.apache.org/doc/ ... html#sc_maintenance
#
# The number of snapshots toretain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval inhours
# Set to "0" todisable auto purge feature
#autopurge.purgeInterval=1
启动:
cd/usr/local/zookeeper-3.4.8/bin
./zkServer.sh start
查看状态:
cd/usr/local/zookeeper-3.4.8/bin
./zkServer.shstatus
启动客户端
cd/usr/local/zookeeper-3.4.8/bin
./zkCli.sh -server 127.0.0.1:2181
停止zookeeper进程:
cd/usr/local/zookeeper-3.4.8/bin
./zkServer.shstop
修改防火墙:
在开启了防火墙时,如果用java客户端连接时,会报连接失败错误,做如下设置,开启相关端口,
修改/etc/sysconfig/iptables 文件,添加以下内容:
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2181 -j ACCEPT
修改完后,重启防火墙:
service iptables stop
service iptables start