在Oracle数据库服务器上安装zabbix-agent,总是报缺少lib库,这些lib库在数据库软件中本身都由,不需要再安装客户端,配置环境变量即可
systemd的系统
vim /usr/lib/systemd/system/zabbix-agent2.service
Environment="LD_LIBRARY_PATH=/u01/app/oracle/product/12.2.0/db/lib:$LD_LIBRARY_PATH" "CONFFILE=/etc/zabbix/zabbix_agent2.conf"
systemctl daemon-reload
source /etc/profile
systemctl restart zabbix-agent2.service
ps -ef|grep zabbix
可以按如下方式编辑
[Unit]
Description=Zabbix Agent 2
After=syslog.target
After=network.target
[Service]
Environment="ORACLE_HOME=/u01/app/oracle/product/19.3.0/db"
Environment="CONFFILE=/etc/zabbix/zabbix_agent2.conf"
EnvironmentFile=-/etc/sysconfig/zabbix-agent2
Type=simple
Restart=on-failure
PIDFile=/run/zabbix/zabbix_agent2.pid
KillMode=control-group
ExecStart=/usr/sbin/zabbix_agent2 -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
User=zabbix
Group=zabbix
[Install]
WantedBy=multi-user.target
建议单独设置环境变量到一个默认的那个独立文件中
vim /etc/sysconfig/zabbix-agent2
LD_LIBRARY_PATH=/u01/app/oracle/product/12.2.0/db/lib:$LD_LIBRARY_PATH
# 或
echo "LD_LIBRARY_PATH=/u01/app/oracle/product/12.2.0/db/lib:\$LD_LIBRARY_PATH" > /etc/sysconfig/zabbix-agent2
非systemd的系统
在 /etc/init.d/zabbix-agent2 文件的 ### END INIT INFO 这一行下边添加环境变量
# export ORACLE_HOME=/apps/oracle
export LD_LIBRARY_PATH=/u01/app/oracle/product/12.2.0/db/lib:$LD_LIBRARY_PATH
# export NLS_LANG="AMERICAN_AMERICA.AL32UTF8"
# export TNS_ADMIN=/u01/app/oracle/product/12.2.0/db/network/admin