云计算运维

Windows Server 2003 - Windows Server 2019 系统工具,Linux系统脚本,Mysql、Nginx、PHP、Redis、K8S、Seafile、Weblogic 、Jenkins、DNS、DHCP、FTP、IIS、Zookeeper、Rabbitmq、Oracle、Tomcat、Mavrn等服务搭建维护,请关注我.

Ubuntu-24.04 安装 zabbix-7.4


1. 安装 repo 源

## 切换用户
$ sudo -s
## 下载 deb 文件
# wget https://mirrors.huaweicloud.com/zabbix/zabbix/7.4/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest+ubuntu24.04_all.deb
## 安装
# dpkg -i zabbix-release_latest+ubuntu24.04_all.deb
## 更新
# apt update -y

2. 安装数据库

# apt install -y mariadb-server
# systemctl enable --now mariadb
## 初始化数据库
# mariadb-secure-installation 
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.
Enter current password for root (enter for none): 
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] n
 ... skipping.
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n] y
New password: root@123
Re-enter new password: root@123
Password updated successfully!
Reloading privilege tables..
 ... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
 ... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
 ... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
 ... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!

3. 安装 zabbix server,web前端,agent

# apt install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent -y

4. 创建数据库并导入数据


## 创建数据库并授权用户
# mysql -uroot -p
MariaDB [(none)]> create database zabbix character set utf8mb4 collate utf8mb4_bin;
MariaDB [(none)]> create user zabbix@localhost identified by '自行设置密码';
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
MariaDB [(none)]> set global log_bin_trust_function_creators = 1;
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> \q
## 导入数据
# zcat /usr/share/zabbix/sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
## 禁用
# mysql -uroot -p 
MariaDB [(none)]> set global log_bin_trust_function_creators = 0;
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> \q

5. 配置 zabbix

## 配置数据库
# cd /etc/zabbix/
# vim zabbix_server.conf
##### content #####
# DBPassword=
DBPassword=zabbix@123
##### / #####
# vim nginx.conf
##### content #####
listen          30000;
##### / #####

6.配置 nginx


# vim /etc/nginx/nginx.conf
##### content #####
include /etc/nginx/conf.d/*.conf;
include /etc/zabbix/nginx.conf;
include /etc/nginx/sites-enabled/*;
##### / #####

7.启动服务并设置开机自启动

# systemctl enable --now zabbix-server zabbix-agent nginx php8.3-fpm

8.web 界面

http://192.168.235.202:30000/setup.php
## 注意:使用默认的 Admin:zabbix 初次登录,登录后修改密码

9.安装 agent 主机


## 切换用户
$ sudo -s
## 下载 deb 文件
# wget https://mirrors.huaweicloud.com/zabbix/zabbix/7.4/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest+ubuntu24.04_all.deb
## 安装 deb 包
# dpkg -i zabbix-release_latest+ubuntu24.04_all.deb
## 更新
# apt update -y
## 安装 agent
# apt install -y zabbix-agent
## 配置 agent
# cd /etc/zabbix/
# vim zabbix_agentd.conf
##### content #####
Server=服务端IP #允许哪些Zabbix Server来拉取数据(被动检查),Zabbix Server IP
ServerActive=服务端IP:10051 #允许哪些Zabbix Server来接收主动检查,Zabbix Server IP
Hostname=服务端名称 #重要!此处的Hostname必须和在Web界面创建主机时使用的主机名称一致
##### / #####
# systemctl enable --now zabbix-agent

10.添加 agent 主机

  • 分享: