1#!/bin/Bash2 3 #4#0, configure unattended installation, define some of the information you need to use during installation5 #6mysql_root_pw=ROOT_PW7mysql_zabbix_pw=ZABBIX_PW8dbpassword=$mysql _ZABBIX_PW9Cachesize=256MTenzbx_server_name=my-zabbix-Server One A # -#1, configuring the Yum source - # the - Cat/etc/redhat-release |grep-I CentOS |grep '6.[[:d igit:]]'&>/dev/NULL - - if[[ $? !=0 ]] + Then - Echo-E"Unsupported operating system, this script is only available for CentOS 6.x operating system" +Exit1 A fi at -os_m=$ (uname-m) -za_rpm=$ (curl-s http://mirrors.aliyun.com/zabbix/zabbix/2.4/rhel/6/$os _m/|grep release |awk-f ' >|< ' {print $} ') -Rpm-i--force http://mirrors.aliyun.com/zabbix/zabbix/2.4/rhel/6/$os _m/$za _rpm - - if[[ $? !=0 ]] in Then - Echo-E"Yum Source configuration failed, please check the network or other reasons" toExit1 + fi - the sed-I.'[email protected] @mirrors. Aliyun.com/[email protected]'/etc/Yum. repos.d/Zabbix.repo * $ #Panax Notoginseng#2, installing Zabbix with Yum and software prerequisites - # the + Yum Install-Y httpd mysql-Server PHP A Yum Install-y Zabbix the Yum Install-Y zabbix-agent zabbix-Sender + Yum Install-Y Zabbix-server zabbix-Get - Yum Install-Y Zabbix-web zabbix-web-MySQL $ $ # -#3, configure MySQL - # the - sed-I.'/^symbolic-links=0/a character-set-server=utf8\ninnodb_file_per_table=1'/etc/my.cnfWuyi chkconfig mysqld on the/etc/init.d/mysqld Start -Mysqladmin-uroot password $mysql _root_pw WuMysql-h LOCALHOST-UROOT-P$MYSQL_ROOT_PW-E"CREATE database Zabbix character set UTF8;" -Mysql-h LOCALHOST-UROOT-P$MYSQL_ROOT_PW-E"Grant all privileges the zabbix.* to [e-mail protected] identified by ' $mysql _ZABBIX_PW ';" AboutMysql-h LOCALHOST-UROOT-P$MYSQL_ROOT_PW-E"flush Privileges;" $ -Mysql-h Localhost-uzabbix-p$mysql_zabbix_pw-dzabbix </usr/share/doc/$ (Rpm-q Zabbix-server-mysql |awk-F'-' '{print $ "-" $ "-" $ $ "-" $4} "')/create/Schema.sql -Mysql-h Localhost-uzabbix-p$mysql_zabbix_pw-dzabbix </usr/share/doc/$ (Rpm-q Zabbix-server-mysql |awk-F'-' '{print $ "-" $ "-" $ $ "-" $4} "')/create/Images.sql -Mysql-h Localhost-uzabbix-p$mysql_zabbix_pw-dzabbix </usr/share/doc/$ (Rpm-q Zabbix-server-mysql |awk-F'-' '{print $ "-" $ "-" $ $ "-" $4} "')/create/Data.sql A + # the#4, configuration Zabbix - # $ the sed-I."/^# dbpassword=/a dbpassword= $DBPassword"/etc/zabbix/zabbix_server.conf the sed-I."/^# cachesize=8m/a cachesize= $CacheSize"/etc/zabbix/zabbix_server.conf the sed-I.'s/^# php_value date.timezone europe\/riga/php_value date.timezone asia\/shanghai/'/etc/httpd/conf.d/zabbix.conf the CP/usr/share/zabbix/conf/zabbix.conf.php.example/etc/zabbix/web/zabbix.conf.php - sed-I."10c \ $DB [\ "password\"] = ' $DBPassword ';"/etc/zabbix/web/zabbix.conf.php in sed-I."16c \ $ZBX _server_name = ' $ZBX _server_name ';"/etc/zabbix/web/zabbix.conf.php theChkconfig zabbix-Server on theChkconfig zabbix-Agent on About chkconfig httpd on the/etc/init.d/zabbix-Server Start the/etc/init.d/zabbix-Agent Start the/etc/init.d/httpd Start +Iptables-i input-m State--state new-p TCP--dport10051-J ACCEPT -Iptables-i input-m State--state new-p TCP--dport the-J ACCEPT the/etc/init.d/iptables SaveBayiSetenforce0 the sed-I.'s/selinux=enforcing/selinux=permissive/'/etc/sysconfig/selinux
Install Zabbix2.4 Server on CentOS6