contos7 安装zookeeper集群
1.软件版本:
zookeeper-3.4.6.tar.gz
2.下载地址:
https://mirrors.cnnic.cn/apache/zookeeper/
3.上传到机器目录:/usr/local
4.进入上传的目录后解压zookeeper:
tar -zxvf zookeeper-3.4.6.tar.gz zookeeper
# 进入zookeeper目录
cd zoookeeper/
# 创建data 和 logs目录
mkdir data logs
5.在 data 目录下创建 myid 文件,并写入编号
1 2 3 | cd ../data touch myid echo "1" >>myid |
每台机器的myid里面的值对应server.后面的数字x。
6.需要开放3个端口(可选做)
1 2 3 | [root@redhat66 data]# sudo /sbin/iptables -I INPUT -p tcp --dport 2181 -j ACCEPT [root@redhat66 data]# sudo /sbin/iptables -I INPUT -p tcp --dport 2888 -j ACCEPT [root@redhat66 data]# sudo /sbin/iptables -I INPUT -p tcp --dport 3888 -j ACCEPT |
7.配置zookeeper环境变量
1 2 3 4 5 6 7 8 9 10 | # 编辑 /etc/profile [root@192 ~]# vi /etc/profile # 在文件尾部新增如下内容: #zookeeper export ZOOKEEPER_HOME=/usr/local/zookeeper export PATH=$ZOOKEEPER_HOME/bin/:$PATH # 使文件生效 source /etc/profile |
8.配置zookeeper启动文件
1 2 3 4 5 6 7 8 | # 进入conf cd conf/ # 拷贝文件 cp zoo_sample.cfg zoo.cfg # 编辑 vim zoo.cfg |
全部配置如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # 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/zookeeper/data dataLogDir=/usr/local/zookeeper/logs/ server.1=192.168.0.165:2888:3888 server.2=192.168.0.166:2888:3888 server.3=192.168.0.167:2888:3888 # 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.x x与myid文件中的内容保持一致
9.其他的机器重复步骤3-8步骤
10.分别启动三台机器上的zookeeper服务
1 | zkServer.sh start |
11.查看服务状态
1 | zkServer.sh status<br><br> |
[root@192 bin]# zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Mode: follower
[root@redhat66 bin]# zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Mode: leader
[root@192 bin]# ./zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Mode: follower
12.或者使用jps,有(4895 QuorumPeerMain)则启动成功
1 2 3 | [root@192 bin]# jps 4922 Jps 4895 QuorumPeerMain |
13.客户端连接
1 | ./zkCli.sh -server 192.168.0.166:2181 |
go big or go home -- facebook
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· Vue3状态管理终极指南:Pinia保姆级教程
2021-08-07 CentOS 7 虚拟机将修改为固定IP
2021-08-07 CentOS 7 安装虚拟机
2019-08-07 规则引擎 drools