创建elasticsearch.service文件
cd /usr/lib/systemd/system
sudo vi elasticsearch.service
[Unit]
Description=elasticsearch
After=network.target
[Service]
Type=simple
User=es
Group=es
LimitNOFILE=100000
LimitNPROC=100000
LimitMEMLOCK=infinity
Restart=on-failure
RestartSec=10s
ExecStart=/opt/es/elasticsearch-7.9.0/bin/elasticsearch
PrivateTmp=true
[Install]
WantedBy=multi-user.target
2 重新加载elasticseach.service,每次改完之后重新加载
sudo systemctl daemon-reload
4 开启elasticsearch服务
sudo systemctl enable elasticsearch.service
5 elasticsearch服务管理
#启动
sudo systemctl start elasticsearch.service
#停止
sudo systemctl stop elasticsearch.service
#重启
sudo systemctl restart elasticsearch.service
#查看状态
systemctl status elasticsearch.service
原文链接:https://blog.csdn.net/m0_37566009/article/details/121760811