> /dev/nullsystemctl disable firewalld >>/dev/nullif [ $? -eq 0 ];thenecho"Firewall防火墙初始化完毕!。一键搭建zabbix脚本。" />

一键搭建zabbix脚本

标题搭建zabbix脚本

#!/bin/bash #1.配置防火墙和selinux echo"正在配置firewall防火墙……" systemctl stop firewalld >> /dev/null systemctl disable firewalld >>/dev/null if [ $? -eq 0 ]; then echo"Firewall防火墙初始化完毕!" fi echo"正在关闭SELinux……" setenforce 0 > /dev/null 2>&1 sed -i '/^SELINUX=/s/=.*/=disabled/' /etc/selinux/config if [ $? -eq 0 ]; then echo"SELinux初始化完毕!" fi#2.安装lamp环境 echo"安装lamp" yum -y install httpd mariadb mariadb-server php php-mysql php-gd &>/dev/null if [ $? -eq 0 ]; then echo "lamp 安装成功" else echo "lamp 安装失败" fi#3.启动数据库 mysql -e "create database zabbix charset utf8; grant all on zabbix.* to zabbix@'localhost' identified by 'zabbix'; flush privileges; " if [ $? -eq 0 ]; then echo"数据库初始化完成" else echo"数据库初始化失" fi#4.启动httpd服务并设置为开机自启 systemctlstarthttpd && systemctl enable httpd &>/dev/null if [ $? -eq 0 ]; then echo "apache 启动成功" else echo "apache 启动失败" fi#5.安装zabbix服务 rpm -ivh zabbix-release-3.4-2.el7.noarch.rpm &>/dev/null &>/dev/null yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent if [ $? -eq 0 ]; then echo"zabbix-server安装完成" else echo"zabbix-server安装失败" fi#6.导入数据库 cd /usr/share/doc/zabbix-server-mysql-3.4.15/ zcat create.sql.gz | mysql -uzabbix -pzabbix zabbix if [ $? -eq 0 ]; then echo"数据导入完成" else echo"数据导入失败" fi#7.配置zabbix配置文件并启动 sed -i '/# DBPassword=/a\DBPassword=zabbix'/etc/zabbix/zabbix_server.conf if [ $? -eq 0 ]; then echo"zabbix配置完成" else echo"zabbix配置失败" fisystemctl start zabbix-server && systemctl enable zabbix-server &>/dev/null if [ $? -eq 0 ]; then echo"zabbix-server 服务启动成功" else echo"zabbix-server 服务启动失败" fised -i '/^; date.timezone/a\date.timezone =Asia/Shanghai' /etc/php.ini#8。重启httpd服务 systemctlrestarthttpd && systemctl enable httpd &>/dev/null if [ $? -eq 0 ]; then echo "apache 启动成功" else echo "apache 启动失败" fi#9。修改zabbix乱码 sed -i s/graphfont/simkai/g /usr/share/zabbix/include/defines.inc.php

    推荐阅读