# 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.
dataDir=/usr/solrcould/service1/data
dataLogDir=/usr/solrcould/service1/datalog
# the port at which the clients will connect
clientPort=2181
server.1=192.168.238.133:2888:3888
server.2=192.168.238.133:2889:3889
server.3=192.168.238.133:2890:3890
service2 的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.
dataDir=/usr/solrcould/service2/data
dataLogDir=/usr/solrcould/service2/datalog
# the port at which the clients will connect
clientPort=2182
server.1=192.168.238.133:2888:3888
server.2=192.168.238.133:2889:3889
server.3=192.168.238.133:2890:3890
service3 的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.
dataDir=/usr/solrcould/service3/data
dataLogDir=/usr/solrcould/service3/datalog
# the port at which the clients will connect
clientPort=2183
server.1=192.168.238.133:2888:3888
server.2=192.168.238.133:2889:3889
server.3=192.168.238.133:2890:3890 参数说明:
tickTime:zookeeper中使用的基本时间单位, 毫秒值.
initLimit: zookeeper集群中的包含多台server, 其中一台为leader, 集群中其余的server为follower。 initLimit参数配置初始化连接时, follower和leader之间的最长心跳时间. 此时该参数设置为5, 说明时间限制为5倍tickTime, 即5*2000=10000ms=10s.
syncLimit: 该参数配置leader和follower之间发送消息, 请求和应答的最大时间长度. 此时该参数设置为2, 说明时间限制为2倍tickTime, 即4000ms.
dataDir: 数据存放目录. 可以是任意目录.但是我喜欢这么干
dataLogDir: log目录, 同样可以是任意目录. 如果没有设置该参数, 将使用和dataDir相同的设置
clientPort: 监听client连接的端口号.
server.X=A:B:C 其中X是一个数字, 表示这是第几号server. A是该server所在的IP地址. B配置该server和集群中的leader交换消息所使用的端口. C配置选举leader时所使用的端口. 由于配置的是伪集群模式, 所以各个server的B, C参数必须不同.
[iyunv@bogon bin]# sh zkServer.sh start #启动
JMX enabled by default
Using config: /usr/solrcould/service3/zookeeper-3.3.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[iyunv@bogon bin]# sh zkServer.sh status #查看当前状态,他会报异常,不要紧,因为是集群,其他两台没有起来,无法进行相互连接,当然报错,启动另外两台就不会报错了!
JMX enabled by default
Using config: /usr/solrcould/service3/zookeeper-3.3.6/bin/../conf/zoo.cfg
Error contacting service. It is probably not running
进入不同的zookeeper的bin,分别启动,常用命令如下
启动ZK服务: sh zkServer.sh start
查看ZK服务状态: sh zkServer.sh status
停止ZK服务: sh zkServer.sh stop
重启ZK服务: sh zkServer.sh restart