zookeeper集羣部署

1、至少3臺主機
2、jdk環境
3、安裝java

官網下載zk安裝(本文檔安裝版本3.4.6)markdown

# 測試地址
zk1 192.168.233.133
zk2 192.168.233.134
zk3 192.168.233.135
須要安裝jdk(這一步安裝省略)
如下操做都須要在三臺主機進行
# 添加JDK環境變量
JAVA_HOME=/usr/local/jdk
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH
[root@zk1 ~]# java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
# 添加ZK環境變量
export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.6
export PATH=$PATH:$ZOOKEEPER_HOME/bin:$ZOOKEEPER_HOME/conf
# 手動建立文件夾機文件
/usr/loacl/zookeeper-3.4.6/下
mkdir data
mkdir log
# 在data下建立文件myid
echo '0' >/usr/local/zookeeper-3.4.6/data/myid #三臺主機依次添加0,1,2
# 拷貝配置文件
/usr/local/zookeeper-3.4.6/conf/
cp zoo_sample.cfg zoo.cfg
# 修改配置文件
#如下配置須要在分別三臺zk上配置
[root@zk1 conf]# cat zoo.cfg
ckTime=2000
dataDir=/usr/local/zookeeper-3.4.6/data
dataLogDir=/usr/local/zookeeper-3.4.6/logs
clientPort=2181
initLimit=5
syncLimit=2
server.0=192.168.233.133:2880:3880
server.1=192.168.233.134:2881:3881
server.2=192.168.233.135:2882:3882
# 啓動zk集羣
#依次分別啓動三臺zk
[root@zk1 bin]# pwd
/usr/local/zookeeper-3.4.6/bin
[root@zk1 bin]# sh zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@zk2 bin]# pwd
/usr/local/zookeeper-3.4.6/bin
[root@zk1 bin]# sh zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@zk3 bin]# pwd
/usr/local/zookeeper-3.4.6/bin
[root@zk1 bin]# sh zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
#啓動完成檢查進程,並檢查zk狀態角色
[root@zk1 bin]# sh zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: follower
[root@zk2 bin]# sh zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: leader
[root@zk3 bin]# sh zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: follower

zk集羣部署完成ide

相關文章
相關標籤/搜索