Deploying the Zookeeper service on CentOS7

Source: Internet
Author: User
Tags zookeeper download server memory

Deploying the Zookeeper service on CentOS7


1 Connect to the CENTOS7 server with Linux client tools such as SECURECRT or Xshell;

2 enter into the/usr/local/tools directory:
cd/usr/local/
If you do not have this directory, create:
Mkdir-p Tools

3 Download zookeeper-3.4.8.tar.gz:
wget http://apache.fayea.com/zookeeper/zookeeper-3.4.8/zookeeper-3.4.8.tar.gz

4 return to the previous level directory and create the Zookeeper folder:
Cd..
Mkdir-p Zookeeper

5 Move the zookeeper-3.4.8 file from the/usr/local/tools folder to the/usr/local/zookeeper folder:
mv./tools/zookeeper-3.4.8./zookeeper/

6 enter into the zookeeper/zookeeper-3.4.8/conf directory:
CD zookeeper/zookeeper-3.4.8/conf

7 Copy the Zoo_sample.cfg file and name the new file zoo.cfg:
CP Zoo_sample.cfg Zoo.cfg

8 Modify the Zoo.cfg file:
VI zoo.cfg
enter into the zoo.cfg file;
Modify Data folder Datadir=/tmp/zookeeper to Datadir=/usr/local/zookeeper/zookeeper-3.4.8/data
Configure the log folder Datalogdir=/usr/local/zookeeper/zookeeper-3.4.8/logs
save and exit;

9 Set the root directory of the zookeeper to the system environment variable PATH:
sudo vi/etc/profile
Append the following configuration to the end of the open profile file:
Export zookeeper_home=/usr/local/zookeeper/zookeeper-3.4.8
Export path= $ZOOKEEPER _home/bin: $PATH
Export PATH
Save and exit VI;
Refresh the profile to take effect immediately:
Source/etc/profile

10 execute the following command to start the Zookeeper service:
zkserver.sh start
If you print the following information, it indicates that the startup zookeeper succeeded:
ZooKeeper JMX enabled by default
Using config:/usr/local/zookeeper/zookeeper-3.4.8/bin/. /conf/zoo.cfg
Starting zookeeper ... STARTED

Since we have configured the zookeeper into the system environment variable PATH, we can execute the Zookeeper command anywhere.
If we don't do the 9th step, then we need to go to the Zookeeper Command Tool folder:
Cd/usr/local/zookeeper/zookeeper-3.4.8/bin
Then perform the operation to start the Zookeeper service;

11 View the current status of zookeeper:
zkserver.sh status
The following information appears:
Using config:/usr/local/zookeeper/zookeeper-3.4.8/bin/. /conf/zoo.cfg
Mode:standalone
Where standalone is in stand-alone mode;

12 Close the Zookeeper service:
zkserver.sh stop
If you print the following information, the zookeeper success is turned off:
Using config:/usr/local/zookeeper/zookeeper-3.4.8/bin/. /conf/zoo.cfg
Stopping zookeeper ... STOPPED

13 Restart Zookeeper service:
zkserver.sh restart

zookeeper JMX enabled by default
using config:/usr/local/zookeeper/zookeeper-3.4.8/bin/. /conf/zoo.cfg
using config:/usr/local/zookeeper/zookeeper-3.4.8/bin/. /conf/zoo.cfg
zookeeper JMX enabled by default
using config:/usr/local/zookeeper/zookeeper-3.4.8/bin/. /conf/zoo.cfg

14 Zookeeper servers that specify IP through client-side programs can also connect to zookeeper servers of any IP:
Zkcli.sh-server localhost:2181
How to be native can also use the following command directly:
zkcli.sh

15 View the startup status of the zookeeper:
echo Ruok | NC localhost 2181

16 Viewing the Zookeeper process:
JPs
The number before the Quorumpeermain in the printed information indicates the PID of the zookeeper;

17 Create a myID file in the/usr/local/zookeeper/zookeeper-3.4.8/data/directory with the contents of the service number;

There is no deliberate master-slave relationship between the ZooKeeper service (master/slave relationship), each node is a server, if the server leader is hung, will be immediately from the server follower from the election as a new leader server. Information is exchanged between the zookeeper servers through the TCP protocol.

Attach one:
Zookeeper Download list:
http://apache.fayea.com/zookeeper/
can choose
http://apache.fayea.com/zookeeper/zookeeper-3.4.8/

Annex II:
zoo.cfg configuration file:

# The number of milliseconds of each tick
ticktime=2000
# The number of ticks that initial
# Synchronization phase can take
initlimit=10
# The number of ticks that can pass between
# Sending a request and getting an acknowledgement
# Synchronization Phase A time between a relaxed and accepted request that does not allow more than a tick
synclimit=5
# The directory where the snapshot is stored.
# do not use/tmp for storage,/tmp here are just
# example Sakes.
# Datadir=/tmp/zookeeper
# Configuration Data Directory
Datadir=/usr/local/zookeeper/zookeeper-3.4.8/data
# Configure the log directory
Datalogdir=/usr/local/zookeeper/zookeeper-3.4.8/logs
# The port at which the clients would connect
# port number of Client Access zookeeper:
clientport=2181
# The maximum number of the client connections.
# Increase this if you need to handle more clients
#maxClientCnxns =60
#
# Be sure to read the Maintenance section of the
# Administrator Guide before turning on Autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in DataDir
#autopurge. snapretaincount=3
# Purge Task interval in hours
# Set to ' 0 ' to disable Auto Purge feature
#autopurge. Purgeinterval=1


