2.1.5. zookeeper分布式部署

1.修改zoo.cfg相关配置




 
  
  [root@hadoop202
  ~]# cd /opt/module/zookeeper-3.4.10/
  [root@hadoop202
  zookeeper-3.4.10]# ll
  总用量 1600
  drwxr-xr-x.  2 cevent cevent    4096 3月  23 2017 bin
  -rw-rw-r--.  1 cevent cevent   84725 3月  23 2017 build.xml
  drwxr-xr-x.  2 cevent cevent    4096 4月  18 16:11 conf
  drwxr-xr-x. 10
  cevent cevent    4096 3月  23 2017 contrib
  drwxrwxr-x.  3 cevent cevent    4096 4月  18 16:10 data
  drwxr-xr-x.  2 cevent cevent    4096 3月  23 2017 dist-maven
  drwxr-xr-x.  6 cevent cevent    4096 3月  23 2017 docs
  -rw-rw-r--.  1 cevent cevent    1709 3月  23 2017 ivysettings.xml
  -rw-rw-r--.  1 cevent cevent    5691 3月  23 2017 ivy.xml
  drwxr-xr-x.  4 cevent cevent    4096 3月  23 2017 lib
  -rw-rw-r--.  1 cevent cevent   11938 3月  23 2017 LICENSE.txt
  -rw-rw-r--.  1 cevent cevent    3132 3月  23 2017 NOTICE.txt
  -rw-rw-r--.  1 cevent cevent    1770 3月  23 2017
  README_packaging.txt
  -rw-rw-r--.  1 cevent cevent    1585 3月  23 2017 README.txt
  drwxr-xr-x.  5 cevent cevent    4096 3月  23 2017 recipes
  drwxr-xr-x.  8 cevent cevent    4096 3月  23 2017 src
  -rw-rw-r--.  1 cevent cevent 1456729 3月  23 2017 zookeeper-3.4.10.jar
  -rw-rw-r--.  1 cevent cevent     819 3月  23 2017
  zookeeper-3.4.10.jar.asc
  -rw-rw-r--.  1 cevent cevent      33 3月  23 2017
  zookeeper-3.4.10.jar.md5
  -rw-rw-r--.  1 cevent cevent      41 3月  23 2017
  zookeeper-3.4.10.jar.sha1
  -rw-rw-r--.  1 cevent cevent    6005 4月  18 16:14 zookeeper.out
  [root@hadoop202
  zookeeper-3.4.10]# cd conf/
  [root@hadoop202
  conf]# ll
  总用量 12
  -rw-rw-r--. 1
  cevent cevent  535 3月  23 2017 configuration.xsl
  -rw-rw-r--. 1
  cevent cevent 2161 3月  23 2017 log4j.properties
  -rw-rw-r--. 1
  cevent cevent  948 4月  18 16:11 zoo.cfg
  [root@hadoop202
  conf]# vi 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=/opt/module/zookeeper-3.4.10/data/zkData
  # the port at
  which the clients will connect
  clientPort=2181
   
  ##################cluster#################
  server.2=hadoop202.cevent.com:2888:3888
  server.3=hadoop203.cevent.com:2888:3888
  server.4=hadoop204.cevent.com:2888:3888
   
  # 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
  ~
  
 




