分类: 架构设计与优化
2015-01-27 15:29:52
1.集群安装
下载安装包,目前最稳定的是3.4.6版本
zookeeper-3.4.6.tar.gz
tar -xzvf zookeeper-3.4.6.tar.gz
cd ./zookeeper-3.4.6
cp conf/zoo_sample.cfg conf/zoo.cfg
创建安装目录文件夹
mkdir /var/lib/zookeeper/
mkdir /var/lib/zookeeper/data
vi 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.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/var/lib/zookeeper/data
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
server.1=10.160.29.5:2888:3888
server.2=10.160.29.10:2888:3888
保存后进入data
对应上面zoo.cfg中server.后的数字,第一台的内容为1,第二台的内容为2
vi myid
修改内容如下:
1
启动
./zkServer.sh start
[root@BZYWPT-server6 bin]# ./zkServer.sh start
JMX enabled by default
Using config: /usr/src/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
停止
./zkServer.sh stop
客户端测试
./zkCli.sh -server 10.160.29.5:2181
PS:防火墙端口要开放,否则无法访问。