CentOS8 部署 zabbix-server

发布于:2022-11-05 ⋅ 阅读:(845) ⋅ 点赞:(0)

环境

真机:win11专业版,VMware workstation16

虚拟机:CentOS Stream 8  ip:192.168.8.20  DNS:192.168.8.2      nat8 联网

一、防火墙与selinux配置

firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=10051/tcp
firewall-cmd --permanent --add-port=10050/tcp
firewall-cmd --permanent --add-port=3306/tcp
firewall-cmd --permanent --add-port=3306/udp
firewall-cmd --reload
setsebool -P httpd_can_connect_zabbix on
setsebool -P httpd_can_network_connect_db on
# 下面是在启动 zabbix_server 报错后添加的
ausearch -c 'zabbix_server' --raw | audit2allow -M my-zabbixserver
semodule -X 300 -i my-zabbixserver.pp

二、部署 zabbix-server

2.1、配置 zabbix 下载源

vim /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/8/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591


[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/8/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1

2.2、安装 Zabbix server,Web 前端, agent

dnf -y install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-agent

2.3、初始化数据库

a、/etc/my.cnf

# vim /etc/my.cnf
# 仅适用于小规模,小于1000台设备的zabbix-agent
[mysqld]
# root 原始密码为空
skip-grant-tables

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# 设置字符集为 UTF-8
character-set-server=utf8
# 让 InnoDB 的每个表文件单独存储
innodb_file_per_table=1

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[client-server]
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

b、/etc/my.cnf.d/client.cnf

# cat /etc/my.cnf.d/client.cnf
#
# These two groups are read by the client library
# Use it for options that affect all clients, but not the server
#

[client]
socket=/var/lib/mysql/mysql.sock

# This group is not read by mysql client library,
# If you use the same .cnf file for MySQL and MariaDB,
# use it for MariaDB-only client options
[client-mariadb]
socket=/var/lib/mysql/mysql.sock

c、安装数据库,并初始化

yum install mariadb mariadb-server -y
systemctl start mariadb
systemctl enable mariadb
ps -ef | grep mysql
lsof -i :3306
msyql_secure_installation

2.4、数据库用户管理

# 设置 root 密码为 admin
# mysqladmin -uroot password admin
mysql -u root -p

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.000 sec)

MariaDB [(none)]> create user long90@'%' identified by 'Tangyulong90?';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> create user zabbix@'%' identified by 'Zabbix90?';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]>  grant all privileges on *.* to long90@'%';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> grant all on zabbix.* to zabbix@'%';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@'%' identified by 'Zabbix90?';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> grant all privileges on *.* to long90@'%' identified by 'Tangyulong90?';
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> exit
Bye

2.5 导入zabbix-server 初始架构和数据

zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uzabbix -p zabbix
vim /etc/zabbix/zabbix_server.conf
DBPassword=Zabbix90?

2.6、为 Zabbix 前端配置 PHP

vim /etc/php-fpm.d/zabbix.conf
# 末行
php_value[date.timezone] = Asia/Shanghai

2.7、启动Zabbix server和agent进程 zabbix_server 10051 10050

systemctl restart zabbix-server zabbix-agent httpd php-fpm
systemctl enable zabbix-server zabbix-agent httpd php-fpm
netstat -ntlp

三、zabbix-server web 配置

1、真机浏览器输入 http://192.168.8.20/zabbix

 

 

 

 

 

 登陆用户选超级管理员 Admin   密码默认: zabbix

 

 


网站公告

今日签到

点亮在社区的每一天
去签到