ElasticSearch7.9.3版本在启动报错

首先问题:

[root@VM125 ELK]# systemctl restart elasticsearch
[root@VM125 ELK]# systemctl status elasticsearch 
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: https://www.elastic.co

May 20 10:40:06 VM125 systemd[1]: elasticsearch.service failed.
May 20 10:43:38 VM125 systemd[1]: Starting Elasticsearch...
May 20 10:45:08 VM125 systemd[1]: elasticsearch.service start operation timed out. Terminating.
May 20 10:45:08 VM125 systemd[1]: Failed to start Elasticsearch.
May 20 10:45:08 VM125 systemd[1]: Unit elasticsearch.service entered failed state.
May 20 10:45:08 VM125 systemd[1]: elasticsearch.service failed.

搜索了几个文章,发现改elasticsearch的systemctl配置文件的较多

两个流派:

1.修改启动脚本

vim /usr/lib/systemd/system/elasticsearch.service
# 找到ExecStart开头的行
将
ExecStart=/usr/share/elasticsearch/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet
修改为
ExecStart=/bin/bash -c "/usr/share/elasticsearch/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet &"

2.设置超时时间

vim /usr/lib/systemd/system/elasticsearch.service
# Java process is never killed
SendSIGKILL=no

# When a JVM receives a SIGTERM signal it exits with code 143
SuccessExitStatus=143
TimeoutStartSec=120 #在这添加一个超时间 设置长一点,我这边设置了两分钟
[Install]
WantedBy=multi-user.target

# Built for packages-7.9.3 (packages)

结果

第一个方法尝试后服务起来了,但是端口都没有启用,log中也有报错。
第二个方法就都起来了:

[root@VM125 ELK]# systemctl daemon-reload        
[root@VM125 ELK]# systemctl restart elasticsearch                  
[root@VM125 ELK]# systemctl status elasticsearch 
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2021-05-20 10:57:42 CST; 56s ago
     Docs: https://www.elastic.co
 Main PID: 24469 (java)
    Tasks: 58
   Memory: 1.2G
   CGroup: /system.slice/elasticsearch.service
           ├─24469 /usr/share/elasticsearch/jdk/bin/java -Xshare:auto -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:-OmitStackTra...
           └─24637 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller

May 20 10:55:59 VM125 systemd[1]: Starting Elasticsearch...
May 20 10:57:42 VM125 systemd[1]: Started Elasticsearch.
[root@VM125 ELK]# 
[root@VM125 ELK]# 
[root@VM125 ELK]# netstat -anp |grep 9200
tcp6       0      0 :::9200                 :::*                    LISTEN      24469/java          
[root@VM125 ELK]# netstat -anp |grep 9300
tcp6       0      0 :::9300                 :::*                    LISTEN      24469/java          
[root@VM125 ELK]# 

你可能感兴趣的:(ElasticSearch7.9.3版本在启动报错)