上传 zookeeper-3.4.10.tar.gz 到服务器

root@temple-102:/usr/local/temple/jar# ll
total 710940
drwxr-xr-x 2 root root      4096 8月  17 15:10 ./
drwxr-xr-x 7 root root      4096 8月  17 15:33 ../
-rw-r--r-- 1 root root   8534562 8月  17 15:10 apache-maven-3.5.0-bin.tar.gz
-rw-r--r-- 1 root root 266688029 8月  17 15:10 hadoop-2.7.4.tar.gz
-rw-r--r-- 1 root root 185515842 8月  17 15:10 jdk-8u144-linux-x64.tar.gz
-rw-r--r-- 1 root root  28460530 8月  17 15:10 scala-2.11.7.tgz
-rw-r--r-- 1 root root 203728858 8月  17 15:11 spark-2.2.0-bin-hadoop2.7.tgz
-rw-r--r-- 1 root root  35042811 8月  17 15:11 zookeeper-3.4.10.tar.gz

 

解压并重命名

root@temple-102:/usr/local/temple/jar# tar zxvf zookeeper-3.4.10.tar.gz -C /usr/local/temple/
root@temple-102:/usr/local/temple/jar# cd /usr/local/temple/
root@temple-102:/usr/local/temple# ll
total 28
drwxr-xr-x  7 root root 4096 8月  17 15:33 ./
drwxr-xr-x 11 root root 4096 8月  17 15:06 ../
drwxr-xr-x  3 root root 4096 8月  17 15:34 data/
drwxr-xr-x  2 root root 4096 8月  17 15:10 jar/
drwxr-xr-x  8 uucp  143 4096 7月  22 13:11 jdk/
drwxrwxr-x  6 1001 1001 4096 6月  23  2015 scala/
drwxr-xr-x 10 1001 1001 4096 8月  17 15:34 zookeeper/

配置,复制zoo.cfg文件, 并分别配置

root@temple-102:/usr/local/temple/zookeeper/conf# ll
total 64
drwxr-xr-x  2 1001 1001  4096 8月  17 16:02 ./
drwxr-xr-x 10 1001 1001  4096 8月  17 15:34 ../
-rw-rw-r--  1 1001 1001   535 3月  23 18:14 configuration.xsl
-rw-rw-r--  1 1001 1001  2161 3月  23 18:14 log4j.properties
-rw-r--r--  1 root root  1048 8月  17 15:32 zoo.cfg
-rw-r--r--  1 root root 34842 8月  17 15:53 zookeeper.out
-rw-rw-r--  1 1001 1001   922 3月  23 18:14 zoo_sample.cfg
-rw-r--r--  1 root root  1099 8月  17 16:02 zoo_slave01.cfg
-rw-r--r--  1 root root  1099 8月  17 16:02 zoo_slave02.cfg
-rw-r--r--  1 root root  1099 8月  17 16:02 zoo_slave03.cfg
zoo_slave01.cfg
root@temple-102:/usr/local/temple/zookeeper/conf# cat zoo_slave01.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/local/temple/data/zk/slave01/data
dataLogDir=/usr/local/temple/data/zk/slave01/dataLog
# 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=192.168.1.102:2889:3889
server.2=192.168.1.102:2890:3890
server.3=192.168.1.102:2891:3891
 
zoo_slave02.cfg

root@temple-102:/usr/local/temple/zookeeper/conf# cat zoo_slave02.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/local/temple/data/zk/slave02/data
dataLogDir=/usr/local/temple/data/zk/slave02/dataLog
# the port at which the clients will connect
clientPort=2182
# 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=192.168.1.102:2889:3889
server.2=192.168.1.102:2890:3890
server.3=192.168.1.102:2891:3891
zoo_slave03.cfg
root@temple-102:/usr/local/temple/zookeeper/conf# cat zoo_slave03.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/local/temple/data/zk/slave03/data
dataLogDir=/usr/local/temple/data/zk/slave03/dataLog
# the port at which the clients will connect
clientPort=2183
# 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=192.168.1.102:2889:3889
server.2=192.168.1.102:2890:3890
server.3=192.168.1.102:2891:3891

 

分别创建上面标红的文件夹

