3.3.1 zabbix proxy安装(源码方式)
1.创建目录
mkdir -p /usr/local/zabbix
2.安装必要软件
yum install -y fping(若安装不成功) 或 wget http://pkgs.repoforge.org/fping/fping-3.1-1.el6.rf.i686.rpm yum install -y gcc make cmake mysql-server mysql-devel php php-gd php-devel php-mysql php-bcmath php-ctytpe php-xml php-xmlreader php-xlmwriter php-session php-net-socket php-mbstring php-gettext httpd net-snmp curl curl-devel net-snmp net-snmp-devel perl-DBI libxml libxml2-devel
3. 添加用户
groupadd zabbix
useradd -g zabbix zabbix -s /sbin/nologin
4. 创建数据库
service mysqld start
mysql -uroot -p
>create database zabbix_proxy default charset utf8;
> grant all on zabbix_proxy.* to zabbix@localhost identified by 'zabbix';
>flush privileges;
>exit
5. 导入数据库中的表
cd /root/zabbix-2.2./database/mysql
# mysql -uzabbix -pzabbix zabbix < schema.sql (proxy端只需要这一步,不需要数据)
6. 编译安装(proxy和client)
proxy:
cd /root/zabbix-2.2.
./configure --enable-agent --enable-proxy --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --prefix=/usr/local/zabbix
make && make install agent:
cd /root/zabbix-2.2.4
./configure --enable-agent --prefix=/usr/local/zabbix
make && make install
7. 编辑配置文件(zabbix_proxy)
cd /usr/local/zabbix/etc/ vi /usr/local/zabbix/etc/zabbix_proxy.conf
Server=192.168.1.100
Hostname=db-proxy
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
ProxyLocalBuffer=
ProxyOfflineBuffer=
ConfigFrequency=
DataSenderFrequency=
StartPollers=
StartIPMIPollers=
StartPollersUnreachable=
StartTrappers=
StartPingers=
StartHTTPPollers=
StartVMwareCollectors=
VMwareCacheSize=40M
StartSNMPTrapper=
CacheSize=100M
StartDBSyncers=
HistoryCacheSize=100M
HistoryTextCacheSize=200M
Timeout=
LogSlowQueries=
AllowRoot=
8. 配置proxy的agent文件
vi /usr/local/zabbix/etc/zabbix_agentd.conf修改如下内容:
Server=192.168.1.100
ServerActive=192.168.1.100
Hostname=db-proxy
RefreshActiveChecks=
MaxLinesPerSecond=
Timeout=
AllowRoot=
UnsafeUserParameters=
UserParameter=system.agent.checkSecure,/usr/local/ServerScript/check_secure.sh
9. 添加到services
# vi /etc/services
在文件最后面添加如下的内容:
zabbix-agent /tcp # Zabbix Agent
zabbix-agent /udp # Zabbix Agent
zabbix-trapper /tcp # Zabbix Trapper
zabbix-trapper /udp # Zabbix Trapper
10. 启动守护进程
vi /etc/init.d/zabbix_proxy
vi /etc/init.d/zabbix_agentd
添加后面的脚本
chmod a+x /etc/init.d/zabbix_proxy
chmod a+x /etc/init.d/zabbix_agentd
service zabbix_proxy start
service zabbix_agentd start
11. 添加开机启动
chkconfig zabbix_proxy on
chkconfig zabbix_agentd on
12. 允许10050和10051通过防火墙
iptables -A INPUT -p tcp --dport -j ACCEPT
iptables -A INPUT -p tcp --dport -j ACCEPT
或者关闭防火墙
service iptables stop
setenforce
13. 启动服务
service zabbix_proxy start
service zabbix_agentd start
3.3.2 Agent端配置
1.修改客户(agent)端配置文件
vi /usr/local/zabbix/etc/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agented_om.pid
LogFile=/var/log/zabbix/zabbix_agented_om.log
LogFileSize=
Server=10.19.1.18
ListenPort=
ServerActive=10.19.1.18
Hostname=db-proxy
Include=/etc/zabbix_agentd_om/etc/zabbix_agentd.conf.d/
2.重启客户端
service zabbix_agentd restart
3.脚本zabbix_proxy
#!/bin/sh
# chkconfig:
# desctription: Zabbix Proxy
# Zabbix
# Copyright (C) - Zabbix SIA
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., Franklin Street, Fifth Floor, Boston, MA -, USA. # Start/Stop the Zabbix agent daemon.
# Place a startup script in /sbin/init.d, and link to it from /sbin/rc[].d SERVICE="Zabbix proxy"
DAEMON=/usr/local/zabbix/sbin/zabbix_proxy
PIDFILE=/tmp/zabbix_agentd.pid
BASEDIR=/usr/local/zabbix/
ZABBIX_AGENTD=$BASEDIR/sbin/zabbix_proxy
case $ in
'start')
if [ -x ${DAEMON} ]
then
$DAEMON
# Error checking here would be good...
echo "${SERVICE} started."
else
echo "Can't find file ${DAEMON}."
echo "${SERVICE} NOT started."
fi
;;
'stop')
if [ -s ${PIDFILE} ]
then
if kill `cat ${PIDFILE}` >/dev/null >&
then
echo "${SERVICE} terminated."
rm -f ${PIDFILE}
fi
fi
;;
'restart')
$ stop
sleep
$ start
;;
*)
echo "Usage: $0 start|stop|restart"
;;
esac
4.脚本zabbix_agentd
#!/bin/sh
#chkconfig:
#description:Zabbix agent
# Zabbix
# Copyright (C) - Zabbix SIA
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., Franklin Street, Fifth Floor, Boston, MA -, USA. # Start/Stop the Zabbix agent daemon.
# Place a startup script in /sbin/init.d, and link to it from /sbin/rc[].d SERVICE="Zabbix agent"
DAEMON=/usr/local/zabbix/sbin/zabbix_agentd
PIDFILE=/tmp/zabbix_agentd.pid
BASEDIR=/usr/local/zabbix
ZABBIX_AGENTD=$BASEDIR/sbin/zabbix_agentd case $ in
'start')
if [ -x ${DAEMON} ]
then
$DAEMON
# Error checking here would be good...
echo "${SERVICE} started."
else
echo "Can't find file ${DAEMON}."
echo "${SERVICE} NOT started."
fi
;;
'stop')
if [ -s ${PIDFILE} ]
then
if kill `cat ${PIDFILE}` >/dev/null >&
then
echo "${SERVICE} terminated."
rm -f ${PIDFILE}
fi
fi
;;
'restart')
$ stop
sleep
$ start
;;
*)
echo "Usage: $0 start|stop|restart"
;;
Esac
3.3.2 zabbix proxy安装(yum安装方式简要安装)
1、安装yum源
yum clean all
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
2、安装proxy和agent
yum install zabbix-proxy-3.0. zabbix-proxy-mysql-3.0. zabbix-agent-3.0.
yum install zabbix-agent-3.0.
3、导入表文件
mysql -uzabbix -pzabbix zabbix_proxy < schema.sql
4、数据库授权
use mysql
grant all privileges on *.* to root@"%" identified by "EhqSDFW{OZzS7XX";
update user set password= password('EhqW{OZSFDzS7XX') where user='root';
flush privileges; create database zabbix_proxy default charset utf8;
grant all on zabbix_proxy.* to zabbix@localhost identified by 'zabbix';
flush privileges;
5、配置proxy
cat /etc/zabbix/zabbix_proxy.conf
LogFile=/var/log/zabbix/zabbix_proxy.log
PidFile=/var/log/zabbix/zabbix_proxy.pid
Server=172.29.31.112
Hostname=gz-qxg-proxy
DBName=zabbix_proxy
DBUser=zabbix
DBPassword=zabbix
ProxyLocalBuffer=
ProxyOfflineBuffer=
ConfigFrequency=
DataSenderFrequency=
StartPollers=
StartIPMIPollers=
StartPollersUnreachable=
StartTrappers=
StartPingers=
StartHTTPPollers=
StartVMwareCollectors=
VMwareCacheSize=40M
StartSNMPTrapper=
CacheSize=256M
StartDBSyncers=
HistoryCacheSize=256M
Timeout=
LogSlowQueries=
6、启动服务
启动proxy
service zabbix-proxy start
启动agent
service zabbix-agent start