一, zabbix 安装与基本配置
1, 配置 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?
- Yum clean all
- Yum makecache
2, 安装 zabbix, 初始化 MySQL,zabbix 数据库
- yum install zabbix-server-MySQL zabbix-web-MySQL mariadb-server zabbix-agent -y
- systemctl start mariadb
- systemctl enable mariadb
- mysql_secure_installation
- 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.4/create.sql.gz|MySQL -uzabbix -p123456 zabbix
3, 配置 zabbix
- VIM /etc/httpd/conf.d/zabbix.conf
- php_value date.timezone Asia/Shanghai
- systemctl start httpd
- systemctl enable httpd
- VIM /etc/zabbix/zabbix_server.conf
- DBPassword=123456
- systemctl start zabbix-server
- systemctl enable zabbix-server
- VIM /etc/zabbix/zabbix_agentd.conf
- Server=192.168.100.110
- ServerActive=192.168.100.110 #主动模式的 server IP 地址
- systemctl start zabbix-agent
- systemctl enable zabbix-agent
- http://192.168.100.100/zabbix/setup.php
2,MySQL 监控: MySQL 登录有密码
(1) 修改 userparameter_mysql.conf
- VIM userparameter_mysql.conf
- UserParameter=MySQL.status[],echo "show global status where Variable_name='$3';" | HOME=/var/lib/zabbix MySQL -u$1 -p$2 -N | awk '{print $$2}'
- UserParameter=MySQL.ping[],HOME=/var/lib/zabbix mysqladmin -u$1 -p$2 ping | grep -c alive
- UserParameter=MySQL.version,MySQL -V
(2) 修改 MySQL 默认模板
(3) 被监控主机重新链接模板
(4) 查看数据
(5) 监控 MySQL 主从状态
- VIM userparameter_mysql.conf
- UserParameter=MySQL.rep[*],MySQL -u$1 -p$2 -e "show slave status \G;"|grep -E "Slave_IO_Running|Slave_SQL_Running"|grep -c "Yes"
创建监控项
查看图形
(6) 创建模板, 复制监控项
(7) 导入导出模板
来源: http://www.bubuko.com/infodetail-2987853.html