一键安装Zabbix 7.0 LTS、MySQL、Nginx和Grafana

!/bin/bash

# 更新系统
apt update && apt upgrade -y

# 安装所需的软件包
apt install -y gnupg2 wget lsb-release

# 添加Zabbix官方仓库
wget -qO- https://repo.zabbix.com/zabbix/7.0/debian/pool/main/z/zabbix-release/zabbix-release_7.0-1%2Bdebian12_all.deb | dpkg -i –

# 更新软件包列表
apt update

# 安装Zabbix服务器、前端和代理
apt install -y zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-agent

# 安装MySQL数据库服务器
apt install -y mysql-server

# 设置MySQL root用户密码
MYSQL_ROOT_PASSWORD=”XXXXX”

# 启动MySQL服务并设置开机自启动
systemctl start mysql
systemctl enable mysql

# 安全安装MySQL,并设置root密码和字符集
mysql_secure_installation <<EOF

y
$MYSQL_ROOT_PASSWORD
$MYSQL_ROOT_PASSWORD
y
y
y
y
EOF

# 创建Zabbix数据库和用户,并设置密码,适配中文字符
mysql -u root -p$MYSQL_ROOT_PASSWORD -e “CREATE DATABASE zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;”
mysql -u root -p$MYSQL_ROOT_PASSWORD -e “CREATE USER ‘zabbix’@’localhost’ IDENTIFIED BY ‘XXXXX’;”
mysql -u root -p$MYSQL_ROOT_PASSWORD -e “GRANT ALL PRIVILEGES ON zabbix.* TO ‘zabbix’@’localhost’;”
mysql -u root -p$MYSQL_ROOT_PASSWORD -e “FLUSH PRIVILEGES;”

# 导入初始架构和数据
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pDsadmin1129! zabbix

# 配置Zabbix服务器
sed -i ‘s/# DBPassword=/DBPassword=XXXXXX/g’ /etc/zabbix/zabbix_server.conf

# 配置PHP时区为美国洛杉矶时区
sed -i ‘s/# php_value\[date\.timezone\] = Europe\/Riga/php_value\[date\.timezone\] = America\/Los_Angeles/g’ /etc/zabbix/nginx.conf

# 启动Zabbix服务器和代理进程
systemctl restart zabbix-server zabbix-agent
systemctl enable zabbix-server zabbix-agent

# 配置Nginx以使用Zabbix前端
sed -i ‘s/# listen 8080;/ listen 80;/g’ /etc/zabbix/nginx.conf
sed -i ‘s/# server_name example.com;/ server_name localhost;/g’ /etc/zabbix/nginx.conf

# 启动Nginx并设置开机自启动
systemctl restart nginx
systemctl enable nginx

# 安装Grafana
# 添加Grafana GPG key和仓库
wget -q -O – https://packages.grafana.com/gpg.key | apt-key add –
add-apt-repository “deb https://packages.grafana.com/oss/deb stable main”

# 更新软件包列表并安装Grafana
apt update
apt install -y grafana

# 启动Grafana服务并设置开机自启动
systemctl start grafana-server
systemctl enable grafana-server

# 打印安装完成信息
echo “Zabbix 7.0 LTS 和 Grafana 已成功安装并配置完成!”
echo “请访问 http://服务器IP 以完成Zabbix前端的设置。”
echo “请访问 http://服务器IP:3000 以访问Grafana。”

 

将此脚本保存为一个`.sh`文件(例如`install_zabbix_grafana.sh`),然后在终端中运行以下命令来执行它:

chmod +x install_zabbix_grafana.sh
sudo ./install_zabbix_grafana.sh

 

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