将需要手动启动的服务,添加至systemctl管理中进行服务的统一管理,可以配置开机自动启动。
将prometheus加入到system
[root@localhost system]# cat prometheus.service[Unit]Description=Promethues Watch App[Service]Restart=on-failureExecStart=/home/watch/prometheus/prometheus --config.file=/home/watch/prometheus/prometheus.yml[Install]WantedBy=multi-user.target#添加至开机启动[root@localhost system]# systemctl enable prometheus.serviceCreated symlink from /etc/systemd/system/multi-user.target.wants/prometheus.service to /usr/lib/systemd/system/prometheus.service.#会将/usr/lib/systemd/system下的对应service文件软连接到/etc/systemd/system/multi-user.target下#multi-user.target.wants是字符界面默认启动的服务集合
将alertmanager加入到system
[root@localhost system]# systemctl status alertmanager.service● alertmanager.service - Alertmanager serverLoaded: loaded (/usr/lib/systemd/system/alertmanager.service; disabled; vendor preset: disabled)Active: inactive (dead)[root@localhost system]# systemctl enable alertmanager.serviceCreated symlink from /etc/systemd/system/multi-user.target.wants/alertmanager.service to /usr/lib/systemd/system/alertmanager.service.[root@localhost system]# cat alertmanager.service[Unit]Description=Alertmanager server[Service]ExecStart=/home/watch/alertmanager/alertmanager --config.file=/home/watch/alertmanager/alertmanager.yml --storage.path=/home/watch/alertmanager/dataRestart=on-failure[Install]WantedBy=multi-user.target[root@localhost system]# systemctl status alertmanager.service● alertmanager.service - Alertmanager serverLoaded: loaded (/usr/lib/systemd/system/alertmanager.service; enabled; vendor preset: disabled)Active: active (running) since 二 2021-03-30 10:54:51 CST; 7s agoMain PID: 8373 (alertmanager)Tasks: 12Memory: 8.8MCGroup: /system.slice/alertmanager.service└─8373 /home/watch/alertmanager/alertmanager --config.file=/home/watch/alertmanager...3月 30 10:54:51 localhost.localdomain systemd[1]: Started Alertmanager server.3月 30 10:54:51 localhost.localdomain alertmanager[8373]: level=info ts=2021-03-30T02:54:51...."3月 30 10:54:51 localhost.localdomain alertmanager[8373]: level=info ts=2021-03-30T02:54:51...."3月 30 10:54:51 localhost.localdomain alertmanager[8373]: level=info ts=2021-03-30T02:54:51....43月 30 10:54:51 localhost.localdomain alertmanager[8373]: level=info ts=2021-03-30T02:54:51....s3月 30 10:54:51 localhost.localdomain alertmanager[8373]: level=info ts=2021-03-30T02:54:51....l3月 30 10:54:51 localhost.localdomain alertmanager[8373]: level=info ts=2021-03-30T02:54:51....l3月 30 10:54:51 localhost.localdomain alertmanager[8373]: level=info ts=2021-03-30T02:54:51....r3月 30 10:54:51 localhost.localdomain alertmanager[8373]: level=info ts=2021-03-30T02:54:51....33月 30 10:54:53 localhost.localdomain alertmanager[8373]: level=info ts=2021-03-30T02:54:53....sHint: Some lines were ellipsized, use -l to show in full.
