一、主机信息
- UOS系统版本:UOS Server 20 (1070e)
- zabbix版本:5.0
二、安装相关软件
[root@omnis ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent mariadb-server httpd php-fpm zabbix-apache-conf
三、初始化数据库
[root@omnis ~]# systemctl start mariadb
[root@omnis ~]# systemctl enable mariadb
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
[root@omnis ~]# mysqladmin -u root password 'Thzk211!'
[root@omnis ~]# mysql -uroot -p'Thzk211!'
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 10.3.39-MariaDB MariaDB Server
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)]>
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> create user zabbix@localhost identified by 'Zabbix123!';
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]>
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]>
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> exit
Bye
四、导入初始架构和数据
[root@omnis ~]# zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uzabbix -pZabbix123! zabbix
五、修改配置文件
5.1、修改zabbix-server.conf文件
[root@omnis ~]# grep -Ev "^#|^$" /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=127.0.0.1
DBName=zabbix
DBUser=zabbix
DBPassword=Zabbix123!
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
[root@omnis ~]#
5.2、修改zabbix.conf.php文件
[root@omnis ~]# grep -Ev "^/|^$" /usr/share/zabbix/conf/zabbix.conf.php
<?php
$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = '127.0.0.1';
$DB['PORT'] = '3306';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'Zabbix123!';
$DB['SCHEMA'] = '';
$DB['ENCRYPTION'] = false;
$DB['KEY_FILE'] = '';
$DB['CERT_FILE'] = '';
$DB['CA_FILE'] = '';
$DB['VERIFY_HOST'] = false;
$DB['CIPHER_LIST'] = '';
$DB['DOUBLE_IEEE754'] = true;
$ZBX_SERVER = 'localhost';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = '';
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
[root@omnis ~]#
5.3、修改php.ini文件
[root@omnis ~]# cat /etc/php.ini | grep date.timezone
; http://php.net/date.timezone
date.timezone = Asia/Shanghai
[root@omnis ~]#
六、启动服务并登录前端页面进行访问
[root@omnis ~]# systemctl start zabbix-server zabbix-agent httpd
[root@omnis ~]# systemctl enable zabbix-server zabbix-agent httpd
访问地址: http://IP地址/zabbix
image.png