CentOS7上安装Zabbix3.0
#
# 0、配置无人值守的安装,定义安装过程中需要用到的一些信息
#
mysql_root_pw=root_pw
mysql_zabbix_pw=zabbix_pw
DBPassword=$mysql_zabbix_pw
CacheSize=256M
ZBX_SERVER_NAME=My-Zabbix-Server
#
# 1、配置yum源
#
cat /etc/redhat-release |grep -i centos |grep '7.[[:digit:]]' >/dev/null
if [[ $? != 0 ]]
then
echo -e "不支持的操作系统,该脚本只适用于CentOS 7.x x86_64 操作系统"
exit 1
fi
rpm -i --force http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/$(curl -s http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/ |grep release |awk -F '>|<' '{print $3}') &>/dev/null
sed -i 's@repo.zabbix.com@mirrors.aliyun.com/zabbix@' /etc/yum.repos.d/zabbix.repo
#
# 2、使用yum安装Zabbix及必备软件
#
yum install -y httpd mariadb-server php gd php-bcmath php-ctype php-xml php-xmlreader php-xmlwriter php-session php-mbstring php-gettext php-ldap OpenIPMI libssh2 fping libcurl libxml2 net-snmp
yum install -y gnutls trousers
yum install -y zabbix-get zabbix-server-mysql zabbix-web-mysql
#
# 3、配置MySQL
#
sed -i '/^symbolic-links=0/a character-set-server=utf8\ninnodb_file_per_table=1' /etc/my.cnf
systemctl enable mariadb.service
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 on zabbix.* to zabbix@localhost 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
#
# 4、配置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
systemctl enable zabbix-server
systemctl start zabbix-server
systemctl enable httpd
systemctl start httpd
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-port=10051/tcp
firewall-cmd --permanent --zone=public --add-port=162/udp
firewall-cmd --reload
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/sysconfig/selinux
目录 返回
首页