一篇文章带你熟悉zabbix企业级监控平台

一、.zabbix介绍

Zabbix 是一个企业级的分布式开源监控方案。
Zabbix是一款能够监控各种网络参数以及服务器健康性和完整性的软件。Zabbix使用灵活的通知机制,允许用户为几乎任何事件配置基于邮件的告警。这样可以快速反馈服务器的问题。
Zabbix支持主动轮询和被动捕获。Zabbix所有的报告、统计信息和配置参数都可以通过基于Web的前端页面进行访问。基于Web的前端页面可以确保您从任何方面评估您的网络状态和服务器的健康性。

二、zabbix组件

Zabbix server是整个Zabbix软件的核心程序。
Server通过轮询和捕获数据,计算是否满足触发器条件,向用户发送通知。是agent程序报告系统可用性、系统完整性和统计数据的核心组件,是所有配置信息、统计信息和操作数据的核心存储器。
数据库存储:所有配置信息和Zabbix收集到的数据都被存储在数据库;
web界面:为了从任何地方和任何平台都可以轻松的访问Zabbix, 提供基于Web的Zabbix界面。该界面是Zabbix Server的一部分,通常(但不一定)跟Zabbix Server运行在同一台物理机器上。
Zabbix proxy: 可以替Zabbix Server收集性能和可用性数据。
Proxy代理服务器:是Zabbix软件可选择部署的一部分,也可以帮助单台Zabbix Server分担负载压力。
Zabbix agents监控代理: 部署在监控目标上,能够主动监控本地资源和应用程序,并将收集到的数据报告给Zabbix Server。

三、zabbix 工作原理

zabbix-server,mysql数据库,zabbix-web gui是可以分布安装在不同服务器,zabbix-server启动时读取配置文件
zabbix_server.conf来运行zabbix-server服务并且将日志输出到zabbix-server.log文件;zabbix-serevr通过主动模式或者被动模式获取数据,zabbix-agent服务器启动时会读取配置文件zabbix-agent.conf输出日志到配置文件zabbix-agent.log;zabbix-server服务通过zabbix-web gui从数据库提取数据绘制图形在浏览器里面进行展示;
zabbix收集数据分为主动和被动两种模式:
被动模式:zabbix-server服务主动请求zabbix-agent服务,zabbix-service通过zabbix-get方式获取zabbix-agent端的数据;
主动模式:zabbix-agent主动将收集的数据定时通过zabbix-sender进程将数据发送给zabbix-server服务并且存储在本地数据库;

四、zabbix安装与配置

可以参考官网:https://www.zabbix.com/

安装源

将仓库指向清华下载站

[root@server1 zabbix]# cd /etc/yum.repos.d/
[root@server1 yum.repos.d]# vim zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/$basearch/
enabled=1
gpgcheck=0

[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1
gpgcheck=0

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgcheck=0

安装部署包server和agent

[root@server1 yum.repos.d]# yum install zabbix-server-mysql zabbix-agent

安装前端

[root@server1 ~]# yum install -y centos-release-scl-2-3.el7.centos.noarch.rpm centos-release-scl-rh-2-3.el7.centos.noarch.rpm
[root@server1 ~]# yum install zabbix-web-mysql-scl zabbix-apache-conf-scl

安装mysql数据库

[root@server1 ~]# tar xf mysql-5.7.33-1.el7.x86_64.rpm-bundle.tar
[root@server1 ~]# yum install -y mysql-community-client-5.7.33-1.el7.x86_64.rpm mysql-community-common-5.7.33-1.el7.x86_64.rpm mysql-community-libs-5.7.33-1.el7.x86_64.rpm mysql-community-libs-compat-5.7.33-1.el7.x86_64.rpm mysql-community-server-5.7.33-1.el7.x86_64.rpm
#设置开机自启
[root@server1 ~]# systemctl  enable --now mysqld

获取初始化密码

[root@server1 ~]# grep 'temporary password' /var/log/mysqld.log
2023-02-26T08:52:37.676190Z 1 [Note] A temporary password is generated for root@localhost: s!DOgafjt9+d

Mysql安全启动配置向导

[root@server1 ~]# mysql_secure_installation
安装完mysql-server 会提示可以运行mysql_secure_installation。运行mysql_secure_installation会执行以下几个设置:
- 为root用户设置密码
- 删除匿名账号
- 取消root用户远程登录
- 删除test库和对test库的访问权限
- 刷新授权表使修改生效

使用的mysql版本为5.7.33默认会有密码强壮度检测

密码需要大于8位切必须要有大小写字母特殊符号和数字

Securing the MySQL server deployment.

Enter password for user root:

The existing password for the user account root has expired. Please set a new password.

New password:

Re-enter new password:
 ... Failed! Error: Your password does not satisfy the current policy requirements

New password:

Re-enter new password:
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) :

 ... skipping.
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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y
Success.

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? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - 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? (Press y|Y for Yes, any other key for No) : y
Success.

All done!

创建zabbix数据库

在MySQL上安装Zabbix数据库和用户

[root@server1 ~]# mysql -p
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

mysql> create user zabbix@localhost identified by 'Whr12345-';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> set global log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.00 sec)

导入数据

将zabbix自带的数据库表迁移到数据库中,迁移过程中千万不要强制结束,不然重新迁移会报错,需要将数据库清理干净在进行迁移。

[root@server1 ~]# zcat /usr/share/doc/zabbix-server-mysql-5.0.31/create.sql.gz | mysql -uzabbix -pYakexi+007 zabbix

导入后再禁用数据库参数

[root@server1 ~]# mysql -p
mysql> set global log_bin_trust_function_creators = 0;
Query OK, 0 rows affected (0.00 sec)

配置zabbix server

[root@server1 ~]# vim /etc/zabbix/zabbix_server.conf
#只需修改数据库密码
DBPassword=Abc123456-

配置zabbix前端

[root@server1 zabbix]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
#去掉此行的注释,并修改时区
php_value[date.timezone] = Asia/Shanghai

启动服务

[root@server1 zabbix]# systemctl enable --now zabbix-server zabbix-agent httpd rh-php72-php-fpm

访问前端:http://192.168.18.11/zabbix

全为OK即可

密码为数据库密码

Name随意

登录前端的用户密码是:Admin/zabbix

修改前端语言

修改字体文件

cp simkai.ttf /usr/share/zabbix/assets/fonts

cd /usr/share/zabbix/assets/fonts

[root@server1 fonts]# rm -f graphfont.ttf

[root@server1 fonts]# ln -s simkai.ttf graphfont.ttf

五、添加agent

1、手动添加

agent配置

从server1拷贝repo文件

[root@server1 yum.repos.d]# scp zabbix.repo server2:/etc/yum.repos.d/

[root@server2 yum.repos.d]# yum install -y zabbix-agent

[root

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值