Principles and configurations of zookepper

Source: Internet
Author: User

Http://agapple.iteye.com/blog/1292129

Http://www.blogjava.net/xylz/archive/2011/12/05/365578.html

========================================================== ============================================

Copy the conf/zoo_sample.cfg file to CONF/zoo. cfg and modify the data directory.

# Cat/opt/apps/zookeeper/CONF/zoo. cfg ticktime = 2000 initlimit = 5 synclimit = 2 datadir =/opt/zkdata clientport = 2181

The configuration is as follows:

· Ticktime: This time is used to maintain heartbeat between zookeeper servers or between servers and clients. The time is measured in milliseconds.

· Initlimit: the initial delay of leader election. Since loading data on the server takes a certain amount of time (especially when there are a lot of configuration data), it takes some time to complete initialization before synchronizing data immediately after the election leader. You can zoom in a bit. The delay time is initlimit * ticktime, that is, the number of times the value is ticktime.

· Synclimit: the maximum response time unit between the leader and the follower. If the timeout time (synclimit * ticktime) occurs, the leader considers the follwer to die, will be deleted from the server list.

For standalone mode, you only need three parameters: ticktime, datadir, and clientport, which is effective in standalone debugging environment.

Cluster Environment Configuration

 

Add configurations for other machines

# Cat/opt/apps/zookeeper/CONF/Zoo. CFG ticktime = 2000 initlimit = 5 synclimit = 2 datadir =/opt/zkdata clientport = 2181 server.1 = 10.11.5.202: 2888: 3888 server.2 = 192.168.105.218: 2888: 3888 server.3 = 192.168.105.65: 2888: 3888

The configuration of server. X is related to each machine. X indicates the unique sequence number, such as 1/2/3. The value is IP: Port: port. The IP address is the IP address or domain name of the zookeeper server, and the first port (for example, 2888) is the port for data exchange between servers, that is, the port connecting the follower to the leader, the second port (for example, 3888) is the port used by each server to elect the leader. You can use different ports to configure a cluster on a single machine.

Synchronization file directory

# Rsync -- inplace-vzrtlp -- delete-after -- Progress/opt/apps/zookeeper root@192.168.105.218: /opt/apps # rsync -- inplace-vzrtlp -- delete-after -- Progress/opt/apps/zookeeper root@192.168.106.65:/opt/apps

CreateID

Note: This ID must correspond to the configuration in zoo. cfg.

SSH root@10.11.5.202 'echo 1>/opt/zkdata/myid' SSH root@192.168.105.218 'echo 2>/opt/zkdata/myid' SSH root@192.168.106.65 'echo 3>/opt/zkdata/myid'

Start the server

 

SSH root@10.11.5.202 '/opt/apps/zookeeper/bin/zkserver. sh start 'ssh root@192.168.105.218 '/opt/apps/zookeeper/bin/zkserver. sh start 'ssh root@192.168.106.65 '/opt/apps/zookeeper/bin/zkserver. sh start'

 

 

 

Reference: http://hadoop.apache.org/zookeeper/docs/r3.3.1/zookeeperAdmin.html# SC _configuration

Zookeeper server behavior is affected by the configuration file Zoo. CFG control, zoo. CFG is designed to allow all servers to use the same configuration file. To use different configuration files, ensure that the parameters of the cluster are the same. The following are specific parameters:

Minimum required parameters

Clientport

Listening port of the service

Datadir

The folder used to store memory database snapshots, And the myid file used for the cluster also exists in this folder (Note: a configuration file can only contain one datadir, even if it is commented out .)

Ticktime

Heartbeat time. To ensure a connection exists, the minimum timeout value is in milliseconds.

Advanced configuration parameters

Datalogdir

Used to separately set the directory of the transaction log. The transaction log separation can avoid competition with common logs and snapshots.

Globaloutstandinglimit

The maximum length of the client request queue to prevent memory overflow. The default value is 1000.

Preallocsize

The pre-allocated transaction log space is a block of proallocsize kb. The default block is 64 MB, which does not need to be changed unless the snapshot is too frequent.

Snapcount

Write a transaction log after snapcount snapshot. The default value is 100,000.

Tracefile

Used to record the log of the request. Opening will affect the performance, which is used for Debug. It is best not to define

Maxclientcnxns

Maximum number of concurrent clients, used to prevent Dos. The default value is 10 and the value 0 is unlimited.

Clientportbindaddress

Add a parameter after 3.3.0, but set the specified Client IP address and port. If this parameter is not set, it is equal to any: clientport.

Minsessiontimeout

New Parameter after 3.3.0, Minimum Client Session Timeout. Default Value: 2 ticktime, in milliseconds

Maxsessiontimeout

Added a parameter after 3.3.0. The maximum Client Session Timeout time. The default value is 20 ticktime, in milliseconds.

Cluster Parameters

Electionalg

The parameter used for election implementation. 0 is the original UDP-based collaboration, and 1 is the UDP-based quick election without user verification, 2. for user verification based on UDP fast election, 3 is based on TCP fast election, the default value is 3

Initlimit

During how many heartbeat times, other servers are allowed to connect and initialize data. If the data managed by zookeeper is large, the value should be increased accordingly.

Leaderserves

Whether the leader accepts client connection. The default value is yes. The leader is responsible for coordinating updates. When the update throughput is much higher than the read throughput, you can set it to reject client connections so that the leader can focus on synchronization and coordination. The default value is yes, indicating that the leader can accept client connection. (Note: When there are more than three zookeeper servers in the cluster, it is strongly recommended to enable the Leader Election)

Server. x = [hostname]: nnnnn [: nnnnn], etc

Configure the host information in the cluster. The X of server. X must be written in the myid file to determine the ID of the current machine. The first port is used to connect the leader, and the second is used for leader election. If electionalg is 0, the second port is not required. The hostname can also be an IP address.

Synclimit

The number of ticktimes allowed for follower synchronization. If follower lags behind too much, it will be discarded.

Group. x = nnnnn [: nnnnn]

Weight. x = nnnnn

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.