其他教程

其他教程

Products

当前位置:首页 > 其他教程 >

Zabbix监控系统部署详细步骤

GG网络技术分享 2025-03-18 16:14 0


大家好,这里是关于[zabbix使用教程+受监控服务器的添加安装教程],[Zabbix监控系统部署详细步骤]问题的解答,希望对您有所帮助。如果你还想了解更多这方面的信息,请关注本站其他相关内容,共同学习吧!

zabbix使用教程+受监控服务器的添加安装教程

教程大全zabbix,zabbix监控,宝塔面板zabbix

zabbix使用教程+受监控服务器的添加安装教程

前面我们写了zabbix宿主机的安装教程:centos6/7系统-宝塔linux面板安装Zabbix监控服务器资源使用状态

下面我们写一下添加其他受监控服务器是如何操作的。

我们先看看,监控宿主机(安装zabbix主程序的机器)是怎么监控的

点击上方:配置–主机–下面有一个本机的主机

然后里面有个:agent代理程序的接口。这里面IP改成我们服务器的IP。改完点下方的保存即可。

这个步骤就是我们添加了对宿主机的监控,然后下面写一下如何查看宿主机的监控图形。

点击上方:检测中–图形–选择群组–主机–图形,然后即可显示对应图形的数据,如下图

可以查看的参数很多。多多研究下。

下面是如何添加其他受监控的服务器。

我们只需要连入受监控服务器的SSH,SSH连接教程参考:购买服务器后如何远程连接登陆?

在SSH中输入以下命令安装Agentd客户端

先安装EPEL源

yum -y install epel-release

安装依赖组件

yum -y install fping

输入以下命令安装Agentd

rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/6/x86_64/zabbix-agent-4.0.1-1.el6.x86_64.rpm

其他系统以及zabbix的Agentd安装包到http://repo.zabbix.com/zabbix去寻找。

然后是编辑配置文件,在目录/etc/zabbix/有个zabbix_agentd.conf文件,编辑它。把里面的Server=的IP改成你服务端的IP。

然后在宝塔安全里面放行10050端口。

登陆zabbix的WEB管理端:配置-主机-创建主机

填写主机名称、可见的名称、群组、agent代理程序的接口这几项。

然后点击:模板

点击链接指示器后面的:选择

假如我们监控服务器的ping和丢包率就选择Template Module ICMP Ping这一项。

然后点击添加,把我们选择的模板添加上去

然后点击最下方的添加,把服务器添加上去。

这里有个错误,主机名称不能用中文,我教程里写的是中文。自己修改下改成英文即可正常添加。

上面教程就完成了基本操作,我们下面写一下如何使用图形界面查看ping和丢包率

点击配置–主机–然后是主机列表的图形,在弹出的界面点击创建图形

然后就可以到检测中–图形里面来查看了。

更多功能自己发掘吧。

Zabbix监控系统部署详细步骤

Zabbix 是一个企业级的分布式开源监控方案。Zabbix 是由Alexei Vladishev创建,目前由Zabbix SIA在持续开发和支持。Zabbix是一款能够监控各种网络参数以及服务器健康性和完整性的软件。Zabbix使用灵活的通知机制,允许用户为几乎任何事件配置基于邮件的告警。这样可以快速反馈服务器的问题。基于已存储的数据,Zabbix提供了出色的报告和数据可视化功能。这些功能使得Zabbix成为容量规划的理想方案。

我是去年开始接触到这款产品,确实为我的工作带来了很大的帮助,下面介绍一下zabbix的详细部署步骤,当时的版本为zabbix3.4。

首先搭建LAMP环境(Linux+Apache+Mysql或者Mariadb+Php)。

1.查看系统环境。

# cat /etc/redhat-release

CentOS Linux release 7.2.1511 (Core)

2.对系统初始默认源配置文件进行备份。

# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-

Base.repo.backup

3.下载阿里源。

#wget –O /etc/yum.repos.d/CentOS-Base.repo

http://mirrors.aliyun.com/repo/Centos-7.repo

