zookeeper本机伪集群模式配置,坑人的配置。

来源:互联网 发布:淘宝店铺图标是什么 编辑:程序博客网 时间:2024/05/29 06:38

1.zookeeper解压的路径由以下可知:

/home/doctor/opt/zookeeper-3.4.6/conf

本地设置3个zookeeper,配置文件为:


 zoo2.cfg  zoo3.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/doctor/zookeeper/d_1
# 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=localhost:2887:3887
server.2=localhost:2888:3888
server.3=localhost:2889:3889


zoo2.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/doctor/zookeeper/d_2
# the port at which the clients will connect
clientPort=2182
# 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=localhost:2887:3887
server.2=localhost:2888:3888
server.3=localhost:2889:3889


zoo3.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/doctor/zookeeper/d_3
# the port at which the clients will connect
clientPort=2183
# 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=localhost:2887:3887
server.2=localhost:2888:3888
server.3=localhost:2889:3889


注意:大家都知道,关键是clientPort 不能相同。


其次,让我启动失败的配置那就是:dataDir=/home/doctor/zookeeper/d_x (d_1,d_2,d_3)

里面的配置。

大家应该知道在此文件下需要建立myid文件,里面的内容就是对应server.1=localhost:2887:3887  里面的server.1中的1.例如:

[doctor@localhost d_1]$ pwd
/home/doctor/zookeeper/d_1
[doctor@localhost d_1]$ ls
myid  version-2  zookeeper_server.pid
[doctor@localhost d_1]$ 

[doctor@localhost d_1]$ cat myid 
1

内容是1,


问题根源:我写入的内容为1,不后面加了空格,就报错,启动不了。

所以,。。。。应该程序读取配置文件时候,就应该trim一下吧。。

0 0
原创粉丝点击