参考官方文档:http://zookeeper.apache.org/doc/r3.4.6/zookeeperStarted.html
zookeeper完全分布式的安装1、下载zookeeper-3.4.6 2、解压到安装目录 3、编辑配置文件{ZOOKEEPER_HOME/conf/zoo.cfg}
dataDir:指定内存数据库的路径 server.x中序号是为了区分zookeeper集群,当zookeeper集群启动, 会在myid文件找到对应的序号。
[chb@TEST conf]$ cat zoo.cfg
tickTime=2000
dataDir=/usr/local/zookeeper-3.4.6/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=TEST:2888:3888
server.2=TEST1:2888:3888
server.3=TEST2:2888:3888
[chb@TEST conf]$
tickTime the basic time unit in milliseconds used by ZooKeeper. It is used to do heartbeats and the minimum session timeout will be twice dataDir the location to store the in-memory database snapshots and, unless specified otherwise, the transaction log of updates to the database. clientPort the port to listen for client connection
4、创建myid文件, 对应server.x的序号添加如下:
#zookeeper
export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.6
export PATH=$PATH:$ZOOKEEPER_HOME/bin
使/etc/profile
有效:
source /etc/profile
6、启动zookeeper server
zkServer.sh start
7、会在当前目录下生成一个zookeeper.out的日志文件:
确保没有错误出现
8、查看zookeeper的内存数据库修改zookeeper配置如下:
端口server.1=192.168.10.224:2878:3878
server.2=192.168.10.225:2898:3898
server.3=192.168.10.226:2889:3889
clientPort=3384