zookeeper注册中心安装(单机版)
下载zookeeper-3.4.9.tar.gz
wget http://apache.fayea.com/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz
解压到 /home/目录下:
cd /home/zookeeper-3.4.9
在/home/zookeeper-3.4.9目录下创建以下目录:
mkdir data
mkdir logs
将/home/zookeeper-3.4.9/conf/下的zoo.sample.cfg 文件拷贝一份,命名为zoo.cfg
cp zoo_sample.cfg zoo.cfg
修改zoo.cfg的配置文件:
vi 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=/tmp/zookeeper
# 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
#
# 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=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
其他默认,dataDir修改成刚才新建的data目录,同时新增dataLogDir:
dataDir=/home/zookeeper-3.4.9/data
dataLogDir=/home/zookeeper-3.4.9/logs
保存,单机版配置已经完成。
vi /root/.bash_profile
# zookeeper env
export ZOOKEEPER_HOME=/home/zookeeper-3.4.9
export PATH=$ZOOKEEPER_HOME/bin:$PATH
source /root/.bash_profile
启动zk:
sh /home/zookeeper-3.4.9/bin/zkServer.sh start
jps:
sh zkServer.sh status
开机启动:
在/etc/rc.local文件中追加:
# java_home
export JAVA_HOME=/opt/java/jdk1.7.0_75
# zookeeper
/home/zookeeper-3.4.9/bin/zkServer.sh start
以上即可开机自动启动!!
(带用户:- user -c '/home/zookeeper-3.4.9/bin/zkServer.sh start')