others linux服务器运维 django3 监控 k8s golang 数据库 大数据 前端 devops 理论基础 java oracle 运维日志

centos7 安装zookeeper 3.6.1

访问量:1383 创建时间:2020-05-18

下载zookeeper

zookeeper下载地址

IP 角色
192.168.0.126 zk
192.168.0.127 zk
192.168.0.128 zk

安装jdk(3台机器都安装)

查看是否已经安装java
[root@k8s-n4 ~]# java -version
openjdk version "1.8.0_222-ea"
OpenJDK Runtime Environment (build 1.8.0_222-ea-b03)
OpenJDK 64-Bit Server VM (build 25.222-b03, mixed mode)
[root@k8s-n4 ~]# rpm -e java-1.8.0-openjdk
[root@k8s-n4 ~]# yum remove java-1.8.0-openjdk java-1.8.0-openjdk-headless
#安装jdk-8u231-linux-x64(根据自己需要选择版本)
[root@k8s-n4 ~]# mv jdk1.8.0_231 /usr/local/

[root@k8s-n2 ~]# vim /etc/profile
#在末尾增加3行内容
export JAVA_HOME=/usr/local/jdk1.8.0_231
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
[root@k8s-n4 ~]# . !$
. /etc/profile
[root@k8s-n4 ~]# java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)

安装zookeeper(3台机器都安装)

[root@k8s-n4 ~]# mkdir -pv /data/zk3.6
[root@k8s-n4 ~]# tar xf apache-zookeeper-3.6.1-bin.tar.gz 
[root@k8s-n4 ~]# ll
总用量 201760
-rw-------. 1 root root      1887 4月   9 10:45 anaconda-ks.cfg
drwxr-xr-x  6 root root       133 5月  18 10:41 apache-zookeeper-3.6.1-bin
-rw-r--r--  1 root root  12436328 5月  18 09:53 apache-zookeeper-3.6.1-bin.tar.gz
-rw-r--r--. 1 root root      1918 4月   9 10:55 initial-setup-ks.cfg
-rw-r--r--  1 root root 194151339 5月  18 10:09 jdk-8u231-linux-x64.tar.gz
[root@k8s-n4 ~]# mv apache-zookeeper-3.6.1-bin /data/zk3.6/zookeeper
[root@k8s-n4 ~]# cd !$
cd /data/zk3.6/zookeeper
[root@k8s-n4 zookeeper]# cp conf/zoo_sample.cfg conf/zoo.cfg 
[root@k8s-n4 zookeeper]# cat conf/zoo.cfg | grep -v '^#'
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/zk3.6/zookeeper/data
LogDir=/data/zk3.6/zookeeper/logs
clientPort=2181
server.1=192.168.0.126:2888:3888
server.2=192.168.0.127:2888:3888
server.3=192.168.0.128:2888:3888
[root@k8s-n4 zookeeper]# mkdir -pv /data/zk3.6/zookeeper/{logs,data}
#分别在3台机器上单独执行如下命令,区分zk节点
[root@k8s-n2 zookeeper]# echo 1 > /data/zk3.6/zookeeper/data/myid
[root@k8s-n3 zookeeper]# echo 2 > /data/zk3.6/zookeeper/data/myid
[root@k8s-n4 zookeeper]# echo 3 > /data/zk3.6/zookeeper/data/myid
#启动(3节点都执行)
[root@k8s-n2 zookeeper]# ./bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /data/zk3.6/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@k8s-n3 zookeeper]# ./bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /data/zk3.6/zookeeper/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: leader

[root@k8s-n3 zookeeper]# ./bin/zkCli.sh
[zk: localhost:2181(CONNECTED) 1] ls /
[zookeeper]
[zk: localhost:2181(CONNECTED) 2] ls /zookeeper
[config, quota]

至此zookeeper安装完成

登陆评论: 使用GITHUB登陆