#!/bin/bash ########################################################################################## # #0、定制配置文件所需参数 # ########################################################################################## mysql_root_pw=root_pw mysql_zabbix_pw=zabbix_pw DBPassword=$mysql_zabbix_pw CacheSize=256M ZBX_SERVER_NAME=My-Zabbix-Server ########################################################################################## # #1、安装Zabbix及MySQL # ########################################################################################## yum clean all #rpm -ivh http://mirrors.aliyun.com/zabbix/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm rpm -ivh http://mirrors.aliyun.com/zabbix/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm perl -p -i -e "s/repo.zabbix.com/mirrors.aliyun.com\/zabbix/g" /etc/yum.repos.d/zabbix.repo rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm yum install -y zabbix zabbix-get zabbix-server zabbix-web-mysql zabbix-web zabbix-agent yum install -y mysql-server ########################################################################################## # #2、配置MySQL # ########################################################################################## sed -i ‘/^symbolic-links=0/a character-set-server=utf8\ninnodb_file_per_table=1‘ /etc/my.cnf chkconfig mysqld on /etc/init.d/mysqld start 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 on zabbix.* to zabbix@localhost identified by ‘$mysql_zabbix_pw‘;" mysql -h localhost -uroot -p$mysql_root_pw -e "flush privileges;" #mysql -h localhost -uzabbix -p$mysql_zabbix_pw -Dzabbix < /usr/share/doc/zabbix-server-mysql-2.2.10/create/schema.sql #mysql -h localhost -uzabbix -p$mysql_zabbix_pw -Dzabbix < /usr/share/doc/zabbix-server-mysql-2.2.10/create/images.sql #mysql -h localhost -uzabbix -p$mysql_zabbix_pw -Dzabbix < /usr/share/doc/zabbix-server-mysql-2.2.10/create/data.sql mysql -h localhost -uzabbix -p$mysql_zabbix_pw -Dzabbix < /usr/share/doc/zabbix-server-mysql-2.4.6/create/schema.sql mysql -h localhost -uzabbix -p$mysql_zabbix_pw -Dzabbix < /usr/share/doc/zabbix-server-mysql-2.4.6/create/images.sql mysql -h localhost -uzabbix -p$mysql_zabbix_pw -Dzabbix < /usr/share/doc/zabbix-server-mysql-2.4.6/create/data.sql ########################################################################################## # #3、配置Zabbix # ########################################################################################## sed -i "/^# DBPassword=/a DBPassword=$DBPassword" /etc/zabbix/zabbix_server.conf sed -i "/^# CacheSize=8M/a CacheSize=$CacheSize" /etc/zabbix/zabbix_server.conf 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 sed -i "16c \$ZBX_SERVER_NAME = ‘$ZBX_SERVER_NAME‘;" /etc/zabbix/web/zabbix.conf.php chkconfig zabbix-server on chkconfig httpd on /etc/init.d/zabbix-server start /etc/init.d/httpd start iptables -I INPUT -m state --state NEW -p tcp --dport 10050 -j ACCEPT iptables -I INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT /etc/init.d/iptables save setenforce 0 sed -i ‘s/SELINUX=enforcing/SELINUX=permissive/‘ /etc/sysconfig/selinux
脚本安装zabbix2.2,基于centos6.6 basic server
原文地址:http://www1707.blog.51cto.com/1184226/1709158