Centos7.4部署配置Elasticsearch5.6集群

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos7.4部署配置Elasticsearch5.6集群相关的知识,希望对你有一定的参考价值。

参考文档

https://www.elastic.co/guide/en/elasticsearch/reference/5.6/index.html
https://www.elastic.co/guide/cn/elasticsearch/guide/current/important-configuration-changes.html
https://www.elastic.co/guide/en/elasticsearch/reference/master/setting-system-settings.html

一、环境

1、系统环境

cat /etc/security/limits.conf?
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited
elasticsearch soft nofile 131072
elasticsearch hard nofile 131072
elasticsearch soft nproc 4096
elasticsearch hard nproc 4096

2、JAVA环境

java -version
openjdk version "1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)

二、安装配置

1、安装
rpm -qa |grep elas
elasticsearch-5.6.8-1.noarch

注意Centos7.4服务里面需要配置内存锁定,需要修改文件/etc/systemd/system/elasticsearch.service.d/override.conf 参考https://www.elastic.co/guide/en/elasticsearch/reference/master/setting-system-settings.html
EDITOR=vim systemctl edit elasticsearch

[Service]
LimitMEMLOCK=infinity

#systemctl daemon-reload

2、配置

注意配置使用默认的就行,大部分参数都是按照默认即可,官方已经调优过了,特别是Centos7里面,不需要在配置文件里面添加,只有那些必须要根据实际情况修改的配置需要填写。

1)、master节点配置

cat /etc/elasticsearch/elasticsearch.yml
cluster.name: roobo-escluster
node.name: master-01
node.master: true
node.ingest: true
node.data: false
path.data: /data/es-data01,/data/es-data02
path.logs: /data/es-data01/eslogs
bootstrap.memory_lock: true
network.host: 172.20.3.17
http.port: 9200
discovery.zen.ping.unicast.hosts: ["172.20.3.17:9300","172.20.3.18:9300","172.20.3.19:9300"]
discovery.zen.minimum_master_nodes: 2
gateway.recover_after_nodes: 6
gateway.expected_nodes: 8
gateway.recover_after_time: 5m
http.cors.enabled: true
http.cors.allow-origin: "*"

2)、data节点配置

cat /etc/elasticsearch/elasticsearch.yml
cluster.name: roobo-escluster
node.name: data-01
node.master: false
node.ingest: false
node.data: true
path.data: /data/es-data01,/data/es-data02
path.logs: /data/es-data01/eslogs
bootstrap.memory_lock: true
network.host: 172.20.3.20
http.port: 9200
discovery.zen.ping.unicast.hosts: ["172.20.3.17:9300","172.20.3.18:9300","172.20.3.19:9300"]
discovery.zen.minimum_master_nodes: 2
gateway.recover_after_nodes: 6
gateway.expected_nodes: 8
gateway.recover_after_time: 5m
http.cors.enabled: true
http.cors.allow-origin: "*"

3)、jvm调优

默认只需要调整HEAP大小,最好不超过内存的50%,大内存服务器不超过31G

cat /etc/elasticsearch/jvm.options |egrep ‘Xms|Xmx‘
-Xms14g
-Xmx14g

3、开机启动

systemctl enable elasticsearch

三、Elasticsearch常见操作

查看nodes

curl http://172.20.3.20:9200/_cat/nodes?v
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
172.20.3.20 4 57 0 0.04 0.03 0.05 d - data-01
172.20.3.18 4 60 0 0.05 0.03 0.05 mi - master-02
172.20.3.24 5 57 0 0.00 0.01 0.05 d - data-05
172.20.3.19 9 38 0 0.02 0.02 0.05 mi - master-03
172.20.3.21 4 57 0 0.00 0.02 0.05 d - data-02
172.20.3.23 5 57 0 0.00 0.01 0.05 d - data-04
172.20.3.22 3 57 0 0.00 0.01 0.05 d - data-03
172.20.3.17 4 68 0 0.00 0.01 0.05 mi * master-01

查看nodes状态 curl http://172.20.3.20:9200/_nodes/stats?pretty 查看集群健康状态 curl http://172.20.3.20:9200/_cluster/health?pretty
curl http://172.20.3.20:9200/_cluster/health?level=indices
curl http://172.20.3.20:9200/_cluster/health?level=shards
查找索引 curl http://172.20.3.20:9200/_cat/indices?bytes=b | sort -rnk8 |grep -V marvel
查看设置 curl http://172.20.3.20:9200/_cluster/settings?pretty

以上是关于Centos7.4部署配置Elasticsearch5.6集群的主要内容,如果未能解决你的问题,请参考以下文章

基于Centos7.4安装部署大数据基础软件环境

centos7.4安装部署jumpserver(数据库外置)配置全过程--无问题

阿里服务器+Centos7.4+Tomcat+JDK部署

cobbler一键部署centos7.4(脚本)

Centos7.4 安装elasticsearch6.1.3集群部署

Centos7.4下部署PowerDNS的操作记录