Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Elasticsearch common operations: cluster management chapter

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

[TOC]

0 description

Based on es 5.6, you can refer to the official documentation:

Cat API: https://www.elastic.co/guide/en/elasticsearch/reference/5.6/cat.htmlCluster API: https://www.elastic.co/guide/en/elasticsearch/reference/5.6/cluster.html1 Cat API1.1 cat aliases

Displays alias information, filters, and routing information for the index.

GET _ cat/aliases?v

? v is the output header.

The returned result is as follows:

Alias index filter routing.index routing.searche3-commons-es es-java-api-goods_index my_index_new-alias_test my_index3-alias_test2 my_index3- Alias_test my_index2-my_search_indices bank_news_news-bank_alias bank-1.2 cat allocation

View the number of shards per node and the disk space usage of each node.

GET _ cat/allocation?v

The returned result is as follows:

Shards disk.indices disk.used disk.avail disk.total disk.percent host ip node 361 15.1gb 1.6tb 7.3tb 8.9tb 18 172.18.5.206 172.18.5.206 es01 361 15.4gb 1.7tb 7.2tb 8.9tb 19 172.18.5.204 172.18.5.204 es02 361 15gb 1.4tb 7.4tb 8.9tb 16 172.18.5.205 172.18.5.205 es031.3 cat count

View the number of documents in the index or cluster.

GET _ cat/count?v

Or:

GET _ cat/count/books?v

The returned result is as follows:

Epoch timestamp count1544437087 18:18:07 67541.4 cat fielddata

View the amount of heap memory used by fielddata on each data node.

GET _ cat/fielddata?v

The returned result is as follows:

Id host ip node field sizejA22IcavSn6DU9RP3S081g 127.0.0.1 127.0.0.1 jA22Ica _ uid 1.6kbjA22IcavSn6DU9RP3S081g 127.0.0.1 127.0.0.1 jA22Ica _ parent#rd_center 1.4kbjA22IcavSn6DU9RP3S081g 127.0.0.1 127.0.0.1 jA22Ica _ parent#country 1.4kbjA22IcavSn6DU9RP3S081g 127.0.0.1 127.0.0.1 jA22Ica _ parent 1.4kb

The relevant principle knowledge of fielddata can be learned by finding documents on its own.

1.5 cat health

Displays the health status information of the cluster.

GET _ cat/health?v

The returned result is as follows:

Epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent1544437302 18:21:42 elasticsearch yellow 1 1 186 186 0 179 0-51.0% 1.6 cat indices

View index information, including: health status, index switch status, number of fragments, number of copies, number of documents, number of documents marked for deletion, storage space occupied, unique identification of the index, and so on.

GET _ cat/indices?v

Or:

GET _ cat/indices/forum?v

The returned result is as follows:

Health status index uuid pri rep docs.count docs.deleted store.size pri.store.sizeyellow open twitter ih6fzecDRFKHDoKPkAyQTg 5 1 3 0 15kb 15kbyellow open cat_shop AALA-CWYREaLJUN8sMdbIg 5 1 1 0 5.1kb 5.1kbyellow open range_index r8nh_ljRST-K4jztd0gHiw 5 1 1 0 4kb 4kbyellow open myblog ZZEavPu9Q7uOH_QlXEcSQQ 5 1 2 0 7.4kb 7.4kbyellow open .kibana d189HADjSKCy6fV1ogmRgg 1 1 1 0 3.1kb 3.1kbyellow open forum JLUjf6LTRPylrayBIJgzbw 5 1 6 0 41.7kb 41.7kb1.7 cat master

Displays the id, ip, and node name of the master node.

GET _ cat/master?v

The returned result is as follows:

Id host ip node-UobleMyQPmJOTAeEtoUdQ 192.168.10.102 192.168.10.102 es021.8 cat nodeattrs

Returns information about the node, but in fact the test does not return a result.

GET _ cat/nodeattrs?v1.9 cat nodes

Returns the information of each node in the cluster.

GET _ cat/nodes?v

