Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to get started with etcd Cluster

Shulou Source: shulou.com Published: 2022-06-01 08:39:38 09月24日 Update

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.

Tags: Change directory cluster command situation monitoring more knowledge article thread utility event function history cycle subdirectory subdirectory that is work meeting article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Tech Info Shulou Information Docker Linux