部署分布式zookeeper部署分布式zookeeper的步骤:

部署分布式zookeeper的步骤:


1. 从官网下载zookeepr的最新版本

http://zookeeper.apache.org/releases.html

本文下载的版本是zookeeper-3.3.3

2. 本文将3个peer都部署在一台机器上。

|-- server1
|   `-- zookeeper-3.3.3
|-- server2
|   `-- zookeeper-3.3.3
`-- server3
    `-- zookeeper-3.3.3

3. 以server1为例,配置server1/zookeeper-3.3.3/conf/zoo.cfg,conf目录下自带zoo_sample.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.
dataDir=/export/crawlspace/mahadev/zookeeper/server1/data
# the port at which the clients will connect

clientPort=12181

server.1=10.20.146.29:12888:13888
server.2=10.20.146.29:22888:23888
server.3=10.20.146.29:32888:33888
 
server2和server3的配置拷贝一份,然后分别修改dataDir和clientPort
server2:
dataDir=/export/crawlspace/mahadev/zookeeper/server2/data
clientPort=22181
server3:
dataDir=/export/crawlspace/mahadev/zookeeper/server3/data
clientPort=32181


4. 创建myid到各个server的data目录下:
cat 1 > /export/crawlspace/mahadev/zookeeper/server1/data
cat 2 > /export/crawlspace/mahadev/zookeeper/server2/data
cat 3 > /export/crawlspace/mahadev/zookeeper/server3/data
 
5. 启动:
在各个server的部署目录下启动服务
sh bin/zkServer.sh start
 
启动第一个的时候会抛异常,这是因为其他server还没有启动的缘故。

你可能感兴趣的:(zookeeper,职场,休闲)