Chinaunix首页 | 论坛 | 博客
  • 博客访问: 141201
  • 博文数量: 31
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 318
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-24 22:10
个人简介

2011.4 ~ 2015.7 就职于百度运维部,负责百度推广后台系统运维; 2015.7至今,就职于北京屏芯科技(互联网+餐饮),负责稳定性、安全、敏捷、速度等工作。

文章分类

全部博文(31)

文章存档

2016年(4)

2015年(27)

我的朋友

分类: 系统运维

2015-06-26 19:53:44

源码编译后,打成RPM包,方便后续管理。
= zabbix_server = 
安装目录: /root/zabbix_server
提前安装:  yum install libxml2 libxml2-devel net-snmp-devel curl curl-devel php php-bcmath php-mbstring php-gd php-mysql
编译参数:  ./configure --enable-server --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --prefix=/root/zabbix_server
其他安装步骤见官方文档

= zabbix_agentd = 
安装目录: /root/zabbix_agentd
使用RPM包管理的优势:
1. 便于安装及升级
2. 安装目录规范统一
3. RPM中将zabbix_agentd放入系统的service中进行管理

zabbix_agentd.spec

点击(此处)折叠或打开

  1. %define _topdir
  2. %define debug_package %{nil}
  3. %define zabbix_home /root/zabbix_agentd
  4. %define %{_initrddir} /etc/init.d
  5. Summary: RPM for zabbix agentd
  6. Name: zabbix_agentd
  7. Version: 2.4.5
  8. Release: 1
  9. Vendor: zabbix
  10. License: GPL
  11. Group: Applications/Internet
  12. BuildRoot: %{_builddir}/%{name}
  13. Packager: guofzhao
  14. Source0: %{name}-%{version}.tar.gz
  15. Source1: zabbix_agentd.init
  16. Requires(post): /sbin/chkconfig
  17. Requires(preun): /sbin/chkconfig
  18. Requires(preun): /sbin/service
  19. %description
  20. Zabbix agentd
  21. %prep
  22. rm -rf ${buildroot}
  23. %setup -c

  24. %install
  25. mkdir -p %{buildroot}%{zabbix_home}
  26. mkdir -p %{buildroot}%{_initrddir}
  27. cp -r %{name}-%{version}/* %{buildroot}%{zabbix_home}
  28. %{__install} -D -p -m 0755 %{SOURCE1} %{buildroot}%{_initrddir}/%{name}
  29. %clean
  30. rm -rf %{buildroot}
  31. %post
  32. grep -q %{name} /etc/services || cat >> /etc/services <<EOF
  33. zabbix_agentd 10050/tcp #Zabbix Agent
  34. zabbix_agentd 10050/udp #Zabbix Agent
  35. EOF
  36. # Add zabbix-agent to system start-up
  37. /sbin/chkconfig --add %{name}
  38. /sbin/chkconfig %{name} on
  39. %preun
  40. # Stop and disable service before removal
  41. /sbin/service %{name} stop >/dev/null 2>&1 || :
  42. /sbin/chkconfig --del %{name}
  43. sed -i "/%{name}/d" /etc/services
  44. %files
  45. %{zabbix_home}
  46. %attr(755,root,root) %{_initrddir}/%{name}

zabbix_agentd.init

点击(此处)折叠或打开

  1. #!/bin/sh
  2. # chkconfig: 235 85 15
  3. # description: Zabbix is an enterprise-class open source distributed monitoring solution.
  4. # zabbix_agentd_ctl
  5. #
  6. # control script to stop/start/restart zabbix_agentd
  7. # author: charlie collins
  8. # date: 01.21.2002
  9. #
  10. # revised 09.21.2003
  11. # (setup for Red Hat 7.3 with Zabbix 1.0 beta)
  12. # (should work for other Red Hat and Sys V style init machines as well)
  13. #
  14. # (modeled after apache style control scripts)
  15. # (this script can be placed in init.d and respective runlevel for startup usage)
  16. #
  17. #
  18. # The exit codes returned are:
  19. # 0 - operation completed successfully
  20. # 1 -
  21. # 2 - usage error
  22. # 3 - zabbix_agentd could not be started
  23. # 4 - zabbix_agentd could not be stopped
  24. # 5 - zabbix_agentd could not be started during a restart
  25. # 6 - zabbix_agentd could not be restarted during a restart
  26. #
  27. #
  28. #
  29. # **************
  30. # config options
  31. # **************
  32. #
  33. # (set config options to match your system settings)
  34. # base zabbix dir
  35. BASEDIR=/root/zabbix_agentd
  36. # pid file (as of 1.0 beta 10)
  37. PIDFILE=$BASEDIR/log/zabbix_agentd.pid
  38. # binary file
  39. ZABBIX_AGENTD="$BASEDIR/sbin/zabbix_agentd"
  40. # **************
  41. # logic section (below here) does NOT normally need any modification
  42. # **************
  43. # establish args
  44. ERROR=0
  45. ARGV="$@"
  46. if [ "x$ARGV" = "x" ] ; then
  47. ARGS="help"
  48. fi
  49. # perform action based on args
  50. for ARG in $@ $ARGS
  51. do
  52. # check if PIDFILE exists and ensure is not zero size and react accordingly
  53. if [ -f $PIDFILE ] && [ -s $PIDFILE ] ; then
  54. PID=`cat $PIDFILE`
  55. if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then
  56. STATUS="zabbix_agentd (pid $PID) running"
  57. RUNNING=1
  58. else
  59. STATUS="zabbix_agentd (pid $PID?) not running"
  60. RUNNING=0
  61. fi
  62. else
  63. STATUS="zabbix_agentd (no pid file) not running"
  64. RUNNING=0
  65. fi
  66. # parse arg and react accordingly
  67. case $ARG in
  68. start)
  69. if [ $RUNNING -eq 1 ]; then
  70. echo "$0 $ARG: $PID already running"
  71. continue
  72. fi
  73. if $ZABBIX_AGENTD ; then
  74. echo "$0 $ARG: OK"
  75. else
  76. echo "$0 $ARG: ERROR"
  77. ERROR=3
  78. fi
  79. ;;
  80. stop)
  81. if [ $RUNNING -eq 0 ]; then
  82. echo "stop called - in running eq 0"
  83. echo "$0 $ARG: $STATUS"
  84. continue
  85. fi
  86. if kill $PID ; then
  87. echo "$0 $ARG: OK"
  88. else
  89. echo "$0 $ARG: ERROR"
  90. ERROR=4
  91. fi
  92. ;;
  93. restart)
  94. $0 stop
  95. sleep 5
  96. $0 start
  97. ;;
  98. *)
  99. echo "usage: $0 (start|stop|restart|help)"
  100. cat <<EOF
  101. start - start zabbix_agentd
  102. stop - stop zabbix_agentd
  103. restart - restart zabbix_agentd if running by sending a SIGHUP or start if not running
  104. help - this screen
  105. EOF
  106. ERROR=2
  107. ;;
  108. esac
  109. done
  110. exit $ERROR


阅读(1375) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~