标签:zabbix;监控
实验环境:在虚拟机Vmware中安装Centos6.5 X64的操作系统 ,搭建的基础环境是LAMP环境。
实验的详细配置步骤为:
(1)yum安装LAMP环境
[root@bogon ~]# service iptables stop
[root@bogon ~]# setenforce 0
[root@bogon ~]#yum -y install gcc gcc-c++ autoconf httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-bcmath mysql-connector-odbc mysql-devel libdbi-dbd-mysql net-snmp-devel curl-devel
(2)修改php.ini
[root@bogon ~]#vi /etc/php.ini
date.timezone = Asia/Shanghai
max_execution_time = 300
post_max_size = 32M
max_input_time=300
memory_limit = 128M
mbstring.func_overload = 0
(3)开启httpd,mysqld 服务,设置开机启动
[root@bogon ~]#chkconfig mysqld on
[root@bogon ~]#chkconfig httpd on
[root@bogon ~]#service mysqld start
[root@bogon ~]#service httpd start
(4)下载zabbix包到/usr/local/src
[root@bogon ~]#cd /usr/local/src
[root@bogon~]#wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.4/zabbix-2.4.4.tar.gz
[root@bogon~]#cd
[root@bogon~]#groupadd zabbix -g 201
[root@bogon~]#useradd -g zabbix -u 201 -m zabbix
[root@bogon~]#cd /usr/local/src
[root@bogon src]#tar xvf zabbix-2.4.4.tar.gz
[root@bogon src]#cd zabbix-2.4.4
[root@bogon zabbix-2.4.4]#./configure --prefix=/usr/local/zabbix --enable-server --enable-proxy --enable-agent --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl
[root@bogon zabbix-2.4.4]#make
[root@bogon zabbix-2.4.4]#make install
(5)添加 zabbix到系统服务文件
[root@bogon zabbix-2.4.4]#vim /etc/service
zabbix-agent 10050/tcp #Zabbix Agent
zabbix-agent 10050/udp #Zabbix Agent
zabbix-trapper 10051/tcp #Zabbix Trapper
zabbix-trapper 10051/udp #Zabbix Trappe
[root@bogon zabbix-2.4.4]#tail -n4 /etc/services
zabbix-agent 10050/tcp #Zabbix Agent
zabbix-agent 10050/udp #Zabbix Agent
zabbix-trapper 10051/tcp #Zabbix Trapper
zabbix-trapper 10051/udp #Zabbix Trapper
(6)导入zabbix数据库
[root@bogon zabbix-2.4.4]#mysqladmin -uroot password ‘zht‘;
[root@bogon zabbix-2.4.4]#mysql -uroot -p
mysql>create database zabbix character set utf8;
mysql>grant all privileges on zabbix.* to zabbix@localhost identified by ‘zabbix‘;
mysql>flush privileges;
mysql>exit
[root@bogon zabbix-2.4.4]#mysql -uzabbix -pzabbix zabbix< ./database/mysql/schema.sql
[root@bogon zabbix-2.4.4]#mysql -uzabbix -pzabbix zabbix < ./database/mysql/images.sql
[root@bogon zabbix-2.4.4]#mysql -uzabbix -pzabbix zabbix < ./database/mysql/data.sql
[root@bogon zabbix-2.4.4]#mkdir /var/log/zabbix
[root@bogon zabbix-2.4.4]#chown zabbix.zabbix /var/log/zabbix
[root@bogon zabbix-2.4.4]#ln -s /usr/local/zabbix/etc /etc/zabbix
[root@bogon zabbix-2.4.4]#ln -s /usr/local/zabbix/bin/* /usr/bin/
[root@bogon zabbix-2.4.4]#ln -s /usr/local/zabbix/sbin/* /usr/sbin/
(7)拷贝 service启动脚本
[root@bogon zabbix-2.4.4]#cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
[root@bogon zabbix-2.4.4]#chmod 755 /etc/init.d/zabbix_*
[root@bogon zabbix-2.4.4]#sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g" /etc/init.d/zabbix_server
[root@bogon zabbix-2.4.4]#sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g" /etc/init.d/zabbix_agentd
(8)配置 zabbix_server.conf 服务端文件
[root@bogon zabbix-2.4.4]# vim /etc/zabbix/zabbix_server.conf
DBName=zabbix 数据库名称
DBUser=zabbix 数据库用户
DBPassword=zabbix 数据库密码
(9)配置 zabbix_agentd.conf 文件
[root@bogon zabbix-2.4.4]#vim /etc/zabbix/zabbix_agent.conf
Server=127.0.0.1此处添加服务端的ip,如服务器不为本机,则需要填写远端zabbix_server的ip 地址
UnsafeUserParameters=0 默认是不启用自定义脚本功能的,要自定义key,需开启,设置为1
Include=/etc/zabbix/zabbix_agentd.conf.d/ 自定义的agentd配置文件可以写在这个目录下面
(10)拷贝网页文件到 apache 目录
[root@bogon zabbix-2.4.4]#cp -r ./frontends/php/ /var/www/html/zabbix
[root@bogon zabbix-2.4.4]#chown -R apache.apache /var/www/html/zabbix
(11)设置 zabbix开机启动
[root@bogon zabbix-2.4.4]#chkconfig zabbix_server on
[root@bogon zabbix-2.4.4]#chkconfig zabbix_agentd on
[root@bogon zabbix-2.4.4]#service zabbix_server start
[root@bogon zabbix-2.4.4]#service zabbix_agentd start
至此,zabbix 的server 端安装完
(12)防火墙设置
[root@localhost ~]# vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10051 -j ACCEPT
-A OUTPUT -m state --state NEW -m tcp -p tcp --dport 10050 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --sport 10050 -j ACCEPT
(13)Selinux的设置
[root@localhost ~]# vim /etc/selinux/config
SELINUX=disabled
标签:zabbix;监控
原文地址:http://zht880301.blog.51cto.com/3072712/1660558