zookeeper集群搭建和说明
2017-04-18
阅读数:215
现假设要在3台服务器上搭建zookeeper集群,分别为
既然前篇博文提到有关zookeeper的使用的说明,且现在生产环境基本上zookeeper都是以集群的方式被使用着,不完善一篇zookeeper集群的安装博文岂不显得很不协调,然后就有了本文的废话。
192.168.2.220
192.168.2.221
192.168.2.222
在每台服务器上先装好zookeeper
wget tar zxf zookeeper-3.4.8.tar.gz cd zookeeper-3.4.8/src/c ./configure --prefix=/usr/local/zookeeper-3.4.8/ make && make install
修改配置文件
cp /usr/local/zookeeper-3.4.8/conf/zoo_sample.cfg /usr/local/zookeeper-3.4.8/conf/zoo.cfg vim /usr/local/zookeeper-3.4.8/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=/data/zookeeper/data dataLogDir=/data/zookeeper/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.220=192.168.2.220:2888:3888 server.221=192.168.2.221:2888:3888 server.222=192.168.2.222:2888:3888
务必确认3台服务器上的配置文件内容一致,配置完成将3台服务器的zookeeper启动:
/usr/local/zookeeper-3.4.8/bin/zkServer.sh start
因为zookeeper的启动是通过nohup方式运行的,所以期间会产生一个zookeeper.out的文件,该文件会逐渐增大,所以需要指定到空间富余的磁盘上,zookeeper的实际启动命令在zkServer.sh中有,根据shell命令修改路径即可。
如果在zookeeper长时间运行后才留意到zookeeper.out这个文件快要将磁盘撑满了,不用慌,删掉就行,不过直接的rm -f不能达到目的,必须将zookeeper服务停掉才能释放空间,现告知一个不用停止服务也能清掉zookeeper.out文件的方法:
#第一种方法(推荐) cp /dev/null zookeeper.out #第二种方法 cat /dev/null zookeeper.out
完事了,附上zookeeper客户端控制台的操作说明:http://blog.dongguagua.com/Index/detail/Id/17.html
前方10米有沙发可抢!
大人,请先右上角登个录 ↑