In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Next we will start a single instance zookeeper and build the simplest zookeeper cluster on this basis. In order to implement the simplest concept, our cluster will have only three nodes, and they will all be on the same machine.
All right, let's get to work!
Single instance 1. Extract the installation package and copy the configuration file
Tar-xvzf zookeeper-3.4.12.tar.gz
After decompression, go to the conf directory and copy a configuration file:
Cp zoo_sample.cfg zoo.cfg
two。 Modify dataDir
Although optional, it's best to move data out of the / tmp directory. I created a data directory under the zookeeper installation directory and executed it under the zookeeper directory:
Mkdir data
Then modify the dataDir in the zoo.cfg file. The contents of my modified file are as follows:
TickTime=2000initLimit=10syncLimit=5dataDir=/home/ym/zookeeper/zookeeper-3.4.12/dataclientPort=21813. Start the instance
Execute the following in the bin directory:
. / zkServer.sh start
The following indicates success:
[ym@localhost bin] $. / zkServer.sh startZooKeeper JMX enabled by defaultUsing config: / home/ym/zookeeper/zookeeper-3.4.12/bin/../conf/zoo.cfgStarting zookeeper. STARTED cluster building 1. Modify the configuration file
First, make a copy from the above single instance configuration file zoo.cfg:
Cp zoo.cfg zoo1.cfg
Modify the content as follows:
TickTime=2000initLimit=10syncLimit=5dataDir=/home/ym/zookeeper/zookeeper-3.4.12/data1clientPort=2182server.1=127.0.0.1:2222:2223server.2=127.0.0.1:3333:3334server.3=127.0.0.1:4444:4445
Create zoo2.cfg and zoo3.cfg:
Cp zoo1.cfg zoo2.cfgcp zoo1.cfg zoo3.cfg
Modify the clientPort of 2183 and 2184 in zoo2.cfg and zoo3.cfg, and point to data2 and data3 in dataDir. The modified contents are as follows:
Data2.cfg
TickTime=2000initLimit=10syncLimit=5dataDir=/home/ym/zookeeper/zookeeper-3.4.12/data2clientPort=2183server.1=127.0.0.1:2222:2223server.2=127.0.0.1:3333:3334server.3=127.0.0.1:4444:4445
Data3.cfg
TickTime=2000initLimit=10syncLimit=5dataDir=/home/ym/zookeeper/zookeeper-3.4.12/data3clientPort=2183server.1=127.0.0.1:2222:2223server.2=127.0.0.1:3333:3334server.3=127.0.0.1:4444:4445
Each server.n entry specifies the address and port number used by the ZooKeeper server numbered n. Each server.n entry is divided into three parts by colons. The first part is the IP address or hostname (hostname) of server n, and the second and third parts are TCP port numbers, which are used for arbitration communication and group head election, respectively. Because we are running three server processes on the same machine, we need to use a different port number in each entry. Typically, we run each server process on a different server, so each server item can be configured with the same port number.
2 create a data directory
Execute to the zookeeper installation directory:
Mkdir data1mkdir data2mkdir data3
When starting a server, we need to know which server is started. A suit.
The server gets the server ID information by reading a file called myid under the data directory. But
To create these files with the following command:
Echo 1 > data1/myidecho 2 > data2/myidecho 3 > data3/myid3 start the instance
Open the three terminals and execute them in the zookeeper directory:
Bin/zkServer.sh start.. / conf/zoo1.cfgbin/zkServer.sh start.. / conf/zoo2.cfgbin/zkServer.sh start.. / conf/zoo3.cfg4 uses zkCli.sh to access the cluster
Bin/zkCli.sh-server 127.0.0.1 purl 2182127.0.0.1 purl 2183127.0.0.1purl 2184
The following message appears:
[myid:]-INFO [...]-Session establishmentcomplete on server localhost/127.0.0.1:2182.
The ostensible client connects to the zookeeper server with port 2182.
Use ctrl+c to stop and re-use the above command to connect, so several times you will find that the connected port changes back and forth in 2182, 2183, and 2184.
Reference: "ZooKeeper- distributed process collaboration Technology"
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.