运行环境:
操作系统:CentOS release 6.10 (Final)
数据库:MySQL Ver 14.14 Distrib 5.5.55
Web中间件:Apache/2.2.15 (Unix)
程序语言环境:PHP 5.4.45
软件包:Zabbix 3.4
任务:安装配置Zabbix,尝试使用在生产环境中。
操作步骤:
1.安装MySQL数据库
# rpm -i https://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
2.安装Zabbix server,Web前端,agent
# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
3.创建初始数据库
# mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
mysql> quit;
导入初始架构和数据,系统将提示您输入新创建的密码。
#zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
4.为Zabbix server配置数据库
编辑配置文件/etc/zabbix/zabbix_server.conf
DBPassword=password
5.为Zabbix前端配置PHP
配置时区
[root@sky9890 conf.d]# pwd
/etc/httpd/conf.d
[root@sky9890 conf.d]# vi php.conf
php_value date.timezone Asia/Shanghai
[root@sky9890 ~]# vi /etc/php.ini
date.timezone =Asia/Shanghai
6.启动Zabbix server和agent进程
[root@sky9890 ~]# service zabbix-server restart
Shutting down Zabbix server: [确定]
Starting Zabbix server: [确定]
[root@sky9890 ~]# service zabbix-agent restart
Shutting down Zabbix agent: [确定]
Starting Zabbix agent:
7.配置Zabbix前端
[root@sky9890 zabbix]# pwd
/usr/share/zabbix
[root@sky9890 share]# cp –r zabbix/ /var/www/html/
#如果前端无法访问zabbix,将原安装zabbix的源码位置迁移到httpd的/var/www/html目录下
连接到新安装的Zabbix前端: http://server_ip_or_name/zabbix
前端配置,请访问官网:https://www.zabbix.com/documentation/3.0/manual/installation/install#installing_frontend
Pre-requisite | Minimum value | Description |
---|---|---|
PHP version | 5.4.0 | |
PHP memory_limit option | 128MB | In php.ini: memory_limit = 128M |
PHP post_max_size option | 16MB | In php.ini: post_max_size = 16M |
PHP upload_max_filesize option | 2MB | In php.ini: upload_max_filesize = 2M |
PHP max_execution_time option | 300 seconds (values 0 and -1 are allowed) | In php.ini: max_execution_time = 300 |
PHP max_input_time option | 300 seconds (values 0 and -1 are allowed) | In php.ini: max_input_time = 300 |
PHP session.auto_start option | must be disabled | In php.ini: session.auto_start = 0 |
Database support | One of: IBM DB2, MySQL, Oracle, PostgreSQL, SQLite | One of the following modules must be installed: ibm_db2, mysql, oci8, pgsql, sqlite3 |
bcmath | php-bcmath | |
mbstring | php-mbstring | |
PHP mbstring.func_overload option | must be disabled | In php.ini: mbstring.func_overload = 0 |
PHP always_populate_raw_post_data option | must be disabled | Required only for PHP versions 5.6.0 or newer. In php.ini: always_populate_raw_post_data = -1 |
sockets | php-net-socket. Required for user script support. | |
gd | 2.0 or higher | php-gd. PHP GD extension must support PNG images (--with-png-dir), JPEG (--with-jpeg-dir) images and FreeType 2 (--with-freetype-dir). |
libxml | 2.6.15 | php-xml or php5-dom |
xmlwriter | php-xmlwriter | |
xmlreader | php-xmlreader | |
ctype | php-ctype | |
session | php-session | |
gettext | php-gettext Since Zabbix 2.2.1, the PHP gettext extension is not a mandatory requirement for installing Zabbix. If gettext is not installed, the frontend will work as usual, however, the translations will not be available. |
配置php.ini参数表
相关步骤按默认导航安装即可。
配置Zabbix时要注意几个事项:
1.配置zabbix.conf.php文件
[root@sky9890 web]# pwd
/etc/zabbix/web
[root@sky9890 web]# vi zabbix.conf.php
$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = 'localhost';
$DB['PORT'] = '3306';
$DB['DATABASE'] = '*****';
$DB['USER'] = '******';
$DB['PASSWORD'] = '**********';
// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';
$ZBX_SERVER = 'localhost';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = 'zabbix_server';
2.配置zabbix_agentd.conf和zabbix_server.conf两个文件
[root@sky9890 zabbix]# pwd
/etc/zabbix
ServerActive=ip #启用服务IP
ListenIP=127.0.0.1 #启用监控IP
3.配置防火墙
[root@sky9890 /]# cat /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 10051 -j ACCEPT
-A OUTPUT -p tcp -m state --state NEW -m tcp --dport 10050 -j ACCEPT
以上服务器端基本配置完成,客户端在这里不做说明。
4.相关Zabbix配置文档请点击下面链接:
https://blog.51cto.com/sky9896/1852873
https://blog.51cto.com/sky9896/1940105
5.运行效果图如下:
自动监控设备运行情况
监控Nginx
监控IIS连接数
Zabbix功能强大于Cacti监控系统。
相对Cacti来讲,Zabbix配置应用更复杂。