欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

linux(centos)下zookeeper安装和配置

程序员文章站 2022-05-31 11:01:32
...

zookeeper安装

cd /tmp
wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11.tar.gz
sudo su
mkdir  /opt/yourpath/
tar xvf zookeeper-3.4.11.tar.gz -C /opt/yourpath/
cd  /opt/yourpath/
mv zookeeper-3.4.11/ zookeeper
cd zookeeper
mkdir data
mkdir log

myid文件

data目录下新建myid文件,写入一个id(在ip上取一个不同的值,区分开,这个值会和下面的zoo.cfg的一个值有关)

[[email protected] data]# pwd
/opt/interlive/yourpath/data
[[email protected] data]# cat myid
179

zoo.cfg文件

conf目录下,新建zoo.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.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/opt/interlive/zookeeper/data
dataLogDir=/opt/interlive/zookeeper/log
# the port at which the clients will connect
clientPort=2181
server.179=10.0.100.179:2888:3888
server.180=10.0.100.180:2888:3888
server.181=10.0.100.181:2888:3888
# the maximum number of client connections.
# increase this if you need to handle more clients
maxClientCnxns=0
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
autopurge.snapRetainCount=10
# Purge task interval in hours
# Set to "0" to disable auto purge feature
autopurge.purgeInterval=4

启动

/bin/yum install java
cd /opt/interlive/zookeeper/bin
 ./zkServer.sh start

建立节点

cd /opt/yourpath/zookeeper/bin
./zkCli.sh -server 10.0.100.179:2181;10.0.100.180:2181;10.0.100.181:2181
create /online "online"
create /online/yournode "yournode"
create /online/yournode/yournodesub "yournodesub"

查看节点

ls /
ls /online

参考

http://coolxing.iteye.com/blog/1871009
http://www.tuicool.com/articles/Y3eame