root@temple-102:/usr/local/temple/data/zk# ll
total 20
drwxr-xr-x 5 root root 4096 8月  17 15:39 ./
drwxr-xr-x 3 root root 4096 8月  17 15:34 ../
drwxr-xr-x 4 root root 4096 8月  17 15:40 slave01/
drwxr-xr-x 4 root root 4096 8月  17 15:40 slave02/
drwxr-xr-x 4 root root 4096 8月  17 15:40 slave03/

  

分别创建myid 文件

root@temple-102:/usr/local/temple/data/zk/slave01/data# pwd
/usr/local/temple/data/zk/slave01/data
root@temple-102:/usr/local/temple/data/zk/slave01/data# ll
total 16
drwxr-xr-x 3 root root 4096 8月  17 15:53 ./
drwxr-xr-x 4 root root 4096 8月  17 15:40 ../
-rw-r--r-- 1 root root    2 8月  17 15:43 myid
drwxr-xr-x 2 root root 4096 8月  17 16:02 version-2/
root@temple-102:/usr/local/temple/data/zk/slave01/data# cat myid 
1

 

root@temple-102:/usr/local/temple/data/zk/slave02/data# pwd
/usr/local/temple/data/zk/slave02/data
root@temple-102:/usr/local/temple/data/zk/slave02/data# ll
total 16
drwxr-xr-x 3 root root 4096 8月  17 15:53 ./
drwxr-xr-x 4 root root 4096 8月  17 15:40 ../
-rw-r--r-- 1 root root    2 8月  17 15:43 myid
drwxr-xr-x 2 root root 4096 8月  17 16:02 version-2/
root@temple-102:/usr/local/temple/data/zk/slave02/data# cat myid 
2
root@temple-102:/usr/local/temple/data/zk/slave03/data# pwd
/usr/local/temple/data/zk/slave03/data
root@temple-102:/usr/local/temple/data/zk/slave03/data# ll
total 16
drwxr-xr-x 3 root root 4096 8月  17 15:53 ./
drwxr-xr-x 4 root root 4096 8月  17 15:40 ../
-rw-r--r-- 1 root root    2 8月  17 15:43 myid
drwxr-xr-x 2 root root 4096 8月  17 16:02 version-2/
root@temple-102:/usr/local/temple/data/zk/slave03/data# cat myid 
3

 

关闭防火墙

root@temple-102:/usr/local/temple/zookeeper/conf# ufw disable

分别启动, 建议第一次启动使用start-foreground, 方便查看启动错误

root@temple-102:/usr/local/temple/zookeeper/conf# zkServer.sh start-foreground /usr/local/temple/zookeeper/conf/zoo_slave01.cfg
root@temple-102:/usr/local/temple/zookeeper/conf# zkServer.sh start-foreground /usr/local/temple/zookeeper/conf/zoo_slave02.cfg
root@temple-102:/usr/local/temple/zookeeper/conf# zkServer.sh start-foreground /usr/local/temple/zookeeper/conf/zoo_slave03.cfg

 

查看zookeeper 状态

root@temple-102:/usr/local/temple/zookeeper/conf# zkServer.sh status /usr/local/temple/zookeeper/conf/zoo_slave03.cfg
ZooKeeper JMX enabled by default
Using config: /usr/local/temple/zookeeper/conf/zoo_slave03.cfg
Mode: follower

 

查看进程

