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 '7.[[:d igit:]]'>/dev/NULL - - if[[ $? !=0 ]] + Then - Echo-E"Unsupported operating system, this script is only available for CentOS 7.x x86_64 operating system" +Exit1 A fi at -Rpm-i--force http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/$ (curl-shttp://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/|grep release |awk-f ' >|< ' {print $} ') &>/dev/null - - sed-I.'[email protected] @mirrors. Aliyun.com/[email protected]'/etc/Yum. repos.d/Zabbix.repo - - # in#2, installing Zabbix with Yum and software prerequisites - # to + Yum Install-y httpd mariadb-server php gd php-bcmath php-ctype php-xml php-xmlreader php-xmlwriter php-session php-mbstring Php-gette XT Php-ldap OpenIPMI libssh2 fping libcurl libxml2 net-SNMP - Yum Install-y gnutls Trousers the Yum Install-Y zabbix-get zabbix-server-mysql zabbix-web-MySQL * $ #Panax Notoginseng#3, configure MySQL - # the + sed-I.'/^symbolic-links=0/a character-set-server=utf8\ninnodb_file_per_table=1'/etc/my.cnf A Systemctl Enable Mariadb.service the systemctl start Mariadb.service +Mysqladmin-uroot password $mysql _root_pw -Mysql-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 ';" $Mysql-h LOCALHOST-UROOT-P$MYSQL_ROOT_PW-E"flush Privileges;" - - Zcat/usr/share/doc/zabbix-server-mysql-3.0. */create.sql.gz | Mysql-uroot-P$MYSQL_ROOT_PW Zabbix the - #Wuyi#4, configuration Zabbix the # - Wu sed-I."/^# dbpassword=/a dbpassword= $DBPassword"/etc/zabbix/zabbix_server.conf - sed-I."/^# cachesize=8m/a cachesize= $CacheSize"/etc/zabbix/zabbix_server.conf About $ sed-I.'s/# php_value date.timezone europe\/riga/php_value date.timezone asia\/shanghai/'/etc/httpd/conf.d/zabbix.conf - - 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 A sed-I."16c \ $ZBX _server_name = ' $ZBX _server_name ';"/etc/zabbix/web/zabbix.conf.php + theSystemctl Enable zabbix-Server -Systemctl Start zabbix-Server $ Systemctl Enable httpd the systemctl start httpd the theFirewall-cmd--permanent--zone=public--add-service=http theFirewall-cmd--permanent--zone=public--add-port=10050/TCP -Firewall-cmd--permanent--zone=public--add-port=162/UDP inFirewall-cmd--Reload the theSetenforce0 About sed-I.'s/selinux=enforcing/selinux=permissive/'/etc/sysconfig/selinux
Installing the Zabbix3.0 on the CentOS7