The returned result is as follows:

Ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name192.168.10.102 7 73 0 0.10 0.03 0.00 mdi * es02192.168.10.103 10 73 0 0.00 0.00 mdi-es03192.168.10.101 3 97 1 0.01 0.01 0.00 mdi-es011.10 cat pending tasks

View a list of tasks that are being performed.

GET / _ cat/pending_tasks?v

The returned result is as follows:

GET / _ cat/pending_tasks?v1.11 cat plugins

View the plug-in information that the node is running.

GET / _ cat/plugins?v

The returned result is as follows:

Name component versiones02 repository-hdfs 5.6.8es03 repository-hdfs 5.6.8es01 repository-hdfs 5.6.81.12 cat recovery

Check the progress of index shard recovery.

GET / _ cat/recovery?v

The returned result is as follows:

Index shard time type stage source_host source_node target_host target_node repository snapshot files files_recovered files_percent files_total bytes bytes_recovered bytes_percent bytes_total translog_ops translog_ops_recovered translog_ops_percentlogs-000001 0 782ms peer done 192.168.10.103 es03 192.168.10.101 es01 n/a n/a 1 1 100.0% 1 162 100.0% 16200 100.0%logs-000001 0 35ms empty_store done nqqa a 192.168.10.103 es03 namea 00 0. 0% 000 0. 0% 000 100.0%logs-000001 1 31ms empty_store done a n es01 a 192.168.10.101 N cat repositories a 00 0.0% 00 00.0% 00 0 100.0% 1.13

View the snapshot library in the cluster.

GET / _ cat/repositories?v

The returned result is as follows:

Id typemy_hdfs_repository2 hdfs

The snapshot library is used for index backup and recovery.

1.14 cat thread pool

View thread pool statistics for each node in the cluster.

GET / _ cat/thread_pool?v

The returned result is as follows:

Node_name name active queue rejectedjA22Ica bulk 0 0 0jA22Ica fetch_shard_started 0 0 0jA22Ica fetch_shard_store 0 0 0jA22Ica flush 0 0 0jA22Ica force_merge 0 0 0jA22Ica generic 0 0 0jA22Ica get 0 0 0jA22Ica index 0 0 0jA22Ica listener 0 0 0jA22Ica management 1 0 0jA22Ica refresh 0 0 0jA22Ica search 0 0 0jA22Ica snapshot 0 0 0jA22Ica warmer 0 0 01.15 cat shards

View the shard information of each node in the cluster, including shard name, number, whether it is the main shard, status, document data, space size, ip of all nodes, and node name.

GET / _ cat/shards?v

The returned result is as follows:

Index shard prirep state docs store ip nodemy_index 2 r STARTED 1 3.2kb 192.168.10.103 es03my_index 2 p STARTED 1 3.2kb 192.168.10.102 es02my_index 1 p STARTED 0 162b 192.168.10.103 es03my_index 1 r STARTED 0 162b 192.168.10.102 es02my_index 3 P STARTED 1 3.2kb 192.168.10.101 es01my_index 3 r STARTED 1 3.2kb 192.168.10.103 es03my_index 4 r STARTED 0 162b 192.168.10.101 es01my_index 4 p STARTED 0 162b 192.168.10.103 es03my_index 0 p STARTED 0 162b 192.168.10.101 es01my_index 0 R STARTED 0 162b 192.168.10.102 es021.16 cat segments

Look at the segment information of the index and notice that the index data is actually stored in a segment-by-segment manner.

GET / _ cat/segments?v

The returned result is as follows:

