In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Zookeeper architecture
The zookeeper server runs in two modes: stand-alone mode (standalone) and arbitration mode (quorum). Stand-alone mode: there is a separate server and the zookeeper state cannot be replicated. Arbitration mode: has a set of zookeeper servers, which we call zookeeper clusters (zookeeper ensemble), that can previously replicate status and serve client requests at the same time.
2. Start using zookeeper
Download address: https://archive.apache.org/dist/zookeeper/zookeeper-3.5.5/apache-zookeeper-3.5.5-bin.tar.gz
Zookeeper is written in the Java language, and jdk must be installed in the system to start zookeeper.
First we run zookeeper in stand-alone mode and create a session.
Upload to the Linux server and decompress:
[root@localhost opt] # tar xvf apache-zookeeper-3.5.5-bin.tar.gz-C / opt/
If you are using the Windows system, you can use winzip's unzip tool to extract the distribution package.
In the distribution directory, you will find a script to start zookeeper in the bin directory. Footsteps that end in .sh run on the Unix platform, and scripts that end in .cmd are used for Windows. Save the configuration file in the conf directory. The lib directory includes Java's jar files, which are the third-party support needed to run zookeeper.
Modify the configuration file:
[root@localhost zookeeper] # cd conf/ [root@localhost conf] # mv zoo_sample.cfg zoo.cfg [root@localhost conf] # vim zoo.cfgdataDir=/opt/zookeeper/dataDir
Officially, it is not recommended to use the default dataDir. Modify dataDir to save and exit.
Configuration items for zookeeper:
The configuration items for zookeeper are configured in the zoo.cfg configuration file, and some other configurations can be configured through the Java system properties. Three important configuration items are listed below:
DataDir, the port on which clientPort:zookeeper provides services to the client: the directory used to save snapshot files. If dataLogDir is not set, the transaction log is also saved to this directory dataLogDir: the directory where the transaction log files are saved. Because zookeeper needs to ensure that the transaction log records fall before committing a transaction, an exclusive storage device needs to be allocated to dataLogDir.
Start the server and execute the following command:
[root@localhost conf] # cd.. [root@localhost zookeeper] # bin/zkServer.sh startZooKeeper JMX enabled by defaultUsing config: / opt/zookeeper/bin/../conf/zoo.cfgStarting zookeeper... STARTED
This server-side command causes the zookeeper server to run in the background. If you are running in the foreground to view the server output, you can run it using the following command:
[root@localhost zookeeper] # bin/zkServer.sh start-foreground
This option provides the output of a large number of details to allow you to see what happened to the server.
After startup, check the log file for error messages:
[root@localhost zookeeper] # cd logs/ [root@localhost logs] # lltotal 8murr RWMurray Rafael-1 root root 7516 Oct 21 18:28 zookeeper-root-server-localhost.localdomain.out [root@localhost logs] # grep-E-I "((exception) | (error))" *
If the query result is empty, no error information is reported.
Now use the zookeeper client to connect to the zookeeper server and run the following command:
[root@localhost zookeeper] # bin/zkCli.sh.2019-10-21 18 purl 37GV 35242 [myid:localhost:2181]-INFO [main-SendThread (localhost:2181): ClientCnxn$SendThread@959]-Socket connection established, initiating session, client: / 0VOV0VOUL0VOUL0VO 0VOULING 39276 Server: localhost/0:0:0:0:0:0:0:1:21812019-10-21 18 myid:localhost:2181 37V 35308 [myid:localhost:2181]-INFO [main-SendThread (localhost:2181): ClientCnxn$SendThread@1394]-Session establishment complete on server localhost/0:0:0:0:0:0:0:1:2181, sessionid = 0x1000132e0500000, negotiated timeout = 30000WATCHER::WatchedEvent state:SyncConnected type:None path:null [zk: localhost:2181 (CONNECTED) 0]
From the above information, we know the connection between the zookeeper client and the server.
3. Zookeeper basic commands
View all the znode under the root:
[zk: localhost:2181 (CONNECTED) 3] ls-R / zookeeper/zookeeper/config/zookeeper/quota
Create a znode named workers:
[zk: localhost:2181 (CONNECTED) 4] create / workersCreated / workers [zk: localhost:2181 (CONNECTED) 7] ls-R / workers/zookeeper/zookeeper/config/zookeeper/quota
Delete the created workers node and exit zkCli:
[zk: localhost:2181 (CONNECTED) 8] delete / workers [zk: localhost:2181 (CONNECTED) 9] ls-R / zookeeper/zookeeper/config/zookeeper/quota [zk: localhost:2181 (CONNECTED) 10] quitWATCHER::WatchedEvent state:Closed type:None path:null2019-10-21 19CONNECTED 3546321 [myid:]-INFO [main:ZooKeeper@1422]-Session: 0x1000132e0500000 closed2019-10-21 19V 35V 46322 [myid:]-INFO [main-EventThread:ClientCnxn$EventThread@524]-EventThread shut down for session: 0x1000132e0500000
Shut down the zookeeper server:
[root@localhost zookeeper] # bin/zkServer.sh stopZooKeeper JMX enabled by defaultUsing config: / opt/zookeeper/bin/../conf/zoo.cfgStopping zookeeper... STOPPED
By viewing the zkServer.sh script, you can see that six parameters are acceptable, as follows:
Start: start the service
Start-foreground: front desk startup service
Print-cmd: printing command line information
Stop: stop servic
Restart: restart the service (stop first, then start)
Status: service statu
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.