Linux配置安裝监控服务器---Zabbix监控(一)

tech2025-05-14  10

Linux配置监控服务器:Zabbix监控(一)

 

一、Linux监控平台介绍

cacti、nagios、zabbix、smokeping、open-falcon等;cacti、smokeping偏向基础监控,成图非常漂亮;cacti、nagios、zabbix服务端监控中心,需要PHP环境支持,其中zabbix和cacti都需要mysql作为数据存储,nagios不用存储历史数据,注重服务或者监控项的状态,zabbix会获取服务或者监控项目的数据,会把数据记录到数据库里,从而可以成图;open-falcon为小米公司开发,开源后受到诸多大公司和运维工程师的追捧,适合大企业,滴滴、360、新浪微博、京东等大公司在使用这款监控软件,值得研究;

二、Zabbix监控介绍

C/S架构,基于C++开发,监控中心支持web界面配置和管理;单server节点可以支持上万台客户端;最新版本3.4 ,官网文档https://www.zabbix.com/manuals

1、组件

Zabbix整个体系架构中有几个主要角色:

zabbix-server:核心,监控中心,接收客户端上报信息,负责配置、统计、操作数据;数据存储:存放数据,比如mysql;web界面:也叫web UI ,在web界面下操作配置是zabbix简单易用的主要原因;zabbix-proxy:可选组件,它可以代替zabbix-server的功能,减轻server的压力;zabbix-agent:客户端软件,负责采集各个监控服务或项目的数据,并上报。

2、架构

三、Zabbix监控安装与部署

1、用yum安装Zabbix

[root@zlinux-01 ~]# wget repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm //下载Zabbix的yum扩展源 [root@zlinux-01 ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm //安装扩展源 [root@zlinux-01 ~]# yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql //安装相关安装包 #会连带安装httpd和php #如果mysql之前没有装的话,需要根据lamp那一章的mysql安装方法安装msyql [root@zlinux-01 ~]# ps aux | grep mysql //查看mysql服务是否启动,没有就启动下

2、配置MySQL

[root@zlinux-01 ~]# vim /etc/my.cnf //在[mysqld]下添加以下一行 character_set_server = utf8 [root@zlinux-01 ~]# systemctl restart mysql //重启mysql [root@zlinux-01 ~]# mysql -uroot -pzlinux123456 Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.36-log MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database zabbix character set utf8; //创建zabbix库,字符集utf8 Query OK, 1 row affected (0.00 sec) mysql> grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by 'zlinux123456'; //创建zabbix用户,为了zabbix连接数据库 Query OK, 0 rows affected (0.00 sec) mysql> quit Bye #导入zabbix数据库 [root@zlinux-01 ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/ [root@zlinux-01 zabbix-server-mysql-3.2.11]# ls AUTHORS ChangeLog COPYING create.sql.gz NEWS README [root@zlinux-01 zabbix-server-mysql-3.2.11]# gzip -d create.sql.gz [root@zlinux-01 zabbix-server-mysql-3.2.11]# mysql -uroot -pzlinux123456 zabbix < create.sql #修改zabbix-server配置文件 [root@zlinux-01 ~]# vim /etc/zabbix/zabbix_server.conf //加入以下内容 DBHost=127.0.0.1 DBPassword=zlinux123456

3、启动相关服务

[root@zlinux-01 ~]# systemctl stop nginx //先停止掉Nginx服务因为占用了80,或者Nginx做下代理配置,可参考前文 [root@zlinux-01 ~]# systemctl start httpd //启动httpd [root@zlinux-01 ~]# ps aux | grep httpd root 3472 0.0 0.8 394324 15480 ? Ss 15:20 0:00 /usr/sbin/httpd -DFOREGROUND apache 3474 0.0 0.4 394460 7680 ? S 15:20 0:00 /usr/sbin/httpd -DFOREGROUND apache 3475 0.0 0.4 394460 7680 ? S 15:20 0:00 /usr/sbin/httpd -DFOREGROUND apache 3476 0.0 0.4 394460 7680 ? S 15:20 0:00 /usr/sbin/httpd -DFOREGROUND apache 3477 0.0 0.4 394460 7680 ? S 15:20 0:00 /usr/sbin/httpd -DFOREGROUND apache 3478 0.0 0.4 394460 7680 ? S 15:20 0:00 /usr/sbin/httpd -DFOREGROUND [root@zlinux-01 ~]# systemctl start zabbix-server //启动zabbix服务 [root@zlinux-01 ~]# ps aux | grep zabbix //查看zabbix相关,成功的情况下有很多条服务 [root@zlinux-01 ~]# netstat -lntp //80,3306,11051三个端口 Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:45930 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd tcp 0 0 0.0.0.0:20048 0.0.0.0:* LISTEN 995/rpc.mountd tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 839/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1703/master tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 3393/zabbix_server tcp 0 0 0.0.0.0:42343 0.0.0.0:* LISTEN 824/rpc.statd tcp6 0 0 :::3306 :::* LISTEN 3330/mysqld tcp6 0 0 :::111 :::* LISTEN 1/systemd tcp6 0 0 :::80 :::* LISTEN 3472/httpd tcp6 0 0 :::38704 :::* LISTEN - tcp6 0 0 :::20048 :::* LISTEN 995/rpc.mountd tcp6 0 0 :::22 :::* LISTEN 839/sshd tcp6 0 0 :::40375 :::* LISTEN 824/rpc.statd tcp6 0 0 ::1:25 :::* LISTEN 1703/master tcp6 0 0 :::2049 :::* LISTEN - tcp6 0 0 :::10051 :::* LISTEN 3393/zabbix_server

4、配置web界面

步骤1: 步骤2: 要解决此问题,需要编辑phph.ini或者Zabbix的httpd配置:

[root@zlinux-01 ~]# vim /etc/httpd/conf.d/zabbix.conf //在最后增加下面一行 php_value date.timezone Asia/Shanghai [root@zlinux-01 ~]# systemctl restart httpd //重启

步骤3:刷新下浏览器,继续下一步 步骤4: 步骤5:登录管理后台首先更改密码,默认账户:admin,密码:zabbix

5、Zabbix客户端部署

[root@zlinux-04 ~]# http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm [root@zlinux-04 ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm [root@zlinux-04 ~]# yum install -y zabbix-agent [root@zlinux-04 ~]# vim /etc/zabbix/zabbix_agentd.conf //修改以下内容 Server=192.168.242.128 //定义服务端IP(被动模式) Server=192.168.242.128 //定义服务点IP(主动模式) Hostname=zlinux-01 //自定义主机名 [root@zlinux-04 ~]# systemctl start zabbix-agent //启动 [root@zlinux-04 ~]# netstat -lnp | grep zabbix //zabbix-agent监听10050端口 tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 2436/zabbix_agentd tcp6 0 0 :::10050 :::* LISTEN 2436/zabbix_ag
最新回复(0)