smsd服务错误,找不到LD_LIBRARY_PATH

分享于 

4分钟阅读

互联网

  繁體

问题:

我正在尝试安装Gammu 1.42以在Centos 8上提供我的SMS网关。

make,make test,make install工作正常。

LD_LIBRARY_PATH在/etc/profile中配置为:


......


LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:.:/usr/local/lib64


export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL LD_LIBRARY_PATH


......



我打印env by printenv,找到LD_LIBRARY_PATH,/etc/gammu-smsdrc配置为:


......


[gammu]


device = /dev/ttyUSB0


model = E3131


connection = at115200



[smsd]


service = sql


driver = native_pgsql


logFIle = /var/log/gammu/smsd.log


logFormat = errorsdate


Host = xx.0.1.xx:xxxx


user = xxxx


password = xxxxx


database = xxxxx


debuglevel = 2


StatusFrequency = 60


LoopSleep = 60


DeliveryReport = sms


PhoneID = ozssc-smsd


SMSC = +614xxxxxxxx


BackendRetries = 60



我尝试在终端中启动gammu命令行,它工作正常,但是,当我尝试使用systemctl启动系统服务时,失败。

错误查询结果为:


[root@Centos8Gateway etc]# systemctl status gammu-smsd.service


● gammu-smsd.service - SMS daemon for Gammu


 Loaded: loaded (/usr/lib/systemd/system/gammu-smsd.service; disabled; vendor preset: disabled)


 Active: failed (Result: exit-code) since Sun 2020-10-25 12:13:42 AEDT; 19s ago


 Docs: man:gammu-smsd(1)


 Process: 23247 ExecStopPost=/bin/rm -f /var/run/gammu-smsd.pid (code=exited, status=0/SUCCESS)


 Process: 23245 ExecStart=/usr/local/bin/gammu-smsd --pid=/var/run/gammu-smsd.pid --daemon (code=exited, status=127)



Oct 25 12:13:42 Centos8Gateway systemd[1]: Starting SMS daemon for Gammu...


Oct 25 12:13:42 Centos8Gateway gammu-smsd[23245]: /usr/local/bin/gammu-smsd: error while loading shared libraries: libgsmsd.so.8: cannot open shared object file: No such file or directory


Oct 25 12:13:42 Centos8Gateway systemd[1]: gammu-smsd.service: Control process exited, code=exited status=127


Oct 25 12:13:42 Centos8Gateway systemd[1]: gammu-smsd.service: Failed with result 'exit-code'.


Oct 25 12:13:42 Centos8Gateway systemd[1]: Failed to start SMS daemon for Gammu.


[root@Centos8Gateway etc]# 



我试图找出为什么Centos 8系统服务加载程序不使用配置的系统环境变量的原因?


答案1:

/etc/profile由bash等shell使用;它不用于为systemd服务设置环境。

若要向systemd服务提供环境变量,请在systemd单元文件比如中使用环境=


Environment="LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64"



注意,我省略了$LD_LIBRARY_PATH.,与/etc/profile中的相比:

  • 该变量通常默认情况下为空,并且为清晰起见和明确的期望,在这样的重要变量的systemd单元文件中的任何定义都应该是完全明确的。

答案2:

可以通过以下方式修复这个问题:

在/etc/ld.so.conf.d下仅将一行添加为gammu-smsd-1.42.0-x86_64.conf新文件,如下所示:

/usr/local/lib64

然后由root用户运行ldconfig。



服务  短信