Curl command usage of etcd cluster
This article is about the use of the curl command for etcd clusters. Xiao Bian thinks it is quite practical, so share it for everyone to make a reference. Let's follow the editor and have a look.
##Get etcd version number
curl -L http://127.0.0.1:2379/version
##Set a valuecurl of a key http://127.0.0.1:2379/v2/keys/message-XPUT -d value="Hello world"##Get a valuecurl of a key http://127.0.0.1:2379/v2/keys/message## Change a valuecurl of a key 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-XPUT-d value="Hello etcd"##//127.0.0.1:2379/v2/keys/message-XDeleted ##Use ttl (i.e. set a key value and add a lifetime to the key, after which the value is automatically deleted if not accessed) curl http://127.0.0.1:2379/v2/keys/foo-XPUT -d value=bar -d ttl=5##Wait for a value change curl http://127.0.0.1:2379/v2/keys/foo? wait=true This command will block the process after being invoked until the value changes. When changing the value of a key or deleting an operation occurs, the wait will return. Special attention should be paid to the fact that in the case of a high degree of change, it is best to hand over the change result to another thread for processing. The monitoring thread immediately returns to continue monitoring the change situation. Of course, etcd also provides a command to obtain historical changes. This command is only a remedy for the case of missing listening events.## Create a directory curl http://127.0.0.1:2379/v2/keys/dir-XPUT -d dir=true##List a directory curl http://127.0.0.1:2379/v2/keys/dir## Recursively list a directory curl http://127.0.0.1:2379/v2/keys/dir? Recursive=true Here we can combine many of the above uses to achieve the function we want. 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? recurrent =true&wait=true##Delete a directory curl '127.0.0.1:2379/v2/keys/dir? dir=true' -XDELETE
About etcd cluster curl command usage to share here, hope the above content can have some help to everyone, can learn more knowledge. If you think the article is good, you can share it so that more people can see it.