linux CentOS 7 zabbix服务端自动安装脚本 - com/zabbix/5
#!/bin/bash #by lhy 2023.1.10 @此素材源于zgh共同打造 #This shell script automatically installs zabbix with one click #此shell脚本为了一键自动安装zabbix #Zabbix-Server 5.0 拼多多帮助力入口
#Configure the official zabbix yum source #配置安装zabbix官方yum源 cd /etc/yum.repos.d/ rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
#修改zabbix.repo,改为阿里源,启用yum #sed -i.bak’s#repo.zabbix.com#mirrors.aliyun.com/zabbix#’ zabbix.repo # ——————————有问题 #sed -i’s#enabled=0#enabled=1#’ zabbix.repo #----------有问题 sed -i ‘/[#]*enable/ s/0/1/’ zabbix.repo
#安装zabbix yum install -y epel-release yum install -y epel-release #安装依赖源epel-release yum install -y centos-release-scl #安装依赖 yum install -y zabbix-server-mysql zabbix-agent #安装zabbix服务端与客户端 yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl #安装zabbix_web服务
#安装mariadb服务并启动 yum install -y mariadb mariadb-server httpd mariadb systemctl start mariadb
#创建数据库zabbix(编码)和指定用户zabbix mysql -e ‘CREATE DATABASE zabbix character set utf8 collate utf8_bin;’ mysql -e ‘GRANT all ON zabbix.* TO ‘zabbix’@‘localhost’ IDENTIFIED BY ‘zabbix’ ;’ mysql -e ‘flush privileges;’
#input 指定数据到mysql zcat /usr/share/doc/ zabbix- server -mysq1-5.0.15/create.sql.gz | mysql -uzabbix -pzabbix -Dzabbix
#验证导入数据库后的结果:mysql -e “show databases;” #验证导入数据库后的结果:mysql -e “use zabbix;show tables;”
#更改时区为亚洲/上海 #sed -i.bak ‘/^;php_value[date.timezone]/i php_value[date.timezone]=Asia/Shanghai’ /etc/opt/rh/rh-php72/php-fpm/d/zabbix/conf sed -i 's/^;\sphp_value\s[date.timezone].*/php_value[date.timezone] = Asia/Shanghai/’ /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
#替换文件,解决中文乱码问题 yum install -y wqy-microhei-fonts cp -f /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
#启动服务 systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
#设置开机自动启动 systemctl enable mmariadb && systemctl enable httpd systemctl enable zabbix-server
#访问浏览器,输出zabbix信息 ####curl hostname -I|awk ‘{print $1}’/zabbix 还有问题 echo -e “Please enter the URL in your browser:\nhttp://hostname -I|awk '{print $1}'/zabbix”
推荐阅读