标签:zookeeper
配置hosts
192.168.174.129 huanghe 192.168.174.130 gaorongrong 192.168.174.131 liangyan
下载zookeeper(去http://mirrors.hust.edu.cn/apache/zookeeper/下载)
cd /usr/local/src
wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
tar zxvf zookeeper-3.4.6.tar.gz
mv zookeeper-3.4.6 /usr/local/
mv /usr/local/zookeeper-3.4.6 /usr/local/zookeeper
mv /usr/local/zookeeper/conf/zoo_sample.cfg /usr/local/zookeeper/conf/zoo.cfg
修改配置文件
vim /usr/local/zookeeper/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=/usr/zookeeper/zkdata dataLogDir=/usr/zookeeper/logs # the port at which the clients will connect clientPort=2181 server.1=huanghe:2888:3888 server.2=gaorongrong:2888:3888 server.3=liangyan:2888:3888 # 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
创建数据目录和日志目录
mkdir /usr/zookeeper/zkdata
mkdir /usr/zookeeper/logs
关闭SELinux和firewalld
查看SELinux状态 getenforce
setenforce 0
或者
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled
重启机器即可
systemctl stop firewalld
或者
yum -y install iptables-services
service iptables stop
添加环境变量
vim /etc/profile
在末尾添加
export ZOOKEEPER=/usr/local/zookeeper
export PATH=$ZOOKEEPER/bin:$PATH
保存后source /etc/profile
设置myid
192.168.174.129服务器设置
eccho ‘1‘>/usr/local/zookeeper/zkdata/myid
192.168.174.130服务器设置
eccho ‘2‘>/usr/local/zookeeper/zkdata/myid
192.168.174.131服务器设置
eccho ‘3‘>/usr/local/zookeeper/zkdata/myid
在三台服务器上依次启动
zkServer.sh start
zkServer.sh status
至此,zookeeper集群安装完毕。
标签:zookeeper
原文地址:http://hehe1987.blog.51cto.com/2094458/1833270