zabbix官网:https://www.zabbix.com/cn
系统版本:CentOS-7.6
zabbix版本:5.0LTS
1、安装zabbix
1.更新yum源
# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
# yum clean all
2.安装Zabbix server,Web前端,agent
# yum install zabbix-server-mysql zabbix-agent
3.安装zabbix前端
# yum install centos-release-scl
4.编辑配置文件 /etc/yum.repos.d/zabbix.repo 并启用zabbix前端存储库
# vim /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
...
enabled=1
...
#安装zabbix前端包
# yum install zabbix-web-mysql-scl zabbix-apache-conf-scl
5.创建初始数据库(MySQL安装步骤忽略)
# mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by 'password';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> set global log_bin_trust_function_creators = 1;
mysql> quit;
导入初始架构和数据,系统将提示您输入新创建的密码。
# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -ppassword zabbix
# mysql -uroot -ppassword
mysql> set global log_bin_trust_function_creators = 0;
mysql> quit;
为Zabbix server配置数据库
# vim /etc/zabbix/zabbix_server.conf
...
DBPassword=password
...
6.为Zabbix前端配置PHP(修改时区)
# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai
7.启动Zabbix server和agent进程并设置开机自启动
# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
2、利用自带模板监控MySQL
1.安装zabbix-agent
# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
# yum clean all
# yum install zabbix-agent
# systemctl restart zabbix-agent
# systemctl enable zabbix-agent
# vim /etc/zabbix/zabbix_agentd.conf
...
Server=<zabbix-serve IP>
...
2.配置MySQL监控
# cp /usr/share/doc/zabbix-agent-5.0.34/userparameter_mysql.conf /etc/zabbix/zabbix_agentd.d
# systemctl restart zabbix-agent
# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
# ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/mysqladmin
# mysql -e "CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '123456';"
# mysql -e "GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';"
# mkdir /var/lib/zabbix
# vim /var/lib/zabbix/.my.cnf
[client]
user='zbx_monitor'
password='123456'
3.web界面添加主机监控模板
模板选择:Template DB MySQL by Zabbix agent
标签:5.0,MySQL,zabbix,agent,server,Zabbix,yum,mysql
From: https://www.cnblogs.com/log4g/p/17421253.html