zabbix监控的搭建mysql
zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。linux
zabbix的应用场景:web
推荐博客:https://my.oschina.net/xiaotaochen/blog/1519497sql
1、安装server端数据库
一、首先在server端安装一个网络yum包:vim
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm安全
二、安装zabbix server端:监控端服务器
yum install -y zabbix-server-mysql zabbix-web-mysql网络
三、安装数据库:mariadb分布式
yum groupinstall -y mariadb mariadb-client
四、修改mariadb配置文件
vim /etc/my.cnf
character-set-server=utf8 #设置字符集为utf8
innodb_file_per_table=1 #让innodb的每一个表文件单独存储
五、将mariadb服务开机自动启动和重启服务:
systemctl enable mariadb
systemctl restart mariadb
执行安全操做:
mysql_secure_installation
mysql -uroot -predhat
建立数据库zabbix,受权给用户zabbix访问本地数据库:
a、MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
b、MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
c、MariaDB [(none)]> flush privileges;
在数据库里面导入表:
cd /usr/share/doc/zabbix-server-mysql-3.2.1/
解压缩:gzip -d create.sql.gz
mv /usr/share/doc/zabbix-server-mysql-3.2.1/create.sql /root
登陆zabbix数据库:mysql -uzabbix -pzabbix zabbix
将create.sql表导入数据库:source create.sql
六、配置文件vim /etc/zabbix/zabbix_server.conf
DBPassword=zabbix
七、重启服务(使用rhel7.2,否则7.0要升级)
systemctl enable zabbix-server.service
systemctl restart zabbix-server.service
八、PHP:在配置文件修改时区
重启http服务:
systemctl restart httpd
九、实验的验证:http://172.25.254.132/zabbix
注意:防火墙这边我都没设置,故能够直接关闭防火墙和关闭selinux
2、安装客户端(zabbix-agent):
一、在agent端上安装网络yum源包:
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
二、安装监控主机zabbix-agent
a、yum install -y zabbix-agent
b、要修改好配置文件以后才启动服务。
vim /etc/zabbix/zabbix_agentd.conf 配置文件
Server=172.25.254.132 监控的服务器是谁!
Hostname=chen 监控主机:hostname最左边的字段
systemctl restart zabbix-agent.service 配置改完重启服务
三、建立主机
四、对zabbix-get命令简单的测试
在server端安装zabbix-get包!
yum install -y zabbix-get
zabbix_get --help
zabbix_get -s 172.25.254.133 -k system.hostname
zabbix_get -s 172.25.254.131 -k system.cpu.util[0,user,avg5]