一、目标
在centos7.7上安装部署zabbix5.0监控系统
本帖只写如何安装zabbix5.0、如何在web上添加被监控主机
二、环境准备
zabbix拓扑和角色说明
IP Module Roles
192.168.30.12 vm12、MariaDB、Apache zabbix server/agent(主服务器/客户端)
10.1.1.20 centos 7.6 zabbix_proxy 5.0.5、MariaDB zabbix proxy/agent(代理服务器/客户端--->发送数据给主服务器)
10.1.1.101 centos 7.6 zabbix_agentd 5.0.5 zabbix agent(客户端--->发送数据给代理服务器)
10.1.1.201 centos 7.6 zabbix_agentd 5.0.5 zabbix agent(客户端--->发送数据给主服务器)
1.基础准备工作
关闭防火墙、selinux
或者开放端口,http 80 ,mysql 3306,
三、配置yum源
1、外网“阿里云”源
编写repo文件
# Centos 7 基础数据源
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#Centos 7红帽拓展组件源为了安装php7.0以上版本使用
[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
baseurl=http://mirrors.aliyun.com/centos/7/sclo/x86_64/sclo/
gpgcheck=0
[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=http://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
gpgcheck=0
#zabbix 组件源
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/
gpgcheck=0
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/frontend
gpgcheck=0
[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/debuginfo/
gpgcheck=0
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/x86_64/
gpgcheck=0
四、安装Mariadb数据库
当然你也可以安装mysql
1、vm12安装mariadb数据库
[root@vm12 ~]# yum install mariadb-server mariadb -y
[root@vm12 ~]# systemctl start mariadb
[root@vm12 ~]# systemctl enable mariadb
2.初始化mariadb数据库
[root@vm12 ~]# mysql_secure_installation
Enter current password for root (enter for none): ##这里回车
Set root password? [Y/n] ##回车
New password: ##这里输入一次root账号的密码,并回车。
Re-enter new password: ##这里再输入一次root账号的密码,并回车。
Password updated successfully!
Reloading privilege tables..
... Success!
Remove anonymous users? [Y/n] ##回车
... Success!
Disallow root login remotely? [Y/n] ##回车
... skipping.
Remove test database and access to it? [Y/n] ##回车
... skipping.
Reload privilege tables now? [Y/n] ##回车
... Success
3.创建zabbix所需的数据库、用户
[root@vm12 ~]# mysql -uroot -p123456
# 创建数据库并设置字符集为utf-8
create database zabbix character set utf8 collate utf8_bin;
# 创建用户zabbix 设置密码 zabbix
create user zabbix@localhost identified by 'zabbix';
# 给zabbix用户赋权
grant all privileges on zabbix.* to zabbix@localhost;
五、Zabbix5.0 server端的安装
1、安装zabbix主服务
[root@vm12 ~]# yum install zabbix-server-mysql zabbix-agent -y
[root@vm12 ~]# yum install zabbix-web-mysql-scl zabbix-apache-conf-scl -y
2、导入初始架构和数据
vim /usr/share/doc/zabbix-server-mysql-5.0.13/create.sql.gz
# 首行添加
use zabbix;
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix
3、修改zabbix server的主配置文件、修改数据库密码
[root@vm12 ~]# vim /etc/zabbix/zabbix_server.conf
#将
DBPassword=
#修改为
DBPassword=zabbix
#然后保存退出。
4、修改zabbix的前端页面的php时区
[root@vm12 ~]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
将
; php_value[date.timezone] = Europe/Riga
修改为
php_value[date.timezone] = Asia/Shanghai
# 解决中文乱码问题
[root@vm12 ~]# yum install wqy-microhei-fonts -y
[root@vm12 ~]# cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
5、启动zabbix server 及相关服务,并设置为开机自启
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
6、验证zabbix是否安装成功
访问http://192.168.30.12/zabbix
|