Linux 下部署 Elasticsearch

文章
林里克斯

Elasticsearch 是一个基于 Lucene 的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于 RESTful web 接口。Elasticsearch 是用 Java 语言开发的,并作为 Apache 许可条款下的开放源码发布,是一种流行的企业级搜索引擎。

Linux 下部署 Elasticsearch


实验平台:CentOS 7.7.1908

Elasticsearch Version: 7.10.0

Java Version: openjdk 15.0.1 2020-10-20

节点信息:node-1:10.10.12.7/node-2:10.10.12.9/node-3:10.10.12.10



一、单节点部署


1.官网下载

https://www.elastic.co/cn/
$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.0-linux-x86_64.tar.gz

如果官网下载很慢可在华为镜像站下载

$ https://mirrors.huaweicloud.com/elasticsearch/7.10.0/elasticsearch-7.10.0-linux-x86_64.tar.gz

2.解压

$ tar xf elasticsearch-7.10.0-linux-x86_64.tar.gz 
$ mv elasticsearch-7.10.0 elasticsearch
$ cd elasticsearch

3.启动

若有报错信息科参考此篇文章 --> 启动 Elasticsearch 报错 bootstrap checks failed 解决

$ bin/elasticsearch -d

4.查看信息

$ curl 10.10.12.7:9200
{
  "name" : "node-1",
  "cluster_name" : "linlikesi",
  "cluster_uuid" : "EGXxIZXzR92WI3Ie1CD90g",
  "version" : {
    "number" : "7.10.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "51e9d6f22758d0374a0f3f5c6e8f3a7997850f96",
    "build_date" : "2020-11-09T21:30:33.964949Z",
    "build_snapshot" : false,
    "lucene_version" : "8.7.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

单节点搭建完毕,使用默认配置文件也能启起来


二、集群部署


1.编辑配置文件

$ vim /data/elasticsearch/config/elasticsearch.yml

cluster.name: linlikesi
# 配置的集群名称,默认是elasticsearch,es服务会通过广播方式自动连接在同一网段下的es服务,通过多播方式进行通信,同一网段下可以有多个集群,通过集群名称这个属性来区分不同的集群
node.name: node-1
# 当前配置所在机器的节点名
path.data: /data/elasticsearch/data
# 设置索引数据的存储路径
network.host: 10.10.12.7
# 这个参数是用来同时设置bind_host和publish_host两个参数
http.port: 9200
# 设置对外服务的http端口,默认为9200
transport.tcp.port: 9300
# 设置节点之间交互的tcp端口,默认是9300。
node.master: true
#指定该节点是否有资格被选举成为node(注意这里只是设置成有资格),默认true
node.data: true
## 指定该节点是否存储索引数据,默认为true。
node.ingest: true
bootstrap.memory_lock: true

http.cors.enabled: true
http.cors.allow-origin: "*"
cluster.initial_master_nodes: node-1
## 使用初始的一组符合主节点条件的节点引导集群
discovery.zen.ping.unicast.hosts: ["10.10.12.7:9300","10.10.12.9:9300","10.10.12.10:9300"]

#xpack.license.self_generated.type: basic
#xpack.security.enabled: false
#xpack.ml.enabled: true
#xpack.monitoring.collection.enabled: true
#http.max_initial_line_length: 128k
#http.max_header_size: 64kb
#http.max_content_length: 500mb
#thread_pool.write.size: 3
#thread_pool.write.queue_size: 2000
#### Search pool
#thread_pool.search.size: 72
#thread_pool.search.queue_size: 5000
###
####添加或删除节点及负载均衡时并发恢复的线程个数,默认4个
#cluster.routing.allocation.node_concurrent_recoveries: 16
#####初始化数据恢复时,并发恢复线程的个数,默认4个
#cluster.routing.allocation.node_initial_primaries_recoveries: 16

不同环境不同配置参数不一致,具体配置文件详解可参考 --> Elasticsearch 目录和 yml 配置文件详解

2.其他节点

其他节点配置与几乎一致,修改下 node.name network.host

3.启动

$ bin/elasticsearch -d

4.分别启动后可看到集群状态从 YELLOW 改变为 GREEN

[2020-11-24T06:11:54,040][INFO ][o.e.c.r.a.AllocationService] [node-2] Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[.monitoring-es-7-2020.11.23][0]]]).

5.查看集群信息

$ curl 10.10.12.7:9200/_cluster/health?pretty
{
  "cluster_name" : "linlikesi",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 1,
  "active_shards" : 1,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}

Over~

版权协议须知!

本篇文章来源于 Uambiguous ,如本文章侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意

677 0 2020-11-22


分享:
icon_mrgreen.gificon_neutral.gificon_twisted.gificon_arrow.gificon_eek.gificon_smile.gificon_confused.gificon_cool.gificon_evil.gificon_biggrin.gificon_idea.gificon_redface.gificon_razz.gificon_rolleyes.gificon_wink.gificon_cry.gificon_surprised.gificon_lol.gificon_mad.gificon_sad.gificon_exclaim.gificon_question.gif
博主卡片
林里克斯 博主大人
一个致力于Linux的运维平台
运维时间
搭建这个平台,只为分享及记载自己所遇之事和难题。

现在时间 2024-04-28

今日天气
站点统计
  • 文章总数:240篇
  • 分类总数:29个
  • 评论总数:10条
  • 本站总访问量 216578 次

@奥奥

@Wong arrhenius 牛比

@MakerFace 厉害了!