wskickahn 发表于 2015-11-21 13:36:52

zookeeper-3.3.6----伪集群

  所谓伪集群指的就是在同一台机器上部署多个实例。部署实例的个数要是奇数个数。
  

  如下我将部署的是3个服务实例。直接说步骤。
  

  1,解压zookeeper的包。我的目录是zookeeper-3.3.6.1

  

  2,复制zookeeper-3.3.6.1到zookeeper-3.3.6.2,zookeeper-3.3.6.3
  

  3,修改每个目录下conf/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/nacey/zookeeper-3.3.6.1/dataDir
# the port at which the clients will connect
clientPort=2181

server.1=localhost:2888:3888
server.2=localhost:2889:3889
server.3=localhost:2890:3890
  

  server.x这里的x标识是默认情况下需要设置到zookeeper-3.3.6.1/dataDir/myid这个文件里。
  2888端口代表的是follower与leader之前的通信端口。
  3888端口代表的是进行leader选举的端口。
  2181端口代表的是客户端连接到zookeeper的端口。
  4,在dataDir配置的目录下新建一个myid,在里面设置server.x填的x。
  最后其他的两个文件夹的配置也类似于上面的那个配置。但要注意的是端口不能重复。三个端口都不能重复。
  

  5.启动zookeeper服务器组。执行每个目录下的bin/zkServer.sh start 即可启动。
  

  tip:
  如果在.bashrc下或profile设置过zookeeper的环境变量,有可能会出现问题。提示进程已经启动过。所以得要注意下环境变量的设置。

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  
页: [1]
查看完整版本: zookeeper-3.3.6----伪集群