-
解压安装包
# tar zxvf zookeeper-3.4.8.tar.gz
-
移动安装包到指定目录
# mv zookeeper-3.4.8 zookeeper # mv zookeeper /usr/local/
-
创建数据及日志目录
# mkdir –p /Disk/data/zookeeper # mkdir –p /Disk/logs/zookeeper
-
修改配置文件
复制一份配置文件 # cd /usr/local/zookeeper/conf # cp zoo_sample.cfg zoo.cfg 修改配置文件zoo.cfg # vim zoo.cfg 修改内容: dataDir=/Disk/data/zookeeper dataLogDir=/Disk/logs/zookeeper 最下方添加 server.1=本地局域网ip:2888:3888 保存退出
-
在data目录中创建myid文件并编辑内容为1
# cd /Disk/data/zookeeper # touch myid # vim myid 输入1,然后保存退出
-
启动zookeeper
# cd /usr/local/zookeeper/bin # ./zkServer.sh start # jps 显示QuormPeerMain则表示成功
-
修改日志目录
修改bin/zkEnv.sh 56行修改为:ZOO_LOG_DIR="/Disk/logs/zookeeper" 61行修改为:ZOO_LOG4J_PROP="INFO,ROLLINGFILE" 修改bin/zkServer.sh 129行修改为:_ZOO_DAEMON_OUT="$ZOO_LOG_DIR/zookeeper.log" 修改conf/log4j.properties zookeeper.root.logger=INFO, ROLLINGFILE zookeeper.log.dir=/Disk/logs/zookeeper zookeeper.tracelog.dir=/Disk/logs/zookeeper log4j.appender.ROLLINGFILE=org.apache.log4j.DailyRollingFileAppender 添加: log4j.appender.ROLLINGFILE.DatePattern='.'yyyyMMdd log4j.appender.ROLLINGFILE.encoding=UTF-8 log4j.appender.ROLLINGFILE.Append=false log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout log4j.appender.ROLLINGFILE.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}]%-5p %c(line:%L) %x-%m%n 注释3行: log4j.appender.ROLLINGFILE.MaxFileSize=10MB 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