Ubuntu环境部署分布式ElasticSearch集群

        Ubuntu环境部署分布式ElasticSearch集群

                                 作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

一.实验环境说明

1>.测试集群规模说明

  搭建ElasticSearch集群最少得有2台服务器,我这里使用3台测试机,其主机名如下所示:
    es101.yinzhengjie.org.cn
    es102.yinzhengjie.org.cn
    es103.yinzhengjie.org.cn

  操作环境使用Ubuntu 18.04发行版本,每台节点自行部署JDK和Elasticsearch服务。
[root@es101.yinzhengjie.com ~]# grep yinzhengjie.com /etc/hosts
172.200.5.101 es101.yinzhengjie.com
172.200.5.102 es102.yinzhengjie.com
172.200.5.103 es103.yinzhengjie.com
[root@es101.yinzhengjie.com ~]# 
[root@es101.yinzhengjie.com ~]# grep yinzhengjie.com /etc/hosts

2>.所有节点部署Elaticsearch服务

  博主推荐阅读:
    https://www.cnblogs.com/yinzhengjie2020/p/12940337.html

二.部署分布式ElasticSearch集群

1>.修改es101.yinzhengjie.org.cn的配置文件

[root@es101.yinzhengjie.com ~]# vim /etc/elasticsearch/elasticsearch.yml
[root@es101.yinzhengjie.com ~]# 
[root@es101.yinzhengjie.com ~]# egrep -v "^#|^$" /etc/elasticsearch/elasticsearch.yml
cluster.name: yinzhengjie-es                                    #指定集群名称
node.name: es101.yinzhengjie.com                                  #指定节点名称,通常设置为当前主机名即可
path.data: /yinzhengjie/data/elasticsearch/data                         #指定ES的数据存储目录,生产环境建议单独使用一块磁盘存储,或者使用磁盘阵列存储均可。
path.logs: /yinzhengjie/data/elasticsearch/log                          #指定日志存储路径
network.host: 172.200.5.101                                     #建议大家直接写当前的IP地址,如果有多个地址也可以使用"0.0.0.0",可以指定为当前的主机名,但是会设计到“/etc/hosts"找对应的解析地址.
discovery.zen.ping.unicast.hosts: ["172.200.5.101", "172.200.5.102","172.200.5.103"]   #设置单播地址,建议集群有多少个节点就写多少个地址
[root@es101.yinzhengjie.com ~]# 
[root@es102.yinzhengjie.com ~]# egrep -v "^#|^$" /etc/elasticsearch/elasticsearch.yml
cluster.name: yinzhengjie-es
node.name: es102.yinzhengjie.com
path.data: /yinzhengjie/data/elasticsearch/data
path.logs: /yinzhengjie/data/elasticsearch/log
network.host: 172.200.5.102
discovery.zen.ping.unicast.hosts: ["172.200.5.101", "172.200.5.102","172.200.5.103"]
[root@es102.yinzhengjie.com ~]# 
[root@es102.yinzhengjie.com ~]# egrep -v "^#|^$" /etc/elasticsearch/elasticsearch.yml
[root@es103.yinzhengjie.com ~]# egrep -v "^#|^$" /etc/elasticsearch/elasticsearch.yml
cluster.name: yinzhengjie-es
node.name: es103.yinzhengjie.com
path.data: /yinzhengjie/data/elasticsearch/data
path.logs: /yinzhengjie/data/elasticsearch/log
network.host: 172.200.5.103
discovery.zen.ping.unicast.hosts: ["172.200.5.101", "172.200.5.102","172.200.5.103"]
[root@es103.yinzhengjie.com ~]# 
[root@es103.yinzhengjie.com ~]# egrep -v "^#|^$" /etc/elasticsearch/elasticsearch.yml

2>.修改es102.yinzhengjie.org.cn的配置文件

