Zookeeper clustered environment to build stand-alone &

The installation of a stand-alone environment

ZK first download the binary installer: http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.14/

The installation package uploaded to Linux:

  • Decompressing: tar zxvf zookeeper-3.4.14.tar.gz

  • Renaming: mv zookeeper-3.4.14 zookeeper

  • Delete archive: rm -rf zookeeper-3.4.14.tar.gz

ZK file into the folder renamed after we create a folder: mkdir data

Into the conf folder and rename a file: cp zoo_sample.cfg zoo.cfg

  

For zoo.cfg file for editing vim zoo.cfg

Data folder dataDir specified as a path that data folder we just created, do not use the system in the / tmp directory as the data directory ZK

   

Then we can start the service, in the bin directory of the unzipped files:

  • Start Service: ./zkServer.sh start

  • View status: ./zkServer.sh status

Stand-alone We are here to build even completed, for test environment is still OK, because the stand-alone service there is a fatal problem that single point of failure, it is generally in a production environment and many other services of this type are based on cluster the way appears below us build a cluster ZK composed by three servers

To build a clustered environment

ZK in a clustered environment as long as the machine is generally more than normal start, then the cluster service is OK, so a machine participating in the cluster are single, for example, five machines, only three normal on OJBK, here we take a simple using three machines set up at ZK cluster environment, the three machines ip were as follows:

  • 192.168.159.159

  • 192.168.159.169

  • 192.168.159.179

Creating a stand-alone environment and Mo same steps, just cut and dry

First, we start on a 159 machine

Suit

zk binary file upload, extract, rename, refer to the previous stand-alone installation

First created in the data-extracting file folder, save for saving memory database fuzzy snapshot: mkdir data

Then is the copy and rename a file: cp zoo_sample.cfg zoo.cfg

Cut and dry

Edit the file vim zoo.cfg

  • The first data point to modify dataDir we created the directory

  • Second adding the following data as FIG.

First explain the data and circled added:

  • sserver.1: this represents the start after ZK, ZK is 1 of myId

  • Followed by the corresponding server ip

  • Then is 2888, this is the time a connection port number, data communications (such as synchronization) communicate through this port number

  • Then is 3888, this is an election port number, the port number to use when communicating election

Create a file myid

In addition to changing zoo.cfg configuration file, also configure a clustered mode file myid, dataDir this file in the directory, which is our own creation, that is, the data directory, the file which only one is just configuration data myId the value that will read this file when Zookeeper start, to get inside the data and configuration information inside zoo.cfg comparison to determine in the end is the server.

Create a file in the data files created folder: vi myid

Each machine type corresponds myid save out such myid 59 is myid 1, 69 to 2, the configuration file that is myid

Configuration environment variable

vi / etc / profile data is added following the end

  • export ZOOKEEPER_HOME=/usr/local/ZK/zookeeper

  • export PATH=$PATH:$ZOOKEEPER_HOME/bin:$ZOOKEEPER_HOME/conf

After exiting the Save Go to the / etc directory entry into force of the refresh command source profile

Then is the start of the work of our three machines:

  • Service starts: zkServer.sh start

  • View status: zkServer.sh status

Status of the three machines as follows:

  

  

  

这里提醒一下,防火墙我是直接关闭了的,要么你的开通那几个端口,要么直接关闭防火墙服务

集群环境到这里就算搭建完成了

   

 

Guess you like

Origin www.cnblogs.com/msi-chen/p/11068925.html