Elasticsearch群集安装

运行环境

操作系统:Cent OS 7.0 64bit

Elasticsearch 5.1.1

jdk 1.8.0_112

需求说明

安装 ElasticSearch 群集,初始化配置

安装过程

安装 jdk 1.8

下载安装包

https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.1.1.tar.gz

内存设置

修改 ./config/jvm.options,官方建议文档

https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html

一般来说,-Xms 和 -Xmx 设置为相同的值,为服务器内存总量的一半。

因为内存寻址的性能原因,不要超过30GB。

运行配置

修改 ./config/elasticsearch.yml。

# 群集名
cluster.name: hb0-es

# 节点名
node.name: hb0-es1

# 节点属性,包括 master、data、ingest
node.master: false
node.data: true
node.ingest: false

# 数据存储路径
path.data: /storage/disk1/elasticsearch/data,/storage/disk2/elasticsearch/data

# 日志路径
path.logs: /work/admin/logs/elasticsearch

# 启动时锁定内存
bootstrap.memory_lock: true

# IP地址设置
network.host: 0.0.0.0

# 节点间发现,单播地址
discovery.zen.ping.unicast.hosts: ["hb0.es1.linglongtech.local", "hb0.es2.linglongtech.local","hb0.es3.linglongtech.local","hb0.es7.linglongtech.local","hb0.es8.linglongtech.local","hb0.es9.linglongtech.local","hb0.es10.linglongtech.local","hb0.es101.linglongtech.local","hb0.es102.linglongtech.local","hb0.es103.linglongtech.local","hb0.es201.linglongtech.local","hb0.es202.linglongtech.local","hb0.es203.linglongtech.local"]

# 选主节点,最小节点数,一般为(节点数/2 + 1)
discovery.zen.minimum_master_nodes: 7

# 节点间心跳
discovery.zen.fd.ping_interval: 120s
discovery.zen.fd.ping_timeout: 120s
discovery.zen.fd.ping_retries: 3

# 群集数据恢复
gateway.expected_nodes: 5
gateway.recover_after_nodes: 3
gateway.recover_after_time: 5m

# 删除索引时,需要提供准确名称
action.destructive_requires_name: true

系统配置

open files 数,修改 /etc/security/limits.conf,允许锁定内存。

admin soft nofile 1024000
admin hard nofile 1024000

admin soft memlock unlimited
admin hard memlock unlimited

vm.max_map_count 数,修改 /etc/sysctl.conf。

vm.max_map_count=300000

重启服务器或执行 sysctl -p 立即生效

服务设置