问题现象:
elasticsearch启动失败
启动成功变成running后立马变成failed
查看log
[root@db03 /data]$ systemctl status elasticsearch.service -l
● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/elasticsearch.service.d
└─override.conf
Active: failed (Result: signal) since Sat 2020-04-18 17:20:49 CST; 6min ago
Docs: http://www.elastic.co
Process: 23456 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet (code=killed, signal=KILL)
Main PID: 23456 (code=killed, signal=KILL)
Apr 18 17:20:23 db03 systemd[1]: Started Elasticsearch.
Apr 18 17:20:24 db03 elasticsearch[23456]: OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
Apr 18 17:20:49 db03 systemd[1]: elasticsearch.service: main process exited, code=killed, status=9/KILL
Apr 18 17:20:49 db03 systemd[1]: Unit elasticsearch.service entered failed state.
Apr 18 17:20:49 db03 systemd[1]: elasticsearch.service failed.
[root@db03 /data]$
分析:
看到GC的错误,判断应该是内存问题
free看了服务器的内存本身只有1个G
查看了elasticsearch的内存设定
vim /etc/elasticsearch/jvm.options
当前设置的是需要占用1个g
-Xms1g
-Xmx1g
解决方案:
修改elasticsearch占用的的内存参数
vim /etc/elasticsearch/jvm.options
-Xms512m
-Xmx512m
修改完后重启服务
systemctl restart elasticsearch.service
systemctl status elasticsearch.service
测试成功!
[root@db03 /data]$ systemctl status elasticsearch.service
● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/elasticsearch.service.d
└─override.conf
Active: active (running) since Sat 2020-04-18 17:44:13 CST; 9min ago
Docs: http://www.elastic.co
Main PID: 23590 (java)
CGroup: /system.slice/elasticsearch.service
├─23590 /bin/java -Xms512m -Xmx512m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Des.networkaddress.cache.ttl=60 -Des.networkaddres...
└─23645 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller
Apr 18 17:44:13 db03 systemd[1]: Started Elasticsearch.
Apr 18 17:44:16 db03 elasticsearch[23590]: OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of par...elGCThreads=N
Hint: Some lines were ellipsized, use -l to show in full.
[root@db03 /data]$ curl localhost:9200
{
"name" : "node-3",
"cluster_name" : "linux",
"cluster_uuid" : "gG8lF9pMQxi8EtIyX0pB0A",
"version" : {
"number" : "6.6.0",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "a9861f4",
"build_date" : "2019-01-24T11:27:09.439740Z",
"build_snapshot" : false,
"lucene_version" : "7.6.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}