I. Introduction of Zookeeper
To put it simply, zookeeper is a high-performance, distributed, open-source distributed Application coordination service that can be developed based on zookeeper to enable more advanced services such as distributed synchronization, configuration management, cluster management, and namespaces. Second, installation zookeeper
This learning environment is based on the CentOS 6.5 + JDK 1.8 + Zookeeper 3.4.6, where the installation mode is stand-alone mode. Since Zookeeper is Java-based, it is necessary to install the JDK first and then download the zookeeper installation package from the official website and extract it to the/usr/local directory:
$ sudo tar-zxvf zookeeper-3.4.6.tar.gz-c/usr/local/
Modify the user and user groups to which the extracted directory belongs:
$ sudo chown-r cenmee:cenmee/usr/local/zookeeper-3.4.6/
To facilitate the use of ZOOKEEPER commands, edit the/etc/profile file:
$ sudo vi/etc/profile
To increase the configuration of zookeeper related environment variables:
Export zookeeper_home=/usr/local/zookeeper-3.4.6
export path= $PATH: $ZOOKEEPER _home/bin
To make the configuration effective:
$ . /etc/profile
three, zookeeper basic directory structure Introduction
After the installation is complete, the basic directory structure of Zookeeper is as follows:
Bin directory: Executable script with Zookeeper
Conf directory: A configuration file that contains zookeeper, where zoo_sample.cfg is the sample configuration file, log4j.properties a log profile
Contrib directory: Contains some toolkits for manipulating zookeeper
Lib directory: Some packages that contain zookeeper dependencies
Recipes Directory: code example containing some usage of zookeeper
Dist-maven directory: Maven compiled publish directory
Iv. Start-Stop zookeeper copy the zoo_sample.cfg in the Conf directory as zoo.cfg, because zookeeper uses the file by default when it is started:
$ CP./conf/zoo_sample.cfg./conf/zoo.cfg
Some of these basic configuration parameters are as follows:
Ticktime: The default is 3000ms, as a basic unit, it can be used to represent the time interval configuration within the system, such as 2*ticktime is the client session timeout time, 1*ticktime is the client and zookeeper server side heartbeat interval time
DataDir: Used to configure the directory where the snapshot files are stored, and if the Datalogdir parameter is not configured, the transaction log is also stored in this directory
Clientport:zookeeper run port, default is 2181
Then you can start the zookeeper:
$ zkserver.sh Start
After starting the zookeeper server, you can use zkcli.sh to connect to the server, the default is to connect to the native 2181 port, if you need to connect to another host or port, you can use the Zkcli.sh-server ip:port way to connect:
$ zkcli.sh
You can then enter the help command or any character to see all available client commands and how to use them
To stop the zookeeper server:
$ zkserver.sh Stop