Zookeeper installation (in the CentOS environment)

Source: Internet
Author: User
Tags chmod mkdir zookeeper centos iptables port number

1, modify the operating system of the/etc/hosts file to add:

#zookeeper servers
192.168.102.131  edu-provider-01

2. Download Zookeeper
Download zookeeper-3.4.6 to http://apache.fayea.com/zookeeper/
In the terminal, enter:

# wget  http://apache.fayea.com/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz

3, Decompression zookeeper installation package:

# TAR–ZVXF Zookeeper-3.4.6.tar.gz

Move to/usr/local

# mv   zookeeper-3.4.6  /usr/local

4. Create a directory under/usr/local/zookeeper-3.4.6
Data files

# mkdir Data    

Log file

# mkdir Logs

5, the zoo_sample.cfg copy of the zookeeper/conf directory to backup one copy, named Zoo_sample_bak.cfg

# CP Zoo_sample.cfg Zoo_sample_bak.cfg

6, modify the Zoo_sample.cfg configuration file, add the data files and log files created above

# The number of milliseconds of each tick

ticktime=2000

# The number of ticks that the initial
# synchronization phase can take

initlimit=10

# The number of ticks that can pass between
# Sending a request and getting an acknowledgement

Synclimit=5

# The directory where the snapshot is stored.
# do not use/tmp for storage,/tmp here is just
# example sakes.
#dataDir =/tmp/zookeeper
#添加数据目录和日志目录文件配置


Datadir=/usr/local/zookeeper-3.4.6/data
Datalogdir=/usr/local/zookeeper-3.4.6/logs

# The port at which the clients would connect
clientport=2181 # The maximum number of the
client connections.
# Increase this if you need to handle more clients
#maxClientCnxns =60
#
# is sure to read the maintenance sect Ion of the
# Administrator guide before turning on Autopurge.
# # # # # # # # # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance # #
Snapshots to retain in DataDir
#autopurge. snapretaincount=3
# Purge task interval in hours
# Set to ' 0 ' to Disable Auto Purge feature
#autopurge. purgeinterval=1
#添加服务节点, single node service, as follows:

server.1=
edu-provider-01:2888:3888

Where
2888 port number is the port number of the communication between the zookeeper services
3888 is zookeeper ports that communicate with other applications
Edu-provider-01: is the host name of the IP that was mapped in the hosts
Initlimit: This configuration is used to configure the Zookeeper accept client (the client is not the client that is connected to the zookeeper server, Instead, the zookeeper server cluster connects to the leader follower service) the maximum number of heartbeat intervals that can be accepted when the connection is initialized. This client connection failed when the zookeeper server has not received the information returned by the client after the length of time (that is, ticktime) has exceeded 10 heartbeats. The total length of time is 10*2000=20 seconds.
Synclimit: This configuration identifies the length of time that a message is sent between leader and follower, the length of the request and the promise, the maximum number of ticktime, and the total length of time is 5*2000=10 seconds
Server. A=b:c:d: Where A is a number, indicating this is the first server, B is the IP address of the server or the host name of the IP mapped in the/etc/hosts file, and C represents the port where the server exchanges information with the leader server in the cluster D means that in case the leader server in the cluster is hung up, a port is needed to re-elect the new leader, and this port is the port that the server communicates with when the election is executed, and if it is configured in a pseudo-cluster, because B is the same, So different zookeeper instance communication port numbers cannot be the same, so assign them a different port number
7, create a myID file under/usr/local/zookeeper-3.4.6/data
Edit the myID file, and enter the corresponding number on the corresponding IP machine, such as on zookeeper, Nyid file content is 1, if only on a single point of installation configuration, then there is only one Server.1
8, in/home/admin/. Add environment variables in Bash_profile, increase zookeeper configuration

Vi   /home/admin/.bash_profile
#zookeeper CVN
export zookeeper_home=/usr/local/zookeeper-3.4.6
Export path= $PATH: $ZOOKEEPER _home/bin

(The above is the temporary environment variable for the current user)
Can be in

/etc/profile

Vi/etc/profile

Add to

#zookeeper CVN
Export zookeeper_home=/usr/local/zookeeper-3.4.6
export path= $PATH: $ZOOKEEPER _home/bin

Source/etc/profile Making environment variables effective
9, open in the firewall to use the port number 2181, 2888, 3888
Under root user rights, execute the following command

# chkconfig Iptables on
#service iptables Start

Edit/etc/sysconfig/iptables

# Vi/etc/sysconfig/iptables

Add three lines

-A input-p tcp-m TCP--dport 2181-j accept
-a input-p tcp-m tcp--dport 2888-j ACCEPT
-a input-p tcp-m TCP --dport 3888-j ACCEPT

Restarting the firewall

Service Iptables Restart


View Firewall port Status

Service Iptables Status


10. Start and test the zookeeper (do not use the root user)
(1) Exit root user, enter/usr/local/zookeeper-3.4.6/bin
Start Service: zkserver.sh start
If it appears

Starting zookeeper .../usr/local/zookeeper-3.4.6/bin/zkserver.sh:line 113:/usr/local/zookeeper-3.4.6/data/ Zookeeper_server.pid:Permission denied
FAILED to WRITE PID

Description of permissions not written
Access root user, grant permissions

chmod  A+rwx/usr/local/zookeeper-3.4.6/data
# exit

Restart

Started successfully.

(2) Check if the boot status is really started successfully
Execute the following command:

zkserver.sh status

If the above error contacting service appears. It is probably not running. This means failure.
View the output log under the/usr/local/zookeeper-3.4.6/directory
Execute the following command:

Vi/usr/local/zookeeper-3.4.6/zookeeper.out

can see the error
I'm here for the same reason I didn't give logs permission to read and write.
Perform

chmod a+rwx/usr/local/zookeeper-3.4.6/logs

Can
Reboot to view status:

Started successfully.
(3) View Zookeeper Service log output
Enter the/usr/local/zookeeper-3.4.6/directory and execute the following command

#  

11. Stop Zookeeper Service

# zkserver.sh Stop
Related Article

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.