4.生成缓存。

#yum makecache

5.查看yum源。

# yum repolist

Loaded plugins: fastestmirror, langpacks

Loading mirror speeds from cached hostfile

* base: mirrors.aliyun.com

* extras: mirrors.aliyun.com

* updates: mirrors.aliyun.com

repo id repo name status

base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 9911

extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 401

updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 1308

repolist: 11620

6.下载yum源配置文件。

# wget -p /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-7.rep

7.清缓存,然后再创建缓存。

# yum clean all

# yum makecache

8.查看epel源加入情况。

# yum repolist

Loaded plugins: fastestmirror, langpacks

Loading mirror speeds from cached hostfile

* base: mirrors.aliyun.com

* extras: mirrors.aliyun.com

* updates: mirrors.aliyun.com

repo id repo name status

base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 9911

epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 12660

extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 401

updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 1308

repolist: 24280

9.关闭SELINUX,可以通过vi修改配置文件来修改SELinux的状态或者用sed命令进行修改,此时需要重启才生效,使用命令setenforce 0临时生效。

# sed -i \'s#SELINUX=enforcing#SELINUX=disable#g\' /etc/sysconfig/selinux

# setenforce 0

10.安装Apache。

# yum install httpd –y

11.启动Apache,设置开机启动Apache,设置防火墙对Apache放行,并重启防火墙。

# systemctl start httpd

# systemctl enable httpd

Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

# firewall-cmd --permanent --add-service=http

success

# systemctl restart firewalld

12.打开火狐浏览器输入本服务器IP后回车,这时就应该能看到Apache的页面的,说明Apahce状态正常。

13.安装Mariadb数据库。

yum install mariadb-server -y

14.启动数据库,设置开机启动数据库,设置防火墙端口放行,并重启防火墙生效。

# systemctl start mariadb

# systemctl enable mariadb

Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

# firewall-cmd --permanent --add-port=3306/tcp

success

# firewall-cmd --reload

success

15.登入数据库查看是否安装正常。

# mysql -u root -p

Enter password:

Welcome to the MariaDB monitor. Commands end with ; or \\g.

Your MariaDB connection id is 2

Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type \'help;\' or \'\\h\' for help. Type \'\\c\' to clear the current input statement.

MariaDB [(none)]> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| test |

+--------------------+

4 rows in set (0.00 sec)

MariaDB [(none)]> exit

Bye

16.安装php和php对数据库的支持扩展。

yum install php php-mysql –y

17. 创建编辑一个测试文件对PHP测试。

# cat /var/www/html/testphp.php

<?php

phpinfo();

?>

18.重启Apache。

# systemctl restart httpd

19. 在火狐浏览器输入IP/testphp.php回车,将看到php相关信息页面,php测试正常。

20.至此LAMP环境搭建完成。

安装zabbix 3.4

1. 安装zabbix需要的软件包。

#yum install mysql-devel gcc net-snmp-devel curl-devel perl-DBI php-gd php-

mysql php-bcmath php-mbstring php-xml

- mysql-devel: 开发用到的库以及包含文件;

- gcc:为强制安装的包。即编译器;

- net-snmp-devel:为可选安装包,按需安装。用来支持SNMP监控;

- curl-devel:为可选安装包,但建议安装。用来支持 Web 监控;

- php-gd:PHP GD扩展库必须支持 PNG 图像(--with-png-dir)、JPEG 图像 (--with-jpeg-dir)和FreeType2(--with-freetype-dir);

- php-mysql:使用MySQL作为Zabbix后端数据库所需要的组件;

- php-bcmath:包含所需的bcmath;

- php-mbstring:包含所需的mbstring扩展。

- php-xml:包含所需的libXML、xmlreader和xmlwriter扩展。

2.打开zabbix官网点击Download,选择zabbix server平台操作系统为CentOS,

Version 7 Database MySQL(默认选择)。

3.安装源码库配置部署包,这个部署包包含了yum配置文件。

#rpm -ivh https://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release

