Let’s start with a basic health check, which we can use to see how our cluster is doing. We’ll be using curl to do this but you can use any tool that allows you to make HTTP/REST calls. Let’s assume that we are still on the same node where we started Elasticsearch on and open another command shell window.
让我们从基本运行状况检查开始,我们可以使用它来查看集群的运行情况。我们将使用curl来执行此操作,但您可以使用任何允许您进行HTTP / REST调用的工具。假设我们仍然在我们启动Elasticsearch的同一节点上打开另一个命令shell窗口。
To check the cluster health, we will be using the
_cat
API. You can run the command below in Kibana’s Console by clicking "VIEW IN CONSOLE" or with curl
by clicking the "COPY AS CURL" link below and pasting it into a terminal.要检查群集运行状况,我们将使用_cat API。您可以通过单击“查看控制台”或通过单击下面的“COPY AS CURL”链接并将其粘贴到终端中,在Kibana控制台中运行以下命令。
GET /_cat/health?v
And the response:
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent 1475247709 17:01:49 elasticsearch green 1 1 0 0 0 0 0 0 - 100.0%
We can see that our cluster named "elasticsearch" is up with a green status.
我们可以看到名为“elasticsearch”的群集处于绿色状态。
Whenever we ask for the cluster health, we either get green, yellow, or red.
每当我们要求群集健康时,我们要么获得绿色,黄色或红色。
1、Green - everything is good (cluster is fully functional)绿色 - 一切都很好(集群功能齐全)
2、Yellow - all data is available but some replicas are not yet allocated (cluster is fully functional)
黄色 - 所有数据均可用,但尚未分配一些副本(群集功能齐全)
3、Red - some data is not available for whatever reason (cluster is partially functional)
红色 - 某些数据由于某种原因不可用(群集部分功能)
Note: When a cluster is red, it will continue to serve search requests from the available shards but you will likely need to fix it ASAP since there are unassigned shards.
注意:当群集为红色时,它将继续提供来自可用分片的搜索请求,但您可能需要尽快修复它,因为存在未分配的分片。
Also from the above response, we can see a total of 1 node and that we have 0 shards since we have no data in it yet. Note that since we are using the default cluster name (elasticsearch) and since Elasticsearch uses unicast network discovery by default to find other nodes on the same machine, it is possible that you could accidentally start up more than one node on your computer and have them all join a single cluster. In this scenario, you may see more than 1 node in the above response.
同样从上面的响应中,我们可以看到总共1个节点,并且我们有0个分片,因为我们还没有数据。请注意,由于我们使用的是默认群集名称(elasticsearch),并且由于Elasticsearch默认使用单播网络发现来查找同一台计算机上的其他节点,因此您可能会意外启动计算机上的多个节点并拥有它们所有人都加入一个集群。在这种情况下,您可能会在上面的响应中看到多个节点。
We can also get a list of nodes in our cluster as follows:
我们还可以获得群集中的节点列表,如下所示:
GET /_cat/nodes?v
And the response:
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name 127.0.0.1 10 5 5 4.46 mdi * PB2SGZY
Here, we can see our one node named "PB2SGZY", which is the single node that is currently in our cluster.
在这里,我们可以看到一个名为“PB2SGZY”的节点,它是我们集群中当前的单个节点。