ZooKeeper - shawfdong/hyades GitHub Wiki
ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. ZooKeeper was a sub-project of Hadoop but is now a top-level project of Apache Software Foundation.
On the Huawei Universal Distributed Storage, ZooKeeper 3.34 service is running on Management Node, as well as on the 2 Operation Maintenance Servers (OMS). The configuration file for ZooKeeper service is /opt/sod/zookeeper/conf/zoo.cfg.
MN:
# The number of milliseconds of each tick tickTime=6000 # 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 dataDir=/UDS_data/zookeeper/data #the directory where the log is stored dataLogDir=/UDS_data/zookeeper/log # the port at which the clients will connect clientPort=2100 # server list server.1=172.16.0.11:2101:2102 server.2=172.16.0.12:2104:2105 server.3=172.16.0.13:2107:2108
OMS01:
# The number of milliseconds of each tick tickTime=6000 # 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 dataDir=/UDS_data/zookeeper/data #the directory where the log is stored dataLogDir=/UDS_data/zookeeper/log # the port at which the clients will connect clientPort=2103 # server list server.1=172.16.0.11:2101:2102 server.2=172.16.0.12:2104:2105 server.3=172.16.0.13:2107:2108
OMS02:
# The number of milliseconds of each tick tickTime=6000 # 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 dataDir=/UDS_data/zookeeper/data #the directory where the log is stored dataLogDir=/UDS_data/zookeeper/log # the port at which the clients will connect clientPort=2106 # server list server.1=172.16.0.11:2101:2102 server.2=172.16.0.12:2104:2105 server.3=172.16.0.13:2107:2108
Note the clientPorts are 2100, 2103 & 2106, respectively, on 3 servers. The 3 ZooKeeper services are run in replicated mode[1]. The 3 servers form a quoram; As long as a majority of the servers are available, the ZooKeeper service will be available.
We can use the Java client zkCli.sh to connect to either of the ZooKeeper servers[2]. :
# zkCli.sh -server 172.16.0.11:2100or
# zkCli.sh -server 172.16.0.12:2103or
# zkCli.sh -server 172.16.0.13:2106
The name space provided by ZooKeeper is much like that of a standard file system. A name is a sequence of path elements separated by a slash (/). Every node in ZooKeeper's name space is identified by a path.
# zkCli.sh -server 172.16.0.11:2100 Connecting to 172.16.0.11:2100 Welcome to ZooKeeper! JLine support is enabled [zk: 172.16.0.11:2100(CONNECTING) 0] [zk: 172.16.0.11:2100(CONNECTED) 1] ls / [uds_obs_omd_router4, uds_obs_omd_router5, uds_obs_omd_router6, uds_obs_omd_router7, zookeeper, lock, config, uds_obs_omd_router2, uds_obs_omd_router3, uds_obs_omd_router] [zk: 172.16.0.11:2100(CONNECTED) 2] ls /config [cluster, tasks, parameters, stores, staticconfig] [zk: 172.16.0.11:2100(CONNECTED) 3] ls /config/cluster [nodeDynamicConfig.xml] [zk: 172.16.0.11:2100(CONNECTED) 4] get /config/cluster/nodeDynamicConfig.xml <info> <version>5085</version> <name>SoD</name> <operationPermission>readwritedelete</operationpermission> <nodedynamic> <id>0</id> <staticId>0</staticid> <enable>true</enable> <config>config_sync</config> <fault-type>normal</fault-type> <partitions>663,749,888,2917,3499,3905,4573,4990,5279,6688,6691,6986,7711,7719,7963,8505,8511,8599,8708,8937,9194,9695,10245,11541,11617,11742,11796,12367,12837,13783</partitions> </nodedynamic> ... <nodedynamic> <id>482</id> <staticId>482</staticid> <enable>true</enable> <config>config_sync</config> <fault-type>normal</fault-type> <partitions>288,863,868,1082,1519,1579,2143,3320,3446,3542,3933,4448,4525,6000,6023,6163,6264,7012,7767,8257,8645,8782,9642,10257,11077,12365,12603,12864,13084,14034</partitions> </nodedynamic> </info> cZxid = 0x900000049 ctime = Tue Jun 18 12:10:31 PDT 2013 mZxid = 0x35009bc03a mtime = Tue Oct 13 13:14:12 PDT 2015 pZxid = 0x900000049 cversion = 0 dataVersion = 41637 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 188981 numChildren = 0 [zk: 172.16.0.11:2100(CONNECTED) 5] quit Quitting...