オープンソース監視ソフトウェア Zabbix5 の導入実践

シリーズ記事ディレクトリ



ここに画像の説明を挿入


1. zabbix の概要

百度百科WEB: Zabbix は、分散型およびネットワーク監視機能を提供する、インターフェイスベースの系统监视エンタープライズレベルのオープンソース ソリューションです。服务器系统これは、エンタープライズレベルの高度に統合されたオープンソース監視ソフトウェアであり、機器、サーバー、データベースなどの可用性とパフォーマンスを監視し、データベースの安全な運用を保証するために使用できます。系统管理员また、さまざまな問題を迅速に特定/解決するための柔軟な通知メカニズムを提供します。

zabbix は、zabbix サーバーとオプションのコンポーネントである zabbix エージェントの 2 つの部分で構成されます。SNMPzabbix エージェント、ポート監視などのping方法を通じて、リモート サーバー/ネットワークのステータスを監視できます。Linux 、Solaris、HP-UX、AIX、Free BSD、Open BSD、OS X、およびその他のプラットフォームで実行できます。数据收集

Zabbix公式サイト:https://www.zabbix.com/cn
ここに画像の説明を挿入

Zabbix公式ドキュメントアドレス:https://www.zabbix.com/documentation/5.0/zh/manual
ここに画像の説明を挿入

1.Zabbixの導入

1.Zabbix環境

IP CPU名 役割
192.168.200.182 zabbix_server 監視サーバー
192.168.200.183 ウェブ001 ビジネスホスト

2. zabbix インストールパッケージをインストールします

zabbix_server をインストールする

1. zabbix_server ホスト名を設定します

[root@zabbix_server ~]#hostnamectl set-hostname zabbix_server 或者 hostname  zabbix_server  #设置完成后需要退出终端然后重新打开,新的主机名就生效了

2. ファイアウォールと selinux をオフにする

[root@zabbix_server ~]# systemctl stop firewalld.service  #停止防火墙服务
[root@zabbix_server ~]# systemctl disable firewalld.service  
[root@zabbix_server ~]# setenforce 0  #临时关闭selinux
setenforce: SELinux is disabled
[root@zabbix_server selinux]# vim   /etc/selinux/config   #编辑配置文件为`SELINUX=disabled` 即可永久关闭selinux

ここに画像の説明を挿入
3. zabbix-repo を準備する
ここに画像の説明を挿入

4. ダウンロードをクリックしてここに移動します
ここに画像の説明を挿入
5. Zabbix サーバーのプラットフォームを選択します
ここに画像の説明を挿入
6. Zabbix パッケージをインストールします

  1. プラットフォームに合わせて Zabbix をインストールして構成する
    ここに画像の説明を挿入
