集群内加入新节点

新增2个节点,并以将这两个节点命名为ceph4和ceph5为例,介绍如何配置新节点加入进群。

操作步骤

  1. 安装ZooKeeper软件包。

    详情请参考安装Zookeeper

  2. 配置新节点的myid。

    1. 将ceph4配置为4。
      1
      2
      mkdir /opt/apache-zookeeper-3.6.3-bin-bcm/zkData
      echo 4 > /opt/apache-zookeeper-3.6.3-bin-bcm/zkData/myid
      
    2. 将ceph5配置为5。
      1
      2
      mkdir /opt/apache-zookeeper-3.6.3-bin-bcm/zkData
      echo 5 > /opt/apache-zookeeper-3.6.3-bin-bcm/zkData/myid
      

  3. 在2个新节点修改“zoo.cfg”配置文件。

    1. 打开文件。
      1
      vim /opt/apache-zookeeper-3.6.3-bin-bcm/conf/zoo.cfg
      
    2. “i”键进入编辑模式,参照如下内容进行修改。
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      # The number of milliseconds of each tick
      tickTime=1000
      # 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=2
      # the directory where the snapshot is stored.
      # do not use /tmp for storage, /tmp here is just 
      # example sakes.
      dataDir=/opt/apache-zookeeper-3.6.3-bin-bcm/zkData
      # 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=333
      #
      # 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=3
      
      ## Metrics Providers
      #
      # https://prometheus.io Metrics Exporter
      #metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
      #metricsProvider.httpPort=7000
      #metricsProvider.exportJvmInfo=true
      server.80=ceph1:2889:3889;2182
      server.90=ceph2:2889:3889;2182
      server.100=ceph3:2889:3889;2182
      server.4=ceph4:2889:3889;2182
      server.5=ceph5:2889:3889;2182
      4lw.commands.whitelist=*
      
    3. “Esc”键退出编辑模式,输入:wq!并按“Enter”键保存退出文件。

  4. 在2个新节点重启ZooKeeper服务。

    1
    /opt/apache-zookeeper-3.6.3-bin-bcm/bin/zkServer.sh start
    

  5. 在2个新节点查询ZooKeeper服务状态。

    1
    /opt/apache-zookeeper-3.6.3-bin-bcm/bin/zkServer.sh status
    
    回显如下所示。
    1
    2
    3
    4
    ZooKeeper JMX enabled by default
    Using config: /opt/apache-zookeeper-3.6.3-bin-bcm/bin/../conf/zoo.cfg
    Client port found: 2182. Client address: localhost. Client SSL: false.
    Mode: follower