zabbix简介:
zabbix(音同 zæbix)是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
zabbix由2部分构成,zabbix server与可选组件zabbix agent。
zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。
Alexei Vladishev创建了Zabbix项目,当前处于活跃开发状态,Zabbix SIA提供支持.
Zabbix是一个企业级的、开源的、分布式的监控套件
Zabbix可以监控网络和服务的监控状况. Zabbix利用灵活的告警机制,允许用户对事件发送基于Email的告警. 这样可以保证快速的对问题作出相应. Zabbix可以利用存储数据提供杰出的报告及图形化方式. 这一特性将帮助用户完成容量规划.
Zabbix支持polling和trapping两种方式. 所有的Zabbix报告都可以通过配置参数在WEB前端进行访问. Web前端将帮助你在任何区域都能够迅速获得你的网络及服务状况. Zabbix可以通过尽可能的配置来扮演监控你的IT基础框架的角色,而不管你是来自于小型组织还是大规模的公司.
Zabbix是零成本的. 因为Zabbix编写和发布基于GPL V2协议. 意味着源代码是免费发布的.
Zabbix公司也提供商业化的技术支持.
zabbix的特性:
(1)安装与配置简单。
(2)可视化web管理界面。
(3)免费开源。
(4)支持中文。
(5)自动发现。
(6)分布式监控。
(7)实时绘图。
环境说明:
check1为Server,check2和check3为Proxy
[root@check1 ~]# cat /etc/redhat-release CentOS release 6.9 (Final) [root@check1 ~]# uname -a Linux check1 2.6.32-696.16.1.el6.x86_64 #1 SMP Wed Nov 15 16:51:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
一、zabbix安装
Zabbix 3.0对PHP的要求最低为5.4,而CentOS6默认为5.3.3,完全不满足要求,故需要利用第三方源,将PHP升级到5.4以上,注意,不支持PHP7
[root@check1 ~]# mkdir zabbix [root@check1 ~]# cd zabbix/ [root@check1 zabbix]# rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm [root@check1 zabbix]# yum -y install php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap [root@check1 zabbix]# vim /etc/php.ini 889 date.timezone = Asia/Shanghai 663 post_max_size = 32M 375 max_execution_time = 300 385 max_input_time = 300 705 always_populate_raw_post_data = -1
安装MySQL
MySQL建议使用5.6版本,CentOS6.x默认为5.1,不建议使用性能偏低
[root@check1 ~]# rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm [root@check1 ~]# yum -y install mysql-server mysql-devel [root@check1 ~]# rpm -qa | grep mysql* mysql-community-libs-5.6.40-2.el6.x86_64 mysql-community-release-el6-5.noarch php56w-mysql-5.6.35-1.w6.x86_64 mysql-community-common-5.6.40-2.el6.x86_64 mysql-community-libs-compat-5.6.40-2.el6.x86_64 mysql-community-client-5.6.40-2.el6.x86_64 mysql-community-server-5.6.40-2.el6.x86_64 mysql-community-devel-5.6.40-2.el6.x86_64 [root@check1 ~]# vim /etc/my.cnf [mysqld] innodb_file_per_table [root@check1 ~]# service mysqld start [root@check1 ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): #初次运行直接回车 OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. Set root password? [Y/n] y #是否设置root密码,输入y回车设置密码 New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y #是否删除匿名用户,生产环境建议删除,可直接回车 ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] n #是否禁止root用户远程登录,根据自己的需求选择 ... skipping. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y #是否删除test数据库,可直接回车 - Dropping test database... ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist ... Failed! Not critical, keep moving... - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] #是否重新加载权限表,直接回车 ... Success! All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL! Cleaning up... 上面如果没有设置root密码可用一下命令进行设置 [root@check1 ~]# mysqladmin -u root password [root@check1 ~]# mysql -uroot -p Enter password: mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin; Query OK, 1 row affected (0.00 sec) mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix'; #IP地址与zabbix的用户、库和密码自行更换 Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> show databases; +------------------------+ | Database | +------------------------+ | information_schema | | mysql | | performance_schema | | zabbix | +------------------------+ 4 rows in set (0.00 sec)
安装zabbix
[root@check1 ~]# useradd -m -s /sbin/nologin zabbix [root@check1 ~]# yum -y install httpd libxml2-devel net-snmp-devel libcurl-devel [root@check1 ~]# wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.2.0/zabbix-3.2.0.tar.gz [root@check1 ~]# mv zabbix-3.2.0.tar.gz zabbix [root@check1 ~]# cd zabbix/ [root@check1 zabbix]# tar xf zabbix-3.2.0.tar.gz [root@check1 zabbix]# cd zabbix-3.2.0 [root@check1 zabbix-3.2.0]# /usr/bin/mysql -uzabbix -p zabbix < database/mysql/schema.sql Enter password: [root@check1 zabbix-3.2.0]# /usr/bin/mysql -uzabbix -p zabbix < database/mysql/images.sql Enter password: [root@check1 zabbix-3.2.0]# /usr/bin/mysql -uzabbix -p zabbix < database/mysql/data.sql Enter password: [root@check1 zabbix-3.2.0]# ./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix/ --enable-server --enable-agent --with-net-snmp --with-libcurl --with-mysql --with-libxml2 [root@check1 zabbix-3.2.0]# make [root@check1 zabbix-3.2.0]# make install 编译过程中如果遇到报错如下: configure: error: Not found mysqlclient library 解决: ln -s /usr/lib64/mysql/libmysqlclient.so.18.1.0 /usr/lib64/mysql/libmysqlclient.so ln -s /usr/lib64/mysql/libmysqlclient_r.so.18.1.0 /usr/lib64/mysql/libmysqlclient_r.so)
配置zabbix:
[root@check1 ~]# vim /etc/zabbix/zabbix_server.conf DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix ListenIP=127.0.0.1,192.168.1.1 #自行更改zabbix监听的IP地址 [root@check1 ~]# iptables -I INPUT -p tcp -m multiport --dports 10050:10051 -j ACCEPT [root@check1 ~]# service iptables save &&service iptables restart iptables:将防火墙规则保存到 /etc/sysconfig/iptables: [确定] iptables:将链设置为政策 ACCEPT:filter [确定] iptables:清除防火墙规则: [确定] iptables:正在卸载模块: [确定] iptables:应用防火墙规则: [确定] [root@check1 ~]# setenforce 0 [root@check1 ~]# vim /etc/selinux/config SELINUX=disabled [root@check1 ~]# ln -s /usr/local/zabbix/sbin/* /usr/sbin/ [root@check1 ~]# cp /root/zabbix/zabbix-3.2.0/misc/init.d/fedora/core/zabbix_* /etc/init.d/ [root@check1 ~]# chmod +x /etc/init.d/zabbix_* [root@check1 ~]# sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_server
配置Web
[root@check1 ~]# vim /etc/httpd/conf/httpd.conf ServerName 127.0.0.1,192.168.1.1 DocumentRoot "/var/www/html/zabbix" [root@check1 ~]# mkdir -p /var/www/html/zabbix [root@check1 ~]# cp -r /root/zabbix/zabbix-3.2.0/frontends/php/* /var/www/html/zabbix/ [root@check1 ~]# chown -R apache.apache /var/www/html/zabbix/ [root@check1 ~]# service httpd start 正在启动 httpd: [确定] [root@check1 ~]# chkconfig zabbix_server on [root@check1 ~]# /etc/init.d/zabbix_server start Starting zabbix_server: [确定] [root@check1 ~]# netstat -anpt | grep zabbix tcp 0 0 192.168.1.1:10051 0.0.0.0:* LISTEN 2433/zabbix_server tcp 0 0 127.0.0.1:10051 0.0.0.0:* LISTEN 2433/zabbix_server [root@check1 ~]# iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
web配置zabbix
用户名和密码默认为:
用户名:Admin
密码:zabbix
简单配置
1、改为中文
更换语言后zabbix会出现乱码,需要给zabbix更换下字体库
在任意一台windows执行
找一种字体复制出去一份,把名字改为msyh.ttf或MSYH.ttf
把字体文件上传到/var/www/html/zabbix/fonts目录下
编辑文件
[root@check1 fonts]# vim vim /var/www/html/zabbix/include/defines.inc.php 45 define('ZBX_GRAPH_FONT_NAME', 'MSYH'); // font file name 93 define('ZBX_FONT_NAME', 'MSYH'); [root@check1 fonts]# /etc/init.d/zabbix_server restart
安装配置zabbix代理之zabbix_proxy:http://www.cnblogs.com/LuckWJL/p/9055587.html
zabbix安装配置agent程序之agent配置文件详解:http://www.cnblogs.com/LuckWJL/p/9055912.html
zabbix_server通过zabbix_proxy进行监控Host:http://www.cnblogs.com/LuckWJL/p/9056195.html