4、安装zookeeper群集
1)、安装zookeeper程序包
[root@localhost ~]# mkdir /usr/local/zookeeper01
[root@localhost ~]# mkdir /usr/local/zookeeper02
[root@localhost ~]# mkdir /usr/local/zookeeper03
[root@localhost ~]# wget http://apache.fayea.com/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
[root@localhost ~]# tar -zxvf zookeeper-3.4.6.tar.gz
[root@localhost ~]# cp zookeeper-3.4.6/* /usr/local/zookeeper01/
[root@localhost ~]# cp zookeeper-3.4.6/* /usr/local/zookeeper02/
[root@localhost ~]# cp zookeeper-3.4.6/* /usr/local/zookeeper03/
2)、修改配置文件
[root@localhost ~]# mkdir /usr/local/zookeeper01/data/
[root@localhost ~]# mkdir /usr/local/zookeeper02/data/
[root@localhost ~]# mkdir /usr/local/zookeeper03/data/
[root@localhost ~]# mkdir /usr/local/zookeeper01/logs/
[root@localhost ~]# mkdir /usr/local/zookeeper02/logs/
[root@localhost ~]# mkdir /usr/local/zookeeper03/logs/
[root@localhost ~]# touch /usr/local/zookeeper01/data/myid
[root@localhost ~]# touch /usr/local/zookeeper02/data/myid
[root@localhost ~]# touch /usr/local/zookeeper03/data/myid
[root@localhost ~]# echo 1 > /usr/local/zookeeper01/data/myid
[root@localhost ~]# echo 2 > /usr/local/zookeeper01/data/myid
[root@localhost ~]# echo 3 > /usr/local/zookeeper01/data/myid
[root@localhost ~]# mv /usr/local/zookeeper01/conf/zoo_sample.cfg /usr/local/zookeeper01/conf/zoo.cfg
[root@localhost ~]# mv /usr/local/zookeeper02/conf/zoo_sample.cfg /usr/local/zookeeper02/conf/zoo.cfg
[root@localhost ~]# mv /usr/local/zookeeper03/conf/zoo_sample.cfg /usr/local/zookeeper03/conf/zoo.c
fg
[root@localhost ~]# vi /usr/local/zookeeper01/conf/zoo.cfg
修改并追加以下内容:
clientPort=2181
#zookeeper02节点的这个位置为2182,zookeeper03节点的这个位置为2183
dataDir=/usr/local/zookeeper01/data
# zookeeper02和zookeeper03节点要修改成响应的目录。
dataLogDir=/usr/local/zookeeper01/logs
# zookeeper02和zookeeper03节点要修改成响应的目录。
server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:2889:3889
server.3=127.0.0.1:2890:3890
按照上面的修改继续修改zookeeper02和zookeeper03的配置项。
3)、依次启动zookeeper节点服务
[root@localhost ~]# /usr/local/zookeeper01/bin/zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper01/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@localhost ~]# /usr/local/zookeeper02/bin/zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper02/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@localhost ~]# /usr/local/zookeeper03/bin/zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper03/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
4)、查看状态
[root@localhost ~]# /usr/local/zookeeper02/bin/zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper02/bin/../conf/zoo.cfg
Mode: leader
[root@localhost ~]# /usr/local/zookeeper01/bin/zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper01/bin/../conf/zoo.cfg
Mode: follower
[root@localhost ~]# /usr/local/zookeeper03/bin/zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper03/bin/../conf/zoo.cfg
Mode: follower
上篇:
Linux部署Saltstack自动化及常见用法
下篇:
Zabbix-agent批量自动部署
1 Kubernetes集群日志-使用Loki实现高效日志分析和查询 2 Linux搭建Weblogic集群 3 Weblogic集群部署详解 4 使用OBD白屏部署OceanBase数据库 5 OceanBase 集群高可用部署方案简介 6 KubeSphere中部署Redis高可用集群 7 KubeSphere构建mysql集群 8 KubeSphere——常用应用UI可视化部署实战(1) 9 KubeSphere——常用应用UI可视化部署实战(2) 10 mysql每天新增加1百万数据 怎么办?有什么好的方案 11 RHCS实验 - RedHatClusterSuite 12 RHCS 红帽子集群套件