zabbix监控服务
- zabbix :是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。能监控各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
部署zabbix
- 因为zabbix是用PHP语言开发的,所以必须先部署lamp或者lnmp架构,使其能够支持运行php网页。
lamp架构的部署
zabbix服务端安装
这里是已经搭好lamp架构的服务器
//安装依赖包
[root@hxdserver ~]# yum -y install net-snmp-devel libevent-devel
//下载zabbix
[root@hxdserver ~]# cd /usr/src/
[root@hxdserver src]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.12/zabbix-3.4.12.tar.gz
[root@hxdserver src]# tar xf zabbix-3.4.12.tar.gz
//创建zabbix用户和组
[root@hxdserver ~]# groupadd -r zabbix
[root@hxdserver ~]# useradd -r -g zabbix -M -s /sbin/nologin zabbix
//配置zabbix数据库
[root@hxdserver ~]# mysql -uroot -p
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.32 sec)
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix123!';
Query OK, 0 rows affected, 2 warnings (0.09 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.05 sec)
mysql> quit
[root@hxdserver ~]# cd /usr/src/zabbix-3.4.12/database/mysql/
[root@hxdserver mysql]# mysql -uzabbix -pzabbix123! zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@hxdserver mysql]# mysql -uzabbix -pzabbix123! zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@hxdserver mysql]# mysql -uzabbix -pzabbix123! zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
//编译安装zabbix
[root@hxdserver ~]# cd /usr/src/zabbix-3.4.12
[root@hxdserver zabbix-3.4.12]# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
[root@hxdserver zabbix-3.4.12]# make install
zabbix服务端配置
[root@hxdserver ~]# ls /usr/local/etc/
zabbix_agentd.conf zabbix_server.conf
zabbix_agentd.conf.d zabbix_server.conf.d
[root@hxdserver ~]# vim /usr/local/etc/zabbix_server.conf
DBPassword=zabbix123! //设置zabbix数据库连接密码
//启动zabbix_server和zabbix_agentd
[root@hxdserver ~]# zabbix_server
[root@hxdserver ~]# zabbix_agentd
[root@hxdserver ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:10050 *:*
LISTEN 0 128 *:10051 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::*
zabbix服务端web界面安装与配置
zabbix web界面安装前配置
//修改/etc/php.ini的配置并重启php-fpm
[root@hxdserver ~]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
[root@hxdserver ~]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini
[root@hxdserver ~]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
[root@hxdserver ~]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
[root@hxdserver ~]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
[root@hxdserver ~]# cd /usr/src/zabbix-3.4.12
[root@hxdserver zabbix-3.4.12]# mkdir /usr/local/apache/htdocs/zabbix
[root@hxdserver zabbix-3.4.12]# cp -a frontends/php/* /usr/local/apache/htdocs/zabbix/
[root@hxdserver zabbix-3.4.12]# chown -R apache.apache /usr/local/apache/htdocs
//配置apache虚拟主机
[root@hxdserver ~]# vim /etc/httpd24/httpd.conf
//添加以下内容
<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs/zabbix"
ServerName zabbix.dubai.com
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1
<Directory "/usr/local/apache/htdocs/zabbix">
Options none
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
// 设置zabbix/conf目录权限,让zabbix有权限生成配置文件zabbix.conf.php
[root@hxdserver ~]# chmod 777 /usr/local/apache/htdocs/zabbix/conf
//重启apache
[root@hxdserver ~]# apachectl -t
Syntax OK
[root@hxdserver ~]# apachectl restart
安装zabbix web界面
- 修改/etc/hosts文件,添加域名与IP的映射
- 在浏览器上访问域名,zabbix.dubai.com
- 恢复zabbix/conf目录的权限为755
访问域名安装
登录zabbix
zabbix默认登录用户名和密码:
用户名 | 密码 |
---|---|
Admin | zabbix |