Zookeeper服务部署

前提:已经安装JDK1.8

一、zookeeper单机版

1、下载并发送到服务器

http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.12/zookeeper-3.4.12.tar.gz

2、解压安装并进入安装目录

[root@host1 ~]# tar xf zookeeper-3.4.12.tar.gz 
[root@host1 ~]# mv zookeeper-3.4.12 /usr/local
[root@host1 ~]# cd /usr/local/zookeeper-3.4.12

3、拷贝并修改配置文件

[root@host1 zookeeper-3.4.12]# cp conf/zoo_sample.cfg conf/zoo.cfg 
[root@host1 zookeeper-3.4.12]# vim conf/zoo.cfg
//...
dataDir=/usr/local/zookeeper/data
//...

4、启动服务

[root@host1 zookeeper-3.4.12]# ./bin/zkServer.sh start

5、验证:客户端连接测试,quit退出连接

[root@host1 zookeeper-3.4.12]# ./bin/zkCli.sh -server 127.0.0.1:2181
Connecting to 127.0.0.1:2181
...
[zk: 127.0.0.1:2181(CONNECTED) 0] quit

 

二、zookeeper集群

1、主机名ip地址映射

[root@host1 ~]# vim /etc/hosts
192.168.100.11 host1
192.168.100.12 host2
192.168.100.13 host3

2、关闭selinux和防火墙

[root@host1 ~]# systemctl stop firewalld ; systemctl disable firewalld
[root@host1 ~]# setenforce 0 ; sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config

3、解压安装并进入安装目录

[root@host1 ~]# tar xf zookeeper-3.4.12.tar.gz 
[root@host1 ~]# mv zookeeper-3.4.12 /usr/local
[root@host1 ~]# cd /usr/local/zookeeper-3.4.12

4、拷贝并修改配置文件

[root@host1 zookeeper-3.4.12]# cp conf/zoo_sample.cfg conf/zoo.cfg 
[root@host1 zookeeper-3.4.12]# vim conf/zoo.cfg
[root@host1 zookeeper-3.4.12]# egrep -v '(^#|^$)' conf/zoo.cfg 
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper-3.4.12/data
clientPort=2181
server.1=host1:2888:3888
server.2=host2:2888:3888
server.3=host3:2888:3888
maxClientCnxns=60

5、启动服务并查看jvm进程状态

[root@host1 zookeeper-3.4.12]# ./bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.4.12/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

[root@host1 zookeeper-3.4.12]# jps
2357 QuorumPeerMain
2520 Jps

6、查看集群状态

[root@host1 zookeeper-3.4.12]# ./bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.4.12/bin/../conf/zoo.cfg
Mode: follower

[root@host2 zookeeper-3.4.12]# ./bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.4.12/bin/../conf/zoo.cfg
Mode: leader

[root@host3 zookeeper-3.4.12]# ./bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.4.12/bin/../conf/zoo.cfg
Mode: follower

 

你可能感兴趣的:(Zookeeper服务部署)