配置yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
清理缓存
yum clean all
yum makecache
安装zabbix、初始化mysql、zabbix数据库

Yum -y install zabbix-server-mysql zabbix-web-mysql mariadb-server zabbix-agent
启动数据库并设置为开机自启
systemctl start mariadb
systemctl enable mariadb
修改mysql密码
mysql_secure_installation
进入mysql
Mysql -p123456
创建数据库和授权刷新
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
解压包
zcat /usr/share/doc/zabbix-server-mysql-4.0.5/create.sql.gz|mysql -uzabbix -p123456 zabbix
配置zabbix修改时间
vim /etc/httpd/conf.d/zabbix.conf
Centos7 Zabbix监控mysql
启动httpd并设置为开机自启
systemctl start httpd
systemctl enable httpd
改zabbix-server配置文件添加密码
vim /etc/zabbix/zabbix_server.conf
Centos7 Zabbix监控mysql
启动zabbix-server并设置为开机自启
systemctl start zabbix-server
systemctl enable zabbix-server
改zabbix-agent配置文件ip
vim /etc/zabbix/zabbix_agentd.conf

访问http://192.168.10.157/zabbix进入zabbix页面

在另外一台虚拟机安装zabbix-agent 和mysql
yum -y install zabbix-agent mariadb-server
改zabbix-agent配置文件中的ip(要写zabbix-server的ip)
vim /etc/zabbix/zabbix_agentd.conf
Centos7 Zabbix监控mysql
Centos7 Zabbix监控mysql
启动zabbix-agent并设置为开机自启
systemctl start zabbix-agent
systemctl enable zabbix-agent
启动数据库并设置为开机自启
systemctl start mariadb
systemctl enable mariadb
访问zabbix页面创建主机群组
Centos7 Zabbix监控mysql_第1张图片
创建主机
Centos7 Zabbix监控mysql_第2张图片
创建监控项
Centos7 Zabbix监控mysql_第3张图片
创建触发器
Centos7 Zabbix监控mysql_第4张图片
创建图形

Centos7 Zabbix监控mysql_第5张图片
Centos7 Zabbix监控mysql_第6张图片