2.创建并配置每个服务器的myid




 
  
  [root@hadoop202
  conf]# cd ..
  [root@hadoop202
  zookeeper-3.4.10]# ll
  总用量 1600
  drwxr-xr-x.  2 cevent cevent    4096 3月  23 2017 bin
  -rw-rw-r--.  1 cevent cevent   84725 3月  23 2017 build.xml
  drwxr-xr-x.  2 cevent cevent    4096 4月  18 20:46 conf
  drwxr-xr-x. 10
  cevent cevent    4096 3月  23 2017 contrib
  drwxrwxr-x.  3 cevent cevent    4096 4月  18 16:10 data
  drwxr-xr-x.  2 cevent cevent    4096 3月  23 2017 dist-maven
  drwxr-xr-x.  6 cevent cevent    4096 3月  23 2017 docs
  -rw-rw-r--.  1 cevent cevent    1709 3月  23 2017 ivysettings.xml
  -rw-rw-r--.  1 cevent cevent    5691 3月  23 2017 ivy.xml
  drwxr-xr-x.  4 cevent cevent    4096 3月  23 2017 lib
  -rw-rw-r--.  1 cevent cevent   11938 3月  23 2017 LICENSE.txt
  -rw-rw-r--.  1 cevent cevent    3132 3月  23 2017 NOTICE.txt
  -rw-rw-r--.  1 cevent cevent    1770 3月  23 2017 README_packaging.txt
  -rw-rw-r--.  1 cevent cevent    1585 3月  23 2017 README.txt
  drwxr-xr-x.  5 cevent cevent    4096 3月  23 2017 recipes
  drwxr-xr-x.  8 cevent cevent    4096 3月  23 2017 src
  -rw-rw-r--.  1 cevent cevent 1456729 3月  23 2017
  zookeeper-3.4.10.jar
  -rw-rw-r--.  1 cevent cevent     819 3月  23 2017 zookeeper-3.4.10.jar.asc
  -rw-rw-r--.  1 cevent cevent      33 3月  23 2017 zookeeper-3.4.10.jar.md5
  -rw-rw-r--.  1 cevent cevent      41 3月  23 2017 zookeeper-3.4.10.jar.sha1
  -rw-rw-r--.  1 cevent cevent    6005 4月  18 16:14 zookeeper.out
  [root@hadoop202
  zookeeper-3.4.10]# cd data/zkData/
  [root@hadoop202
  zkData]# ll
  总用量 4
  drwxrwxr-x. 2
  cevent cevent 4096 4月  18
  16:14 version-2
  [root@hadoop202
  zkData]# touch myid
  [root@hadoop202
  zkData]# ll
  总用量 4
  -rw-r--r--. 1
  root   root      0 4月  18 20:47 myid
  drwxrwxr-x. 2
  cevent cevent 4096 4月  18
  16:14 version-2
   
  插入myid的value=202
  
 


3.分发zookeeper




 
  
  [root@hadoop202
  zkData]# cd ..
  [root@hadoop202
  data]# cd ..
  [root@hadoop202
  zookeeper-3.4.10]# ll
  总用量 1600
  drwxr-xr-x.  2 cevent cevent    4096 3月  23 2017 bin
  -rw-rw-r--.  1 cevent cevent   84725 3月  23 2017 build.xml
  drwxr-xr-x.  2 cevent cevent    4096 4月  18 20:46 conf
  drwxr-xr-x. 10
  cevent cevent    4096 3月  23 2017 contrib
  drwxrwxr-x.  3 cevent cevent    4096 4月  18 16:10 data
  drwxr-xr-x.  2 cevent cevent    4096 3月  23 2017 dist-maven
  drwxr-xr-x.  6 cevent cevent    4096 3月  23 2017 docs
  -rw-rw-r--.  1 cevent cevent    1709 3月  23 2017 ivysettings.xml
  -rw-rw-r--.  1 cevent cevent    5691 3月  23 2017 ivy.xml
  drwxr-xr-x.  4 cevent cevent    4096 3月  23 2017 lib
  -rw-rw-r--.  1 cevent cevent   11938 3月  23 2017 LICENSE.txt
  -rw-rw-r--.  1 cevent cevent    3132 3月  23 2017 NOTICE.txt
  -rw-rw-r--.  1 cevent cevent    1770 3月  23 2017
  README_packaging.txt
  -rw-rw-r--.  1 cevent cevent    1585 3月  23 2017 README.txt
  drwxr-xr-x.  5 cevent cevent    4096 3月  23 2017 recipes
  drwxr-xr-x.  8 cevent cevent    4096 3月  23 2017 src
  -rw-rw-r--.  1 cevent cevent 1456729 3月  23 2017 zookeeper-3.4.10.jar
  -rw-rw-r--.  1 cevent cevent     819 3月  23 2017
  zookeeper-3.4.10.jar.asc
  -rw-rw-r--.  1 cevent cevent      33 3月  23 2017
  zookeeper-3.4.10.jar.md5
  -rw-rw-r--.  1 cevent cevent      41 3月  23 2017
  zookeeper-3.4.10.jar.sha1
  -rw-rw-r--.  1 cevent cevent    6005 4月  18 16:14 zookeeper.out
  [root@hadoop202
  zookeeper-3.4.10]# cd conf/
  [root@hadoop202
  conf]# ll
  总用量 12
  -rw-rw-r--. 1
  cevent cevent  535 3月  23 2017 configuration.xsl
  -rw-rw-r--. 1
  cevent cevent 2161 3月  23 2017 log4j.properties
  -rw-rw-r--. 1
  cevent cevent 1113 4月  18 20:46 zoo.cfg
  [root@hadoop202
  conf]# vi zoo.cfg
   
  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=/opt/module/zookeeper-3.4.10/data/zkData
  # the port at
  which the clients will connect
  clientPort=2181
   
  ##################cluster#################
  server.202=hadoop202.cevent.com:2888:3888
  server.203=hadoop203.cevent.com:2888:3888
  server.204=hadoop204.cevent.com:2888:3888
   
  # 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
  ~
  分发zookeeper
  [root@hadoop202
  module]# xsync zookeeper-3.4.10/
  
 


