银河麒麟V10 SP1 服务器编译agent后配置zabbix_agentd服务自启动

目录

一、背景需求

二、实现方法

1、查看自启动脚本

2、将启动脚本拷贝到/etc/init.d目录

3、修改zabbix_agentd启动脚本

4、启动zabbix_agentd服务

5、设置开机自动启动


一、背景需求

        编译完zabbix-agent后,生成sbin/zabbix_agentd启动命令,需求是希望zabbix_agentd以服务的形式启动,并能开机自启动。

二、实现方法

1、查看自启动脚本

        在源码包路径下,有脚本文件:

/usr/local/src/zabbix/misc/init.d/fedora/core5/zabbix_agentd

        查看脚本文件内容命令:

        cat zabbix_agentd

[root@localhost tru64]# cat zabbix_agentd

#!/bin/bash                        

#       /etc/rc.d/init.d/zabbix_agentd  

# Starts the zabbix_agentd daemon      

# chkconfig: - 95 5                  

# description: Zabbix Monitoring Agent  

# processname: zabbix_agentd         

# pidfile: /tmp/zabbix_agentd.pid       

# Modified for Zabbix 2.0.0           

# May 2012, Zabbix SIA              

# Source function library.             

. /etc/init.d/functions                 

RETVAL=0                        

prog="Zabbix Agent"                

ZABBIX_BIN="/usr/local/sbin/zabbix_agentd"

if [ ! -x ${ZABBIX_BIN} ] ; then

        echo -n "${ZABBIX_BIN} not installed! "

        # Tell the user this has skipped

        exit 5

fi

start() {        echo -n $"Starting $prog: "

        daemon $ZABBIX_BIN

        RETVAL=$?

        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_agentd

        echo}

stop() {      echo -n $"Stopping $prog: "

        killproc $ZABBIX_BIN

        RETVAL=$?

        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zabbix_agentd

        echo}

case "$1" in  start)

        start ;;  stop)

        stop ;;  reload|restart)

        stop        sleep 10        start

        RETVAL=$?;;  condrestart)

        if [ -f /var/lock/subsys/zabbix_agentd ]; then

            stop           start        fi        ;;  status)

        status $ZABBIX_BIN        RETVAL=$?       ;;  *)

        echo $"Usage: $0 {condrestart|start|stop|restart|reload|status}"

        exit 1

esac

exit $RETVAL      

2、将启动脚本拷贝到/etc/init.d目录

        源码包在/usr/local/src/目录执行拷贝命令:

cp /usr/local/src/zabbix/misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/

3、修改zabbix_agentd启动脚本

        将DAEMON启动命令路径修改为安装时指定的路径。

        实际环境中DAEMON是引用ZABBIX_BIN

        所以修改文件内容为:ZABBIX_BIN=”/usr/local/zabbix-agent/sbin/zabbix_agentd”

4、启动zabbix_agentd服务

        执行服务启动命令:

/etc/init.d/zabbix_agentd start

出现警告:Warning: The unit file, source configuration file or drop-ins of zabbix_agentd.service changed on disk. Run 'systemctl daemon-reload' to reload units.

        解决方法:执行systemctl daemon-reload赋予执行权限即可

5、设置开机自动启动

        设置开机自启动命令:

systemctl enable zabbix_agentd

出现提示:zabbix_agentd.service is not a native service, redirecting to systemd-sysv-install. 

Executing: /usr/lib/systemd/systemd-sysv-install enable zabbix_agentd                     

        解决方法:执行/usr/lib/systemd/systemd-sysv-install enable zabbix_agentd即可。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

見贤思齊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值