-3.4-2.el7.noarch.rpm

4.安装Zabbix部署包,使用Mysql数据库安装Zabbix server、WEB前端以及Zabbix Agent。

# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent

5.可以安装zabbix sender、get等一些用来测试的组件。

# yum install -y zabbix-get zabbix-java-gateway zabbix-web zabbix-sender

6.关闭mariadb,更改mariadb共享表空间为独立表空间,使用vi修改my.cnf文件,添加“innodb-file-per-table=1”到配置文件,然后重新启动mariadb。

# systemctl stop mariadb

# head -5 /etc/my.cnf

[mysqld]

innodb-file-per-table=1

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks

# systemctl restart mariadb

7.登入数据库验证功能是否开启。

# mysql -u root -p

Enter password:

Welcome to the MariaDB monitor. Commands end with ; or \\g.

Your MariaDB connection id is 2

Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type \'help;\' or \'\\h\' for help. Type \'\\c\' to clear the current input statement.

MariaDB [(none)]> show variables like \'%per_table%\';

+-----------------------+-------+

| Variable_name | Value |

+-----------------------+-------+

| innodb_file_per_table | ON |

+-----------------------+-------+

1 row in set (0.00 sec)

8.创建一个数据库‘zabbix’和数据库用户‘zabbix’,密码为‘zabbix’。

MariaDB [(none)]> create database zabbix character set utf8;

Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to \'zabbix\'@\'localhost\' identified by \'zabbix\';

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit;

Bye

9.解压zabbix初始化sql脚本。

# gzip -d /usr/share/doc/zabbix-server-mysql-3.4.12/create.sql.gz

10. zabbix用户登录数据库,切换到zabbix数据库,导入初始化sql脚本。

# mysql -u zabbix -p

Enter password:

Welcome to the MariaDB monitor. Commands end with ; or \\g.

Your MariaDB connection id is 4

Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type \'help;\' or \'\\h\' for help. Type \'\\c\' to clear the current input statement.

MariaDB [zabbix]> use zabbix;

Database changed

MariaDB [zabbix]> source /usr/share/doc/zabbix-server-mysql-3.4.12/create.sql

Query OK, 1 row affected (0.00 sec)

MariaDB [zabbix]> show tables;

11.配置zabbix server端并启动。

# vim /etc/zabbix/zabbix_server.conf

修改以下内容:

DBHost=localhost

DBName=zabbix

DBUser=zabbix

DBPassword=zabbix

此处列出可能会经常修改的参数:

ListenPort=10051

#服务器端监听的端口,保持默认即可。

SourceIP=

#通过SourceIP参数可以指定服务端的源IP,当server端有多个IP地址时,我们可以指定服务端使用固定的IP与agent端进行通讯。

LogType=file

#通过LogType参数,可以指定通过哪种方式记录日志,此参数可以设置三种值,system、file、console,system表示将日志发往syslog,file表示使用指定的文件作为日志文件,console表示将日志发往控制台,默认为file。

LogFile=/var/log/zabbix/zabbix_server.log

#当LogType设置为file时,通过LogFile参数设置日志文件位置。

LogFileSize=0

#指明日志文件达到多大时自动滚动,单位为MB,如果设置为50,表示日志大小到达50MB滚动一次,设置为0表示日志文件不会滚动,所有日志保存再一个文件中。

DebugLevel=3

#通过DebugLevel参数可以定义日志的详细程度,即为日志级别。

DBHost=localhost

#通过DBHost参数设置zabbix数据库所在的服务器IP,由于此处zabbix与mysql安装在同一服务器上,所以设置为localhost。

DBName=zabbix

#通过DBName指定zabbix数据库对应的名称。

DBUser=Zabbix

#通过DBUser指定zabbix数据库用户名。

DBPassword=Zabbix

#通过DBPassword指定zabbix数据库用户的密码。

DBPort=3306

#通过DBPort指定zabbix所在数据库服务监听的端口号。

防火墙开放zabbix server端口10051,重启防火墙生效。

