zabbix 2.2.3 一键安装脚本

3030阅读 0评论2017-11-01 douyaqiang123
分类:系统运维


  1. yum install make gcc mysql-server mysql-devel libcurl-devel net-snmp-devel php php-gd php-xml php-mysql php-mbstring php-bcmath httpd wget lrzsz telnet lsof -y

  2. groupadd zabbix
  3. useradd zabbix -g zabbix

  4. wget -c http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.3/zabbix-2.2.3.tar.gz
  5. tar zxf zabbix-2.2.3.tar.gz
  6. cd zabbix-2.2.3
  7. ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent \
  8. --with-mysql --with-net-snmp --with-libcurl
  9. make install

  10. service mysqld start;
  11. mysql -e "create database zabbix character set utf8;"
  12. mysql -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';flush privileges;"

  13. mysql -uroot zabbix < database/mysql/schema.sql
  14. mysql -uroot zabbix < database/mysql/images.sql
  15. mysql -uroot zabbix < database/mysql/data.sql

  16. sed -i 's/^DBUser=.*$/DBUser=zabbix/g' /usr/local/zabbix/etc/zabbix_server.conf
  17. sed -i 's/^.*DBPassword=.*$/DBPassword=zabbix/g' /usr/local/zabbix/etc/zabbix_server.conf
  18. cp -r frontends/php /var/www/html/zabbix
  19. cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
  20. sed -i 's#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g' /etc/init.d/zabbix_server
  21. sed -i 's#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g' /etc/init.d/zabbix_agentd

  22. cat >>/etc/services <<EOF
  23. zabbix-agent 10050/tcp Zabbix Agent
  24. zabbix-agent 10050/udp Zabbix Agent
  25. zabbix-trapper 10051/tcp Zabbix Trapper
  26. zabbix-trapper 10051/udp Zabbix Trapper
  27. EOF



  28. cat >>/etc/php.ini <<EOF
  29. date.timezone = Asia/Shanghai
  30. max_execution_time = 300
  31. max_input_time = 300
  32. post_max_size = 32M
  33. memory_limit = 128M
  34. mbstring.func_overload = 2
  35. EOF


  36. cat >>/etc/httpd/conf/httpd.conf <<EOF
  37. ServerName 127.0.0.1
  38. <VirtualHost *:80>
  39. DocumentRoot "/var/www/html"
  40. ServerName zabbix_server
  41. </VirtualHost>
  42. EOF


  43. cat >/var/www/html/zabbix/conf/zabbix.conf.php <<EOF
  44. <?php
  45. // Zabbix GUI configuration file
  46. global $DB;

  47. $DB['TYPE'] = 'MYSQL';
  48. $DB['SERVER'] = 'localhost';
  49. $DB['PORT'] = '0';
  50. $DB['DATABASE'] = 'zabbix';
  51. $DB['USER'] = 'zabbix';
  52. $DB['PASSWORD'] = 'zabbix';

  53. // SCHEMA is relevant only for IBM_DB2 database
  54. $DB['SCHEMA'] = '';

  55. $ZBX_SERVER = 'localhost';
  56. $ZBX_SERVER_PORT = '10051';
  57. $ZBX_SERVER_NAME = '';

  58. $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
  59. ?>
  60. EOF

  61. service iptables stop
  62. chkconfig --level 345 iptables off
  63. setenforce 0
  64. sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
  65. echo "/etc/init.d/zabbix_server start" >> /etc/rc.local
  66. echo "/etc/init.d/zabbix_agentd start" >> /etc/rc.local
  67. chkconfig --level 345 mysqld on
  68. chkconfig --level 345 httpd on


  69. /etc/init.d/zabbix_server start
  70. /etc/init.d/zabbix_agentd start
  71. /etc/init.d/httpd start

上一篇:mycat分库规则sharding-by-date
下一篇:这套方法论,彻底终结MySQL同步延迟问题!