centos7部署zookeeper集群

zookeeper集群的搭建

环境:
centos7 hmaster 192.168.0.107
centos7 hnode1 192.168.0.108
centos7 hnode2 192.168.0.109
版本:zookeeper-3.8.0
myid配置:
192.168.0.107 1
192.168.0.108 2
192.168.0.109 3

1.下载安装包

https://dlcdn.apache.org/zookeeper/zookeeper-3.8.0/apache-zookeeper-3.8.0-bin.tar.gz

2.解压并进行配置文件的修改

将压缩包放在/usr/local/lib/目录下

cd /usr/local/lib/
tar -zxvf  apache-zookeeper-3.8.0-bin.tar.gz
cd apache-zookeeper-3.8.0-bin
mkdir data
cd conf
cp zoo_sample.cfg zoo.cfg
vim zoo.cfg

添加集群的节点ip和端口,并配置dataDir
server.1=192.168.0.107:2888:3888
server.2=192.168.0.108:2888:3888
server.3=192.168.0.109:2888:3888
dataDir=/usr/local/lib/apache-zookeeper-3.8.0-bin/data
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=/usr/local/lib/apache-zookeeper-3.8.0-bin/data
# 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.
#
# https://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

## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpHost=0.0.0.0
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
server.1=192.168.0.107:2888:3888
server.2=192.168.0.108:2888:3888
server.3=192.168.0.109:2888:3888

3.创建myid

myid的值是zoo.cfg文件里定义的server.A项A的值,三台机器分别为1,2,3

cd ../data
vim myid

4.配置环境变量

vim /etc/profile
export ZOOKEEPER_HOME=/usr/local/lib/apache-zookeeper-3.8.0-bin
export PATH=$PATH:$ZOOKEEPER_HOME/bin
source /etc/profile

5.启动zookeeper

#测试环境变量
echo $ZOOKEEPER_HOME
# 启动集群,每台机器都要启动
zkServer.sh start   
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值