[root@zabbix_server ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
获取https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

  1. rpm パッケージをアンインストールする
[root@zabbix_server ~]# yum remove -y zabbix-release.noarch
  1. 上の写真は公式の倉庫です。ダウンロード速度が非常に遅いため、使用はお勧めしません。

外部ミラーが使用できない場合は、Ali が提供する zabbixYUM ソースまたはその他の国内の YUM ソースを使用できます。
Ali ミラー ステーションのアドレスを入力します: https://developer.aliyun.com/mirror/?spm=a2c6h.25603864.0.0.3d501929Ml2fFi
ここに画像の説明を挿入
プルダウンして zabbix を見つけます
ここに画像の説明を挿入
ここに画像の説明を挿入
ここに画像の説明を挿入
ここに画像の説明を挿入
ここに画像の説明を挿入
ここに画像の説明を挿入
ここに画像の説明を挿入
ここに画像の説明を挿入

  1. zabbix YUM リポジトリの構成
[root@zabbix_server ~]# cd /etc/yum.repos.d
[root@zabbix_server yum.repos.d]# ls
CentOS-Base.repo  CentOS-Base.repo.bak  epel.repo  epel-testing.repo  vscode.repo  zabbix.repo
[root@zabbix_server yum.repos.d]# vim zabbix.repo

[zabbix]
name=alibaba zabbix
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/
gpgcheck=0
enabled=1

[zabbix2]
name=alibaba zabbix frontend
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/frontend/
gpgcheck=0
enabled=1

  1. zabbix yum リポジトリを設定した後、リストをクリアします
[root@zabbix_server ~]# yum repolist
已加载插件:langpacks
zabbix                           | 2.9 kB     00:00     
zabbix2                          | 2.9 kB     00:00     
zabbix2/primary_db                 |  60 kB   00:00     
源标识           源名称                           状态
base/7/x86_64    CentOS-7 - Base - mirrors.aliyun 10,072
code             Visual Studio Code                2,753
epel/x86_64      Extra Packages for Enterprise Li 13,735
extras/7/x86_64  CentOS-7 - Extras - mirrors.aliy    515
updates/7/x86_64 CentOS-7 - Updates - mirrors.ali  4,300
zabbix           alibaba zabbix                      321
zabbix2          alibaba zabbix frontend             293
repolist: 31,989

ここに画像の説明を挿入

[root@zabbix_server ~]#  yum clean all 
已加载插件:langpacks
正在清理软件源: base code epel extras updates zabbix
               : zabbix2
Other repos take up 32 M of disk space (use --verbose for details)
[root@zabbix_server ~]# yum repolist
已加载插件:langpacks
base                             | 3.6 kB     00:00     
code                             | 3.0 kB     00:00     
epel                             | 4.7 kB     00:00     
extras                           | 2.9 kB     00:00     
updates                          | 2.9 kB     00:00     
zabbix                           | 2.9 kB     00:00     
zabbix2                          | 2.9 kB     00:00     
(1/10): epel/x86_64/group_gz       |  98 kB   00:00     
(2/10): base/7/x86_64/group_gz     | 153 kB   00:00     
(3/10): code/primary_db            | 2.6 MB   00:01     
(4/10): extras/7/x86_64/primary_db | 249 kB   00:01     
(5/10): zabbix/primary_db          | 187 kB   00:01     
(6/10): zabbix2/primary_db         |  60 kB   00:00     
(7/10): epel/x86_64/updateinfo     | 1.0 MB   00:03     
(8/10): base/7/x86_64/primary_db   | 6.1 MB   00:20     
(9/10): epel/x86_64/primary_db     | 7.0 MB   00:24     
(10/10): updates/7/x86_64/primary_ |  17 MB   00:58     
源标识           源名称                           状态
base/7/x86_64    CentOS-7 - Base - mirrors.aliyun 10,072
code             Visual Studio Code                2,753
epel/x86_64      Extra Packages for Enterprise Li 13,735
extras/7/x86_64  CentOS-7 - Extras - mirrors.aliy    515
updates/7/x86_64 CentOS-7 - Updates - mirrors.ali  4,300
zabbix           alibaba zabbix                      321
zabbix2          alibaba zabbix frontend             293
repolist: 31,989

  1. Zabbixサーバー、Webフロントエンド、エージェントのインストール
    ここに画像の説明を挿入
[root@zabbix_server yum.repos.d]# yum install zabbix-server-mysql zabbix-agent -y
已加载插件:langpacks
zabbix                                                                                                 | 2.9 kB  00:00:00     
zabbix2                                                                                                | 2.9 kB  00:00:00     
软件包 zabbix-server-mysql-5.0.28-1.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 zabbix-agent.x86_64.0.5.0.28-1.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

==============================================================================================================================
 Package                         架构                      版本                               源                         大小
==============================================================================================================================
正在安装:
 zabbix-agent                    x86_64                    5.0.28-1.el7                       zabbix                    479 k

事务概要
==============================================================================================================================
安装  1 软件包

总下载量:479 k
安装大小:1.9 M
Downloading packages:
No Presto metadata available for zabbix
zabbix-agent-5.0.28-1.el7.x86_64.rpm                                                                   | 479 kB  00:00:02     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
** 发现 1 个已存在的 RPM 数据库问题, 'yum check' 输出如下:
yum-3.4.3-168.el7.centos.noarch 有缺少的需求 yum-plugin-fastestmirror
  正在安装    : zabbix-agent-5.0.28-1.el7.x86_64                                                                          1/1 
  验证中      : zabbix-agent-5.0.28-1.el7.x86_64                                                                          1/1 

已安装:
  zabbix-agent.x86_64 0:5.0.28-1.el7                                                                                          

完毕!

  1. Zabbix フロントエンドをインストールする
    ここに画像の説明を挿入
[root@zabbix_server yum.repos.d]# yum install centos-release-scl -y
已加载插件:langpacks
软件包 centos-release-scl-2-3.el7.centos.noarch 已安装并且是最新版本
无须任何处理

構成ファイル /etc/yum.repos.d/zabbix.repo を編集し、zabbix-frontend リポジトリを有効にします。

vim  /etc/yum.repos.d/zabbix.repo

[zabbix2]
name=alibaba zabbix frontend
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/frontend/
gpgcheck=0
enabled=1

  1. Zabbix フロントエンド パッケージをインストールする
[root@zabbix_server yum.repos.d]# yum install centos-release-scl -y
已加载插件:langpacks
软件包 centos-release-scl-2-3.el7.centos.noarch 已安装并且是最新版本
无须任何处理
[root@zabbix_server yum.repos.d]# vim zabbix.repo
[root@zabbix_server yum.repos.d]# yum install zabbix-web-mysql-scl zabbix-apache-conf-scl -y
已加载插件:langpacks
zabbix                           | 2.9 kB     00:00     
zabbix2                          | 2.9 kB     00:00     
软件包 zabbix-web-mysql-scl-5.0.28-1.el7.noarch 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 zabbix-apache-conf-scl.noarch.0.5.0.28-1.el7 将被 安装
--> 正在处理依赖关系 httpd,它被软件包 zabbix-apache-conf-scl-5.0.28-1.el7.noarch 需要
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-97.el7.centos.5 将被 安装
--> 解决依赖关系完成

依赖关系解决

========================================================
 Package     架构   版本                  源       大小
========================================================
正在安装:
 zabbix-apache-conf-scl
             noarch 5.0.28-1.el7          zabbix2  16 k
为依赖而安装:
 httpd       x86_64 2.4.6-97.el7.centos.5 updates 2.7 M

事务概要
========================================================
安装  1 软件包 (+1 依赖软件包)

总下载量:2.7 M
安装大小:9.4 M
Downloading packages:
(1/2): zabbix-apache-conf-scl-5.0. |  16 kB   00:00     
(2/2): httpd-2.4.6-97.el7.centos.5 | 2.7 MB   00:09     
--------------------------------------------------------
总计                       302 kB/s | 2.7 MB  00:09     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : httpd-2.4.6-97.el7.centos.5.x86_6   1/2 
  正在安装    : zabbix-apache-conf-scl-5.0.28-1.e   2/2 
  验证中      : zabbix-apache-conf-scl-5.0.28-1.e   1/2 
  验证中      : httpd-2.4.6-97.el7.centos.5.x86_6   2/2 

已安装:
  zabbix-apache-conf-scl.noarch 0:5.0.28-1.el7          

作为依赖被安装:
  httpd.x86_64 0:2.4.6-97.el7.centos.5                  

完毕!

7 初期データベースの作成

  1. データベースをインストールする
[root@zabbix_server ~]# yum -y install mariadb mariadb-server
已加载插件:langpacks
软件包 1:mariadb-5.5.68-1.el7.x86_64 已安装并且是最新版本
软件包 1:mariadb-server-5.5.68-1.el7.x86_64 已安装并且是最新版本
无须任何处理

  1. データベースを開始する
[root@zabbix_server ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

[root@zabbix_server ~]# systemctl start mariadb
[root@zabbix_server ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: active (running) since 六 2022-10-29 00:59:24 CST; 8s ago
  Process: 23579 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 23543 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 23578 (mysqld_safe)
    Tasks: 20
   CGroup: /system.slice/mariadb.service
           ├─23578 /bin/sh /usr/bin/mysqld_safe --bas...
           └─23743 /usr/libexec/mysqld --basedir=/usr...

1029 00:59:22 zabbix_server systemd[1]: Starting ...
1029 00:59:22 zabbix_server mariadb-prepare-db-dir[23543]: ...
1029 00:59:22 zabbix_server mariadb-prepare-db-dir[23543]: ...
1029 00:59:22 zabbix_server mysqld_safe[23578]: 2...
1029 00:59:22 zabbix_server mysqld_safe[23578]: 2...
1029 00:59:24 zabbix_server systemd[1]: Started M...
Hint: Some lines were ellipsized, use -l to show in full.


  1. データベースにログインし、zabbix アカウントを認証します。
[root@zabbix_server ~]# mysql -uroot -p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 24
Server version: 5.5.68-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)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> create user zabbix@localhost identified by '123456';
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit; 

  1. zabbix を初期化する
    注: バージョンに問題があります
[root@zabbix_server ~]# ls /usr/share/doc/zabbix-server-mysql-5.0.28
AUTHORS    COPYING        double.sql  README
ChangeLog  create.sql.gz  NEWS
[root@zabbix_server ~]# zcat /usr/share/doc/zabbix-server-mysql-5.0.8/create.sql.gz | mysql -uzabbix    -p'123456'  zabbix

データベースに再度ログインして、インポートが成功したかどうかを確認します。

[root@zabbix_server ~]# mysql -uroot -p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 110
Server version: 5.5.68-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 |
| zabbix             |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
| alerts                     |
| application_discovery      |
| application_prototype      |
| application_template       |
| applications               |
| auditlog                   |
| auditlog_details           |
| autoreg_host               |
| conditions                 |
| config                     |
| config_autoreg_tls         |
| corr_condition             |
| corr_condition_group       |
| corr_condition_tag         |
| corr_condition_tagpair     |
| corr_condition_tagvalue    |
| corr_operation             |
| correlation                |
| dashboard                  |
| dashboard_user             |
| dashboard_usrgrp           |
| dbversion                  |
| dchecks                    |
| dhosts                     |
| drules                     |
| dservices                  |
| escalations                |
| event_recovery             |
| event_suppress             |
| event_tag                  |
| events                     |
| expressions                |
| functions                  |
| globalmacro                |
| globalvars                 |
| graph_discovery            |
| graph_theme                |
| graphs                     |
| graphs_items               |
| group_discovery            |
| group_prototype            |
| history                    |
| history_log                |
| history_str                |
| history_text               |
| history_uint               |
| host_discovery             |
| host_inventory             |
| host_tag                   |
| hostmacro                  |
| hosts                      |
| hosts_groups               |
| hosts_templates            |
| housekeeper                |
| hstgrp                     |
| httpstep                   |
| httpstep_field             |
| httpstepitem               |
| httptest                   |
| httptest_field             |
| httptestitem               |
| icon_map                   |
| icon_mapping               |
| ids                        |
| images                     |
| interface                  |
| interface_discovery        |
| interface_snmp             |
| item_application_prototype |
| item_condition             |
| item_discovery             |
| item_preproc               |
| item_rtdata                |
| items                      |
| items_applications         |
| lld_macro_path             |
| lld_override               |
| lld_override_condition     |
| lld_override_opdiscover    |
| lld_override_operation     |
| lld_override_ophistory     |
| lld_override_opinventory   |
| lld_override_opperiod      |
| lld_override_opseverity    |
| lld_override_opstatus      |
| lld_override_optag         |
| lld_override_optemplate    |
| lld_override_optrends      |
| maintenance_tag            |
| maintenances               |
| maintenances_groups        |
| maintenances_hosts         |
| maintenances_windows       |
| mappings                   |
| media                      |
| media_type                 |
| media_type_message         |
| media_type_param           |
| module                     |
| opcommand                  |
| opcommand_grp              |
| opcommand_hst              |
| opconditions               |
| operations                 |
| opgroup                    |
| opinventory                |
| opmessage                  |
| opmessage_grp              |
| opmessage_usr              |
| optemplate                 |
| problem                    |
| problem_tag                |
| profiles                   |
| proxy_autoreg_host         |
| proxy_dhistory             |
| proxy_history              |
| regexps                    |
| rights                     |
| screen_user                |
| screen_usrgrp              |
| screens                    |
| screens_items              |
| scripts                    |
| service_alarms             |
| services                   |
| services_links             |
| services_times             |
| sessions                   |
| slides                     |
| slideshow_user             |
| slideshow_usrgrp           |
| slideshows                 |
| sysmap_element_trigger     |
| sysmap_element_url         |
| sysmap_shape               |
| sysmap_url                 |
| sysmap_user                |
| sysmap_usrgrp              |
| sysmaps                    |
| sysmaps_elements           |
| sysmaps_link_triggers      |
| sysmaps_links              |
| tag_filter                 |
| task                       |
| task_acknowledge           |
| task_check_now             |
| task_close_problem         |
| task_data                  |
| task_remote_command        |
| task_remote_command_result |
| task_result                |
| timeperiods                |
| trends                     |
| trends_uint                |
| trigger_depends            |
| trigger_discovery          |
| trigger_tag                |
| triggers                   |
| users                      |
| users_groups               |
| usrgrp                     |
| valuemaps                  |
| widget                     |
| widget_field               |
+----------------------------+
166 rows in set (0.00 sec)

若看到这些表则说明导入成功

8 Zabbix サーバーのデータベースを構成する

  1. 構成ファイル /etc/zabbix/zabbix_server.conf を編集し
    、次の構成からコメントを削除します。
[root@zabbix_server ~]# vim /etc/zabbix/zabbix_server.conf 

DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456

9 Zabbix フロントエンド用に PHP を構成する

1. 設定ファイル /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf を編集してコメントを解除し、正しいタイムゾーンを設定します。

[root@zabbix_server ~]# vim  /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf

php_value[date.timezone] = Asia/Shanghai #只需将这行配置好就是行了,其它的不变

  1. Zabbix サーバーとエージェントのプロセスを開始する
    Zabbix サーバーとエージェントのプロセスを開始し、自動的に開始するように設定します。
[root@zabbix_server ~]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
[root@zabbix_server ~]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 六 2022-10-29 01:31:51 CST; 1min 33s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 24463 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 24440 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 24440 (code=exited, status=1/FAILURE)

#说明80端口被占用 在终端: ps -ef|grep httpd察看占用的进程或者用netstat -lnp|grep 80
找到后用kill杀掉
1029 01:31:51 zabbix_server httpd[24440]: (98)Address already in use: AH00072: make_sock: could not bind to addres...:]:80
1029 01:31:51 zabbix_server httpd[24440]: (98)Address already in use: AH00072: make_sock: could not bind to addres....0:80
1029 01:31:51 zabbix_server httpd[24440]: no listening sockets available, shutting down
1029 01:31:51 zabbix_server httpd[24440]: AH00015: Unable to open logs
1029 01:31:51 zabbix_server systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
1029 01:31:51 zabbix_server kill[24463]: kill: cannot find process ""
1029 01:31:51 zabbix_server systemd[1]: httpd.service: control process exited, code=exited status=1
1029 01:31:51 zabbix_server systemd[1]: Failed to start The Apache HTTP Server.
1029 01:31:51 zabbix_server systemd[1]: Unit httpd.service entered failed state.
1029 01:31:51 zabbix_server systemd[1]: httpd.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

[root@zabbix_server ~]#  ps -ef|grep httpd
root      24639  18075  0 01:35 pts/0    00:00:00 grep --color=auto httpd
[root@zabbix_server ~]# netstat -lnp|grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      6782/nginx: master  
tcp6       0      0 :::80                   :::*                    LISTEN      6782/nginx: master  
[root@zabbix_server ~]# kill -9 6782
[root@zabbix_server ~]# netstat -lnp|grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      6783/nginx: worker  
tcp6       0      0 :::80                   :::*                    LISTEN      6783/nginx: worker  
[root@zabbix_server ~]# kill -9 6783
[root@zabbix_server ~]# netstat -lnp|grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      6785/nginx: worker  
tcp6       0      0 :::80                   :::*                    LISTEN      6785/nginx: worker  
[root@zabbix_server ~]# netstat -lnp|grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      6787/nginx: worker  
tcp6       0      0 :::80                   :::*                    LISTEN      6787/nginx: worker  

[root@zabbix_server ~]# kill -9 6787
[root@zabbix_server ~]# netstat -lnp|grep 80
[root@zabbix_server ~]#  ps -ef|grep httpd
root      24806  18075  0 01:38 pts/0    00:00:00 grep --color=auto httpd
[root@zabbix_server ~]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@zabbix_server ~]# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.


