英文:
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 }}'
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论