编写一键部署Zabbix的shell脚本
时间: 2023-10-29 09:55:47 浏览: 200
好的,以下是一键部署Zabbix的shell脚本:
```bash
#!/bin/bash
# 安装依赖
yum -y install httpd php php-mysql php-gd php-xml mariadb mariadb-server mariadb-devel
# 启动MariaDB
systemctl start mariadb
systemctl enable mariadb
# 配置MariaDB
mysql -e "CREATE DATABASE zabbix character set utf8 collate utf8_bin;"
mysql -e "GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost' IDENTIFIED BY 'zabbix';"
mysql -e "FLUSH PRIVILEGES;"
# 导入Zabbix数据库
cd /tmp
wget https://repo.zabbix.com/zabbix/5.0/mysql/zabbix-5.0.11-mysql.sql
mysql -uzabbix -pzabbix zabbix < zabbix-5.0.11-mysql.sql
# 安装Zabbix服务器和代理
rpm -ivh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
# 配置Zabbix服务器
sed -i 's/# DBPassword=/DBPassword=zabbix/g' /etc/zabbix/zabbix_server.conf
systemctl start zabbix-server
systemctl enable zabbix-server
# 配置Zabbix代理
sed -i 's/Server=127.0.0.1/Server=127.0.0.1,zabbix.example.com/g' /etc/zabbix/zabbix_agentd.conf
sed -i 's/ServerActive=127.0.0.1/ServerActive=127.0.0.1,zabbix.example.com/g' /etc/zabbix/zabbix_agentd.conf
systemctl start zabbix-agent
systemctl enable zabbix-agent
# 配置Apache
sed -i 's/# php_value date.timezone Europe\/Riga/php_value date.timezone Asia\/Shanghai/g' /etc/httpd/conf.d/zabbix.conf
systemctl start httpd
systemctl enable httpd
```
注意,该脚本默认使用MariaDB作为数据库,并导入Zabbix 5.0.11版本的数据库文件。如果需要使用其他数据库或版本,请自行修改相应的部分。另外,脚本中的zabbix.example.com为示例域名,需要替换为实际使用的域名。
阅读全文
相关推荐
















