使用curl与集群交互

DEV Tools本质上是发送HTTP请求,同样的交互查询使用CURL一样能实现

获取Elasticsearch Endpoint

访问: https://cloud.elastic.co/deployments ,进入集群页面:

image-20220708221945332

复制Endpoint URL:

image-20220708222000106

访问集群:

 curl -u elastic:{PASSWORD} {ENDPOINT_URL}   # password在创建集群时返回,参考第二节

image-20220709000649242

在URL后加参数:

$ curl  -u elastic:{PASSWORD} https://elasticsearch-demo-3c803f.es.us-central1.gcp.cloud.es.io/_cat/nodes\?v
ip          heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
10.42.6.6             25          71   2    1.82    1.79     1.67 himrst    *      instance-0000000000
10.42.8.9             34          88   0    0.49    0.79     0.87 mv        -      tiebreaker-0000000002
10.42.6.190           55          65   1    1.99    1.66     1.56 himrst    -      instance-0000000001

image-20220709000834301


上面讨论的是Elastic Cloud下的访问方式,如果是docker搭建的ES,在执行上述命令时可能会有证书信任问题,可以用-k参数来解决:

image-20220724235042788

参考: https://unix.stackexchange.com/questions/451207/how-to-trust-self-signed-certificate-in-curl-command-line