标签:style class blog code java http
IP | Host Name | Software |
192.168.23.128 | ae01 | JDK 1.7 |
192.168.23.129 | ae02 | JDK 1.7 |
192.168.23.130 | ae03 | JDK 1.7 |
user@ae01:/usr/local/ae$ sudo vim /etc/hosts
127.0.0.1 localhost 192.168.23.128 ae01 192.168.23.129 ae02 192.168.23.129 ae03
user@ae01:/usr/local/ae$ sudo tar -zxvf zookeeper-3.4.5.tar.gz
user@ae01:/usr/local/ae/zookeeper-3.4.5/conf$ sudo vm zoo_sample.cfg zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=5
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=2
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/usr/local/ae/storage/zookeeper
# 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=ae01:2888:3888
server.2=ae02:2888:3888
server.3=ae03:2888:3888
dataDir 为Zookeeper保存数据的文件夹
server.1=ae01:2888:3888 ‘2888‘为连接所使用的端口号,‘3888‘为选举leader使用的端口号
user@ae01:/usr/local/ae$ scp -r zookeeper-3.3.5/ user@ae01:/usr/local/ae
user@ae01:/usr/local/ae$ scp -r zookeeper-3.3.5/ user@ae02:/usr/local/ae
user@ae01:/usr/local/ae$ echo "1" > /usr/local/ae/storage/zookeeper/myid
user@ae02:/usr/local/ae$ echo "1" > /usr/local/ae/storage/zookeeper/myid
user@ae03:/usr/local/ae$ echo "1" > /usr/local/ae/storage/zookeeper/myid
user@ae01:/usr/local/ae/zookeeper-3.4.5/bin$ sudo zkServer.sh start
user@ae02:/usr/local/ae/zookeeper-3.4.5/bin$ sudo zkServer.sh start
user@ae03:/usr/local/ae/zookeeper-3.4.5/bin$ sudo zkServer.sh start
由于ZooKeeper集群启动的时候,每个结点都试图去连接集群中的其它结点,先启动的肯定连不上后面还没启动的,日志前面部分出现连接异常(java.net.ConnectException: Connection refused )是可以忽略的。集群在选出一个Leader后,最后稳定了。
user@ae01:/usr/local/ae/zookeeper-3.4.5/bin$ zkServer.sh status
JMX enabled by default
Using config: /usr/local/ae/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: leader
user@ae02:/usr/local/ae/zookeeper-3.4.5/bin$ zkServer.sh status
JMX enabled by default
Using config: /usr/local/ae/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: follower
user@ae03:/usr/local/ae/zookeeper-3.4.5/bin$ zkServer.sh status
JMX enabled by default
Using config: /usr/local/ae/zookeeper-3.4.5/bin/../conf/zoo.cfg
Mode: follower
Zookeeper 分布式环境搭建,布布扣,bubuko.com
标签:style class blog code java http
原文地址:http://www.cnblogs.com/tannerBG/p/3784540.html