ZooKeeper installation in multiple ways

Source: Internet
Author: User

ZooKeeper installation in multiple ways

System: CentOS 6.5x64

1. Installation in standalone Mode

Ii. Installation in pseudo cluster mode

Iii. cluster mode installation

-------------------------------------- Split line --------------------------------------

ZooKeeper cluster configuration

Use ZooKeeper to implement distributed shared locks

Distributed service framework ZooKeeper-manage data in a distributed environment

Build a ZooKeeper Cluster Environment

Test Environment configuration of ZooKeeper server cluster

ZooKeeper cluster Installation

-------------------------------------- Split line --------------------------------------

1. Install zookeeper in standalone Mode

1.1 create an account zk

[Root @ master ~] # Useradd-d/opt/zk
[Root @ master ~] # Echo "zk" | passwd -- stdin zk

1.2 download, decompress,

[Root @ master ~] # Su-zk
[Zk @ master ~] $ Pwd
/Opt/zk
[Zk @ master ~] $ Wget
[Zk @ master ~] $ Tar zxvf zookeeper-3.5.0-alpha.tar.gz
[Zk @ master ~] $ Mv zookeeper-3.5.0-alpha zk

1.3 configure the current user environment variable

Export ZOOKEEPER_HOME =/opt/zk
PATH = $ ZOOKEEPER_HOME/bin: $ PATH
Export PATH

1.4 configure the configuration file zoo. cfg

[Zk @ master conf] $ cat zoo. cfg
InitLimit = 10
SyncLimit = 5
ClientPort = 2181
TickTime = 2000
DataDir =/opt/zk/data
DataLogDir =/opt/zk/logs

1.5 start zk

[Zk @ master bin] $ pwd
/Opt/zk/bin
[Zk @ master bin] $./zkServer. sh start

1.6 client link test:

[Zk @ master bin] $ pwd
/Opt/zk/bin
[Zk @ master bin] $./zkCli. sh-server localhost: 2181
Connecting to localhost: 2181
...
[Zk: localhost: 2181 (CONNECTED) 0] ls/
[Zookeeper]
[Zk: localhost: 2181 (CONNECTED) 1] create/Test hellozk
Created/Test
[Zk: localhost: 2181 (CONNECTED) 2] get/Test
Hellozk
[Zk: localhost: 2181 (CONNECTED) 3] set/Test hellozookeeper
[Zk: localhost: 2181 (CONNECTED) 4] get/Test
Hellozookeeper
[Zk: localhost: 2181 (CONNECTED) 5] delete/Test
[Zk: localhost: 2181 (CONNECTED) 6] get/Test
Node does not exist:/Test
[Zk: localhost: 2181 (CONNECTED) 7] quit
03:53:50, 180 [myid:]-INFO [main: ZooKeeper @ 968]-Session: 0x149c475d7db0000 closed
03:53:50, 182 [myid:]-INFO [main-EventThread: ClientCnxn $ EventThread @ 529]-EventThread shut down

Description of the zookeeper configuration file:

