1、安装jdk环境
zookeeper官网
主机:10.1.1.161
2、修改hosts
10.1.1.161 edu-provider-01
3、创建服务存放目录
mkdir /home/wusc && cd /home/wusc
4、下载解压zookeeper
使用 3.4.10版本
tar xvf
zookeeper-3.4.10.tar.gz
5、创建存放数据和日志的目录
cd zookeeper-3.4.10
mkdir data
mkdir logs
6、拷贝配置文件并修改
cd conf/
cp zoo_sample.cfg zoo.cfg
修改配置文件
vim 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=
/home/wusc/zookeeper-3.4.10/data
dataLogDir=
/home/wusc/zookeeper-3.4.10/logs
# 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
server.1=edu-provider-01:2888:3888
#2888端口是zookeeper服务之间通信的端口
#3888端口是zookeeper与其他应用程序通信的端口
7、创建myid文件
cd ../data/
vim myid
1
## "1"是在zoo.cfg中配置的server.1
8、添加zookeeper环境
vim /etc/profile
## zookooper
export ZOOKEEPER_HOME=/home/wusc/zookeeper-3.4.10
export PATH=$ZOOKEEPER_HOME/bin:$PATH
使配置文件生效
source /etc/profile
9、修改防火墙或关闭防火墙
vim /etc/sysconfig/iptables
# zookeeper
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2181 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2888 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3888 -j ACCEPT
重启iptables
service iptables restart
10、启动测试zookeeper
cd bin/
sh zkServer.sh start
Using config: /home/wusc/zookeeper-3.4.10/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
查看状态:
# sh zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/wusc/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode:
standalone
重启
# sh zkServer.sh restart