「Elasticsearch」- 集群搭建(Elasticsearch 6.8.6)

  CREATED BY JENKINSBOT

注意事项

1)版本不同,集群配置方法不同。例如 Elasticsearch 6.8.6 与 7.6.2 的集群配置方法是不同的。

第一步、服务搭建

跳过服务部署步骤,详细参考 Elasticsearch on CentOS 笔记。

第二步、调整配置

修改每台主机/etc/elasticsearch/elasticsearch.yml文件,修改以下地方:

# 设置集群的名称
cluster.name: production-elasticsearch-cluster

# 设置节点的名称,取当前主机名。
node.name: ${HOSTNAME}

# 设置集群节点
discovery.zen.ping.unicast.hosts: ["10.0.0.1", "10.0.0.2", "10.0.0.3"]

第三步、重启服务

重启每台主机的 Elasticsearch 服务。

第四步、查看状态

执行curl -s http://ipaddress:9200/_cluster/state/?pretty | less命令,如果产生类似如下输出,则表示集群正常:

{
  "cluster_name" : "elasticsearch-cluster",
  "cluster_uuid" : "Mq7wyMd9Rw2nMQHhrPB-PA",
  "version" : 13,
  "state_uuid" : "ZnWe0IL_TRiH1hgwQSEz-g",
  "master_node" : "4LLJp6NQTbGJmTcNmkHeSg",
  "blocks" : { },
  "nodes" : {
    "Gq1ngfj_SlSCtY1gpjZsmg" : {
      "name" : "esclus-02",
      "ephemeral_id" : "XFYlGhtMRYy5KOtcZl__5w",
      "transport_address" : "10.10.50.218:9300",
      "attributes" : {
        "ml.machine_memory" : "8203100160",
        "ml.max_open_jobs" : "20",
        "xpack.installed" : "true",
        "ml.enabled" : "true"
      }
    },
    "4LLJp6NQTbGJmTcNmkHeSg" : {
      "name" : "esclus-01",
      "ephemeral_id" : "UQwkjF1kSU2sKwREgDZSOA",
      "transport_address" : "10.10.50.217:9300",
      "attributes" : {
        "ml.machine_memory" : "8203100160",
        "xpack.installed" : "true",
        "ml.max_open_jobs" : "20",
        "ml.enabled" : "true"
      }
    },
    "Si-Ou_b-QBKuHQvOZ5fz-g" : {
      "name" : "esclus-03",
      "ephemeral_id" : "GY1mHaTiRheXSqxZbAKEHQ",
      "transport_address" : "10.10.50.219:9300",
      "attributes" : {
        "ml.machine_memory" : "8203100160",
        "ml.max_open_jobs" : "20",
        "xpack.installed" : "true",
        "ml.enabled" : "true"
      }
    }
  },
......

参考文献

How To Set Up a Production Elasticsearch Cluster on CentOS 7
Elasticsearch Reference [7.5] » REST APIs » Cluster APIs » Cluster state API