创建系统服务的路径是
/usr/lib/systemd/system/elasticsearch.service
这个是绝对路径,而不是用相对路径/etc/systemd/system/
cp /run/systemd/generator.late/elasticsearch.service /usr/lib/systemd/system/elasticsearch.service
groupadd elasticsearch
chown -R elasticsearch:elasticsearch /opt/server/elasticsearch/elasticsearch-8.2.0
chown -R elasticsearch:elasticsearch /server-log/elasticsearch/
systemctl stop elasticsearch
systemctl enable elasticsearch
会在 /etc/systemd/system/multi-user.target.wants 创建/usr/lib/systemd/system/elasticsearch.service的链接
# linux 在启动时会启动multi-user.target的服务,这就实现了开机自启的功能
ln -s /usr/lib/systemd/system/elasticsearch.service /etc/systemd/system/multi-user.target.wants/elasticsearch.service
阅读(887) | 评论(0) | 转发(0) |