ZooKeeper installation configuration

There are three ways to install Zookeeper, stand-alone mode and cluster mode and pseudo-cluster mode.

Single-machine mode: Zookeeper only runs on one server, suitable for test environments;
■ Pseudo-cluster mode: One Multiple instances of Zookeeper run on one physical machine;
■ Cluster mode: Multiple instances run on multiple physical machines, Zookeeper runs on a cluster, suitable for a production environment, this computer cluster is called an “ensemble” (ensemble)


1.1 Zookeeper’s stand-alone mode construction

DownloadZooKeeper: http://pan.baidu.com/s/1pJlwbR9

Or official website address (http://zookeeper.apache.org/releases.html)

Unzip: tar -zxvf zookeeper-3.4.5.tar.gz Rename: mv zookeeper-3.4.5 zk

Configuration file: Delete the zoo_sample.cfg file in the conf directory, create A configuration file zoo.cfg.

tickTime=2000
dataDir=/usr/local/zk/data
dataLogDir=/usr/ local/zk/dataLog
clientPort=2181


uses the default Configuration file

startupZooKeeper’s Server: zkServer.sh start;

CloseZooKeeper’s Server: zkServer.sh stop


< /p>


1.2 Zookeeper’s pseudo-cluster mode construction

Three servers are deployed on one machine. Note that the cluster is distributed In the mode we use each configuration file simulates a machine, that is to say, a single machine and multiple Zookeeper instances run on it. However, it must be ensured that the port numbers of each configuration file cannot conflict. In addition to the different clientPort, the dataDir is also different. In addition, create a myid file in the directory corresponding to dataDir to specify the corresponding Zookeeper server instance.

clientPort port: If multiple servers are deployed on one machine, each machine must have a different clientPort For example, server1 is 2181, server2 is 2182, server3 is 2183

dataDir and dataLogDir: dataDir and dataLogDir also need to be distinguished Next, store the data files and log files separately, and the paths corresponding to these two variables of each server are different

server.X and myid: server.X is the corresponding number, the number in data/myid. Write 0, 1, 2 in the myid files of the three servers, then the zoo.cfg in each server is configured with server.0, server.2, and server.3. Because on the same machine, the two ports behind, the three servers are not the same, otherwise the port conflicts

The following is the pseudo-distribution mode of the cluster that I configured, respectively through zoo1.cfg, zoo2.cfg, zoo3.cfg to simulate a Zookeeper cluster with three machines, code listing

zoo1.cfg

tickTime=2000initLimit=10syncLimit=5dataDir=/app/svr/ zookeeper/data_1dataLogDir=/app/svr/zookeeper/datalog_1clientPort=2181server.1=localhost:2287:3387server.2=localhost:2288:3388server.3=localhost:2289:3389

At the same time /app/svr/zookeeper /data_1 Create a new myid file below

1

corresponding to the number 1 in server.1 in the configuration file< /p>


zoo2.cfg and zoo3.cfg and so on< /p>


Start pseudo cluster

./zkServer.sh start ../conf/zoo1.cfg

Other startups can be deduced by analogy.

Check the running status:

./zkServer.sh status ../conf /zoo1.cfg You can see that it is a follower or leader

Connect to the cluster:

./zkCli.sh -server localhost:2181,localhost :2182,localhost:2183

Related commands

View ls / ls / strategy_model/82_2_3_2015

Get content get

Set content set

Delete content delete

1.3 Zookeeper’s cluster mode construction

The cluster mode is similar in construction, except that it is distributed on different devices.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4787 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.