上一篇测试过/etc/init.d的开机自启动,这一篇再试下另外一种方式
一、查看是否已经存在kibana的服务文件
[root@qf01 ~]# ls /usr/lib/systemd/system/kib*
二、并没有发现有,那么新增文件
[root@qf01 ~]# vi /usr/lib/systemd/system/kibana.service
输入如下内容:
[Unit]
Description=kibana
After=network.target[Service]
Type=simple
User=es1
ExecStart=/usr/local/kibana/bin/kibana
PrivateTmp=true[Install]
WantedBy=multi-user.target
注意红色部分的用户名和地址,改成你自己的,然后保存
三、设置开机启动
#返回Created...就算是成功了
[root@qf01 ~]# systemctl enable kibana.service
Created symlink from /etc/systemd/system/multi-user.target.wants/kibana.service to /usr/lib/systemd/system/kibana.service
四、各种命令,通用
# 启动服务
[root@qf01 ~]# systemctl start kibana.service
# 停止服务
[root@qf01 ~]# systemctl stop kibana.service
# 重启服务
[root@qf01 ~]# systemctl restart kibana.service
# 禁止开机启动
[root@qf01 ~]# systemctl disable kibana.service
通过http//ip:5601查看,是否启动,可以通过重启电脑,验证是否设置成功。