zookeeper集群安装和配置

1安装JDK1.8
拷贝jdk-8u201-linux-x64.tar.gz包到/usr目录
解压jdk包
vi /etc/profile
最后一行添加如下内容,保存退出后source /etc/profile
#java envirment
export JAVA_HOME=/usr/jdk1.8.0_201
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export ZOOKEEPER_HOME=/usr/zookeeper
export PATH=$PATH:${JAVA_HOME}/bin:$ZOOKEEPER_HOME/bin

验证java:
java -version
显示版本代表成功

2拷贝zookeeper-3.4.13.tar.gz包到/usr目录
解压包
重命名mv zookeeper-3.4.13 zookeeper

source /etc/profile
mv zoo_sample.cfg zoo.cfg
3修改配置文件
vi /usr/zookeeper/conf/zoo.cfg
clientPort=12181 (端口改为12181)
添加如下

server.1=173.16.58.200:2888:3888
server.2=173.16.58.213:2888:3888
server.3=173.16.58.128:2888:3888
4创建myid文件
在dataDir=/tmp/zookeeper目录下
创建myid文件,3个节点内容分别1,2,3

5启动zookeeper
6t测试
root@host-173-16-58-200 /]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/zookeeper/bin/../conf/zoo.cfg
Mode: follower

root@host-173-16-58-213 ~]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/zookeeper/bin/../conf/zoo.cfg
Mode: leader

root@host-173-16-58-128 ~]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/zookeeper/bin/../conf/zoo.cfg
Mode: follower

 

posted @ 2020-09-09 17:21  王能武  阅读(165)  评论(0编辑  收藏  举报