[root@es102.yinzhengjie.com ~]# egrep -v "^#|^$" /etc/elasticsearch/elasticsearch.yml
cluster.name: yinzhengjie-es
node.name: es102.yinzhengjie.com
path.data: /yinzhengjie/data/elasticsearch/data
path.logs: /yinzhengjie/data/elasticsearch/log
network.host: 172.200.5.102
discovery.zen.ping.unicast.hosts: ["172.200.5.101", "172.200.5.102","172.200.5.103"]
[root@es102.yinzhengjie.com ~]# 
[root@es102.yinzhengjie.com ~]# egrep -v "^#|^$" /etc/elasticsearch/elasticsearch.yml

3>.修改es103.yinzhengjie.org.cn的配置文件

[root@es103.yinzhengjie.com ~]# egrep -v "^#|^$" /etc/elasticsearch/elasticsearch.yml
cluster.name: yinzhengjie-es
node.name: es103.yinzhengjie.com
path.data: /yinzhengjie/data/elasticsearch/data
path.logs: /yinzhengjie/data/elasticsearch/log
network.host: 172.200.5.103
discovery.zen.ping.unicast.hosts: ["172.200.5.101", "172.200.5.102","172.200.5.103"]
[root@es103.yinzhengjie.com ~]# 
[root@es103.yinzhengjie.com ~]# egrep -v "^#|^$" /etc/elasticsearch/elasticsearch.yml

4>.各节点创建elasticsearch的数据目录并修改授权

[root@es101.yinzhengjie.com ~]# mkdir -pv /yinzhengjie/data/elasticsearch/{data,log}
mkdir: created directory '/yinzhengjie/data'
mkdir: created directory '/yinzhengjie/data/elasticsearch'
mkdir: created directory '/yinzhengjie/data/elasticsearch/data'
mkdir: created directory '/yinzhengjie/data/elasticsearch/log'
[root@es101.yinzhengjie.com ~]# 
[root@es101.yinzhengjie.com ~]# ll /yinzhengjie/data/elasticsearch/
total 0
drwxr-xr-x 4 root root 29 Jun  3 02:44 ./
drwxr-xr-x 3 root root 27 Jun  3 02:44 ../
drwxr-xr-x 2 root root  6 Jun  3 02:44 data/
drwxr-xr-x 2 root root  6 Jun  3 02:44 log/
[root@es101.yinzhengjie.com ~]# 
[root@es101.yinzhengjie.com ~]# 
[root@es101.yinzhengjie.com ~]# mkdir -pv /yinzhengjie/data/elasticsearch/{data,log}
[root@es101.yinzhengjie.com ~]# ll /yinzhengjie/data/elasticsearch/
total 0
drwxr-xr-x 4 root root 29 Jun  3 02:44 ./
drwxr-xr-x 3 root root 27 Jun  3 02:44 ../
drwxr-xr-x 2 root root  6 Jun  3 02:44 data/
drwxr-xr-x 2 root root  6 Jun  3 02:44 log/
[root@es101.yinzhengjie.com ~]# 
[root@es101.yinzhengjie.com ~]# chown -R elasticsearch:elasticsearch /yinzhengjie/data/elasticsearch/
[root@es101.yinzhengjie.com ~]# 
[root@es101.yinzhengjie.com ~]# ll /yinzhengjie/data/elasticsearch/
total 0
drwxr-xr-x 4 elasticsearch elasticsearch 29 Jun  3 02:44 ./
drwxr-xr-x 3 root          root          27 Jun  3 02:44 ../
drwxr-xr-x 2 elasticsearch elasticsearch  6 Jun  3 02:44 data/
drwxr-xr-x 2 elasticsearch elasticsearch  6 Jun  3 02:44 log/
[root@es101.yinzhengjie.com ~]# 
[root@es101.yinzhengjie.com ~]# 
[root@es101.yinzhengjie.com ~]# chown -R elasticsearch:elasticsearch /yinzhengjie/data/elasticsearch/

5>.各节点启动Elasticsearch服务(第一次启动会很慢,因为要初始化目录信息,请耐心等待)

