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

How to get started with etcd Cluster

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article is about how to get started with etcd clusters. The editor thinks it is practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it with the editor.

Use docker-compose to build etcd cluster environment https://www.jianshu.com/p/44022c67f117Docker build etcd cluster API use: https://www.cnblogs.com/xishuai/p/docker-etcd.html## get the version number of etcd curl-L http://127.0.0.1:2379/version## set a key valuecurl http://127.0.0.1:2379/v2/keys/message-XPUT-d value= "Hello world" # # get a key valuecurl http://127.0.0.1:2379/v2/keys/message## change a key valuecurl http://127.0.0.1:2379/v2/keys/message-XPUT-d value= "Hello etcd" # # Delete a key node curl http://127.0.0.1:2379/v2/keys/message-XDELETE## use ttl (that is, set a key value and add a life cycle to the key Curl http://127.0.0.1:2379/v2/keys/foo-XPUT-d value=bar-d ttl=5## waits for a value change curl http://127.0.0.1:2379/v2/keys/foo?wait=true after the command is called, it blocks the process until the value changes, when changing the value of a key, or deleting, etc. The wait will return special attention. In the case of a high degree of change, it is best to hand over the result of the change to another thread, and the monitoring thread immediately returns to continue to monitor the change. Of course, etcd also provides a command to obtain historical changes, which is only a remedy in the case of lost listening events. # # create a directory curl http://127.0.0.1:2379/v2/keys/dir-XPUT-d dir=true## enumerate a directory curl http://127.0.0.1:2379/v2/keys/dir## recursively enumerate a directory curl http://127.0.0.1:2379/v2/keys/dir?recursive=true here we can combine the above many uses to achieve the desired functions. For example, monitor all key changes in a directory, including subdirectories. You can use the command: curl http://127.0.0.1:2379/v2/keys/dir?recursive=true&wait=true## delete a directory curl 'http://127.0.0.1:2379/v2/keys/dir?dir=true'-XDELETE above is how to get started with etcd clusters. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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

Servers

Wechat

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

12
Report