Index shard prirep ip segment generation docs.count docs.deleted size size.memory committed searchable version compoundlogs-000001 2 p 192.168.10.103 _ 001 0 3.1kb 1498 true true 6.6.1 truelogs-000001 2 r 192.168.10.102 _ 001 0 3.1kb 1498 true true 6.6.1 truelogs-000001 3 p 192.168.10.101 _ 001 0 3.1kb 1498 true true 6.6.1 truelogs-000001 3 r 192.168.10.103 _ 001 0 3.1kb 1498 true true 6.6.1 truelogs-000001 4 r 192.168.10.101 _ 001 0 3.1kb 1498 true true 6.6.1 truelogs-000001 4 p 192.168.10.102 _ 001 0 3.1kb 1498 true True 6.6.1 true.kibana 0 p 192.168.10.101 _ 0 01 0 2.9kb 1737 true true 6.6.1 true.kibana 0 r 192.168.10.102 _ 0 01 0 2.9kb 1737 true true 6.6.1 truemy_index 2 r 192.168.10.103 _ 0 0 10 2.9kb 1497 true true 6.6.1 truemy_index 2 p 192.168.10.102 _ 0 0 10 2.9kb 1497 true true 6. 6.1 truemy_index 3 p 192.168.10.101 _ 2 2 10 2.9kb 1497 true true 6.6.1 truemy_index 3 r 192.168.10.103 _ 2 2 10 2.9kb 1497 true true 6.6.1 true1.17 cat templates

View the templates in the cluster.

GET / _ cat/templates?v

The returned result is as follows:

Name template order versionlogstash logstash-* 0 50001

Search template, please refer to the documentation:

2 Cluster API2.1 Cluster Health

Check the health status of the cluster.

GET / _ cluster/health

The returned result is as follows:

{"cluster_name": "es-prd", "status": "yellow", "timed_out": false, "number_of_nodes": 3, "number_of_data_nodes": 3, "active_primary_shards": 20, "active_shards": 37, "relocating_shards": 0, / the part "initializing_shards": 0, / the part being initialized "unassigned_shards": 6 / / No assigned shards "delayed_unassigned_shards": 0, / delay unassigned shards "number_of_pending_tasks": 0, / / number of tasks in the node queue "number_of_in_flight_fetch": 0, / / number of shards being migrated "task_max_waiting_in_queue_millis": 0 / / maximum waiting time for tasks in the queue "active_shards_percent_as_number": 86.04651162790698 / / percentage of active shards}

In addition, the explanation for status is as follows:

Status indicates that not all indexes' primary shard of green is in active state, and some indexes have lost data (because if only primary shard is unavailable, replica shard will be promoted, which means some data is lost) yellow every index's primary shard is in active state, but part of replica shard is not in active state, red is unavailable, primary shard and replica shard of each index are active state 2.2 Cluster State

Returns the full status information of the cluster.

GET / _ cluster/state

A lot of data is returned, which is not shown here, but only part of the data can be returned, such as:

GET / _ cluster/state/version2.3 Cluster Stats

Get all kinds of statistics. It includes two parts of data:

Index level: number of shards, storage size, memory usage, etc.; node level: number of nodes, node roles, operating system, jvm information, memory, CPU, plug-ins, etc.; GET / _ cluster/stats2.4 Pending Cluster Tasks

Returns a list of tasks that are being added to the cluster state.

GET / _ cluster/pending_tasks

The returned result is as follows:

{"tasks": []} 2.5 Cluster Reroute

Explicitly execute the cluster reroute assignment command.

POST / _ cluster/reroute

Of course, you can also add other optional parameters, which can be referred to the official documentation.

2.6 Cluster Update Settings

Update the configuration in the cluster. If the configuration is permanent, the cluster needs to be restarted; the temporarily configured configurations do not need to restart the cluster.

PUT / _ cluster/settings {"persistent": {"discovery.zen.minimum_master_nodes": 1}}

If it is a temporary change, transient is used.

2.7 Nodes Stats

Statistics of one or more nodes in the cluster.

GET / _ nodes

Or:

GET / _ nodes/es01,es02

You can also return only part of the information:

GET / _ nodes/es01,es02/os,jvm2.8 Nodes Info

Ref. 2.7.

2.9 Task Management API

Gets the information about the tasks being executed in the nodes in the cluster.

GET / _ tasks2.10 Cluster Allocation Explain API

Check the reason why the shard is not allocated. For example, if you see that an index is not allocated through GET / _ cat/shards?v, you can use the following command to see why it is not allocated.

GET / _ cluster/allocation/explain {"index": "twitter", "shard": 0, "primary": true}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report