zabbix后续

mysql监控

[root@server11 ~]# vim /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf 
[root@server11 ~]# mkdir /var/lib/zabbix       ##建立文件目录(userparameter_mysql.conf指定 )
[root@server11 ~]# cd /var/lib/zabbix/
[root@server11 zabbix]# vim .my.cnf     ##编辑配置文件
[mysql]
host = localhost
user = zabbix
password = westos
socket = /var/lib/mysql/mysql.sock
[mysqladmin]
host = localhost
user = zabbix
password = westos
socket = /var/lib/mysql/mysql.sock

[root@server11 zabbix]# systemctl restart zabbix-agent

[root@server11 ~]# rpm -ivh percona-zabbix-templates-1.1.8-1.noarch.rpm    ##需要模板,引用现成的percona模板
[root@server11 zabbix_agentd.d]# cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
[root@server11 zabbix_agentd.d]# pwd
/etc/zabbix/zabbix_agentd.d
[root@server11 zabbix_agentd.d]# ls
userparameter_mysql.conf  userparameter_percona_mysql.conf
[root@server11 zabbix_agentd.d]# systemctl restart zabbix-agent
[root@server11 zabbix_agentd.d]# cd /var/lib/zabbix/percona/scripts/
[root@server11 scripts]# ls
get_mysql_stats_wrapper.sh  ##通过这个脚本执行  
ss_get_mysql_stats.php      ##通过php这个脚本访问数据库文件
[root@server11 scripts]# cd /tmp/
[root@server11 tmp]# ls     ##这个目录下保存提取出的数据库文件并格式化
systemd-private-e8dd855afa664b96a7b04332a7795dfa-httpd.service-5B6lGG
systemd-private-e8dd855afa664b96a7b04332a7795dfa-mariadb.service-vTGU3V
[root@server11 scripts]# vim /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php.cnf
<?php
$mysql_user = 'root';
$mysql_pass = 'westos';
[root@server11 zabbix_agentd.d]# mysql_secure_installation  ##设置数据库密码
[root@server11 zabbix_agentd.d]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
15
[root@server11 zabbix_agentd.d]# cat /tmp/localhost-mysql_cacti_stats.txt   ##显示文件信息
[root@server11 zabbix_agentd.d]# rm -rf /tmp/localhost-mysql_cacti_stats.txt    ##用其他用户时最好删掉,否则因权限问题无法写入,或者增加权限

[root@server11 zabbix]# vim /var/lib/zabbix/.my.cnf ##根据官网重写
[client]
user = root
password = westos

[root@server11 zabbix]# vim /var/lib/zabbix/.my.cnf
[client]
user = zabbix       ##第二次更改为zabbix
password = westos

[root@server11 templates]# sudo -u zabbix -H /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh running-slave
0

[root@server11 templates]# scp zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.8.xml [email protected]:/home/kiosk/Desktop        ##复制模板

导入模板(会因时间格式问题报错,我用的现成的)
这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

tomcat

[root@server1 ~]# rpm -ivh jdk-8u121-linux-x64.rpm 
[root@server1 ~]# tar zxf apache-tomcat-7.0.37.tar.gz -C /usr/local/
[root@server1 ~]# cd /usr/local/
[root@server1 local]# ln -s apache-tomcat-7.0.37/ tomcat
[root@server1 local]# cd tomcat/bin/
[root@server1 bin]# ./startup.sh
[root@server1 bin]# netstat -antlp      ##80端口查看

[root@server11 ~]# yum install zabbix-java-gateway-3.4.6-1.el7.x86_64.rpm -y

[root@server1 ~]# cd /usr/local/tomcat/bin/
*******************************************************
CATALINA_OPTS='-Dcom.sun.management.jmxremote
        -Dcom.sun.management.jmxremote.port=8888
        -Dcom.sun.management.jmxremote.ssl=false
        -Dcom.sun.management.jmxremote.authenticate=false'
*******************************************************
[root@server1 bin]# ./shutdown.sh
[root@server1 bin]# ./startup.sh
[root@server1 bin]# netstat -antlp  ##查看有没有添加8888端口

[root@server11 ~]# cd /etc/zabbix/
[root@server11 zabbix]# vim zabbix_java_gateway.conf    ##配置gateway
LISTEN_IP=172.25.18.11  ##监听服务ip
LISTEN_PORT=10052   ##监听服务端口
START_POLLERS=5     ##进程数

[root@server11 zabbix]# vim zabbix_server.conf
JavaGateway=172.25.18.11    ##监听网关
JavaGatewayPort=10052       ##监听端口
StartJavaPollers=5      ##进程数

[root@server11 zabbix]# systemctl start zabbix-java-gateway
[root@server11 zabbix]# systemctl restart zabbix-server

模型:
server -> java gatewat -> tomcat

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

[root@server2 ~]# yum install zabbix-agent-3.4.6-1.el6.x86_64.rpm -y   ##反向代理,降低server压力,客户端主动发送给server端
[root@server2 ~]# vim /etc/zabbix/zabbix_agentd.conf
StartAgents=0
ServerActive=172.25.18.11
Hostname=server2

或者

[root@server2 ~]# yum install zabbix-agent-3.4.6-1.el6.x86_64.rpm -y   
[root@server2 ~]# vim /etc/zabbix/zabbix_agentd.conf
server=172.25.18.11
StartAgents=3
ServerActive=172.25.18.11
Hostname=server2

添加template OS Linux模块
这里写图片描述

克隆
这里写图片描述

改名(在其后加active)
这里写图片描述

选择监控项批量更新
这里写图片描述

类型改为主动
这里写图片描述

选择模板(更新)
这里写图片描述

proxy

[root@server2 ~]# /etc/init.d/zabbix-agent stop      ##停止agent,zabbix中删除server2
[root@server2 ~]# yum install zabbix-proxy-mysql-3.4.6-1.el6.x86_64.rpm fping-2.4b2-16.el6.x86_64.rpm -y
[root@server2 zabbix-proxy-mysql-3.4.6]# yum install mysql-server -y
[root@server2 zabbix-proxy-mysql-3.4.6]# /etc/init.d/mysqld start
[root@server2 zabbix-proxy-mysql-3.4.6]# mysql
mysql> create database zabbix_proxy character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix_proxy.* to zabbix@localhost identified by 'westos';

[root@server2 zabbix-proxy-mysql-3.4.6]# zcat schema.sql.gz | mysql zabbix_proxy
[root@server2 zabbix-proxy-mysql-3.4.6]# vim /etc/zabbix/zabbix_proxy.conf
Server=172.25.18.11
ServerPort=10051
Hostname=server2
DBPassword=westos
[root@server2 zabbix-proxy-mysql-3.4.6]# /etc/init.d/zabbix-proxy start

[root@server1 ~]# vim /etc/zabbix/zabbix_agentd.conf   ##客户端更改为代理ip
Server=172.25.18.2
ServerActive=172.25.18.2
[root@server1 ~]# /etc/init.d/zabbix-agent restart


[root@server2 zabbix-proxy-mysql-3.4.6]# /etc/init.d/zabbix-proxy restart
[root@server1 ~]# /etc/init.d/zabbix-agent restart
[root@server1 ~]# cat /var/log/zabbix/zabbix_agentd.log

删除之前的server2–agent,在server2上装proxy
这里写图片描述

这里写图片描述

添加到proxy
这里写图片描述

server1前显示proxy server2
这里写图片描述

#

猜你喜欢

转载自blog.csdn.net/goddevin/article/details/80181984