Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the operation flow of ZOOKEEPER?

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces you how the ZOOKEEPER operation process is, the content is very detailed, interested friends can refer to, hope to be helpful to you.

1. Decompression

2. Configure environment variables

3. Change the conf/zoo_sample.cfg file to zoo.cfg

Server is a fixed value

1 indicates that the myid of the host needs to be the same as the value in the myid file in the data directory

= kd01 represents the hostname

4. Create a myid file in the data directory, and the value is the same as server. The value is the same.

5. Distribute to other hosts to synchronize / etc/profile and take effect.

6. Three hosts run at the same time: zkServer.sh start

ZkServer.sh status View status

Java operation

1. Enter the command window zkCli.sh of zookeeper

2. View: ls /-- View the root directory

Ls / zookeeper/quota

3. Create a node

Create / Node name value

4. Get the value of the node

Get / Node name

5. Modify node value

New value of set / Node name

6. Delete node value

Delete / Node name

JAVA operation ZK

Introducing dependency packages into pom.xml

Com.github.sgroschupfgroupId >

ZkclientartifactId >

0.1version > which department of gynaecology in Wuxi is better http://www.wxbhnkyy39.com?

Dependency >

Write code

Public static voidmain (String [] args)

{

Watcher watcher = newWatcher () {

Public voidprocess (WatchedEvent event) {

System.out.println (event.toString ())

}

}

/ / Connect

Try {

ZkClient zkClient = newZkClient ("192.168.200.100purl 2181192.168.200.101purl 2181192.168.200.102purl 2181")

ZkClient.create ("/ mynode2", "1234", CreateMode.PERSISTENT)

ZkClient.close (); http://www.wxbhnkyy39.com of Wuxi Gynecological examination Hospital

} catch (Exception e) {

E.printStackTrace ()

}

}

About how the ZOOKEEPER operation process is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report