Zookeeper cluster installation and configuration
First introduce the basic configuration of zoo.cfg.
ticktime=2000initlimit=10synclimit=5datadir=/datadatalogdir=/datalogclientport=2181electionalg=3server.1= 127.0.0.1:20881:30881server.2=127.0.0.1:20882:30882server.3=127.0.0.1:20883:30883
Basic information for configuration
ticktime=2000: The basic time unit in milliseconds, other times such as heartbeat/timeout are integer multiples of the unit time;
A multiple of the initlimit=10:ticktime, indicating that after the leader election, followers and leader synchronization takes time, leader the data is very much or followers more, then the value should be appropriate larger;
A multiple of synclimit=5:ticktime that represents the maximum wait time when follower and observer interact with leader, except when a normal request forward or ping waits for a message to interact with leader after synchronization is complete.
clientport=2181: Listening for service ports for client connections
Electionalg=3: Leader election algorithm, default 3. (No Java system property)
Datadir=/data: Memory Database snapshot address, transaction log address (unless otherwise specified by Datalogdir)
Datalogdir=/datalog: Transaction log directory, you can use a dedicated device to avoid contention between transaction logs and snapshots.
SERVER.X=[HOSTNAME]:NNNNN[:NNNNN], etc
In a cluster configuration, there must be a myID file in the DataDir directory, where the value is the number x and the range is 1-255. The first nnnnn is used with leader communication, the second nnnnn is election leader use, and Electionalg equals 0 o'clock this parameter is not required. (No Java system property)
Three instances of zookeeper on a single machine are actually a pseudo-cluster. The three configurations in a cluster are:
Zookeeper Instance One:
ticktime=2000initlimit=10synclimit=5datadir=/zookeeper-3.4.6-1/datadatalogdir=/zookeeper-3.4.6-1/ datalogclientport=2181electionalg=3server.1=127.0.0.1:20881:30881server.2=127.0.0.1:20882:30882server.3= 127.0.0.1:20883:30883
Zookeeper Example Two:
ticktime=2000initlimit=10synclimit=5datadir=/zookeeper-3.4.6-2/datadatalogdir=/zookeeper-3.4.6-2/ datalogclientport=2182electionalg=3server.1=127.0.0.1:20881:30881server.2=127.0.0.1:20882:30882server.3= 127.0.0.1:20883:30883
Zookeeper Example Three:
ticktime=2000initlimit=10synclimit=5datadir=/zookeeper-3.4.6-3/datadatalogdir=/zookeeper-3.4.6-3/ datalogclientport=2183electionalg=3server.1=127.0.0.1:20881:30881server.2=127.0.0.1:20882:30882server.3= 127.0.0.1:20883:30883
which
Datadir=/zookeeper-3.4.6-1/datadatalogdir=/zookeeper-3.4.6-1/datalog
The directory is in the same directory as its instance.
Finally, don't forget to build the myID file in the DataDir configuration directory. Well, the cluster is basically configured.
Finally, each zookeeper instance is started.
such as the status after three zookeeper instances are started:
Open any client, establish Znode, as below,
[Zk:localhost:2181 (CONNECTED) 3] create/zk_test mydatacreated/zk_test[zk:localhost:2181 (CONNECTED) 4] Get/zk_ Testmydataczxid = 0x600000004ctime = Mon Mar 17:51:58 CST 2015mZxid = 0x600000004mtime = Mon Mar 17:51:58 CST 2015pZ XID = 0x600000004cversion = 0dataVersion = 0aclVersion = 0ephemeralOwner = 0x0datalength = 6numChildren = 0[zk:localhost: 2181 (CONNECTED) 5]
Open another client, as below,
[Zk:localhost:2181 (CONNECTED) 1] get/zk_testmydataczxid = 0x600000004ctime = Mon Mar 17:51:58 CST 2015mZxid = 0x60000 0004mtime = Mon Mar 17:51:58 CST 2015pZxid = 0x600000004cversion = 0dataVersion = 0aclVersion = 0ephemeralOwner = 0x0da Talength = 6numChildren = 0[zk:localhost:2181 (CONNECTED) 2] LS/[mynode, zookeeper, zk_test][zk:localhost:2181 (connecte D) 3]
A cluster is built.
Reference: http://ibruce.info/2014/10/23/zookeeper/
http://greemranqq.iteye.com/blog/2171449
Http://www.cnblogs.com/yuyijq/p/3438829.html
==================================end==================================
Zookeeper cluster installation and configuration