root@temple-102:/usr/local/temple/zookeeper/conf# ps -ef | grep zookeeper
root      6085     1  3 16:24 pts/0    00:00:01 /usr/local/temple/jdk/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/local/temple/zookeeper/bin/../build/classes:/usr/local/temple/zookeepe/bin/../build/lib/*.jar:/usr/local/temple/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/temple/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/temple/zookeeper/bin/../lib/netty-3.10.5.Final.jar:/usr/local/temple/zookeeper/bin/../lib/log4j-1.2.16.jar:/usr/local/temple/zookeeper/bin/../lib/jline-0.9.94.jar:/usr/local/temple/zookeeper/bin/../zookeeper-3.4.10.jar:/usr/local/temple/zookeeper/bin/../src/java/lib/*.jar:/usr/local/temple/zookeeper/bin/../conf:/usr/local/temple/zookeeper/bin/../build/classes:/usr/local/temple/zookeeper/bin/../build/lib/*.jar:/usr/local/temple/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/temple/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/temple/zookeeper/bin/../lib/netty-3.10.5.Final.jar:/usr/local/temple/zookeeper/bin/../lib/log4j-1.2.16.jar:/usr/local/temple/zookeeper/bin/../lib/jline-0.9.94.jar:/usr/local/temple/zookeeper/bin/../zookeeper-3.4.10.jar:/usr/local/temple/zookeeper/bin/../src/java/lib/*.jar:/usr/local/temple/zookeeper/bin/../conf:.:/usr/local/temple/jdk/lib/dt.jar:/usr/local/temple/jdk/lib/tools.jar -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /usr/local/temple/zookeeper/conf/zoo_slave01.cfg
root      6177     1  3 16:24 pts/0    00:00:01 /usr/local/temple/jdk/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/local/temple/zookeeper/bin/../build/classes:/usr/local/temple/zookeepe/bin/../build/lib/*.jar:/usr/local/temple/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/temple/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/temple/zookeeper/bin/../lib/netty-3.10.5.Final.jar:/usr/local/temple/zookeeper/bin/../lib/log4j-1.2.16.jar:/usr/local/temple/zookeeper/bin/../lib/jline-0.9.94.jar:/usr/local/temple/zookeeper/bin/../zookeeper-3.4.10.jar:/usr/local/temple/zookeeper/bin/../src/java/lib/*.jar:/usr/local/temple/zookeeper/bin/../conf:/usr/local/temple/zookeeper/bin/../build/classes:/usr/local/temple/zookeeper/bin/../build/lib/*.jar:/usr/local/temple/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/temple/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/temple/zookeeper/bin/../lib/netty-3.10.5.Final.jar:/usr/local/temple/zookeeper/bin/../lib/log4j-1.2.16.jar:/usr/local/temple/zookeeper/bin/../lib/jline-0.9.94.jar:/usr/local/temple/zookeeper/bin/../zookeeper-3.4.10.jar:/usr/local/temple/zookeeper/bin/../src/java/lib/*.jar:/usr/local/temple/zookeeper/bin/../conf:.:/usr/local/temple/jdk/lib/dt.jar:/usr/local/temple/jdk/lib/tools.jar -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /usr/local/temple/zookeeper/conf/zoo_slave02.cfg
root      6283     1  4 16:24 pts/0    00:00:01 /usr/local/temple/jdk/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/local/temple/zookeeper/bin/../build/classes:/usr/local/temple/zookeepe/bin/../build/lib/*.jar:/usr/local/temple/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/temple/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/temple/zookeeper/bin/../lib/netty-3.10.5.Final.jar:/usr/local/temple/zookeeper/bin/../lib/log4j-1.2.16.jar:/usr/local/temple/zookeeper/bin/../lib/jline-0.9.94.jar:/usr/local/temple/zookeeper/bin/../zookeeper-3.4.10.jar:/usr/local/temple/zookeeper/bin/../src/java/lib/*.jar:/usr/local/temple/zookeeper/bin/../conf:/usr/local/temple/zookeeper/bin/../build/classes:/usr/local/temple/zookeeper/bin/../build/lib/*.jar:/usr/local/temple/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/temple/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/temple/zookeeper/bin/../lib/netty-3.10.5.Final.jar:/usr/local/temple/zookeeper/bin/../lib/log4j-1.2.16.jar:/usr/local/temple/zookeeper/bin/../lib/jline-0.9.94.jar:/usr/local/temple/zookeeper/bin/../zookeeper-3.4.10.jar:/usr/local/temple/zookeeper/bin/../src/java/lib/*.jar:/usr/local/temple/zookeeper/bin/../conf:.:/usr/local/temple/jdk/lib/dt.jar:/usr/local/temple/jdk/lib/tools.jar -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /usr/local/temple/zookeeper/conf/zoo_slave03.cfg
root      6435  2277  0 16:25 pts/0    00:00:00 grep --color=auto zookeeper
root@temple-102:/usr/local/temple/zookeeper/conf# 

 

完成

 
posted on 2017-08-17 16:23  肖建锋  阅读(675)  评论(0编辑  收藏  举报