docker安装zookeeper集群

服务器部署环境

CentOS 7 host A 192.168.106.147
CentOS 7 host B 192.168.106.148
CentOS 7 host C 192.168.106.149

部署host A

执行命令

docker run -d --name=zookeeper --net=host -e SERVER_ID=1 -e ADDITIONAL_ZOOKEEPER_1=server.1=192.168.106.147:2888:3888 -e ADDITIONAL_ZOOKEEPER_2=server.2=192.168.106.148:2888:3888 -e ADDITIONAL_ZOOKEEPER_3=server.3=192.168.106.149:2888:3888 -e ADDITIONAL_ZOOKEEPER_4=clientPort=2181 garland/zookeeper

开放端口

firewall-cmd --zone=public --add-port=2181/tcp --permanent
firewall-cmd --zone=public --add-port=2888/tcp --permanent
firewall-cmd --zone=public --add-port=3888/tcp --permanent
firewall-cmd --reload

部署host B

执行命令

docker run -d --name=zookeeper --net=host -e SERVER_ID=2 -e ADDITIONAL_ZOOKEEPER_1=server.1=192.168.106.147:2888:3888 -e ADDITIONAL_ZOOKEEPER_2=server.2=192.168.106.148:2888:3888 -e ADDITIONAL_ZOOKEEPER_3=server.3=192.168.106.149:2888:3888 -e ADDITIONAL_ZOOKEEPER_4=clientPort=2181 garland/zookeeper

开放端口

firewall-cmd --zone=public --add-port=2181/tcp --permanent
firewall-cmd --zone=public --add-port=2888/tcp --permanent
firewall-cmd --zone=public --add-port=3888/tcp --permanent
firewall-cmd --reload

部署host C

docker run -d --name=zookeeper --net=host -e SERVER_ID=3 -e ADDITIONAL_ZOOKEEPER_1=server.1=192.168.106.147:2888:3888 -e ADDITIONAL_ZOOKEEPER_2=server.2=192.168.106.148:2888:3888 -e ADDITIONAL_ZOOKEEPER_3=server.3=192.168.106.149:2888:3888 -e ADDITIONAL_ZOOKEEPER_4=clientPort=2181 garland/zookeeper

开放端口

firewall-cmd --zone=public --add-port=2181/tcp --permanent
firewall-cmd --zone=public --add-port=2888/tcp --permanent
firewall-cmd --zone=public --add-port=3888/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-all

重启zookeeper

[root@bogon ~]# docker restart zookeeper

测试

[root@bogon ~]# echo stat | nc 127.0.0.1 2181

声明:非原创引用自【】
原文链接

你可能感兴趣的:(docker安装zookeeper集群)