4.递归修改权限




 
  
  [root@hadoop203
  module]# chown cevent:cevent -R zookeeper-3.4.10/ 递归修改权限
  [root@hadoop203
  module]# ll
  总用量 12
  drwxr-xr-x. 11
  cevent cevent 4096 3月  21 14:03 hadoop-2.7.2
  drwxr-xr-x.  8 cevent cevent 4096 4月  11 2015 jdk1.7.0_79
  drwxr-xr-x. 11
  cevent cevent 4096 4月  18 21:02 zookeeper-3.4.10
  [root@hadoop203
  module]# cd zookeeper-3.4.10/
  [root@hadoop203
  zookeeper-3.4.10]# ll
  总用量 1600
  drwxr-xr-x.  2 cevent cevent    4096 4月  18 21:02 bin
  -rw-r--r--.  1 cevent cevent   84725 4月  18 21:02 build.xml
  drwxr-xr-x.  2 cevent cevent    4096 4月  18 21:02 conf
  drwxr-xr-x. 10
  cevent cevent    4096 4月  18 21:02 contrib
  drwxr-xr-x.  3 cevent cevent    4096 4月  18 21:02 data
  drwxr-xr-x.  2 cevent cevent    4096 4月  18 21:02 dist-maven
  drwxr-xr-x.  6 cevent cevent    4096 4月  18 21:02 docs
  -rw-r--r--.  1 cevent cevent    1709 4月  18 21:02 ivysettings.xml
  -rw-r--r--.  1 cevent cevent    5691 4月  18 21:02 ivy.xml
  drwxr-xr-x.  4 cevent cevent    4096 4月  18 21:02 lib
  -rw-r--r--.  1 cevent cevent   11938 4月  18 21:02 LICENSE.txt
  -rw-r--r--.  1 cevent cevent    3132 4月  18 21:02 NOTICE.txt
  -rw-r--r--.  1 cevent cevent    1770 4月
   18 21:02
  README_packaging.txt
  -rw-r--r--.  1 cevent cevent    1585 4月  18 21:02 README.txt
  drwxr-xr-x.  5 cevent cevent    4096 4月  18 21:02 recipes
  drwxr-xr-x.  8 cevent cevent    4096 4月  18 21:02 src
  -rw-r--r--.  1 cevent cevent 1456729 4月  18 21:02 zookeeper-3.4.10.jar
  -rw-r--r--.  1 cevent cevent     819 4月  18 21:02
  zookeeper-3.4.10.jar.asc
  -rw-r--r--.  1 cevent cevent      33 4月  18 21:02
  zookeeper-3.4.10.jar.md5
  -rw-r--r--.  1 cevent cevent      41 4月  18 21:02
  zookeeper-3.4.10.jar.sha1
  -rw-r--r--.  1 cevent cevent    6005 4月  18 21:02 zookeeper.out
  
 


5.修改myid




 
  
  [root@hadoop203
  zookeeper-3.4.10]# ll
  总用量 1600
  drwxr-xr-x.  2 cevent cevent    4096 4月  18 21:02 bin
  -rw-r--r--.  1 cevent cevent   84725 4月  18 21:02 build.xml
  drwxr-xr-x.  2 cevent cevent    4096 4月  18 21:02 conf
  drwxr-xr-x. 10
  cevent cevent    4096 4月  18 21:02 contrib
  drwxr-xr-x.  3 cevent cevent    4096 4月  18 21:02 data
  drwxr-xr-x.  2 cevent cevent    4096 4月  18 21:02 dist-maven
  drwxr-xr-x.  6 cevent cevent    4096 4月  18 21:02 docs
  -rw-r--r--.  1 cevent cevent    1709 4月  18 21:02 ivysettings.xml
  -rw-r--r--.  1 cevent cevent    5691 4月  18 21:02 ivy.xml
  drwxr-xr-x.  4 cevent cevent    4096 4月  18 21:02 lib
  -rw-r--r--.  1 cevent cevent   11938 4月  18 21:02 LICENSE.txt
  -rw-r--r--.  1 cevent cevent    3132 4月  18 21:02 NOTICE.txt
  -rw-r--r--.  1 cevent cevent    1770 4月  18 21:02
  README_packaging.txt
  -rw-r--r--.  1 cevent cevent    1585 4月  18 21:02 README.txt
  drwxr-xr-x.  5 cevent cevent    4096 4月  18 21:02 recipes
  drwxr-xr-x.  8 cevent cevent    4096 4月  18 21:02 src
  -rw-r--r--.  1 cevent cevent 1456729 4月  18 21:02 zookeeper-3.4.10.jar
  -rw-r--r--.  1 cevent cevent     819 4月  18 21:02
  zookeeper-3.4.10.jar.asc
  -rw-r--r--.  1 cevent cevent      33 4月  18 21:02
  zookeeper-3.4.10.jar.md5
  -rw-r--r--.  1 cevent cevent      41 4月  18 21:02
  zookeeper-3.4.10.jar.sha1
  -rw-r--r--.  1 cevent cevent    6005 4月  18 21:02 zookeeper.out
  [root@hadoop203
  zookeeper-3.4.10]# cd data
  [root@hadoop203
  data]# ll
  总用量 4
  drwxr-xr-x. 3
  cevent cevent 4096 4月  18 21:02 zkData
  [root@hadoop203
  data]# cd zkData/
  [root@hadoop203
  zkData]# ll
  总用量 8
  -rw-r--r--. 1
  cevent cevent    4 4月  18 21:02 myid
  drwxr-xr-x. 2
  cevent cevent 4096 4月  18 21:02 version-2
  [root@hadoop203
  zkData]# vi myid
  203
  …
  204
  …
  205
  
 