ブラウザにzabbix_serverのURLを入力します。ip/zabbix
ここに画像の説明を挿入
ここに画像の説明を挿入
ここに画像の説明を挿入
ここに画像の説明を挿入
ここに画像の説明を挿入

ここに画像の説明を挿入
ここに画像の説明を挿入
ここに画像の説明を挿入

監視対象web001のインストール

  1. web001をホスト名として設定します
[root@web001 ~]#hostnamectl set-hostname web001 或者 hostname  web001  #设置完成后需要退出终端然后重新打开,新的主机名就生效了

  1. ファイアウォールとselinuxをオフにする
[root@web001 ~]# systemctl stop firewalld.service  #停止防火墙服务
[root@web001 ~]# systemctl disable firewalld.service  
[root@web001 ~]# systemctl status firewalld.service  #查看防火墙状态
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

[root@web001 ~]# setenforce 0  #临时关闭selinux
setenforce: SELinux is disabled
[root@web001 ~ ]# vim   /etc/selinux/config   #编辑配置文件为`SELINUX=disabled` 即可永久关闭selinux

[root@web001 ~]# getenforce #查看selinux的状态
Disabled

  1. zabbix リポジトリを準備する
#将zabbix_server(192.168.200.182) 的 zabbix.repo 拷贝到 web001(192.168.200.183)
[root@web001 ~]# scp 192.168.200.182:/etc/yum.repos.d/zabbix.repo  /etc/yum.repos.d/
The authenticity of host '192.168.200.182 (192.168.200.182)' can't be established.
ECDSA key fingerprint is SHA256:ygT6h9ejxNmaemQtyIzVYHEbRko0BaG4PstS2LTavDM.
ECDSA key fingerprint is MD5:88:1f:c4:d2:fe:73:b9:1f:7f:26:cd:2c:ba:ad:5c:b5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.200.182' (ECDSA) to the list of known hosts.
[email protected]'s password: 
Permission denied, please try again.
[email protected]'s password: 
zabbix.repo                                                      100%  257   100.8KB/s   00:00    

