环境信息
使用的 hadoop 完全分布式集群
1 | 192.168.2.241 hadoop01 |
简介
Elasticsearch 是一个实时的分布式搜索和分析引擎,它可以用于全文搜索、结构化搜索及分析
Elasticsearch 安装
官网 https://www.elastic.co/downloads/elasticsearch
为了安全,使用 elasticsearch 用户
1 | useradd elasticsearch |
配置文件
/opt/bigdata/elasticsearch/current/config/elasticsearch.yml1
2
3
4
5
6
7
8
9
10
11cluster.name: my-application
node.name: hadoop01 # 按需修改
path.data: /data1/elasticsearch,/data2/elasticsearch
path.logs: /opt/bigdata/elasticsearch/current/logs
bootstrap.memory_lock: true
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["hadoop01", "hadoop02", "hadoop03"]
cluster.initial_master_nodes: ["hadoop01", "hadoop02"]
xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false
启动 elasticsearch, 遇到问题根据日志解决
1 | cd /opt/bigdata/elasticsearch/current |
测试1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18$ curl hadoop01:9200
{
"name" : "hadoop01",
"cluster_name" : "my-application",
"cluster_uuid" : "nbaivjfyTOmZD9uC02G7mw",
"version" : {
"number" : "8.2.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "b174af62e8dd9f4ac4d25875e9381ffe2b9282c5",
"build_date" : "2022-04-20T10:35:10.180408517Z",
"build_snapshot" : false,
"lucene_version" : "9.1.0",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}
系统调优(不调整可能导致 elasticsearch 无法启动 )
/etc/sysctl.conf1
2fs.file-max=655360
vm.max_map_count = 262144
- fs.file-max 主要是配置系统最大打开文件描述符数,建议修改为 655360 或者更高
- vm.max_map_count 影响 Java 线程数量
添加如下内容到 /etc/security/limits.conf 文件1
2
3
4
5
6* soft nproc 20480
* hard nproc 20480
* soft nofile 65536
* hard nofile 65536
* soft memlock unlimited
* hard memlock unlimited
/etc/security/limits.d/20-nproc.conf 修改,或者直接删除 /etc/security/limits.d/20-nproc.conf 文件也行1
* soft nproc 20480
/opt/bigdata/elasticsearch/current/config/jvm.options ,一般修改为 可用内存一半,或者不超过 32G
剩下的内存会被 Lucene 使用 (Lucene 是一个开源的全文检索引擎工具包,而 Elasticsearch 底层是基于 Lucene 的)
1 | -Xms4g |