[root@es101.yinzhengjie.com ~]# ss -ntl
State                   Recv-Q                    Send-Q                                        Local Address:Port                                       Peer Address:Port                   
LISTEN                  0                         128                                           127.0.0.53%lo:53                                              0.0.0.0:*                      
LISTEN                  0                         128                                                 0.0.0.0:22                                              0.0.0.0:*                      
LISTEN                  0                         128                                                    [::]:22                                                 [::]:*                      
[root@es101.yinzhengjie.com ~]# 
[root@es101.yinzhengjie.com ~]# systemctl start elasticsearch 
[root@es101.yinzhengjie.com ~]# 
[root@es101.yinzhengjie.com ~]# ss -ntl
State                  Recv-Q                  Send-Q                                              Local Address:Port                                     Peer Address:Port                  
LISTEN                 0                       128                                                 127.0.0.53%lo:53                                            0.0.0.0:*                     
LISTEN                 0                       128                                                       0.0.0.0:22                                            0.0.0.0:*                     
LISTEN                 0                       128                                        [::ffff:172.200.5.101]:9200                                                *:*                     
LISTEN                 0                       128                                        [::ffff:172.200.5.101]:9300                                                *:*                     
LISTEN                 0                       128                                                          [::]:22                                               [::]:*                     
[root@es101.yinzhengjie.com ~]# 
[root@es101.yinzhengjie.com ~]# systemctl start elasticsearch
[root@es101.yinzhengjie.com ~]# systemctl enable elasticsearch
Synchronizing state of elasticsearch.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable elasticsearch
Created symlink /etc/systemd/system/multi-user.target.wants/elasticsearch.service → /usr/lib/systemd/system/elasticsearch.service.
[root@es101.yinzhengjie.com ~]# 
[root@es101.yinzhengjie.com ~]# systemctl enable elasticsearch        #设置开机自启动
[root@es101.yinzhengjie.com ~]# systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2020-06-03 02:54:12 UTC; 4min 4s ago
     Docs: http://www.elastic.co
 Main PID: 2457 (java)
    Tasks: 41 (limit: 4633)
   CGroup: /system.slice/elasticsearch.service
           ├─2457 /usr/local/bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Des.networkaddress.cache.ttl=60 -Des.ne
           └─2540 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller

Jun 03 02:54:12 es101.yinzhengjie.com systemd[1]: Started Elasticsearch.
Jun 03 02:54:12 es101.yinzhengjie.com elasticsearch[2457]: warning: Falling back to java on path. This behavior is deprecated. Specify JAVA_HOME
[root@es101.yinzhengjie.com ~]# 
[root@es101.yinzhengjie.com ~]# systemctl status elasticsearch

6>.使用Restful API查看ES集群的工作状态

  查看ES可以查看的方法:
    http://es101.yinzhengjie.com:9200/_cat

  查看各个node节点信息,不显示头部信息:     http://es101.yinzhengjie.com:9200/_cat/nodes
  查看各个node节点信息,显示头部信息:     http://es101.yinzhengjie.com:9200/_cat/nodes?v
  显示主节点信息,显示头部信息:     http://es101.yinzhengjie.com:9200/_cat/master?v
  查看集群的节点状态:     http://es101.yinzhengjie.com:9200/_cat/health?v

三.配置Elasticsearch的内存

1>.修改Elasticsearch服务的堆内存

[root@es103.yinzhengjie.com ~]# egrep -v "^#|^$" /etc/elasticsearch/jvm.options  | head -2
-Xms1g
-Xmx1g
[root@es103.yinzhengjie.com ~]# 
[root@es103.yinzhengjie.com ~]# vim /etc/elasticsearch/jvm.options
[root@es103.yinzhengjie.com ~]# 
[root@es103.yinzhengjie.com ~]# egrep -v "^#|^$" /etc/elasticsearch/jvm.options  | head -2        #修改堆内存大小,生产环境中官方建议不要超过物理内存的一半,比如32G内存则最少分配16G给ES服务。最大不建议超过32G。
-Xms2g
-Xmx2g
[root@es103.yinzhengjie.com ~]# 

2>.修改elaticsearch的配置文件