# firewall-cmd --permanent --add-port=10051/tcp

success

# firewall-cmd --reload

success

配置完成启动zabbix server并设置开机启动,启动后,10051端口已经被监听。

# systemctl start zabbix-server

# systemctl enable zabbix-server

# ss -ntl

State Recv-Q Send-Q Local Address:Port Peer Address:Port

LISTEN 0 50 *:3306 *:*

LISTEN 0 5 192.168.122.1:53 *:*

LISTEN 0 128 *:22 *:*

LISTEN 0 128 127.0.0.1:631 *:*

LISTEN 0 100 127.0.0.1:25 *:*

LISTEN 0 128 *:10051 *:*

LISTEN 0 128 :::80 :::*

LISTEN 0 128 :::22 :::*

LISTEN 0 128 ::1:631 :::*

LISTEN 0 128 ::1:25 :::*

LISTEN 0 128 :::10051 :::*

12.编辑Zabbix前端的PHP配置。

# cat /etc/httpd/conf.d/zabbix.conf

#

# Zabbix monitoring system php web frontend

#

Alias /zabbix /usr/share/zabbix

<Directory \"/usr/share/zabbix\">

Options FollowSymLinks

AllowOverride None

Require all granted

<IfModule mod_php5.c>

php_value max_execution_time 300

php_value memory_limit 128M

php_value post_max_size 16M

php_value upload_max_filesize 2M

php_value max_input_time 300

php_value max_input_vars 10000

php_value always_populate_raw_post_data -1

# php_value date.timezone Europe/Riga

php_value date.timezone Asia/Shanghai #设置时区

</IfModule>

</Directory>

<Directory \"/usr/share/zabbix/conf\">

Require all granted #可以允许全部可以访问

</Directory>

<Directory \"/usr/share/zabbix/app\">

Require all granted

</Directory>

<Directory \"/usr/share/zabbix/include\">

Require all granted

</Directory>

<Directory \"/usr/share/zabbix/local\">

Require all granted

</Directory>

13.配置完成,重启httpd服务。

# systemctl restart httpd

14. 登录Zabbix管理页面http://zabbix_webip/zabbix,显示Zabbix安装向导。

15.第2步zabbix自动检查了安装环境是否满足要求,如果出现不满足要求的情况需要进一步处理,检查全部OK,点击’Nest step’。

16.第三步zabbix需要配置数据库连接,此处配置数据库的类型、IP、端口、数据库名、用户密码等信息,端口填写0表示使用默认端口(3306端口)。

17.第四步填写zabbix server的详细信息,包括IP地址,端口号以及server名称。

18.第五步查看安装信息汇总,没有问题,继续安装。

19.第六步提示初始化配置已经完成,而且提示这些配置信息被保存到了‘/etc/zabbix/web/zabbix.conf.php’配置文件中,如果想要更改刚才的配置,可以通过修改此文件,点击’Finish’进入登陆界面。

20.第七步点击完成后,可以看到zabbix的登录页面,默认用户名密码admin/zabbix。

21.第八步登入成功。

22.设置中文显示界面。

1点击右上角的小人图标,进入个性化设置界面,可以选择各种语言,设置为Chinese(zh_CN)。

2中文显示界面。

3图形界面会产生乱码情况。

4打开windows开始运行,输入fonts(或者控制面板进入字体),回车进入Windows字体目录,找到楷体-常规字体,复制出来,名称为simkai.ttf。

5将simkai.ttf上传到服务器zabbix字体目录中。

# ls /usr/share/zabbix/fonts/

graphfont.ttf simkai.ttf

6vi修改配置文件/usr/share/zabbix/include/defines.inc.php,查找graphfont替换成simkai,一共需替换2处,也可以使用sed命令进行替换。

# sed -i \'s#graphfont#simkai#g\' /usr/share/zabbix/include/defines.inc.php

7刷新页面中文乱码问题完美解决。

至此zabbix监控系统安装完成。

标签:

提交需求或反馈

Demand feedback