Elasticsearch API 範例

💫Elasticsearch API 範例

Rolling upgrade

https://www.elastic.co/guide/en/elasticsearch/reference/current/rolling-upgrades.html

dev_tools: http://<$kibana_server>/app/dev_tools#/console

1. get cluseter node info

根據節點分組 優先處理非master的節點

dev_tools
GET /_nodes/_all,master:false?pretty&flat_settings
GET /_nodes/master:true?pretty&flat_settings
GET _cluster/settings?pretty&flat_settings

2. disabele node allocation & flush synced

只允許自動分配主要shard 不分配replicate

dev_tools
PUT _cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": "primaries"
}
}
POST _flush

然後開始停服務升級 自行操作 這邊只說api的部分 這邊要注意 有一台會是kibana連接的es(除非用domain 並做輪替詢問之類的HA機制)

3. enabele node allocation & recovery shards status

升級完畢開回自動分配 並查看後續shards回復狀態(到全綠色)

dev_tools
PUT _cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": null
}
}
GET _cat/recovery

4. get info after rolling upgrade

其他查看節點升級狀態的api

dev_tools
GET _cat/nodes
GET _cat/health?v
GET /_cat/nodes?h=ip,name,version&v

Cluster troubleshooting

dev_tools
GET _cluster/health?level=indices
GET _cluster/health?level=shards
GET _cluster/health/nginx-log-2020.06.18-000742?level=shards
GET _cluster/allocation/explain

Set watermark

dev_tools
PUT _cluster/settings
{
"transient": {
"cluster.routing.allocation.disk.watermark.low": "80%",
"cluster.routing.allocation.disk.watermark.high": "85%",
"cluster.routing.allocation.disk.watermark.flood_stage": "90%"
}
}
GET _cluster/settings

Check thread

dev_tools
GET _cat/thread_pool?v
GET _nodes/hot_threads

Get pipeline info

dev_tools
GET _ingest/pipeline/filebeat-7*