安装包下载
http://www-us.apache.org/dist/zookeeper/zookeeper-3.3.6/
安装(伪集群模式)过程
- 解压:tar -zxvf zookeeper-3.4.5.tar.gz
- 配置文件:在conf目录下删除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=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=/home/jiangconglin/zk/data # the port at which the clients will connect clientPort=2187 dataLogDir=/home/jiangconglin/zk/dataLog server.0=127.0.0.1:8880:3387 server.1=127.0.0.1:8881:3388 server.2=127.0.0.1:8882:3389
- 配置文件:创建一个配置文件zoo1.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=/home/jiangconglin/zk/data1 # the port at which the clients will connect clientPort=2188 dataLogDir=/home/jiangconglin/zk/dataLog1 server.0=127.0.0.1:8880:3387 server.1=127.0.0.1:8881:3388 server.2=127.0.0.1:8882:3389
- 配置文件:创建一个配置文件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. dataDir=/home/jiangconglin/zk/data2 # the port at which the clients will connect clientPort=2189 dataLogDir=/home/jiangconglin/zk/dataLog2 server.0=127.0.0.1:8880:3387 server.1=127.0.0.1:8881:3388 server.2=127.0.0.1:8882:3389
- 创建myid
在dataDir(/home/jiangconglin/zk/data|1|2)目录创建myid文件
Server0机器的内容为:0
Server1机器的内容为:1
Server2机器的内容为:2
- 创建日志目录
/home/jiangconglin/zk/dataLog
/home/jiangconglin/zk/dataLog1
/home/jiangconglin/zk/dataLog2