ClientPort # The port on which the client connects to the server, that is, the external service port, which is generally set to 2181.
DataDir # specifies the snapshot file snapshot directory. Transaction logs are stored here by default. We recommend that you configure the dataLogDir parameter at the same time. The Write Performance of transaction logs directly affects zk performance.
TickTime # A time unit in ZK. All time in ZK is configured as an integer multiple based on this time unit. For example, the minimum timeout value of a session is 2 * tickTime.
DataLogDir # transaction log output directory. Configure a separate disk or mount point for the output of transaction logs as much as possible, which will greatly improve ZK performance.
GlobalOutstandingLimit # maximum number of requests accumulated. The default value is 1000. When ZK is running, although the server is no longer idle to process more client requests, it still allows the client to submit requests to the server to improve throughput performance. Of course, in order to prevent Server memory overflow, this number of requests must be limited. Java system property: zookeeper. globalOutstandingLimit.
PreAllocSize # pre-opened disk space for subsequent transaction log writing. The default value is 64 MB, and the size of each transaction log is 64 MB. If the snapshot frequency of ZK is large, we recommend that you reduce this parameter.
SnapCount # after each snapCount transaction log output, a snapshot is triggered. At this time, ZK generates a snapshot. * file, and create a new transaction log file log. *. The default value is 100000. (In real code implementation, random number processing is performed to prevent all servers from performing snapshots at the same time and affecting performance ).
TraceFile # used to record the logs of all requests. It can be used during debugging, but is not recommended in the production environment, which seriously affects the performance.
MaxClientCnxns # the number of connections between a single client and a single server is limited at the ip level. The default value is 60. If it is set to 0, no restrictions are imposed. Note that this restriction only applies to the number of connections between a single client machine and a single ZK server. It does not apply to the specified Client IP address or the number of connections of a ZK cluster, it is not the limit on the number of connections of all clients for a single ZK.
ClientPortAddress # For machines with multiple NICs, you can specify different listening ports for each IP address. By default, all IP addresses listen to the port specified by clientPort.
MinSessionTimeoutmaxSessionTimeout # The Session Timeout time limit. If the timeout time set by the client is not in this range, it is forcibly set to the maximum or minimum time. The default Session timeout value is 2 * tickTime ~ 20 * tickTime.
Fsync. warningthresholdms # When the transaction log is output, if the fsync method is called more than the specified Timeout time, a warning is output in the log. The default value is 1000 ms.
Autopurge. purgeInterval #3.4.0 and later versions, ZK provides the function of automatically clearing transaction logs and snapshot files. This parameter specifies the cleaning frequency, in hours, and requires a 1 or greater integer, the default value is 0, and automatic cleaning is disabled for tables.
Autopurge. snapRetainCount # this parameter is used with the preceding parameter. This parameter specifies the number of files to be retaincount. By default, three are retained.
ElectionAlg # in earlier versions, this parameter configuration allows us to select the leader Election Algorithm. However, in later versions, only the "TCP-based version of fast leader election" algorithm is left, so this parameter does not seem to be used at present.
InitLimit # When Follower is started, it synchronizes all the latest data from the Leader and determines the Starting Status of the external service. Leader allows F to complete this task within the initLimit time. In general, we do not need to care too much about the setting of this parameter. If the amount of data in the ZK cluster is large, the time for synchronizing data from the Leader will also become longer when F is started. Therefore, in this case, it is necessary to increase this parameter properly.
SyncLimit # during running, the Leader is responsible for communicating with all machines in the ZK cluster. For example, through some heartbeat detection mechanisms, the Leader can detect the survival status of the machine. If the heartbeat packet sent by L has not received the response from F after syncLimit, then the F is considered offline. Note: Do not set this parameter too large. Otherwise, some problems may be covered up.
LeaderServes # by default, the Leader accepts client connections and provides normal read/write services. However, if you want the Leader to focus on the coordination of machines in the cluster, you can set this parameter to no, which will greatly improve the performance of write operations.
Server. X = A: B: C # where X is A number, indicating the number of the server. A is the IP address of the server. b. Configure the port used by the server and the leader in the cluster to exchange messages. c. Configure the port used to elect the leader. here, x is a number, which is consistent with the id in the myid file. You can configure two ports on the right. The first port is used for data synchronization between F and L and other communications. The second port is used for voting communication during Leader election.
Group. x = nnnnn [: nnnnn] weight. x = nnnnn # set the machine group and weight,
CnxTimeout # timeout for enabling a connection during Leader election. The default value is 5 s.
Zookeeper. DigestAuthenticationProvider. superDigest # ZK permission settings
SkipACL # No ACL check is performed on all client requests. If a permission restriction is set on the previous node, once this header is opened on the server, it will also become invalid.
ForceSync # This parameter determines whether FileChannel. force needs to be called when transaction logs are submitted to ensure that data is fully synchronized to the disk.
Jute. maxbuffer # maximum data volume of each node. The default value is 1 MB. This restriction takes effect only when both the server and client are configured.

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

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.