解压
tar -zxvf zookeeper-3.4.5.tar.gz
解压成功后放到指定目录
mv zookeeper-3.4.5 /opt/yjx/
进入解压目录
cd /opt/yjx/zookeeper-3.4.5/conf
复制配置文件 改成zoo.cfg zoo_sample.cfg配置文件是不生效的
cp zoo_sample.cfg zoo.cfg
修改配置文件
vim zoo.cfg
# 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=/var/yjx/zookeeper #改变目录
# the port at which the clients will connect
clientPort=2181
#
# 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
# 设置服务器内部通信的地址和zk集群的节点
server.1=node01:2888:3888
server.2=node02:2888:3888
server.3=node03:2888:3888
修改日志路径
vim /opt/yjx/zookeeper-3.4.5/bin/zkEnv.sh
56 ZOO_LOG_DIR="/opt/yjx/zookeeper-3.4.5/logs"
61 ZOO_LOG4J_PROP="INFO,CONSOLE,ROLLINGFILE"
vim /opt/yjx/zookeeper-3.4.5/conf/log4j.properties
# Define some default values that can be overridden by system properties
zookeeper.root.logger=INFO, CONSOLE,ROLLINGFILE ##
zookeeper.console.threshold=INFO ##
zookeeper.log.dir=/opt/yjx/zookeeper-3.4.5/logs ##
zookeeper.log.file=zookeeper.log
zookeeper.log.threshold=DEBUG
zookeeper.tracelog.dir=.
zookeeper.tracelog.file=zookeeper_trace.log
#
# ZooKeeper Logging Configuration
#
# Format is "<default threshold> (, <appender>)+
# DEFAULT: console appender only
log4j.rootLogger=${zookeeper.root.logger}
# Example with rolling log file
#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE
# Example with rolling log file and tracing
#log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE
#
# Log INFO level and above messages to the console
#
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=${zookeeper.console.threshold}
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n
#
# Add ROLLINGFILE to rootLogger to get log file output
# Log DEBUG level and above messages to a log file
log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender ##
log4j.appender.ROLLINGFILE.Threshold=${zookeeper.log.threshold}
log4j.appender.ROLLINGFILE.File=${zookeeper.log.dir}/${zookeeper.log.file}
# Max log file size of 10MB
log4j.appender.ROLLINGFILE.MaxFileSize=10MB
# uncomment the next line to limit number of backup files
#log4j.appender.ROLLINGFILE.MaxBackupIndex=10
log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n
#
# Add TRACEFILE to rootLogger to get log file output
# Log DEBUG level and above messages to a log file
log4j.appender.TRACEFILE=org.apache.log4j.FileAppender ##
log4j.appender.TRACEFILE.Threshold=TRACE
log4j.appender.TRACEFILE.File=${zookeeper.tracelog.dir}/${zookeeper.tracelog.file}
log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout
### Notice we are including log4j's NDC here (%x)
log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L][%x] - %m%n
node02 node03 拷贝zookeeper
[root@node02 ~]# scp -r root@node01:/opt/yjx/zookeeper-3.4.5 /opt/yjx/zookeeper-3.4.5
[root@node03 ~]# scp -r root@node01:/opt/yjx/zookeeper-3.4.5 /opt/yjx/zookeeper-3.4.5
node【123】
mkdir -p /var/yjx/zookeeper
touch /var/yjx/zookeeper/myid
node01
echo 1 > /var/yjx/zookeeper/myid
node02
echo 2 > /var/yjx/zookeeper/myid
node03
echo 3 > /var/yjx/zookeeper/myid
node【123】
vim /etc/profile
# 最后加上
export ZOOKEEPER_HOME=/opt/yjx/zookeeper-3.4.5
export PATH=$ZOOKEEPER_HOME/bin:$PATH
node【123】
source /etc/profile
开启集群
【123】zkServer.sh start 启动
【123】zkServer.sh status 查看状态
【123】zkServer.sh stop 停止
zkCli.sh 进去
关机拍快照
shutdown -h now