基本软件安装:vim、wget、
安装mysql
1、
FATAL ERROR: please install the following Perl modules before executing /usr/bin/mysql_install_db:
Data::Dumper
##解决方案:
#yum install -y perl-Module-Install.noarch
2、
[root[@localhost](https://my.oschina.net/u/570656) mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
##解决方案:
[root[@localhost](https://my.oschina.net/u/570656) mysql]# yum install -y libaio*
3、添加mysql到命令
[root@localhost ~]# vim /etc/profile
PATH=$PATH:/usr/local/mysql/bin/
[root@localhost ~]# source /etc/profile
防火墙
关闭7,开启6的防火墙:
[root@localhost ~]# systemctl stop firewalld; systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[root@localhost ~]# yum install -y iptables-services
[root@localhost ~]# systemctl start iptables
[root@localhost ~]# systemctl enable iptables
Created symlink from /etc/systemd/system/basic.target.wants/iptables.service to /usr/lib/systemd/system/iptables.service.
[root@localhost zabbix]# iptables -F
[root@localhost zabbix]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
安装netstat 等工具:
yum install net-tools
自定义脚本监控:
给与zabbix用户执行权限,并写脚本
[root@127rs1 sbin]# chmod +x zabbix1.sh
[root@127rs1 sbin]# cat zabbix1.sh
#!/bin/bash
##This is the shell script for zabbix !
netstat -ant |awk '{$5="" ; print}' |grep ':80' |grep -c 'ESTABLISHED'
这里脚本定义后,服务端获取值为0时 会报错!(相应监控也会不支持)
[root@127rs1 ~]# cat /usr/local/sbin/zabbix1.sh
#!/bin/bash
##This is the shell script for zabbix !
echo `netstat -ant |awk '{$5="" ; print}' |grep ':80' |grep -c 'ESTABLISHED'`
##将脚本的值echo一下就可以了;
[root@zabbix ~]# /usr/local/zabbix/bin/zabbix_get -s 192.168.14.127 -p 10050 -k 'my.zabbix1.count'
0
##这里就没有报错了;
自定义脚本监控2:
客户端操作--脚本:
[root@localhost sbin]# cat all.sh
#!/bin/bash
netstat -n | awk '/^tcp/ {++b[$NF]} END {for(a in b) print a,b[a]}'> /var/1.txt
case $1 in
1)
a=`cat /var/1.txt |grep 'CLOSE'`
if [ -z "$a" ]
then
echo '0'
else
cat /var/1.txt | awk '/^CLOSE/ {print $2}'
fi
;;
2)
a=`cat /var/1.txt |grep 'ESTAB'`
if [ -z "$a" ]
then
echo '0'
else
cat /var/1.txt | awk '/^ESTAB/ {print $2}'
fi
;;
3)
a=`cat /var/1.txt |grep 'TIME'`
if [ -z "$a" ]
then
echo '0'
else
cat /var/1.txt | awk '/^TIME/ {print $2}'
fi
;;
*)
echo `netstat -ant |awk '{$5="" ; print}' |grep ':80' |grep -c 'ESTABLISHED'`
;;
esac
客户端操作--配置:
[root@localhost sbin]# vim /etc/zabbix/zabbix_agentd.conf
UnsafeUserParameters=1 ##开启自定义监控;
UserParameter=my.all.count[*],/usr/local/sbin/all.sh $1
##定义key=my.all.count,其中[]里面是参数(多个用,逗号隔开)--key和参数都是在zabbix页面定义的;$1就是参数1
服务器操作--检测:
[root@localhost ~]# zabbix_get -s 192.168.60.12 -k 'my.all.count 1'
ZBX_NOTSUPPORTED: Invalid item key format.
[root@localhost ~]# zabbix_get -s 192.168.60.12 -k 'my.all.count[1]'
0
[root@localhost ~]# zabbix_get -s 192.168.60.12 -k 'my.all.count[2]'
2
[root@localhost ~]# zabbix_get -s 192.168.60.12 -k 'my.all.count[3]'
47
[root@localhost ~]# zabbix_get -s 192.168.60.12 -k 'my.all.count[4]'
0
启动程序的故障:
这里面虽然agent是active状态,但端口却没有启用;使用-l选项,查看启动状态详细信息 根据信息排错
[root@Centos-1 zabbix-3.4.1]# systemctl status zabbix_agentd -l
● zabbix_agentd.service - SYSV: Starts and stops Zabbix Agent using chkconfig
Loaded: loaded (/etc/rc.d/init.d/zabbix_agentd; bad; vendor preset: disabled)
Active: active (exited) since 四 2017-09-28 22:36:53 CST; 7min ago
Docs: man:systemd-sysv-generator(8)
9月 28 22:36:53 Centos-1 systemd[1]: Starting SYSV: Starts and stops Zabbix Agent using chkconfig...
9月 28 22:36:53 Centos-1 zabbix_agentd[21497]: Starting zabbix_agentd: /etc/init.d/functions:行573: /usr/local/sbin/zabbix_agentd: 没有那个文件或目录
9月 28 22:36:53 Centos-1 zabbix_agentd[21497]: [失败]
9月 28 22:36:53 Centos-1 systemd[1]: Started SYSV: Starts and stops Zabbix Agent using chkconfig.
使用zabbix自带mysql监控模版:
主从,延迟备份,静态备份