6.启动zookeeper集群




 
  
  [root@hadoop202 module]# cd zookeeper-3.4.10/
  [root@hadoop202 zookeeper-3.4.10]#
  ll
  总用量 1600
  drwxr-xr-x.  2 cevent cevent    4096 3月  23 2017 bin
  -rw-rw-r--.  1 cevent cevent   84725 3月  23 2017
  build.xml
  drwxr-xr-x.  2 cevent cevent    4096 4月  18 20:58 conf
  drwxr-xr-x. 10 cevent cevent    4096 3月  23 2017 contrib
  drwxrwxr-x.  3 cevent cevent    4096 4月  18 16:10 data
  drwxr-xr-x.  2 cevent cevent    4096 3月  23 2017
  dist-maven
  drwxr-xr-x.  6 cevent cevent    4096 3月  23 2017 docs
  -rw-rw-r--.  1 cevent cevent    1709 3月  23 2017
  ivysettings.xml
  -rw-rw-r--.  1 cevent cevent    5691 3月  23 2017 ivy.xml
  drwxr-xr-x.  4 cevent cevent    4096 3月  23 2017 lib
  -rw-rw-r--.  1 cevent cevent   11938 3月  23 2017
  LICENSE.txt
  -rw-rw-r--.  1 cevent cevent    3132 3月  23 2017
  NOTICE.txt
  -rw-rw-r--.  1 cevent cevent    1770 3月  23 2017
  README_packaging.txt
  -rw-rw-r--.  1 cevent cevent    1585 3月  23 2017
  README.txt
  drwxr-xr-x.  5 cevent cevent    4096 3月  23 2017 recipes
  drwxr-xr-x.  8 cevent cevent    4096 3月  23 2017 src
  -rw-rw-r--.  1 cevent cevent 1456729 3月  23 2017 zookeeper-3.4.10.jar
  -rw-rw-r--.  1 cevent cevent     819 3月  23 2017
  zookeeper-3.4.10.jar.asc
  -rw-rw-r--.  1 cevent cevent      33 3月  23 2017
  zookeeper-3.4.10.jar.md5
  -rw-rw-r--.  1 cevent cevent      41 3月  23 2017
  zookeeper-3.4.10.jar.sha1
  -rw-rw-r--.  1 cevent cevent    6005 4月  18 16:14
  zookeeper.out
  [root@hadoop202 zookeeper-3.4.10]# bin/zkServer.sh start
  ZooKeeper JMX enabled by default
  Using config:
  /opt/module/zookeeper-3.4.10/bin/../conf/zoo.cfg
  Starting zookeeper ... STARTED
  [root@hadoop202 zookeeper-3.4.10]# bin/zkServer.sh status
  ZooKeeper JMX enabled by default
  Using config:
  /opt/module/zookeeper-3.4.10/bin/../conf/zoo.cfg
  Error contacting service. It is
  probably not running.
  
 


其他集群




 
  
  [root@hadoop204 zkData]# cd ../..
  You have new mail in
  /var/spool/mail/root
  [root@hadoop204 zookeeper-3.4.10]# bin/zkServer.sh start
  ZooKeeper JMX enabled by default
  Using config:
  /opt/module/zookeeper-3.4.10/bin/../conf/zoo.cfg
  Starting zookeeper ... STARTED
  [root@hadoop204 zookeeper-3.4.10]# bin/zkServer.sh status
  ZooKeeper JMX enabled by default
  Using config:
  /opt/module/zookeeper-3.4.10/bin/../conf/zoo.cfg
  Mode: follower
  
 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值