从Opensearch集群通过API删除设置

huangapple go评论48阅读模式
英文:

Delete settings from Opensearch cluster via API

问题

你可以使用以下代码将交叉集群搜索设置为null以删除它:

curl -k -XPUT -H 'Content-Type: application/json' -u 'admin:admin' 'https://my-cluster-hostname:9200/_cluster/settings' -d '{
  "persistent": {
    "cluster.remote": {
      "cross-cluster-name": {
        "seeds": null
      }
    }
  }
}'

这将删除交叉集群搜索的设置。你可以在这里找到更多关于此的文档:https://www.elastic.co/guide/en/elasticsearch/reference/5.6/modules-cross-cluster-search.html

英文:

I have an Opensearch cluster with cross cluster search setted up with official guide (https://opensearch.org/docs/latest/security/access-control/cross-cluster-search/).
Now I need to disable it. I don't have access to nodes or underlying VMs, only curl and API.

For now my cluster settings looks like that:

# Setting up cross-cluster search
curl -k -XPUT -H 'Content-Type: application/json' -u 'admin:admin' 'https://my-cluster-hostname:9200/_cluster/settings' -d '
{
  "persistent": {
    "cluster.remote": {
      "cross-cluster-name": {
        "seeds": ["cross-cluster-node-01:9300", "cross-cluster-node-02:9300", "cross-cluster-node-03:9300", "cross-cluster-node-04:9300" ]
      }
    }
  }
}'

# Get cluster settings
curl -XGET -k -u 'admin:admin' 'https://my-cluster-hostname:9200/_cluster/settings?pretty'

# output:
{
  "persistent" : {
    "cluster" : {
      "remote" : {
        "cross-cluster-name" : {
          "seeds" : [
            "cross-cluster-node-01:9300",
            "cross-cluster-node-02:9300",
            "cross-cluster-node-03:9300",
            "cross-cluster-node-04:9300"
          ]
        }
      }
    }
  },
  "transient" : { }
}

How can I delete those settings to disable cross cluster search?

What I tried:

# tried to delete settings alltogether
curl -XDELETE -k -u 'admin:admin' 'https://my-cluster-hostname:9200/_cluster/settings'
# output:
{"error":"Incorrect HTTP method for uri [/_cluster/settings] and method [DELETE], allowed: [PUT, GET]","status":405}%  

# tried to replace with empty setting 
curl -k -XPUT -H 'Content-Type: application/json' -u 'admin:admin' 'https://my-cluster-hostname:9200/_cluster/settings' -d '
{ "persistent": { "cluster" : { "remote" : {} } }, "transient" : { } }'
# output:
{"error":{"root_cause":[{"type":"action_request_validation_exception","reason":"Validation Failed: 1: no settings to update;"}],"type":"action_request_validation_exception","reason":"Validation Failed: 1: no settings to update;"},"status":400}%           

Update:
Thanks to Martin P. answer I was able to found the right solution. To remove remote cluster from settings, it seeds must be set to null:

curl -k -XPUT -H 'Content-Type: application/json' -u 'admin:admin' 'https://my-cluster-hostname:9200/_cluster/settings' -d '
{
  "persistent": {
    "cluster.remote": {
      "cross-cluster-name": {
        "seeds": null
      }
    }
  }
}'

found an answer here: https://discuss.elastic.co/t/cross-cluster-search-questions/222379/7 and there is more documentation on module here: https://www.elastic.co/guide/en/elasticsearch/reference/5.6/modules-cross-cluster-search.html

答案1

得分: 0

尝试设置一个空值。这是移除先前设置的方法。

curl -k -XPUT -H 'Content-Type: application/json' -u 'admin:admin' 'https://my-cluster-hostname:9200/_cluster/settings' -d '{ "persistent": { "cluster.remote": null }}'
英文:

Try setting a null value. That's the way to remove a previous done setting.

curl -k -XPUT -H 'Content-Type: application/json' -u 'admin:admin' 'https://my-cluster-hostname:9200/_cluster/settings' -d '{ "persistent": { "cluster.remote": null  }}'

huangapple
  • 本文由 发表于 2023年6月29日 20:26:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76581048.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定