[root@es103.yinzhengjie.com ~]# egrep -v "^#|^$" /etc/elasticsearch/jvm.options  | head -2
-Xms2g
-Xmx2g
[root@es103.yinzhengjie.com ~]# 
[root@es103.yinzhengjie.com ~]# vim /etc/elasticsearch/jvm.options  
[root@es103.yinzhengjie.com ~]# 
[root@es103.yinzhengjie.com ~]# egrep -v "^#|^$" /etc/elasticsearch/jvm.options  | head -2
-Xms2g
-Xmx2g
[root@es103.yinzhengjie.com ~]# 
[root@es103.yinzhengjie.com ~]# vim /etc/elasticsearch/jvm.options
[root@es103.yinzhengjie.com ~]# grep bootstrap.memory_lock /etc/elasticsearch/elasticsearch.yml 
# bootstrap.memory_lock: true
[root@es103.yinzhengjie.com ~]# 
[root@es103.yinzhengjie.com ~]# sed -r -i s'@# (bootstrap.memory_lock: true)@1@' /etc/elasticsearch/elasticsearch.yml 
[root@es103.yinzhengjie.com ~]# 
[root@es103.yinzhengjie.com ~]# grep bootstrap.memory_lock /etc/elasticsearch/elasticsearch.yml 
bootstrap.memory_lock: true            #该参数的含义就是将上一步分配的物理内存进行立即分配操作。
[root@es103.yinzhengjie.com ~]# 
[root@es103.yinzhengjie.com ~]# ps -ef | grep elasticsearch
elastic+  15707      1  1 03:06 ?        00:00:33 /usr/local/bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Des.net
workaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.io.tmpdir=/tmp/elasticsearch-2284876680273723069 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/lib/elasticsearch -XX:ErrorFile=/var/log/elasticsearch/hs_err_pid%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:/var/log/elasticsearch/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=32 -XX:GCLogFileSize=64m -Des.path.home=/usr/share/elasticsearch -Des.path.conf=/etc/elasticsearch -Des.distribution.flavor=default -Des.distribution.type=deb -cp /usr/share/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch -p /var/run/elasticsearch/elasticsearch.pid --quietelastic+  15788  15707  0 03:06 ?        00:00:00 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller
root      15922  14035  0 03:39 pts/1    00:00:00 grep --color=auto elasticsearch
[root@es103.yinzhengjie.com ~]# 
[root@es103.yinzhengjie.com ~]# 
[root@es103.yinzhengjie.com ~]# systemctl restart elasticsearch            #重启Elasticsearch服务使得配置生效
[root@es103.yinzhengjie.com ~]# 
[root@es103.yinzhengjie.com ~]# ps -ef | grep elasticsearch
elastic+  15936      1 99 03:39 ?        00:00:01 /usr/local/bin/java -Xms2g -Xmx2g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Des.net
workaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.io.tmpdir=/tmp/elasticsearch-7570972222642325228 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/lib/elasticsearch -XX:ErrorFile=/var/log/elasticsearch/hs_err_pid%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:/var/log/elasticsearch/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=32 -XX:GCLogFileSize=64m -Des.path.home=/usr/share/elasticsearch -Des.path.conf=/etc/elasticsearch -Des.distribution.flavor=default -Des.distribution.type=deb -cp /usr/share/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch -p /var/run/elasticsearch/elasticsearch.pid --quietroot      16006  14035  0 03:39 pts/1    00:00:00 grep --color=auto elasticsearch
[root@es103.yinzhengjie.com ~]# 
[root@es103.yinzhengjie.com ~]# systemctl restart elasticsearch            #重启Elasticsearch服务使得配置生效
[root@es103.yinzhengjie.com ~]# tail  -100f /yinzhengjie/data/elasticsearch/log/yinzhengjie-es.log 
[2020-06-04T00:32:55,293][WARN ][o.e.b.JNANatives         ] [es103.yinzhengjie.com] Unable to lock JVM Memory: error=12, reason=Cannot allocate memory
[2020-06-04T00:32:55,295][WARN ][o.e.b.JNANatives         ] [es103.yinzhengjie.com] This can result in part of the JVM being swapped out.
[2020-06-04T00:32:55,295][WARN ][o.e.b.JNANatives         ] [es103.yinzhengjie.com] Increase RLIMIT_MEMLOCK, soft limit: 16777216, hard limit: 16777216
[2020-06-04T00:32:55,295][WARN ][o.e.b.JNANatives         ] [es103.yinzhengjie.com] These can be adjusted by modifying /etc/security/limits.conf, for example: 
    # allow user 'elasticsearch' mlockall
    elasticsearch soft memlock unlimited
    elasticsearch hard memlock unlimited
