Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Zookeeper installation and use tutorial

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Zookeeper is a high-performance coordination service for distributed systems. It exposes public services in a simple interface: naming, configuration management, synchronization, and group services, so you don't have to implement them from scratch. You can use off-the-shelf Zookeeper to achieve consensus, group management, leadership elections, and business agreements. And you can build your own specific needs based on it.

Zookeeper is implemented by setting up a cluster server, and the cluster server automatically selects leader and re-elects when the leader is dead. In zookeeper, you can create nodes and listen for changes in node data to enable clients to perform specified operations.

Install jdk$ java-version

If you have java installed on your machine, skip this step directly

1. Download the latest version of JDK and the latest version of JAVA by visiting the link. two。 Install $cd ~ / Downloads$ tar-zxf jdk-8u60-linux-x64.gz # to extract the file $mkdir / opt/jdk$ mv jdk-1.8.0_60 / opt/jdk/3. Set path

To set the path and JAVA_HOME variables, add the following command to the ~ / .bashrc file.

Export JAVA_HOME = / usr/jdk/jdk-1.8.0_60export PATH=$PATH:$JAVA_HOME/bin

Run the changes to take effect

$source ~ / .bashrc II, install zooker1. download

To install the ZooKeeper framework on your computer, please visit the link below and download the latest version of ZooKeeper. Http://zookeeper.apache.org/releases.html

two。 Create a profile

Use the command vi conf/zoo.cfg and all the following parameters as the starting point to open the configuration file named conf/zoo.cfg.

$vi conf/zoo.cfgtickTime = 2000dataDir = / path/to/zookeeper/dataclientPort = 2181initLimit = 5syncLimit = 23. Start the ZooKeeper server

Execute the following command

$bin/zkServer.sh start$ JMX enabled by default$ Using config: / Users/../zookeeper-3.4.6/bin/../conf/zoo.cfg$ Starting zookeeper... STARTED II. Use CLI client 1. Start $bin/zkCli.sh

The following information will be returned after success

Connecting to localhost:2181...Welcome to state:SyncConnected type: None path:null [zk: localhost:2181 (CONNECTED) 0] 3. ZooKeeper service operation description start startup start-foreground view reason for unsuccessful startup stop stop restart restart status view service status upgrade upgrade print-cmd print command 4, configuration file description configuration item default value description clientPort2181 client connects to the dataDirzookeeper installation directory / data storage snapshot file snapshot directory. By default, transaction logs are also stored here. It is recommended to configure the parameter dataLogDir at the same time. The write performance of the transaction log directly affects the performance of zk. A unit of time in tickTime2000ZK. All time in ZK is configured in integral multiples based on this unit of time. For example, the minimum timeout for session is 2*tickTime. DataLogDir transaction log output directory. Try to configure a separate disk or mount point for the output of the transaction log, which will greatly improve ZK performance. The maximum number of requests stacked by globalOutstandingLimit. The default is 1000. When ZK runs, although server is no longer free to handle more client requests, it still allows clients to submit requests to the server to improve throughput performance. Of course, in order to prevent Server memory overflow, this request stacking number still needs to be pre-opened by the limited preAllocSize to open up disk space for subsequent writing to the transaction log. The default is 64m, and each transaction log size is 64m. If the snapshot frequency of ZK is high, it is recommended to reduce this parameter appropriately. After each snapCount transaction log output by snapCount, a snapshot (snapshot) is triggered, and ZK generates a snapshot. File, and create a new transaction log file, log. The default is 100000. (in a real code implementation, a certain random number will be processed to prevent all servers from taking snapshots at the same time, thus affecting performance.) the log used to record all requests by traceFile can be used during general debugging, but it is not recommended in the production environment, which will seriously affect the performance of maxClientCnxns60. The limit on the number of connections between a single client and a single server is ip level, if set to 0. Then it shows that there are no restrictions. Please note that the scope of use of this limit is only the limit on the number of connections between a single client machine and a single ZK server, not for the specified client IP, nor the connection limit for ZK clusters, nor the connection limit for all clients by a single ZK. ClientPortAddress for machines with multiple network cards, you can specify a different listening port for each IP. By default, all IP listen for the port minSessionTimeoutmaxSessionTimeout2 tickTime ~ 20 tickTimeSession timeout limit specified by clientPort. If the timeout set by the client is not in this range, it will be forced to set to the maximum or minimum time. When the fsync.warningthresholdms1000ms transaction log is output, a warning message is output in the log if the call to the fsync method exceeds the specified timeout. As mentioned in autopurge.purgeInterval0 above, ZK provides automatic cleaning of transaction logs and snapshot files in version 3.4.0 and later. This parameter specifies the cleaning frequency (in hours). You need to configure an integer of 1 or more. The default is 0, which means that automatic cleaning is not enabled. The autopurge.snapRetainCount3 parameter is used in conjunction with the above parameter, which specifies the number of files to be retained. During the startup process, initLimit10Follower synchronizes all the latest data from Leader and then determines the starting status of its external service. Leader allows F to finish the job in initLimit time. In general, we don't have to care too much about the setting of this parameter. If the amount of data in the ZK cluster is really large, the time for F to synchronize data from the Leader will be longer when F starts, so in this case, it is necessary to increase this parameter appropriately. During the operation of syncLimit5, Leader is responsible for communicating with all the machines in the ZK cluster, such as checking the survival status of machines through some heartbeat detection mechanisms. If L sends a heartbeat after syncLimit and does not receive a response from F, then the F is no longer online. Note: do not set this parameter too large, or some problems may be masked. LeaderServes by default, Leader accepts client connections and provides normal read and write services. However, if you want 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= [hostname]: nnnnn [: nnnnn] where x is a number, which is consistent with the id in the myid file. Two ports can be configured on the right, the first for data synchronization and other communications between F and L, and the second for voting communication during the Leader election. Group.x=nnnnn [: nnnnn] weight.x=nnnnn sets machine grouping and weight settings. During the http://zookeeper.apache.org/doc/r3.4.3/zookeeperHierarchicalQuorums.htmlcnxTimeout5sLeader election process, the timeout for opening a connection zookeeper.DigestAuthenticationProvider.superDigest https://blog.51cto.com/nileader/930635skipACL does not check all client requests. If permission restrictions were previously set on the node, once this opening is opened on the server, it will also be invalidated. The parameter forceSync determines whether you need to call FileChannel. Force when the transaction log is committed to ensure that the data is fully synchronized to disk. The maximum amount of data per node in jute.maxbuffer1M is 1m by default. This restriction must be set on both the server and client sides to take effect.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report