查看: 525|回复: 2

[shell脚本] 一键部署zabbix2.2监控系统服务端客户端

[复制链接]
  • TA的每日心情
    奋斗
    2017-8-30 16:53
  • 签到天数: 287 天

    连续签到: 1 天

    [LV.8]以坛为家I

    发表于 2016-7-5 19:53:54 | 显示全部楼层 |阅读模式
    一、zabbix2.2服务端和客户端部署

    1、脚本介绍,此脚本支持在网络上6.2-6.8的操作系统使用,部署快。非常的省时间,喜欢的可以收藏
    注:防火墙端口如果有特别要求可以自己设置规则,或者在如上添加进去,运行80,10050端口,即可。
    1. #!/bin/bash
    2. #-------------CopyRight---------------------
    3. #   Name:Mr.Rice                            *
    4. #   Version Number:1.11                     *
    5. #   Type:Service zabbix2.2_install          *
    6. #   Language:bash shell                     *
    7. #   Date:2016-01-29                         *
    8. #   Author:RICE                             *
    9. #   Email:uqsjsj@163.com                    *
    10. #   Environment:CentOS release 6.3 (Final)  *
    11. #--------------------------------------------
    12. setup_select()
    13. {

    14. cat << menu
    15. ++++++++++++++ LINUX Network service INSTALL MENU ++++++++++++++++++++++
    16.         note:all of the need soft must be located in root directory!!!!
    17.          
    18.                 1. Install zabbix-2.22
    19.                 2. Install zabbix-agent
    20.        
    21.                 Q. quit
    22.   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    23. menu
    24. echo -e -n "Please Select [1,2,3.....Q] >"
    25. #read -p "please select [1,2,3,Q] >:" Select
    26. }

    27. amp_setup()
    28. {
    29.                 setup_select
    30.                 read select
    31.                 case $select in
    32.                                

    33. #Installation of zabbix system services       
    34.   1)       
    35. #shutdown selinux
    36. sed -i 's@SELINUX=enforcing@SELINUX=disabled@g' /etc/sysconfig/selinux  
    37. #Install LAMP
    38. yum -y install zlib-devel mysql-devel glibc-devel curl-devel gcc automake mysql libidn-devel openssl-devel net-snmp-devel rpm-devel OpenIPMI-devel httpd mysql-server php-gd php-mysql php-bcmath php-mbstring php-xml perl-DBI php
    39. #Install Epel
    40. rpm -ivh http://mirrors.zju.edu.cn/epel/6/i386/epel-release-6-8.noarch.rpm
    41. #Install zabbix
    42. yum -y install $(yum search zabbix22 | awk -F":" '/zabbix22/&&!/pgsql|Matched|sqlite|proxy/{print $1}')
    43. #Import the database
    44. service mysqld start
    45. mysqladmin -u root password "123456"
    46. mysql -uroot -p123456 <<EOF
    47. create database zabbix character set utf8;
    48. grant all on zabbix.* to zabbix@localhost identified by '123456';
    49. quit
    50. EOF
    51. #Import the database
    52. mysql -uzabbix -p123456 zabbix < /usr/share/zabbix-mysql/schema.sql
    53. mysql -uzabbix -p123456 zabbix < /usr/share/zabbix-mysql/images.sql
    54. mysql -uzabbix -p123456 zabbix < /usr/share/zabbix-mysql/data.sql
    55. #Configuration Zabbix and PHP
    56. sed -i '/^DBName/s/=.*$/=zabbix/' /etc/zabbix_server.conf
    57. sed -i '/^# DBPassword/s/.*$/DBPassword=123456/' /etc/zabbix_server.conf
    58. sed -i 's/post_max_size = 8M/post_max_size = 32M/g' /etc/php.ini
    59. sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /etc/php.ini
    60. sed -i 's/;date.timezone =/date.timezone = Asia\/Shanghai/' /etc/php.ini
    61. sed -i 's/max_execution_time = 30/max_execution_time = 600/g' /etc/php.ini
    62. sed -i 's/max_input_time = 60/max_input_time = 600/g' /etc/php.ini
    63. sed -i 's/memory_limit = 128M/memory_limit = 256M/g' /etc/php.ini
    64. #Configuration to start
    65. chkconfig --level 345 zabbix-server on
    66. chkconfig --level 345 zabbix-agent on
    67. sed -i '@^SELINUX=enforcing@SELINUX=disabled@/s' /etc/sysconfig/selinux
    68. setenforce 0
    69. service zabbix-server start
    70. service zabbix-agent start
    71. service httpd restart
    72. service iptables stop
    73. chkconfig iptables off
    74. echo "The default login name and password;username:admin  password:zabbix"               
    75. ;;


    76.   2)       
    77. #shutdown selinux
    78. sed -i 's@SELINUX=enforcing@SELINUX=disabled@g' /etc/sysconfig/selinux
    79. #INSTALL ZABBIX CLIENT
    80. #Install Epel
    81. rpm -ivh http://mirrors.zju.edu.cn/epel/6/i386/epel-release-6-8.noarch.rpm
    82. yum -y install zabbix22-agent*
    83. sed -i 's/Server=127.0.0.1/Server=192.168.3.200/g' /etc/zabbix_agentd.conf
    84. sed -i 's/ServerActive=127.0.0.1/ServerActive=192.168.3.200:10051/g' /etc/zabbix_agentd.conf
    85. service zabbix-agent start
    86. service iptables stop
    87. ;;                               
    88.                                
    89.                                
    90. esac

    91. }
    92. start_menu()
    93. {
    94. amp_setup
    95. }
    96. start_menu
    复制代码
  • TA的每日心情
    奋斗
    2017-8-30 16:53
  • 签到天数: 287 天

    连续签到: 1 天

    [LV.8]以坛为家I

     楼主| 发表于 2016-7-5 19:55:33 | 显示全部楼层
    如果有需要zabbix2.2的操作使用文档的,可以留言我给你们发PDF说明文档。

    该用户从未签到

    发表于 2016-7-5 19:57:09 | 显示全部楼层
    看一下
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    站长推荐上一条 /1 下一条