Failed to execute operation: Invalid argument

Centos7.5 封装process-exporter.service时失败
在另外一台服务器Centos7.6 封装成功,严重怀疑是BUG
以下是解决过程:

# vim /usr/lib/systemd/system/process-exporter.service
[Unit]
Description=Process-exporter
After=network.target

[Service]
ExecStart=/opt/stc/applocation/process-exporter/process-exporter \
    -config.path /opt/stc/applocation/process-exporter/process-name.yaml
User=product

[Install]
WantedBy=multi-user.targe
# systemctl daemon-reload
# systemctl start process-exporter
# systemctl enable process-exporter
Failed to execute operation: Invalid argument

解决:
#1、google说在你的[Install]指定的want目录已经存在了同名文件,删除即可
#2、还有就是如果你的service文件做了别名,可能别名冲突,更改即可
#3、做软连接

ln -s /usr/lib/systemd/system/process-exporter.service /etc/systemd/system/multi-user.target.wants/process-exporter.service

lrwxrwxrwx  1 root root 41 Jul 18 09:30 node-exporter.service -> /etc/systemd/system/node-exporter.service
lrwxrwxrwx. 1 root root 36 Jul 14 01:26 ntpd.service -> /usr/lib/systemd/system/ntpd.service
lrwxrwxrwx. 1 root root 39 Jul 14 00:57 postfix.service -> /usr/lib/systemd/system/postfix.service
lrwxrwxrwx  1 root root 48 Jul 21 18:09 process-exporter.service -> /usr/lib/systemd/system/process-exporter.service

验证开机自启

# systemctl stop process-exporter.service

#请勿复制下面这条命令,业务故障概不负责

reboot

#验证结果

# systemctl status process-exporter.service 
● process-exporter.service - Process-exporter
   Loaded: loaded (/usr/lib/systemd/system/process-exporter.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2020-07-21 18:11:36 CST; 31s ago

你可能感兴趣的:(linux技术分享)