zookeeper集群

首先准备至少3台主机这里不是伪集群,如果想要伪集群的话自行修改端口号即可。

 

1. 下载zookeeper

http://zookeeper.apache.org/releases.html

 

2. 解压zookeeper 到指定的文件下

 tar -zxvf apache-zookeeper-3.5.6-bin.tar.gz -C /usr/local/

 

3.重新命名

cp -a apache-zookeeper-3.5.6-bin.tar zookeeper

 

4.切换到指定目录下

cd /usr/local/zookeeper/conf

#zookeeper/conf/zoo_sample.cfg拷贝一份命名为zoo.cfg cp zoo_sample.cfg zoo.cfg

 

 也放在conf目录下。然后按照如下值修改其中的配置:

 # The number of milliseconds of each tick

 

#CS通信心跳时间 tickTime=2000

# The number of ticks that the initial

# synchronization phase can take

 

#集群中的follower服务器(F)leader服务器(L)之间初始连接时能容忍的最多心跳数 initLimit=10

# The number of ticks that can pass between # sending a request and getting an acknowledgement

 

#集群中flower服务器(F)跟leaderL)服务器之间的请求和答应最多能容忍的心跳数。 syncLimit=5

# the directory where the snapshot is stored.

# do not use /tmp for storage, /tmp here is just

# example sakes.

 

#数据存放的文件夹 需创建 dataDir=/usr/local/zookeeper/data

#日志地址 需创建 dataLogDir=/usr/local/zookeeper/logs

# 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/ ... 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.31.143:2888:3888 server.2=192.168.31.144:2888:3888 server.3=192.168.31.145:2888:3888

 

创建目录

#创建文件夹mkdir -p cd /usr/local/zookeeper/data cd /usr/local/zookeeper/logs

 

注意:

dataDir,dataLogDir中的datalogs目录开始 是不存在,需要手动创建 并且在dataDir目录下创建文件myid 举列: mkdir -p /usr/local/zookeeper/data /usr/local/zookeeper/logs #创建myid文件初始内容为 1 echo 1 > /home/zookeeper/data/myid #每个zookeeper服务都要有对应的myid内容不要重复 #另外两台也是一样只需要修改对应的myidzookeeper-端口说明2181:对cline端提供服务 2888:集群内机器通讯使用(Leader监听此端口) 3888:选举leader使用

 

 

 

依次启动三台zookeeper

 

# 启动命令 在安装的bin目录里 zkServer.sh start # 查看节点状态 zkServer.sh status # 关闭 zkServer.sh stop # 连接 zkCli.sh -server [你的ip]:2181

 

posted @ 2020-09-17 13:28  RM-RF?  阅读(143)  评论(0)    收藏  举报