# 2888,3888 is election port
# Server.1, 2, 3 represents the 1, 2, and 3rd servers in the Zookeeper cluster;
# zookeeper represents the IP of the current zookeeper server, because zookeeper to map the local IP in the Hosts file, so here directly write zookeeper can;
# 2888 indicates Port 1, 2, 3rd zookeeper server to exchange information with leader server in zookeeper cluster;
# 3888 indicates the port for exchanging information when the leader server in the zookeeper cluster is hung up and used to elect a new leader server;
server.1=192.168.1.100:2888:3888
server.2=192.168.1.101:2888:3888
server.3=192.168.1.102:2888:3888

Attached three:
Zookeeper configuration file Description:

ClientPort # The port of the Client connection server, which is the external service port, is typically set to 2181.
DataDir # The directory where the snapshot file snapshot is stored. By default, the transaction log is also stored here. It is recommended to configure parameter Datalogdir at the same time, and write performance of transaction log directly affects ZK performance.
Ticktime # A time unit in ZK. All time in ZK is based on this time unit and is configured in integer multiples. For example, the minimum time-out period for a 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.
Globaloutstandinglimit # Maximum number of request stacks. The default is 1000. While ZK is running, the server has not been idle to handle more client requests, but it allows the client to submit requests to the server for increased throughput performance. Of course, in order to prevent server memory overflow, this request backlog number still need to be under the limit. Java system Property:zookeeper.globalOutstandingLimit.
Preallocsize # Pre-opens disk space for subsequent writes to the transaction log. The default is 64M, and each transaction log size is 64M. If ZK has a large snapshot frequency, it is advisable to reduce this parameter appropriately.
Snapcount # Once a snapshot (snapshot) is triggered after each snapcount transaction log output, ZK generates a snapshot.* file while creating a new transaction log file log.*. The default is 100000. (In a real code implementation, some random number processing is performed to prevent all servers from taking snapshots at the same time to affect performance).
Tracefile # is used to log all requests, which can be used during general debugging, but the production environment is not recommended and can seriously affect performance
Maxclientcnxns # The limit of the number of connections between a single client and a single server is IP-level, default is 60, and if set to 0, there is no limit. Please note that this limitation is only limited by the number of connections between a single client machine and a single ZK server, not the specified client IP, nor the number of connections to the ZK cluster, nor the number of connections to all clients by a single ZK.
Clientportaddress # for a multi-NIC machine, you can specify a different listening port for each IP. By default, all IPs are listening on the port specified by ClientPort.
Minsessiontimeoutmaxsessiontimeout # Session Timeout limit, if the timeout period set by the client is not in this range, then it will be set to the maximum or minimum time. The default session timeout is at 2 * ticktime * ticktime this range.
Fsync.warningthresholdms # transaction log output, if the call to Fsync method exceeds the specified time-out, a warning message is output in the log. The default is 1000ms.
Autopurge.purgeinterval # 3.4.0 and later, ZK provides the ability to automatically clean up the transaction log and snapshot files, which specifies the cleanup frequency, in hours, the need to configure a 1 or larger integer, the default is 0, the table does not turn on automatic cleanup function
Autopurge.snapretaincount # This parameter is used in conjunction with the above parameter, which specifies the number of files that need to be preserved. The default is to keep 3.
electionalg #在之前的版本中, this parameter configuration allows us to choose the leader election algorithm, but because in later versions, only one "tcp-based version of the fast leader election" algorithm is left, So this parameter doesn't seem to work at the moment.
Initlimit # Follower during the boot process, all the latest data is synchronized from the leader, and then you can determine the starting state of your external service. Leader allows F to complete this work within initlimit time. Normally, we don't have to be too concerned with setting this parameter. If the data volume of the ZK cluster is indeed very large, f at startup, the time to synchronize data from the leader will be correspondingly longer, so in this case it is necessary to adjust this parameter appropriately.
Synclimit # During the run, leader is responsible for communicating with all the machines in the ZK cluster, for example, through some heartbeat detection mechanisms, to detect the machine's survival status. If L make a heartbeat packet after Synclimit, and have not received a response from F, then I think this f is no longer online. Note: Do not set this parameter too large, or it may obscure some problems.
leaderserves # By default, leader will accept client connections and provide normal read and write services. However, if you want leader to focus on the coordination of the machines in the cluster, you can set this parameter to no, which greatly improves the performance of the write operation.
server. X=A:B:C # where x is a number that indicates which is the first server. A is the IP address where the server resides. b Configure the port used by the server and the leader in the cluster to exchange messages. C Configure the port to use when electing leader. The x here is a number that is consistent with the ID in the myID file. On the right can be configured with two ports, the first port for data synchronization between F and L and other communication, the second port is used to leader voting communication during the election process.
group.x=nnnnn[:nnnnn]weight.x=nnnnn # for machine grouping and weight setting,
Cnxtimeout # Leader during an election, the time-out period for opening a connection is 5s by default
zookeeper. Digestauthenticationprovider.superdigest # ZK permission settings related
Skipacl # No ACL checks are made on all client requests. If a permission limit is set on the previous node, it will be invalidated once the start is opened on the server .
Forcesync # This parameter determines whether you need to call FileChannel when the transaction log commits. Force to ensure data is fully synchronized to disk
Jute.maxbuffer # The maximum amount of data per node is 1M by default. This restriction must be set on both the server and client side to take effect.

Deploying the Zookeeper service on CentOS7

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.