zookeeper 的安装与配置
下载
官网下载地址:http://mirrors.shu.edu.cn/apache/zookeeper
上传到 /home 目录下
解压
[root@localhost home]# tar -zxvf zookeeper-3.4.13.tar.gz
重命名为 zookeeper
[root@localhost home]# mv zookeeper-3.4.13 zookeeper
转移到/usr/local目录下
[root@localhost home]# mv zookeeper /usr/local/
配置
[root@localhost home]# vim /etc/profile
在export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL新增或更改以下四行
export JAVA_HOME=/usr/jdk8 export ZOOKEEPER_HOME=/usr/local/zookeeper export CLASSPATH=.:%JAVA_HOME%/lib/dt.jar:%JAVA_HOME%/lib/tools.jar export PATH=$PATH:$ZOOKEEPER_HOME/bin:$JAVA_HOME/bin
进入conf目录
[root@localhost home]# cd /usr/local/zookeeper/conf/ [root@localhost conf]# ll -rw-r--r--. 1 501 games 535 6月 30 01:04 configuration.xsl -rw-r--r--. 1 501 games 2161 6月 30 01:04 log4j.properties -rw-r--r--. 1 501 games 922 6月 30 01:04 zoo_sample.cfg
拷贝zoo_sample.cfg并重命名
[root@localhost conf]# cp zoo_sample.cfg zoo.cfg
打开zoo.cfg
[root@localhost conf]# vim zoo.cfg
配置以下两行
dataDir=/usr/local/zookeeper/dataDir dataLogDir=/usr/local/zookeeper/dataLogDir
在zookeeper目录下创建上面的两个文件夹
[root@localhost conf]# cd /usr/local/zookeeper/ [root@localhost zookeeper]# mkdir dataDir [root@localhost zookeeper]# mkdir dataLogDir
启动
进入bin目录下进行启动
[root@localhost zookeeper]# cd bin/ [root@localhost bin]# ./zkServer.sh start ZooKeeper JMX enabled by default Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg Starting zookeeper ... STARTED
常用命令:
启动:./zkServer.sh start
停止:./zkServer.sh stop
重启:./zkServer.sh restart
状态:./zkServer.sh status
到此单机版的zookeeper配置及启动成功了。