2018-07-11期 Zookeeper集群安装部署【本人亲自反复验证通过分享】

一、安装介质

https://archive.apache.org/dist/zookeeper/zookeeper-3.4.5/

二、安装方法

1、解压安装包

[root@hadoop-server01 conf]# tar -xvf zookeeper-3.4.5.tar.gz  -C /usr/local/apps/

2、修改配置文件

[root@hadoop-server01 conf]# cp zoo_sample.cfg zoo.cfg

[root@hadoop-server01 conf]# vi zoo.cfg

# The number of milliseconds of each tick

tickTime=2000

# The number of ticks that the initial

# synchronization phase can take

initLimit=10

# The number of ticks that can pass between

# sending a request and getting an acknowledgement

syncLimit=5

# the directory where the snapshot is stored.

# do not use /tmp for storage, /tmp here is just

# example sakes.

dataDir=/usr/local/apps/zookeeper-3.4.5/data

# the port at which the clients will connect

clientPort=2181

#

# Be sure to read the maintenance section of the

# administrator guide before turning on autopurge.

#

# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance

#

# The number of snapshots to retain in dataDir

#autopurge.snapRetainCount=3

# Purge task interval in hours

# Set to "0" to disable auto purge feature

#autopurge.purgeInterval=1

server.1=hadoop-server01:2888:3888

server.2=hadoop-server02:2888:3888

server.3=hadoop-server03:2888:3888

#说明

#2888端口代表leader和follower之间通讯端口

#3888代表follower和follower之间的投票端口

3、创建myid文件

[root@hadoop-server01 data]# cd /usr/local/apps/zookeeper-3.4.5/data

[root@hadoop-server01 data]# echo 1 > myid

4、将节点1修改的文件分发到其它节点

[root@hadoop-server01 apps]# scp -r zookeeper-3.4.5/ root@hadoop-server02:/usr/local/apps/

[root@hadoop-server01 apps]# scp -r zookeeper-3.4.5/ root@hadoop-server03:/usr/local/apps/

5、修改myid文件

[root@hadoop-server02 data]# cd /usr/local/apps/zookeeper-3.4.5/data

[root@hadoop-server02 data]# echo 2 > myid

[root@hadoop-server03 data]# cd /usr/local/apps/zookeeper-3.4.5/data

[root@hadoop-server03 data]# echo 3 > myid

6、启动zk服务

[root@hadoop-server01 bin]# ./zkServer.sh start

JMX enabled by default

Using config: /usr/local/apps/zookeeper-3.4.5/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

[root@hadoop-server01 bin]# jps

2514 QuorumPeerMain

2531 Jps

[root@hadoop-server02 bin]# ./zkServer.sh  start

JMX enabled by default

Using config: /usr/local/apps/zookeeper-3.4.5/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

[root@hadoop-server02 bin]# jps

2403 QuorumPeerMain

2434 Jps

[root@hadoop-server03 bin]# ./zkServer.sh  start

JMX enabled by default

Using config: /usr/local/apps/zookeeper-3.4.5/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

[root@hadoop-server03 bin]# jps

2352 QuorumPeerMain

2377 Jps

7、查看当前节点的工作模式

[root@hadoop-server01 bin]# ./zkServer.sh  status

JMX enabled by default

Using config: /usr/local/apps/zookeeper-3.4.5/bin/../conf/zoo.cfg

Mode: follower

[root@hadoop-server02 bin]# ./zkServer.sh  status

JMX enabled by default

Using config: /usr/local/apps/zookeeper-3.4.5/bin/../conf/zoo.cfg

Mode: leader

[root@hadoop-server03 bin]# ./zkServer.sh  status

JMX enabled by default

Using config: /usr/local/apps/zookeeper-3.4.5/bin/../conf/zoo.cfg

Mode: follower

特点:

(1)集群中只要有半数以上的节点活跃,集群服务可以正常提供

(2)集群中配置的节点数最好为基数个


猜你喜欢

转载自blog.51cto.com/2951890/2140133
今日推荐