官方网址
https://www.zabbix.com/cn/download
1.选择相关配置(这里我选择Ubuntu安装)
2.zabbix部署根据官方文档
配置数据库(我安装的数据库为mariadb)
#安装数据库
[root@zabbix ~]#apt -y install mariadb-server
#配置数据库
[root@zabbix ~]#vim /etc/mysql/mariadb.conf.d/50-server.cnf
#skip-external-locking
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 0.0.0.0
#重启数据库
[root@zabbix ~]#systemctl restart mariadb.service
#基本安全配置
[root@zabbix ~]#mysql_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
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
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]
... 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]
... 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]
- 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]
... 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!
#测试效果
[root@zabbix ~]#mysql -uroot -p123456 -e "show databases;"
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
#修改ip
[root@zabbix ~]#vim /etc/mysql/mariadb.conf.d/50-server.cnf
注意:为了避免因为 zabbix源更新后,导致数据库的冲突,所以最好先安装 mysql
软件安装:(参考官方文档)
#配置软件源
# wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-1+ubuntu20.04_all.deb
# dpkg -i zabbix-release_6.0-1+ubuntu20.04_all.deb
# apt update
#安装软件
apt install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent
# 查看版本
[root@zabbix ~]#zabbix_server -V
zabbix_server (Zabbix) 6.0.2
Revision d726a4d916 14 March 2022, compilation time: Mar 6 2022 20:53:10
Copyright (C) 2022 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.
This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/).
Compiled with OpenSSL 1.1.1f 31 Mar 2020
Running with OpenSSL 1.1.1f 31 Mar 2020
3.设置zabbix数据库
[root@zabbix ~]#mysql -uroot -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 36
Server version: 10.3.34-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> create user zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]>
导入初始架构和数据,系统将提示您输入新创建的密码。
zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -p zabbix
vim /etc/zabbix/zabbix_server.conf
[root@zabbix ~]#grep -Env '#|^$' /etc/zabbix/zabbix_server.conf
38:LogFile=/var/log/zabbix/zabbix_server.log
49:LogFileSize=0
72:PidFile=/run/zabbix/zabbix_server.pid
82:SocketDir=/run/zabbix
105:DBName=zabbix
121:DBUser=zabbix
129:DBPassword=zabbix
331:JavaGatewayPort=10052
391:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
515:Timeout=4
575:FpingLocation=/usr/bin/fping
586:Fping6Location=/usr/bin/fping6
605:LogSlowQueries=3000
720:StatsAllowedIP=127.0.0.1
[root@zabbix ~]#cd /etc/nginx/
[root@zabbix nginx]#rm -rf sites-enabled/default
[root@zabbix nginx]#vim conf.d/zabbix.conf
#修改php
# vim /etc/zabbix/php-fpm.conf
php_value[date.timezone] = Asia/Shanghai
# 重启服务
systemctl restart zabbix-server zabbix-agent php7.4-fpm nginx
netstat -tnulp | egrep 're|ngi|php|zabb'
# 设置服务开机自启动
systemctl enable zabbix-server zabbix-agent php7.4-fpm nginx
注意:zabbix的服务在ubuntu上安装后,不会自动设置为开机自启动。
常见错误:
#如果出现以下情况请修改数据库,跟数据库版本不符出现此情况
#出错原因,数据库版本过高,与官方推荐的版本不符合。
vim /etc/zabbix/zabbix_server.conf
AllowUnsupportedDBVersions=1