elasticsearch: centos9用systemctl管理es

一,用systemctl管理es:

1,创建service配置文件:

[root@iZ2zejc9t0hf6pnw6sewrxZ config]# vi /lib/systemd/system/elasticsearch.service

service文件代码:

[root@blog config]# more /lib/systemd/system/elasticsearch.service
[Unit]
Description=ElasticSearch
Requires=NetworkManager.service
After=NetworkManager.service

[Service]
User=lhdop
Group=lhdop
LimitNOFILE=65536
LimitMEMLOCK=infinity
Environment=ES_JAVA_HOME=/usr/local/soft/jdk-17.0.11
ExecStart=/usr/local/soft/elasticsearch-8.14.2/bin/elasticsearch
ExecReload=/bin/kill -HUP $MAINPID
KillMode=mixed
SuccessExitStatus=143
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target

2,重新加载配置文件:

[root@blog config]# systemctl daemon-reload 

 

二,测试效果

1,启动

[root@blog config]# systemctl start elasticsearch.service  

2,停止

[root@blog config]# systemctl stop elasticsearch.service 

3,使能自启动:

查询是否自启动?

[root@blog ~]# systemctl is-enabled elasticsearch.service
disabled

 设置为自启动

[root@blog ~]# systemctl enable elasticsearch.service
Created symlink /etc/systemd/system/multi-user.target.wants/elasticsearch.service → 
/usr/lib/systemd/system/elasticsearch.service.

查看设置自启动是否成功:

[root@blog ~]# systemctl is-enabled elasticsearch.service
enabled

三,查看elasticsearch的版本:

[lhdop@blog ~]$ /usr/local/soft/elasticsearch-8.14.2/bin/elasticsearch --version
warning: ignoring JAVA_HOME=/usr/local/soft/jdk-17.0.11; using ES_JAVA_HOME
Version: 8.14.2, Build: tar/2afe7caceec8a26ff53817e5ed88235e90592a1b/2024-07-01T22:06:58.515911606Z, JVM: 17.0.11

 

posted @ 2024-07-11 17:33  刘宏缔的架构森林  阅读(90)  评论(0编辑  收藏  举报