安装jdk1.8
mkdir /usr/java
tar xf jdk-8u221-linux-x64.tar.gz -C /usr/java/
ln -s /usr/java/jdk1.8.0_221 /usr/java/jdk
vim /etc/profile
export JAVA_HOME=/usr/java/jdk
export PATH=$JAVA_HOME/bin:$JAVA_HOME/bin:$PATH
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
安装zookeeper(3台zk角色主机)
zookeeper下载地址
https://archive.apache.org/dist/zookeeper/
tar xf apache-zookeeper-3.7.2-bin.tar.gz -C /opt/
ln -s /opt/apache-zookeeper-3.7.2-bin /opt/zookeeper
mkdir -pv /data/zookeeper/data /data/zookeeper/logs
添加zookeeper环境变量
vim /etc/profile
export ZOOKEEPER_HOME=/opt/zookeeper
export PATH=$ZOOKEEPER_HOME/bin:$PATH
vim /opt/zookeeper/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/zookeeper/data
dataLogDir=/data/zookeeper/logs
clientPort=2181
server.1=10.0.0.10:2888:3888
server.2=10.0.0.11:2888:3888
server.3=10.0.0.12:2888:3888
myid(三台机器不同)
vim /data/zookeeper/data/myid
1
vim /data/zookeeper/data/myid
2
vim /data/zookeeper/data/myid
3
依次启动zookeeper
/opt/zookeeper/bin/zkServer.sh start
查看状态
/opt/zookeeper/bin/zkServer.sh status
[root@es1 ~]# /opt/zookeeper/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
Mode: follower
[root@es2 opt]# /opt/zookeeper/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
Mode: leader
[root@es3 opt]# /opt/zookeeper/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
Mode: follower
登录
/opt/zookeeper/bin/zkCli.sh -server localhost:2181
...
[zk: localhost:2181(CONNECTED) 4] ls /
[zookeeper]
[zk: localhost:2181(CONNECTED) 5] ls /zookeeper
[quota]
[zk: localhost:2181(CONNECTED) 6] ls /zookeeper/quota
[]