@Author : Spinach | GHB
@Link : http://blog.youkuaiyun.com/bocai8058
配置需求
序号 | 目前配置 | myid | 需求配置 | myid |
---|---|---|---|---|
01 | server.1=10.1.3.6:2881:3881 | 1 | server.1=10.1.3.6:2881:3881 | 1 |
02 | server.2=10.1.3.7:2881:3881 | 2 | server.2=10.1.3.7:2881:3881 | 2 |
03 | server.3=10.1.3.8:2881:3881 | 3 | server.3=10.1.3.8:2881:3881 | 3 |
04 | server.4=10.1.3.9:2881:3881 | 4 | ||
05 | server.5=10.1.3.10:2881:3881 | 5 |
注:server . A = B : C : D【A为第A号服务器;B为客户端端口;C为与leader交换信息端口;D:选举端口】
配置文件有zoo.cfg和myid,如下为server . 1 = 10.1.3.6 : 2881 : 3881 的配置:
######### 路径为./cfg/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=/home/ghb/HadoopCluster/zookeeper001/data
dataLogDir=/home/ghb/HadoopCluster/zookeeper001/logs
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# 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=10.1.3.6:2881:3881
server.2=10.1.3.7:2881:3881
server.3=10.1.3.8:2881:3881
######### 路径为./data/myid ######### 内容如下
1
动态添加节点
- 在10.1.3.9和10.1.3.10上解压zookeeper后,进入cfg中;
- mv zoo_sample.cfg zoo.cfg
- 在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=/home/ghb/HadoopCluster/zookeeper004/data
dataLogDir=/home/ghb/HadoopCluster/zookeeper004/logs
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# 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=10.1.3.6:2881:3881
server.2=10.1.3.7:2881:3881
server.3=10.1.3.8:2881:3881
server.4=10.1.3.9:2881:3881
server.5=10.1.3.10:2881:3881
- 建立/home/ghb/HadoopCluster/zookeeper004/data文件夹,并在里面创建myid文件,并添加内容如下:
4
- 在10.1.3.10上操作类似,修改完后,再回到10.1.3.6,10.1.3.7,10.1.3.8上将zoo.cfg中的内容替换成如下:
server.1=10.1.3.6:2881:3881
server.2=10.1.3.7:2881:3881
server.3=10.1.3.8:2881:3881
# 将上面修改成下面,保持配置相同
server.1=10.1.3.6:2881:3881
server.2=10.1.3.7:2881:3881
server.3=10.1.3.8:2881:3881
server.4=10.1.3.9:2881:3881
server.5=10.1.3.10:2881:3881
动态删除节点
其操作与动态添加节点操作相反,将配置相应移除即可。