1、准备工作
下载zookeeper;
下载地址: http://zookeeper.apache.org/下载zookeeper安装包
下载好zookeeper的压缩包:zookeeper-3.4.6.tar.gz 上传到/tmp目录
2、查看 Linux 自带的 JDK 是否安装
rpm -qa|grep java
卸载 OpenJDK,执行以下操作
rpm -e --nodeps tzdata-java-2012c-1.el6.noarch
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.45-1.45.1.11.1.el6.x86_64
3、开始安装
1、把下载好的zookeeper-3.4.6.tar.gz压缩包上传到服务器上/tmp上
2、解压zookeeper的安装包:tar -xzvf zookeeper-3.4.6.tar.gz
3、把zookeeper包移动到目录/usr/local; mv zookeeper-3.4.6/usr/local/
4、配置zookeeper环境变量
vi /etc/profile
在profile中添加如下内容
#set zookeeper environment
export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.6
export PATH=$ZOOKEEPER_HOME/bin:$ZOOKEEPER_HOME/conf:$PATH
5、设置 profile生效:source /etc/profile
6、修改配置文件/usr/local/zookeeper/conf/zoo.cfg
maxClientCnxns=3000
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper/data
dataLogDir=/usr/local/zookeeper/logs
clientPort=2181
server.1=fee-prod-zk1:2888:3888
server.2=fee-prod-zk2:2888:3888
server.3=fee-prod-zk3:2888:3888
7、创建myid文件 /var/lib/zookeeper
vi /etc/sysconfig/iptables
#添加host
192.168.100.01 fee-prod-zk1 #myid = 1
192.168.100.02 fee-prod-zk2 #myid = 2
192.168.100.03 fee-prod-zk3 #myid = 3
8、启动服务
/usr/local/zookeeper/bin/zkServer.sh start /usr/local/zookeeper/conf/zoo.cfg
查看状态
/usr/local/zookeeper/bin/zkServer.sh status