zabbix安装
安装repo源:
rpm -ivh https://mirrors4.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm #下载后repo包会有zabbix.repo文件
sed -ri "s#repo.zabbix.com#mirrors4.tuna.tsinghua.edu.cn/zabbix#g" /etc/yum.repos.d/zabbix.repo
安装相关软件
#zabbix web运行环境为php
```
yum install httpd -y
```
#php解释器依赖,成功运行默认开放80端口
```
yum -y install php php-gd gcc php-mysql php-xml php-devel -y
```
systemctl start httpd
systemctl enable httpd
#zabbix连接mysql驱动,
```
yum install zabbix-server-mysql -y
```
#zabbix分布式连接mysql驱动
```
yum install zabbix-proxy-mysql -y
```
#zabbix 前端展示页面
```
yum install zabbix-web-mysql -y
```
#zabbix数据存储;成功运行默认开放3306端口
```
yum install mariadb-server -y
```
#zabbix被监控主机驱动
```
yum install zabbix-agent -y
```
数据库操作
systemctl start mariadb.service
systemctl enable mariadb.service
修改密码:
mysql_secure_installation
创建数据库:
create database zabbix character set utf8 collate utf8_bin;
show databases;
grant all on zabbix.* to zabbix@localhost identified by '123456'
数据表结构及默认数据导入:
rpm -ql zabbix-server-mysql #查询相关文件位置
gzip -d /usr/share/doc/zabbix-server-mysql-4.0.27/create.sql.gz
cd /usr/share/doc/zabbix-server-mysql-4.0.27/
mysql -u《zabbix:数据库用户名》 -p《root:数据库连接密码》 《zabbix:数据库名》 < create.sql
zabbix-server配置
# vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=<password>
启动
systemctl start zabbix-server.service
systemctl enable zabbix-server.service
netstat -tunlp | grep -E "\:10051"
zabibix错误解决方案
问题:/zabbix/setup 页面未找到
原因: apache的配置文件没有提供对应php版本的支持
解决办法:
重新编译安装或是yum重新安装
yum -y install php php-gd gcc php-mysql php-xml php-devel
vim /etc/httpd/conf/httpd.conf
#模块中添加php支持
DirectoryIndex index.html index.php
AddType application/x-httpd-php .php .php3 .php4 .php5
修改完成后需重新启动apache
systemctl restart httpd
问题:
解决办法:
问题:
原因: zabbix 会监控自身主机,而本身未安装agent
解决办法:
yum install zabbix-agent -y
systemctl start zabbix-agent.service
systemctl enable zabbix-agent.service
systemctl status zabbix-agent.service
netstat -tunlp | grep -E "\:10050"
Zabbix监控虚拟主机告警Lack of free swap space on Zabbix server解决办法
原因: Zabbix监控没有考虑虚拟主机的交换空间情况
解决办法: 修改配置
{[Template OS Linux:system.swap.size[,pfree\]](http://106.13.51.5/zabbix/items.php?form=update&itemid=17350).**last(**0**)**}<50 and {[Template OS Linux:system.swap.size[,free\]](http://106.13.51.5/zabbix/items.php?form=update&itemid=10014).**last(**0**)**}<>0
zabbix添加监控主机
下载监控插件
rpm -ivh https://mirrors4.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.27-1.el7.x86_64.rpm
#注意版本匹配
systemctl start zabbix-agent.service
systemctl enable zabbix-agent.service
systemctl status zabbix-agent.service
netstat -tunlp | grep -E "\:10050"
修改配置
vim /etc/zabbix/zabbix_agentd.conf
Server=106.13.51.5
systemctl restart zabbix-agent.service
添加监控主机
zabbix添加触发器
zabbix自定义报警
zabbix使用grafana自定义图形
下载grafana组件
wget https://mirrors4.tuna.tsinghua.edu.cn/grafana/yum/rpm/grafana-7.3.6-1.x86_64.rpm
yum localinstall grafana-7.3.6-1.x86_64.rpm
systemctl start grafana-server.service
systemctl enable grafana-server.service
systemctl status grafana-server.service
netstat -tunlp | grep -E "\:3000"
下载grafana插件
grafana-cli plugins list-remote #查找所有插件
grafana-cli plugins list-remote | grep zabbix
grafana-cli plugins install alexanderzobnin-zabbix-app #下载zabbix相关插件
service grafana-server restart #重启服务
grafana模板下载地址
https://grafana.com/grafana/dashboards?search=zabbix
zabbix自定义模板
zabbix 使用 percona 监控mysql
percona下载
rpm -ivh https://downloads.percona.com/downloads/percona-monitoring-plugins/percona-monitoring-plugins-1.1.8/binary/redhat/7/x86_64/percona-zabbix-templates-1.1.8-1.noarch.rpm
cd var/lib/zabbix/percona/templates
cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
zabbix 使用 percona 监控mysql
percona下载
rpm -ivh https://downloads.percona.com/downloads/percona-monitoring-plugins/percona-monitoring-plugins-1.1.8/binary/redhat/7/x86_64/percona-zabbix-templates-1.1.8-1.noarch.rpm
cd var/lib/zabbix/percona/templates
cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
percona模板导入
注意导入升级后的模板
percona测试取值
cat /etc/zabbix/zabbix_agentd.d/userparameter_percona_mysql.conf