What is zookeeper?
Apache ZooKeeper is a high-performance coordination server for distributed applications. It exposes public services (such as naming and configuration management, synchronization, and group services) using a simple interface, so that users do not have to start programming from scratch. It provides ready-made support for consensus-building, group management, leader elections, and presence agreements (presence protocol).
Here is my experience with deploying zookeeper clustered servers in ubuntu14.04 server
Zookeeper deployment of clustered servers
1. Installing the JDK
Prior to installing the JDK is their own manual configuration environment, this time to lazy use of Apt-get installed Oracle JDK
sudo add-apt-repository Ppa:webupd8team/java
sudo apt-get update
sudo apt-get install Oracle-java8-installer
sudo update-java-alternatives-s java-8-oracle
The final step is to set the current JDK as the system default JDK
After the installation is complete, you can use Java-version to see if the installation was successful.
2. Deploy the Zookeeper Cluster Server (take 3 servers as an example)
2.1
Extract the downloaded zookeeper compressed package to the appropriate directory, assuming the directory is zookeeper. Create a datadir to hold the state associated with the zookeeper server , assuming the path is/var/lib/zookeeper
CD conf
MV Zoo_sample.cfg Zoo.cfg
VI zoo.cfg
Modify Datadir=/var/lib/zookeeper
Add 3 cluster nodes at the end:
server.1=ip1:2888:3888
server.2=ip2:2888:3888
server.3=ip3:2888:3888
Where ip1, IP2, IP3 represent three server nodes of the IP, the specific IP should be replaced by itself. Port recommendations do not change.
2.2
Create a new file in/var/lib/zookeeper with the file name myID. Content is server. The following number.
For example, in ip1 this server myID content is 1, this is to let the server can know where to find the corresponding address.
2.3
Start the server.
CD bin
Bash zkserver.sh start
This requires 3 servers to be booted.
2.4
You can create a client to connect to a server on any host that is connected to the server network.
CD bin
Bash Zkcli.sh-server ip:2181
Note: Port 2181 is the default port and can be modified in zoo.cfg if necessary.
At this point, the deployment of the Zookeeper Cluster Server is complete.
ubuntu14.04 Server Deployment Zookeeper Cluster Server