1、编辑一个sevice文件
vim /usr/lib/systemd/system/elasticsearch.service
2、设置相关的用户和路径
# StandardOutput is configured to redirect to journalctl since # some error messages may be logged in standard output before # elasticsearch logging system is initialized. Elasticsearch # stores its logs in /var/log/elasticsearch and does not use # journalctl by default. If you also want to enable journalctl # logging, you can simply remove the "quiet" option from ExecStart. [Unit] Description=elasticsearch After=network.target [Service] Type=simple User=elasticsearch Group=elasticsearch LimitNOFILE=100000 LimitNPROC=100000 Restart=no ExecStart=/opt/elasticsearch-7.12.0/bin/elasticsearch PrivateTmp=true [Install] WantedBy=multi-user.target
3、开启相关的服务
systemctl status elasticsearch systemctl start elasticsearch