[2020-06-04T00:32:55,295][WARN ][o.e.b.JNANatives         ] [es103.yinzhengjie.com] If you are logged in interactively, you will have to re-login for the new limits to take effect.
[2020-06-04T00:32:55,482][INFO ][o.e.e.NodeEnvironment    ] [es103.yinzhengjie.com] using [1] data paths, mounts [[/yinzhengjie (/dev/sda4)]], net usable_space [1.5tb], net total_space [1.5
tb], types [xfs][2020-06-04T00:32:55,482][INFO ][o.e.e.NodeEnvironment    ] [es103.yinzhengjie.com] heap size [1.9gb], compressed ordinary object pointers [true]
[2020-06-04T00:32:55,483][INFO ][o.e.n.Node               ] [es103.yinzhengjie.com] node name [es103.yinzhengjie.com], node ID [bTJW-ix4TfypEdVRyRGMRA]
[2020-06-04T00:32:55,484][INFO ][o.e.n.Node               ] [es103.yinzhengjie.com] version[6.8.9], pid[82531], build[default/deb/be2c7bf/2020-05-04T17:00:34.323820Z], OS[Linux/4.15.0-55-ge
neric/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_201/25.201-b09][2020-06-04T00:32:55,488][INFO ][o.e.n.Node               ] [es103.yinzhengjie.com] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCM
SInitiatingOccupancyOnly, -Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/tmp/elasticsearch-1719552526065582110, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=/var/lib/elasticsearch, -XX:ErrorFile=/var/log/elasticsearch/hs_err_pid%p.log, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:/var/log/elasticsearch/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Des.path.home=/usr/share/elasticsearch, -Des.path.conf=/etc/elasticsearch, -Des.distribution.flavor=default, -Des.distribution.type=deb][2020-06-04T00:32:57,060][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [aggs-matrix-stats]
[2020-06-04T00:32:57,060][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [analysis-common]
[2020-06-04T00:32:57,060][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [ingest-common]
[2020-06-04T00:32:57,060][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [ingest-geoip]
[2020-06-04T00:32:57,061][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [ingest-user-agent]
[2020-06-04T00:32:57,061][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [lang-expression]
[2020-06-04T00:32:57,061][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [lang-mustache]
[2020-06-04T00:32:57,061][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [lang-painless]
[2020-06-04T00:32:57,062][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [mapper-extras]
[2020-06-04T00:32:57,062][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [parent-join]
[2020-06-04T00:32:57,062][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [percolator]
[2020-06-04T00:32:57,063][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [rank-eval]
[2020-06-04T00:32:57,063][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [reindex]
[2020-06-04T00:32:57,063][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [repository-url]
[2020-06-04T00:32:57,064][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [transport-netty4]
[2020-06-04T00:32:57,064][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [tribe]
[2020-06-04T00:32:57,064][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [x-pack-ccr]
[2020-06-04T00:32:57,064][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [x-pack-core]
[2020-06-04T00:32:57,064][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [x-pack-deprecation]
[2020-06-04T00:32:57,065][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [x-pack-graph]
[2020-06-04T00:32:57,065][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [x-pack-ilm]
[2020-06-04T00:32:57,065][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [x-pack-logstash]
[2020-06-04T00:32:57,065][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [x-pack-ml]
[2020-06-04T00:32:57,066][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [x-pack-monitoring]
[2020-06-04T00:32:57,066][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [x-pack-rollup]
[2020-06-04T00:32:57,066][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [x-pack-security]
[2020-06-04T00:32:57,067][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [x-pack-sql]
[2020-06-04T00:32:57,067][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [x-pack-upgrade]
[2020-06-04T00:32:57,067][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] loaded module [x-pack-watcher]
[2020-06-04T00:32:57,068][INFO ][o.e.p.PluginsService     ] [es103.yinzhengjie.com] no plugins loaded
[2020-06-04T00:32:59,953][INFO ][o.e.x.s.a.s.FileRolesStore] [es103.yinzhengjie.com] parsed [0] roles from file [/etc/elasticsearch/roles.yml]
[2020-06-04T00:33:00,412][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [es103.yinzhengjie.com] [controller/82608] [Main.cc@109] controller (64 bit): Version 6.8.9 (Build 9e6927f4414d87) Copyrig
ht (c) 2020 Elasticsearch BV[2020-06-04T00:33:00,881][DEBUG][o.e.a.ActionModule       ] [es103.yinzhengjie.com] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
[2020-06-04T00:33:01,073][INFO ][o.e.d.DiscoveryModule    ] [es103.yinzhengjie.com] using discovery type [zen] and host providers [settings]
[2020-06-04T00:33:01,748][INFO ][o.e.n.Node               ] [es103.yinzhengjie.com] initialized
[2020-06-04T00:33:01,749][INFO ][o.e.n.Node               ] [es103.yinzhengjie.com] starting ...
[2020-06-04T00:33:01,877][INFO ][o.e.t.TransportService   ] [es103.yinzhengjie.com] publish_address {172.200.5.103:9300}, bound_addresses {172.200.5.103:9300}
[2020-06-04T00:33:01,892][INFO ][o.e.b.BootstrapChecks    ] [es103.yinzhengjie.com] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2020-06-04T00:33:01,919][ERROR][o.e.b.Bootstrap          ] [es103.yinzhengjie.com] node validation exception
[1] bootstrap checks failed
[1]: memory locking requested for elasticsearch process but memory is not locked
[2020-06-04T00:33:01,920][INFO ][o.e.n.Node               ] [es103.yinzhengjie.com] stopping ...
[2020-06-04T00:33:02,056][INFO ][o.e.n.Node               ] [es103.yinzhengjie.com] stopped
[2020-06-04T00:33:02,056][INFO ][o.e.n.Node               ] [es103.yinzhengjie.com] closing ...
[2020-06-04T00:33:02,081][INFO ][o.e.n.Node               ] [es103.yinzhengjie.com] closed
^C
[root@es103.yinzhengjie.com ~]# 
[root@es103.yinzhengjie.com ~]# tail -100f /yinzhengjie/data/elasticsearch/log/yinzhengjie-es.log        #重启后服务启动失败,错误原因在日志里已经爆出来啦~(解决方案参考下一步)

3>.内存锁不起作用(memory locking requested for elasticsearch process but memory is not locked)解决方案

  在Elasticsearch版本低于5.1.x,需要修改启动脚本。需要i修改如下的配置文件:
      /etc/elasticsearch/elasticsearch.yml
        bootstrap.memory_lock: true

      /usr/lib/systemd/system/elasticsearch.service
      [Service]    #在该标签内添加下面一行
        LimitMEMLOCK=infinity

      /etc/sysconfig/elasticsearch(Ubuntu系统可忽略该文件,因为默认并不存在该文件,但需要修改下面的limits.conf文件哟~)
        MAX_LOCKED_MEMORY=unlimited

      /etc/security/limits.conf
      CentOS可以参考以下配置:
          * soft memlock unlimited
          * hard memlock unlimited
      Ubuntu可以参考以下配置(需要写具体的账号,不要使用"*"来代指所有用户,否则会不生效哟~):
        elasticsearch soft memlock unlimited
        elasticsearch hard memlock unlimited
 
  博主推荐阅读:
    https://discuss.elastic.co/t/memory-lock-not-working/70576
    https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
原文地址:https://www.cnblogs.com/yinzhengjie2020/p/12953504.html