Zookeeper搭建集群

来源:互联网 发布:苏州淘宝美工培训 编辑:程序博客网 时间:2024/04/28 03:29

## Zookeeper搭建集群 ##
1.准备
操作系统:CentOS-7
环境:JDK8
安装包:zookeeper-3.4.10.tar
2.搭建zookeeper集群
1)解压二进制包

# tar zxvf zookeeper-3.4.9.tar.gz# mv zookeeper-3.4.9 zookeeper

2)拷贝配置文件

# cd zookeeper# cd conf# cp zoo_sample.cfg zoo.cfg

这里写图片描述
3)配置

# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial # synchronization phase can takeinitLimit=10# The number of ticks that can pass between # sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just # example sakes.//新增配置(以下路径是手动新建的)dataDir=/root/zookeeper/datadataLogDir=/root/zookeeper/logs# the port at which the clients will connectclientPort=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.0=192.168.6.128:4001:4002server.1=192.168.6.129:4001:4002server.2=192.168.6.130:4001:4002

3.创建myid文件
分别在三台主机的 dataDir 路径下创建一个文件名为 myid 的文件,文件内容为该 zk 节点的编号。例如,在第一台主机上建立的 myid 文件内容是 0,第二台是 1。
4.启动zookeeper

# cd bin# ./zkServer.sh start

这里写图片描述
5.查看zookeeper服务

# cd bin# ./zkServer.sh status

这里写图片描述
说明集群搭建完毕

原创粉丝点击