Linux Centos7 Zookeeper安转(集群)

Zookeeper安装(集群)

以三个虚拟机为例创建集群
Zookeeper集群节点数量要是奇数

准备工作

  1. 修改主机名hostname
  2. 修改IP地址
  3. 修改hosts映射
  4. 关闭防火墙
  5. 免密登录(非对称单向登录)
  6. jdk安转

Zookeeper安装(单个节点配置)

上传Zookeeper.tar.gz 到Linux(推荐使用Xftp 4)

解压到/export/server (自定义目录方便查找)

  1. 对解压后的文件进行改名 去除版本号(方便使用)

修改zookeeper文件中的zoo_sample.cfg为 zoo.cfg(方便使用)

环境变量配置

编辑 .bashrc 文件, 在文件末尾添加以下环境变量配置:
ZooKeeper Env
export ZOOKEEPER_HOME=/opt/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin

配置zoo.cfg(重点)

  1. dataDir配置路径进行修改

    1. 该配置项用于配置zookeeper快照日志和事务日志的存储地址
    2. /export/data/zkdata (自定义路径)
  2. 在文件末尾添加 server.id=host:port:port

    1. 示例
      server.1=master:2888:3888
      server.2=slave01:2888:3888
      server.3=slave02:2888:3888
      
    2. Server ID, 用来标识服务器在集群中的序号
      ZooKeeper 集群中, 每台服务器上的 zoo.cfg 配置文件内容一致。

  3. 创建myid文件(识别服务器)

    1. echo 1 > /export/data/zkdata/myid
    2. 也可以使用vim 进行修改

如下

# 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=/export/data/zkdata
# 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=master:2888:3888
server.2=slave01:2888:3888
server.3=slave02:2888:3888

剩余节点配置

最后将修改好的zookeeper文件 使用 scp命令复制到剩下两个节点中
在/export/server路径下执行

  • scp -r zookeeper/ root@node2:$PWD
  • 或者 scp -r zookeeper/ root@node2:/export/server

修改myid

  • echo 2 > /export/data/zkdata/myid
  • echo 3 > /export/data/zkdata/myid

初次写,如有错误,还请指正

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值