Zoo Keeperはノードを動的に追加または削除します。


@Author  : Spinach | GHB
@Link    : http://blog.csdn.net/bocai8058
記事の目次
  • 配置需要
  • 動的追加ノード
  • ノード
  • を動的に削除する。
    需要の設定
    番号付け
    現在の設定
    myid
    デマンドの設定
    myid
    01
    server.1=10.1.36:2881:3881
    1
    server.1=10.1.36:2881:3881
    1
    02
    server.2=10.1.3.7:2881:3881
    2
    server.2=10.1.3.7:2881:3881
    2
    03
    server.3=10.1.38:2881:3881
    3
    server.3=10.1.38:2881:3881
    3
    04
    server.4=10.1.39:2881:3881
    4
    05
    server.5=10.1.3.10:2881:3881
    5
    注:server.A=B:C:D【AはA番サーバ、Bはクライアントポート、Cはleaderと情報を交換するポート、D:選挙ポート】
    設定ファイルにはzoo.cfgとmyidがあります。以下はserver.1=10.1.36:2881:3881の構成です。
    #########    ./cfg/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=/home/ghb/HadoopCluster/zookeeper001/data
    dataLogDir=/home/ghb/HadoopCluster/zookeeper001/logs
    # 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=10.1.3.6:2881:3881
    server.2=10.1.3.7:2881:3881
    server.3=10.1.3.8:2881:3881
    
    #########    ./data/myid #########      
    
    1
    
    動的追加ノード
  • は10.1.3.9と10.1.3.10でzookeeperを解凍した後、cfgに入る。
  • mv zoo_sample.cfg zoo.cfg
  • 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=/home/ghb/HadoopCluster/zookeeper004/data
    dataLogDir=/home/ghb/HadoopCluster/zookeeper004/logs
    # 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=10.1.3.6:2881:3881
    server.2=10.1.3.7:2881:3881
    server.3=10.1.3.8:2881:3881
    server.4=10.1.3.9:2881:3881
    server.5=10.1.3.10:2881:3881
    
  • /home/ghb/HadoopCuster/zookeeper 004/dataフォルダを作成し、中にmyidファイルを作成し、下記の内容を追加します。
    4
    
  • は10.1.3.10で同様に動作し、修正したら10.1.366、10.1.3.8に戻り、zoo.cfgの内容を次のように置き換える。
    server.1=10.1.3.6:2881:3881
    server.2=10.1.3.7:2881:3881
    server.3=10.1.3.8:2881:3881
    #         ,      
    server.1=10.1.3.6:2881:3881
    server.2=10.1.3.7:2881:3881
    server.3=10.1.3.8:2881:3881
    server.4=10.1.3.9:2881:3881
    server.5=10.1.3.10:2881:3881
    
    ノードを動的に削除
    その動作は、動的追加ノード動作とは対照的に、対応する構成を除去すればよい。