1 Star 1 Fork 2

孤花暗香/zabbix_onkey

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
install_zabbix_offline.sh 7.33 KB
一键复制 编辑 原始数据 按行查看 历史
孤花暗香 提交于 2023-07-17 23:16 . 添加离线文件
#!/usr/bin/env bash
export PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
# Zabbix Install For 5.0.5
# Installation Zabbix Monitoring System Script
# Author: Mybbsky
# Last update 17/11/2020
# Thank you for using Zabbix script
#切换国内源
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
#关闭防火墙及selinux
setenforce 0
#添加防火墙端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
#防火墙重新载入
firewall-cmd --reload
#暂停防火墙
systemctl stop firewalld
# install
IP=`ip add|grep global|awk -F'[ /]+' '{ print $3 }'|head -n 1`
echo '------------Your IP address---------'
#ip addr | awk '/^[0-9]+: / {}; /inet.*global/ {print gensub(/(.*)\/(.*)/, "\\1", "g", $2)}'
printf $IP"\n";
echo '------------completed---------'
echo '===============================Zabbix5.0.5====================================='
echo 'Installation Zabbix Monitoring System Script '
echo 'Author: Mybbsky '
echo 'Last update 17/11/2020 '
echo '==============================================================================='
read -p "Input yes to install(y/n): " y;
if [ "$yes" == 'n' ];then
exit;
fi
yum install wget -y
rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.4/rhel/7/x86_64/zabbix-release-5.4-1.el7.noarch.rpm
yum clean all
yum install zabbix-server-mysql zabbix-agent -y
安装rh官方php7.2源
yum install centos-release-scl -y
#修改YUM配置
yum install -y rh-php72-php-gd rh-php72-php-bcmath rh-php72-php-mbstring rh-php72-php-mysqlnd rh-php72-php-xml rh-nginx116-nginx rh-php72 rh-php72-php-fpm rh-php72-php-ldap
yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl -y
yum install mariadb-server -y
#安装脚本解释器
yum install -y expect
yum install -y git
echo '=================================Zabbix========================================'
echo ' INSTALL DBSERVER OK , DO YOU WANT START DBSERVER ? '
echo '==============================================================================='
read -p "Input yes to Next (yes/n): " y;
if [ "$yes" == 'n' ];then
exit;
fi
systemctl start mariadb
systemctl enable mariadb
echo '=================================Zabbix========================================'
echo ' DBSERVER START OK , INITIALIZE DATABASE '
echo '==============================================================================='
curl -O https://gitee.com/mybbsky_admin_admin/zabbix_onkey/raw/master/auto_mysql.sh && chmod +x auto_mysql.sh && expect auto_mysql.sh Abc.123+
echo '=================================Zabbix========================================'
echo ' INSTALL DBSERVER OK , DO YOU WANT START DBSERVER ? '
echo '==============================================================================='
read -p "Input yes to Next (yes/n): " y;
echo '=================================Zabbix========================================'
echo ' INITIALIZE DATABASE OK , create database zabbix & create user zabbix '
echo '==============================================================================='
read -p "Input yes to Next (yes/n): " y;
if [ "$yes" == 'n' ];then
exit;
fi
echo '==============================================================================='
echo ' YOUR DBSERVER ROOT PASSWORD create database zabbix '
echo '==============================================================================='
mysql -uroot -pAbc.123+ -e "create database zabbix character set utf8 collate utf8_bin;"
#设置utf编码以便支持中文数据
echo '==============================================================================='
echo ' YOUR DBSERVER ROOT PASSWORD create user zabbix '
echo '==============================================================================='
mysql -uroot -pAbc.123+ -e "create user zabbix@localhost identified by 'zabbix';"
#创建zabbix用户, by'密码'
echo '==============================================================================='
echo ' YOUR DBSERVER ROOT PASSWORD grant all privileges on zabbix '
echo '==============================================================================='
mysql -uroot -pAbc.123+ -e "grant all privileges on zabbix.* to zabbix@localhost;"
#授权zabbix用户登陆范围 @localhost 本地
echo '=================================Zabbix========================================'
echo ' IMPORT DATABASE '
echo ' YOUR DBSERVER Zabbix PASSWORD (default:zabbix) '
echo '==============================================================================='
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
echo ' SETTING ZABBIX SERVER CONFING FILES'
sed -i '/^# DBPassword=.*/c DBPassword=zabbix' /etc/zabbix/zabbix_server.conf
echo ' SETTING PHP TIMEZONE CONFING '
#去注释
sed -i 's/; //' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
#改PHP时区
sed -i 's#Europe/Riga#Asia/Shanghai#' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
#添加PHP配置
sed -i 's/# //' /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf
#配置
sed -i '33{s/fastcgi_pass/#fastcgi_pass/}' /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf
#添加nginx配置
sed -i 's/listen.acl_users = apache/listen.acl_users = apache,nginx/g' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
#添加中文支持
sed -i 's/graphfont/simhei/g' /usr/share/zabbix/include/defines.inc.php
#下载字体修改NGINX默认网站为zabbix
cd /home
git clone https://gitee.com/mybbsky_admin_admin/zabbix_onkey.git
cd zabbix_onkey
mv /etc/opt/rh/rh-nginx116/nginx/nginx.conf /etc/opt/rh/rh-nginx116/nginx/nginx.conf.bak
cp nginx.conf /etc/opt/rh/rh-nginx116/nginx
cp simhei.ttf /usr/share/zabbix/assets/fonts
#删除下载的文件
rm -rf /home/zabbix_onkey
#启动zabbix服务
echo '=================================Zabbix========================================'
echo ' RESTART ALL SERVICES , PLEASE WAIT '
echo '==============================================================================='
#启用服务
systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
#更改selinux设置
sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config
echo '=================================Zabbix========================================'
echo ' install ok, tank you for use zabbix install scripts '
echo '==============================================================================='
printf "Server IP is:"$IP"\n";
printf "Zabbix Url: http://hostname/\n";
printf "hostname config file is /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf\n"
printf "Mysql user:root password is: Abc.123+ \n"
printf "Web HostName is: example.com \n"
#最后可以再修改数据库的root密码
#mysqladmin -u root -password 你的密码
#修改数据库的root密码
#mysqladmin -u root -p 你的密码 password 你的新密码
echo '=================================Zabbix========================================'
echo ' Install End '
echo '==============================================================================='
#
#2021年8月17日最后修改
#
#
#最后可以再修改数据库的root密码
#mysqladmin -u root -password 你的密码
#修改数据库的root密码
#mysqladmin -u root -p 你的密码 password 你的新密码
#
#
#
#
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/mybbsky_admin_admin/zabbix_onkey.git
git@gitee.com:mybbsky_admin_admin/zabbix_onkey.git
mybbsky_admin_admin
zabbix_onkey
zabbix_onkey
master

搜索帮助