zookeeper,kafka,redis 集群环境搭建

高并发之环境搭建

zookeeper集群,kafka集群,redis集群的搭建

zookeeper集群

下载zookeeper

下载地址:https://www.apache.org/dyn/closer.cgi/zookeeper/
选择相应镜像地址,然后选择zookeeper版本,已3.4.10为例
下载成功后,执行命令,完成解压缩

tar -xvf zookeeper-3.4.10.tar.gz

zookeeper配置

Zookeeper推荐使用集群模式,且推荐使用奇数台实例部署(zookeeper特性:集群中只要有过半的机器是正常工作的,那么整个集群对外就是可用的,对于集群部署2n或2n-1个zookeeper实例,对实例宕机数量的容忍度是一样的,都是n-1。所以为了更加高效和节省资源,推荐奇数台实例部署模式)。在这里,采用3台实例部署为例(ip地址为172.21.133.38,172.21.133.39,172.21.133.40)。

首先配置第一个zookeeper实例,ip地址为172.21.133.38,进入zookeeper下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=/home/xw/zookeeper-3.4.10/data/data
dataLogDir=/home/xw/zookeeper-3.4.10/data/log

# 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.1=172.21.133.38:2889:3889
server.2=172.21.133.39:2889:3889
server.3=172.21.133.40:2889:3889
参数说明
  1. tickTime:zookeeper中使用的基本时间单位, 毫秒值.
  2. initLimit:zookeeper集群中的包含多台server, 其中一台为leader, 集群中其余的server为follower. initLimit参数配置初始化连接时, follower和leader之间的最长同步等待初始化时间. 此时该参数设置为10, 说明时间限制为10倍tickTime, 即10*2000=20000ms=20s.
  3. syncLimit:该参数配置Zookeeper集群中leader实例和follower实例之间发送消息, 请求和应答的最大时间长度. 此时该参数设置为5, 说明时间限制为5倍tickTime, 即10000ms=10s.
  4. dataDir:数据目录. 可以是任意目录。设置为/home/xw/zookeeper-3.4.10/data/data,即当前zookeeper安装目录下的/data/data目录。
  5. dataLogDir:log目录, 同样可以是任意目录. 如果没有设置该参数, 将使用和dataDir相同的设置。设置为/home/xw/zookeeper-3.4.10/data/log,即当前zookeeper安装目录下的/data/log目录。
  6. clientPort:监听client连接的端口号.在集群模式中,各个实例的clientPort必须不同。但在集群模式中,建议相同,均配置为2181。
  7. server.X=A:B:C 其中X是一个数字, 表示这是第几号server。 A是该server所在的IP地址。 B配置该server和集群中的leader交换消息所使用的端口。 C配置选举leader时所使用的端口。由于配置的是集群模式,推荐使用相同的port。
  8. myid文件:在集群模式和集群模式中,需要在刚刚设置的dataDir目录下,创建一个myid文件,输入对应唯一标识号。如刚刚设置的Zookeeper为集群中第一台,即设置myid中值为1。该数字必须和zoo.cfg文件中的server.X中的X一一对应。

第二,三台zk配置

由于采用了3台实例部署(ip地址为172.21.133.38,17

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值