zabbix部署

zabbix部署

1 安装zabbix仓库

1.1 下载 zabbix5.0

root@localhost(192.168.199.52)~>wget http://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

1.2 安装

root@localhost(192.168.199.52)~>rpm -ivh zabbix-release-5.0-1.el7.noarch.rpm 

root@localhost(192.168.199.52)~>yum repolist 
repo id                         repo name                                             status
base/7/x86_64                   CentOS-7 - Base - mirrors.aliyun.com                  10,072
extras/7/x86_64                 CentOS-7 - Extras - mirrors.aliyun.com                   518
updates/7/x86_64                CentOS-7 - Updates - mirrors.aliyun.com                5,283
zabbix/x86_64                   Zabbix Official Repository - x86_64                      420
zabbix-non-supported/x86_64     Zabbix Official Repository non-supported - x86_64          5
repolist: 16,298
root@localhost(192.168.199.52)~

1.3 安装zabbix-server和zabbix-agent zabbix-get

root@localhost(192.168.199.52)~>yum install zabbix-server-mysql zabbix-agent  zabbix-get -y

若安装慢。可以在repo文件中将zabbix的下载目录改为阿里的下载

sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo

1.4 安装zabbix前端

root@localhost(192.168.199.52)~>yum install centos-release-scl -y

1.5 使frontend生效

编辑配置文件/etc/yum.repos.d/zabbix.repo,使zabbix-frontend 仓库生效

[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

1.6 安装前端软件包

root@localhost(192.168.199.52)~> yum install zabbix-web-mysql-scl zabbix-apache-conf-scl

2 安装mysql

本次安装采用mysql8.0版本

2.1 直接安装离线包

root@localhost(192.168.199.52)~/mysql-server-8.0.25>ls
mysql-community-client-8.0.25-1.el7.x86_64.rpm
mysql-community-client-plugins-8.0.25-1.el7.x86_64.rpm
mysql-community-common-8.0.25-1.el7.x86_64.rpm
mysql-community-libs-8.0.25-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.25-1.el7.x86_64.rpm
mysql-community-server-8.0.25-1.el7.x86_64.rpm

root@localhost(192.168.199.52)~/mysql-server-8.0.25>yum localinstall *.rpm -y

2.2 初始化数据库

root@localhost(192.168.199.52)~>systemctl enable --now mysqld
root@localhost(192.168.199.52)~>ps -ef |grep mysql
mysql      3198      1  8 16:16 ?        00:00:00 /usr/sbin/mysqld
root       3242   2330  0 16:16 pts/0    00:00:00 grep --color=auto mysql
root@localhost(192.168.199.52)~>grep password /var/log/mysqld.log 
2023-09-25T08:16:23.602831Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Tfn>i)l28VPk
root@localhost(192.168.199.52)~>mysql -uroot -p'Tfn>i)l28VPk'

mysql> alter user 'root'@'localhost' identified by 'AAAaaa111.';
Query OK, 0 rows affected (0.01 sec)

mysql> set global validate_password.policy=0;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password.length=1;
Query OK, 0 rows affected (0.00 sec)

mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.01 sec)

2.3 配置

mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by '123456';  #根据需要修改password
grant all privileges on zabbix.* to zabbix@localhost;
mysql> ALTER USER 'zabbix'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';  #一定要做这一步 低版本的客户端连接不到mysql8.0



2.4 导入数据

zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix


root@localhost(192.168.199.52)~>mysql -uroot -p -e 'use zabbix;show tables;'
Enter password: 
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
| alerts                     |
| application_discovery      |
| application_prototype      |
| application_template       |
| applications               |
| auditlog                   |
| auditlog_details           |

导入成功

3 zabbix配置

3.1 zabbix server配置数据库

编辑配置文件/etc/zabbix/zabbix_server.conf

DBPassword=123456

3.2 zabbix配置php

编辑配置文件/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf设置时区

php_value[date.timezone] = Asia/Shanghai  #最后一行

4 启动

systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm

访问:http://192.168.199.52/zabbix 后面加zabbixzabbix

你可能感兴趣的:(zabbix,zabbix)