[root@web001 ~]# cd /etc/yum.repos.d
[root@web001 yum.repos.d]# ls
CentOS-Base.repo  CentOS-Base.repo.bak  epel.repo  epel-testing.repo  zabbix.repo


ここに画像の説明を挿入
4. zabbix-agent のインストールに関する主な問題は、
ここに画像の説明を挿入
ここに画像の説明を挿入
yum ソースの問題です。そうでない場合は、ネットワークを再起動してみてください。
5. centos7 システム自体にインストールされている yum 依存関係を表示します。

[root@web001 ~]# rpm -qa|grep yum
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch
yum-utils-1.1.31-54.el7_8.noarch
PackageKit-yum-1.1.10-2.el7.centos.x86_64
yum-3.4.3-168.el7.centos.noarch

  1. これらのパッケージをアンインストールする
[root@web001 ~]# rpm -e yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch --nodeps
warning: /etc/yum/pluginconf.d/fastestmirror.conf saved as /etc/yum/pluginconf.d/fastestmirror.conf.rpmsave
[root@web001 ~]# rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps
[root@web001 ~]# rpm -e yum-3.4.3-168.el7.centos.noarch --nodeps
[root@web001 ~]#


  1. centos ミラー Web サイトに入り、対応するシステムでシステム コマンドを表示するために必要な yum パッケージを見つけます。
