3.zookeeper3.4.13安装

主机            IP                      应用目录                              数据目录

JacK6    192.168.99.6   /app/software/zookeeper-3.4.13/   /app/tmp/zookeeper_data/data,/app/tmp/zookeeper_data/log

JacK7     192.168.99.7     /app/software/zookeeper-3.4.13/   /app/tmp/zookeeper_data/data,/app/tmp/zookeeper_data/log

JacK8     192.168.99.8     /app/software/zookeeper-3.4.13//app/tmp/zookeeper_data/data,/app/tmp/zookeep

1.解压下载的安装包,创建目录:

[JacK@JacK6 ~]$tar-xvf/app/setup/zookeeper-3.4.13.tar.gz-C/app/software/

[JacK@JacK6 conf]$ cd/app/software/zookeeper-3.4.13/conf

[JacK@JacK6 conf]$ cpzoo_sample.cfg zoo.cfg

[JacK@JacK6 tmp]$ mkdir-p/app/tmp/zookeeper_data/logs

[JacK@JacK6 tmp]$ mkdir-p/app/tmp/zookeeper_data/data

[JacK@JacK7 tmp]$ mkdir-p/app/tmp/zookeeper_data/logs

[JacK@JacK7 tmp]$ mkdir-p/app/tmp/zookeeper_data/data

[JacK@JacK8 tmp]$ mkdir-p/app/tmp/zookeeper_data/logs

[JacK@JacK8 tmp]$ mkdir-p/app/tmp/zookeeper_data/data

2.编辑配置文件:都在JacK6号机

[JacK@JacK6 conf]cd /app/software/zookeeper-3.4.13/conf

[JacK@JacK6 conf]$ vimzoo.cfg

# The number of milliseconds of each tick

tickTime=2000                                          #心跳探测时间,单位为毫秒

# The number of ticks that the initial

# synchronization phase can take

initLimit=10                                            #连接leader的超时时长

# 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=/app/tmp/zookeeper_data/data                        #数据存放目录

# 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

#

server.1=JacK6:2888:3888                                    #集群节点

server.2=JacK7:2888:3888

server.3=JacK8:2888:3888

# 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

​ 日志配置

[JacK@JacK6 conf]cd /app/software/zookeeper-3.4.13/conf

[JacK@JacK6 conf]$ vimlog4j.properties

# Define some default values that can be overridden by system properties

zookeeper.root.logger=INFO,ROLLINGFILE                      #修改日志器

zookeeper.console.threshold=INFO

zookeeper.log.dir=.

zookeeper.log.file=zookeeper.log

zookeeper.log.threshold=DEBUG

zookeeper.tracelog.dir=.

zookeeper.tracelog.file=zookeeper_trace.log

#

# ZooKeeper Logging Configuration

#

# Format is " (, )+

# 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.DailyRollingFileAppender      #按日期切分

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

[JacK@JacK6 bin]$cd/app/software/zookeeper-3.4.13/bin

[JacK@JacK6 bin]$ vimzkEnv.sh                      #其他内容不动,修改以下说明部分

if["x${ZOO_LOG_DIR}"="x"]

then

ZOO_LOG_DIR="/app/tmp/zookeeper_data/logs"              #修改路径

fi

if["x${ZOO_LOG4J_PROP}"="x"]

then

ZOO_LOG4J_PROP="INFO,ROLLINGFILE"                      #修改日志器

fi

3.复制到其他节点:

[JacK@JacK6 software]$scp-r/app/software/zookeeper-3.4.13 JacK7:/app/software/

[JacK@JacK6 software]$scp-r/app/software/zookeeper-3.4.13 JacK8:/app/software/

4.创建myid文件:保证每个节点的唯一性

[JacK@JacK6 data]$ cd/app/tmp/zookeeper_data/data

[JacK@JacK6 data]$ echo1> myid

[JacK@JacK7 data]$ cd/app/tmp/zookeeper_data/data

[JacK@JacK7 data]$ echo2> myid

[JacK@JacK8 data]$ cd/app/tmp/zookeeper_data/data

[JacK@JacK8 data]$ echo3> myid

5.启停测试:

[JacK@JacK6 data]$ cd/app/software/zookeeper-3.4.13/bin/

[JacK@JacK6 bin]$ shzkServer.shstart

#相同命令启动其他两个节点

查看状态

[JacK@JacK6 bin]$ shzkServer.sh status

ZooKeeper JMX enabled by default

Using config: /app/software/zookeeper-3.4.13/bin/../conf/zoo.cfg

Mode: follower

[JacK@JacK7 bin]$ shzkServer.sh status

ZooKeeper JMX enabled by default

Using config: /app/software/zookeeper-3.4.13/bin/../conf/zoo.cfg

Mode: follower

[JacK@JacK8 bin]$ shzkServer.sh status

ZooKeeper JMX enabled by default

Using config: /app/software/zookeeper-3.4.13/bin/../conf/zoo.cfg

Mode: leader

#可以看到此时8号机是leader

你可能感兴趣的:(3.zookeeper3.4.13安装)