[root@web001 ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

システム内のビット数を確認します。

[root@web001 ~]# file /bin/ls
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=c8ada1f7095f6b2bb7ddc848e088c2d615c3743e, stripped
[root@web001 ~]# 

4. yum 依存関係パッケージをダウンロードします。

[root@web001 ~]#wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
[root@web001 ~]#wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
[root@web001 ~]#wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm

  1. yum 依存関係をインストールする
[root@web001 ~]# rpm -ivh yum-*
准备中...                          ################################# [100%]
	软件包 yum-metadata-parser-1.1.4-10.el7.x86_64 已经安装
	软件包 yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch (比 yum-plugin-fastestmirror-1.1.31-34.el7.noarch 还要新) 已经安装
....
  1. Centos システムのリポジトリ ファイルを更新するための
    一般的な URL :

中国科学技術大学の Web サイト: http://mirrors.ustc.edu.cn/help/centos.html
163 Web サイト: http://mirrors.163.com/.help/centos.html

6.1 /etc/yum.repos.d/CentOS-Base.repoを悪用しないための初回バックアップ

[root@web001 ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

対応するバージョンの /etc/yum.repos.d/CentOS-Base.repo ファイルを選択し、/etc/yum.repos.d/ に配置します。操作前に対応するバックアップを作成してください。

たとえば、自分の centos のバージョンは 7 なので、バージョン 7 のコンテンツを使用します。

ここに画像の説明を挿入

vim /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

6.3 次のコマンドを実行してキャッシュを生成します

[root@web001 yum.repos.d]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base extras updates
Cleaning up list of fastest mirrors
Other repos take up 26 M of disk space (use --verbose for details)
[root@web001 yum.repos.d]# yum makecache
已加载插件:fastestmirror
Determining fastest mirrors
base                                                                   | 3.6 kB  00:00:00     
extras                                                                 | 2.9 kB  00:00:00     
updates                                                                | 2.9 kB  00:00:00     
(1/10): base/7/x86_64/group_gz                                         | 153 kB  00:00:00     
(2/10): base/7/x86_64/filelists_db                                     | 7.2 MB  00:00:01     
(3/10): base/7/x86_64/primary_db                                       | 6.1 MB  00:00:00     
(4/10): base/7/x86_64/other_db                                         | 2.6 MB  00:00:00     
(5/10): extras/7/x86_64/primary_db                                     | 249 kB  00:00:00     
(6/10): extras/7/x86_64/filelists_db                                   | 276 kB  00:00:00     
(7/10): extras/7/x86_64/other_db                                       | 149 kB  00:00:00     
(8/10): updates/7/x86_64/filelists_db                                  | 9.6 MB  00:00:01     
(9/10): updates/7/x86_64/other_db                                      | 1.2 MB  00:00:00     
(10/10): updates/7/x86_64/primary_db                                   |  17 MB  00:00:01     
元数据缓存已建立

[root@web001 yum.repos.d]# yum makecache
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
base                                                                   | 3.6 kB  00:00:00     
extras                                                                 | 2.9 kB  00:00:00     
updates                                                                | 2.9 kB  00:00:00     
zabbix                                                                 | 2.9 kB  00:00:00     
zabbix2                                                                | 2.9 kB  00:00:00     
(1/16): base/7/x86_64/group_gz                                         | 153 kB  00:00:00     
(2/16): base/7/x86_64/filelists_db                                     | 7.2 MB  00:00:00     
(3/16): base/7/x86_64/primary_db                                       | 6.1 MB  00:00:00     
(4/16): base/7/x86_64/other_db                                         | 2.6 MB  00:00:00     
(5/16): extras/7/x86_64/primary_db                                     | 249 kB  00:00:00     
(6/16): extras/7/x86_64/filelists_db                                   | 276 kB  00:00:00     
(7/16): extras/7/x86_64/other_db                                       | 149 kB  00:00:00     
(8/16): updates/7/x86_64/filelists_db                                  | 9.6 MB  00:00:01     
(9/16): updates/7/x86_64/other_db                                      | 1.2 MB  00:00:00     
(10/16): updates/7/x86_64/primary_db                                   |  17 MB  00:00:01     
(11/16): zabbix/filelists_db                                           |  65 kB  00:00:00     
(12/16): zabbix/primary_db                                             | 187 kB  00:00:01     
(13/16): zabbix2/primary_db                                            |  60 kB  00:00:00     
(14/16): zabbix2/filelists_db                                          | 118 kB  00:00:00     
(15/16): zabbix/other_db                                               | 305 kB  00:00:01     
(16/16): zabbix2/other_db                                              | 280 kB  00:00:00     
元数据缓存已建立

[root@web001 yum.repos.d]# yum update
BDB2053 Freeing read locks for locker 0x1265: 15380/139687202490176
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
zabbix                                                                 | 2.9 kB  00:00:00     
zabbix2                                                                | 2.9 kB  00:00:00     
正在解决依赖关系
--> 正在检查事务
---> 软件包 GeoIP.x86_64.0.1.5.0-13.el7 将被 升级
---> 软件包 GeoIP.x86_64.0.1.5.0-14.el7 将被 更新
--> 正在处理依赖关系 geoipupdate,它被软件包 GeoIP-1.5.0-14.el7.x86_64 需要
---> 软件包 ModemManager.x86_64.0.1.6.10-1.el7 将被 升级
---> 软件包 ModemManager.x86_64.0.1.6.10-4.el7 将被 更新

.......
 xorg-x11-server-common.x86_64 0:1.20.4-18.el7_9                                             
  xz.x86_64 0:5.2.2-2.el7_9                                                                   
  xz-libs.x86_64 0:5.2.2-2.el7_9                                                              
  zenity.x86_64 0:3.28.1-2.el7_9                                                              

替代:
  iwl7265-firmware.noarch 0:22.0.7.0-69.el7                 urw-fonts.noarch 0:2.4-16.el7     
  webkitgtk4-plugin-process-gtk2.x86_64 0:2.20.5-1.el7     

完毕!

問題は解決し、正常にインストールされました

[root@web001 yum.repos.d]# yum -y install zabbix-agent
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 zabbix-agent.x86_64.0.5.0.28-1.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

==============================================================================================
 Package                 架构              版本                       源                 大小
==============================================================================================
正在安装:
 zabbix-agent            x86_64            5.0.28-1.el7               zabbix            479 k

事务概要
==============================================================================================
安装  1 软件包

总下载量:479 k
安装大小:1.9 M
Downloading packages:
No Presto metadata available for zabbix
zabbix-agent-5.0.28-1.el7.x86_64.rpm                                   | 479 kB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : zabbix-agent-5.0.28-1.el7.x86_64                                          1/1 
  验证中      : zabbix-agent-5.0.28-1.el7.x86_64                                          1/1 

已安装:
  zabbix-agent.x86_64 0:5.0.28-1.el7                                                          

完毕!

6.4 メインサーバーアドレスの設定

[root@web001 ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.200.182   #者zabbix_server的IP地址
ServerActive=192.200.168.182
Hostname=web001

6.5 zabbix-agentの起動: 10050

[root@web001 ~]# systemctl start zabbix-agent
[root@web001 ~]# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@web001 ~]# ss -anlp |grep :10050
tcp    LISTEN     0      128       *:10050                 *:*                   users:(("zabbix_agentd",pid=112433,fd=4),("zabbix_agentd",pid=112432,fd=4),("zabbix_agentd",pid=112431,fd=4),("zabbix_agentd",pid=112430,fd=4),("zabbix_agentd",pid=112429,fd=4),("zabbix_agentd",pid=112428,fd=4))
tcp    LISTEN     0      128    [::]:10050              [::]:*                   users:(("zabbix_agentd",pid=112433,fd=5),("zabbix_agentd",pid=112432,fd=5),("zabbix_agentd",pid=112431,fd=5),("zabbix_agentd",pid=112430,fd=5),("zabbix_agentd",pid=112429,fd=5),("zabbix_agentd",pid=112428,fd=5))
[root@web001 ~]# 

テスト
zabbix_server (192.168.200.182) で zabbix_get (コマンド ライン監視) を使用してクライアント データを収集する

5.0zabbix では zabbix-get がデフォルトでインストールされていないため、zabbix_server にインストールする必要があります

[root@web001 ~]# yum install -y zabbix-get
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
软件包 zabbix-get-5.0.28-1.el7.x86_64 已安装并且是最新版本
无须任何处理

[root@zabbix_server ~]# zabbix_get -s 192.168.200.183 -k system.uname
Linux web001 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64

[root@zabbix_server ~]# zabbix_get -s 192.168.200.183 -k system.cpu.load[all,avg15]
0.050000

この時点で、zabbix_serverによるweb001の監視が完了します。


おすすめ

転載: blog.csdn.net/guanguan12319/article/details/127579825