Zabbix监控服务综合项目

文章目录

一、项目环境

系统主机名IP服务
Centos7.5Zabbix192.168.137.22Zabbix监控
Centos7.5LNMP192.168.137.33对接监管LNMP架构服务
ensp模拟器Ensp192.168.137.10对接网络设备

二、zabbix监控服务器部署

1.修改主机名和关闭防火墙
[root@lc2 ~]# hostnamectl set-hostname zabbix
[root@lc2 ~]# bash
[root@zabbix ~]# 
[root@zabbix ~]# systemctl stop firewalld.service 
[root@zabbix ~]# systemctl disable firewalld.service 
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

[root@zabbix ~]# setenforce 0
[root@zabbix ~]# vim /etc/selinux/config 
[root@zabbix ~]# cat /etc/selinux/config 

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disable    #(修改此处)
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted 

2.安装repo、server、agent以及frontend等仓库和软件包
[root@zabbix ~]# 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
警告:/var/tmp/rpm-tmp.arxJdL: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:zabbix-release-5.0-1.el7         ################################# [100%]
[root@zabbix ~]# 


[root@zabbix ~]# yum -y install zabbix-server-mysql zabbix-agent -y
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
base                            | 3.6 kB     00:00     
extras                          | 2.9 kB     00:00     
updates                         | 2.9 kB     00:00     
zabbix                          | 2.9 kB     00:00     
zabbix-non-supported            | 2.9 kB     00:00     
(1/3): zabbix-non-supported/x86_6 | 3.7 kB   00:00     
(2/3): zabbix/x86_64/primary_db   | 207 kB   00:01     
(3/3): updates/7/x86_64/primary_d |  20 MB   00:02     
正在解决依赖关系
--> 正在检查事务
---> 软件包 zabbix-agent.x86_64.0.5.0.32-1.el7 将被 安装
---> 软件包 zabbix-server-mysql.x86_64.0.5.0.32-1.el7 将被 安装
--> 正在处理依赖关系 fping,它被软件包 zabbix-server-mysql-5.0.32-1.el7.x86_64 需要
--> 正在处理依赖关系 libOpenIPMIposix.so.0()(64bit),它被软件包 zabbix-server-mysql-5.0.32-1.el7.x86_64 需要
--> 正在处理依赖关系 libOpenIPMI.so.0()(64bit),它被软件包 zabbix-server-mysql-5.0.32-1.el7.x86_64 需要
--> 正在处理依赖关系 libodbc.so.2()(64bit),它被软件包 zabbix-server-mysql-5.0.32-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 OpenIPMI-libs.x86_64.0.2.0.27-1.el7 将被 安装
--> 正在处理依赖关系 OpenIPMI-modalias = 2.0.27-1.el7,它被软件包 OpenIPMI-libs-2.0.27-1.el7.x86_64 需要
---> 软件包 fping.x86_64.0.3.16-1.el7 将被 安装
---> 软件包 unixODBC.x86_64.0.2.3.1-14.el7 将被 安装
--> 正在检查事务
---> 软件包 OpenIPMI-modalias.x86_64.0.2.0.27-1.el7 将被 安装
--> 正在处理依赖关系 OpenIPMI,它被软件包 OpenIPMI-modalias-2.0.27-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 OpenIPMI.x86_64.0.2.0.27-1.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=======================================================
 Package             架构   版本         源       大小
=======================================================
正在安装:
 zabbix-agent        x86_64 5.0.32-1.el7 zabbix  482 k
 zabbix-server-mysql x86_64 5.0.32-1.el7 zabbix  3.1 M
为依赖而安装:
 OpenIPMI            x86_64 2.0.27-1.el7 base    243 k
 OpenIPMI-libs       x86_64 2.0.27-1.el7 base    523 k
 OpenIPMI-modalias   x86_64 2.0.27-1.el7 base     16 k
 fping               x86_64 3.16-1.el7   zabbix-non-supported
                                                  44 k
 unixODBC            x86_64 2.3.1-14.el7 base    413 k

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

总下载量:4.8 M
安装大小:13 M
Downloading packages:
警告:/var/cache/yum/x86_64/7/base/packages/OpenIPMI-2.0.27-1.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
OpenIPMI-2.0.27-1.el7.x86_64.rpm 的公钥尚未安装
(1/7): OpenIPMI-2.0.27-1.el7.x86_ | 243 kB   00:00     
(2/7): OpenIPMI-modalias-2.0.27-1 |  16 kB   00:00     
(3/7): OpenIPMI-libs-2.0.27-1.el7 | 523 kB   00:00     
(4/7): unixODBC-2.3.1-14.el7.x86_ | 413 kB   00:00     
警告:/var/cache/yum/x86_64/7/zabbix-non-supported/packages/fping-3.16-1.el7.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 79ea5ed4: NOKEY
fping-3.16-1.el7.x86_64.rpm 的公钥尚未安装
(5/7): fping-3.16-1.el7.x86_64.rp |  44 kB   00:00     
警告:/var/cache/yum/x86_64/7/zabbix/packages/zabbix-agent-5.0.32-1.el7.x86_64.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
zabbix-agent-5.0.32-1.el7.x86_64.rpm 的公钥尚未安装
(6/7): zabbix-agent-5.0.32-1.el7. | 482 kB   00:01     
(7/7): zabbix-server-mysql-5.0.32 | 3.1 MB   00:02     
-------------------------------------------------------
总计                      1.7 MB/s | 4.8 MB  00:02     
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 检索密钥
导入 GPG key 0xA14FE591:
 用户ID     : "Zabbix LLC <packager@zabbix.com>"
 指纹       : a184 8f53 52d0 22b9 471d 83d0 082a b56b a14f e591
 软件包     : zabbix-release-5.0-1.el7.noarch (installed)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
 用户ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 指纹       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 软件包     : centos-release-7-5.1804.el7.centos.x86_64 (@anaconda)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX 检索密钥
导入 GPG key 0x79EA5ED4:
 用户ID     : "Zabbix SIA <packager@zabbix.com>"
 指纹       : fbab d5fb 2025 5eca b22e e194 d13d 58e4 79ea 5ed4
 软件包     : zabbix-release-5.0-1.el7.noarch (installed)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
  正在安装    : OpenIPMI-libs-2.0.27-1.el7.x86_6   1/7 
  正在安装    : OpenIPMI-2.0.27-1.el7.x86_64       2/7 
  正在安装    : OpenIPMI-modalias-2.0.27-1.el7.x   3/7 
  正在安装    : fping-3.16-1.el7.x86_64            4/7 
  正在安装    : unixODBC-2.3.1-14.el7.x86_64       5/7 
  正在安装    : zabbix-server-mysql-5.0.32-1.el7   6/7 
  正在安装    : zabbix-agent-5.0.32-1.el7.x86_64   7/7 
WARNING: ipmi_devintf module isn't available.
WARNING: ipmi_msghandler module isn't available.
  验证中      : zabbix-server-mysql-5.0.32-1.el7   1/7 
  验证中      : OpenIPMI-2.0.27-1.el7.x86_64       2/7 
  验证中      : zabbix-agent-5.0.32-1.el7.x86_64   3/7 
  验证中      : unixODBC-2.3.1-14.el7.x86_64       4/7 
  验证中      : OpenIPMI-libs-2.0.27-1.el7.x86_6   5/7 
  验证中      : fping-3.16-1.el7.x86_64            6/7 
  验证中      : OpenIPMI-modalias-2.0.27-1.el7.x   7/7 

已安装:
  zabbix-agent.x86_64 0:5.0.32-1.el7                   
  zabbix-server-mysql.x86_64 0:5.0.32-1.el7            

作为依赖被安装:
  OpenIPMI.x86_64 0:2.0.27-1.el7                       
  OpenIPMI-libs.x86_64 0:2.0.27-1.el7                  
  OpenIPMI-modalias.x86_64 0:2.0.27-1.el7              
  fping.x86_64 0:3.16-1.el7                            
  unixODBC.x86_64 0:2.3.1-14.el7                       

完毕!


[root@zabbix ~]# yum -y install centos-release-scl 
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 centos-release-scl.noarch.0.2-3.el7.centos 将被 安装
--> 正在处理依赖关系 centos-release-scl-rh,它被软件包 centos-release-scl-2-3.el7.centos.noarch 需要
--> 正在检查事务
---> 软件包 centos-release-scl-rh.noarch.0.2-3.el7.centos 将被 安装
--> 解决依赖关系完成

依赖关系解决

=======================================================
 Package            架构   版本           源      大小
=======================================================
正在安装:
 centos-release-scl noarch 2-3.el7.centos extras  12 k
为依赖而安装:
 centos-release-scl-rh
                    noarch 2-3.el7.centos extras  12 k

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

总下载量:24 k
安装大小:39 k
Downloading packages:
(1/2): centos-release-scl-2-3.el7 |  12 kB   00:00     
(2/2): centos-release-scl-rh-2-3. |  12 kB   00:00     
-------------------------------------------------------
总计                      208 kB/s |  24 kB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : centos-release-scl-rh-2-3.el7.ce   1/2 
  正在安装    : centos-release-scl-2-3.el7.cento   2/2 
  验证中      : centos-release-scl-2-3.el7.cento   1/2 
  验证中      : centos-release-scl-rh-2-3.el7.ce   2/2 

已安装:
  centos-release-scl.noarch 0:2-3.el7.centos           

作为依赖被安装:
  centos-release-scl-rh.noarch 0:2-3.el7.centos        

完毕!

3.修改zabbix的yum源,并重新安装相关软件包

将第11行的enabled=0改成enabled=1

[root@zabbix ~]# cat /etc/yum.repos.d/zabbix.repo 
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=1

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1


[root@zabbix ~]# sed -i '11s/0/1/' /etc/yum.repos.d/zabbix.repo
[root@zabbix ~]# cat /etc/yum.repos.d/zabbix.repo [zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1       (此处的0改成1)
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=1

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1




[root@zabbix ~]# yum -y install zabbix-we-mysql-scl zabbix-apache-conf-scl 
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * centos-sclo-rh: mirrors.tuna.tsinghua.edu.cn
 * centos-sclo-sclo: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
centos-sclo-rh                  | 3.0 kB     00:00     
centos-sclo-sclo                | 3.0 kB     00:00     
zabbix                          | 2.9 kB     00:00     
zabbix-frontend                 | 2.9 kB     00:00     
zabbix-non-supported            | 2.9 kB     00:00     
(1/3): centos-sclo-sclo/x86_64/pr | 300 kB   00:00     
(2/3): zabbix-frontend/x86_64/pri |  67 kB   00:00     
(3/3): centos-sclo-rh/x86_64/prim | 3.4 MB   00:01     
没有可用软件包 zabbix-we-mysql-scl。
正在解决依赖关系
--> 正在检查事务
---> 软件包 zabbix-apache-conf-scl.noarch.0.5.0.32-1.el7 将被 安装
--> 正在处理依赖关系 zabbix-web-deps-scl = 5.0.32-1.el7,它被软件包 zabbix-

         (省略)
         
  rh-php72-php-pear.noarch 1:1.10.5-1.el7              
  rh-php72-php-pgsql.x86_64 0:7.2.24-1.el7             
  rh-php72-php-process.x86_64 0:7.2.24-1.el7           
  rh-php72-php-xml.x86_64 0:7.2.24-1.el7               
  rh-php72-php-zip.x86_64 0:7.2.24-1.el7               
  rh-php72-runtime.x86_64 0:1-2.el7                    
  zabbix-web.noarch 0:5.0.32-1.el7                     
  zabbix-web-deps-scl.noarch 0:5.0.32-1.el7            
  zabbix-web-pgsql-scl.noarch 0:5.0.32-1.el7           

完毕!

4.安装数据库并启动服务,同时给zabbix创建对应的库和用户授权以及导入Mysql数据库初始架构和数据
[root@zabbix ~]# yum -y install mariadb mariadb-server
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * centos-sclo-rh: mirrors.tuna.tsinghua.edu.cn
 * centos-sclo-sclo: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
正在解决依赖关系

        (省略)

已安装:
  mariadb.x86_64 1:5.5.68-1.el7                        
  mariadb-server.x86_64 1:5.5.68-1.el7                 

作为依赖被安装:
  perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7         
  perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7          
  perl-DBD-MySQL.x86_64 0:4.023-6.el7                  
  perl-DBI.x86_64 0:1.627-4.el7                        
  perl-Data-Dumper.x86_64 0:2.145-3.el7                
  perl-IO-Compress.noarch 0:2.061-2.el7                
  perl-Net-Daemon.noarch 0:0.48-5.el7                  
  perl-PlRPC.noarch 0:0.2020-14.el7                    

作为依赖被升级:
  mariadb-libs.x86_64 1:5.5.68-1.el7                   

完毕!


[root@zabbix ~]# systemctl restart mariadb.service 
[root@zabbix ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.


[root@zabbix ~]# ps aux | grep mysql     #(查看进程)
mysql     28290  0.0  0.0 113304  1608 ?        Ss   13:48   0:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
mysql     28455  0.0  2.0 968888 80804 ?        Sl   13:48   0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock
root      41062  0.0  0.0 112720   984 pts/1    S+   13:58   0:00 grep --color=auto mysql


[root@zabbix ~]# netstat -anplut       #(查看端口状态)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      28455/mysqld        
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      712/rpcbind         
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      1970/dnsmasq        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1152/sshd           
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      1154/cupsd          
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1423/master         
tcp        0      0 192.168.137.22:22       192.168.137.1:65015     ESTABLISHED 3958/sshd: root@not 
tcp        0     52 192.168.137.22:22       192.168.137.1:65014     ESTABLISHED 3917/sshd: root@pts 
tcp6       0      0 :::111                  :::*                    LISTEN      712/rpcbind         
tcp6       0      0 :::22                   :::*                    LISTEN      1152/sshd           
tcp6       0      0 ::1:631                 :::*                    LISTEN      1154/cupsd          
tcp6       0      0 ::1:25                  :::*                    LISTEN      1423/master         
udp        0      0 127.0.0.1:323           0.0.0.0:*                           727/chronyd         
udp        0      0 0.0.0.0:55834           0.0.0.0:*                           710/avahi-daemon: r 
udp        0      0 0.0.0.0:877             0.0.0.0:*                           712/rpcbind         
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           710/avahi-daemon: r 
udp        0      0 192.168.122.1:53        0.0.0.0:*                           1970/dnsmasq        
udp        0      0 0.0.0.0:67              0.0.0.0:*                           1970/dnsmasq        
udp        0      0 0.0.0.0:111             0.0.0.0:*                           712/rpcbind         
udp6       0      0 ::1:323                 :::*                                727/chronyd         
udp6       0      0 :::877                  :::*                                712/rpcbind         
udp6       0      0 :::111                  :::*                                712/rpcbind         



[root@zabbix ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
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;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> create user zabbix@localhost identified by '123456';
Query OK, 0 rows affected (0.01 sec)

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

MariaDB [(none)]> exit
Bye
[root@zabbix ~]# 


[root@zabbix ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password:        #密码是123456

5.更改Zabbix相关配置文件

修改第124行

[root@zabbix ~]# vim /etc/zabbix/zabbix_server.conf +124
[root@zabbix ~]# cat -n /etc/zabbix/zabbix_server.conf 
     1  # This is a configuration file for Zabbix server daemon
     2  # To get more information about Zabbix, visit http://www.zabbix.com
     3  
     4  ############ GENERAL PARAMETERS #################
     5  
     6  ### Option: ListenPort
     7  #       Listen port for trapper.
     8  #
     9  # Mandatory: no
    10  # Range: 1024-32767
    11  # Default:
    12  # ListenPort=10051
    13  
    14  ### Option: SourceIP
    15  #       Source IP address for outgoing connections.
    16  #
        (省略)
     100  DBName=zabbix
   101  
   102  ### Option: DBSchema
   103  #       Schema name. Used for PostgreSQL.
   104  #
   105  # Mandatory: no
   106  # Default:
   107  # DBSchema=
   108  
   109  ### Option: DBUser
   110  #       Database user.
   111  #
   112  # Mandatory: no
   113  # Default:
   114  # DBUser=
   115  
   116  DBUser=zabbix
   117  
   118  ### Option: DBPassword
   119  #       Database password.
   120  #       Comment this line if no password is used.
   121  #
   122  # Mandatory: no
   123  # Default:
   124   DBPassword=123456        #启动密码,设置为123456
   125  
   126  ### Option: DBSocket
   127  #       Path to MySQL socket.
      (省略)
      
      
#在最后一行添加时区信息    
[root@zabbix ~]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf 
[root@zabbix ~]# cat /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf 
[zabbix]
user = apache
group = apache

listen = /var/opt/rh/rh-php72/run/php-fpm/zabbix.sock
listen.acl_users = apache
listen.allowed_clients = 127.0.0.1

pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 200

php_value[session.save_handler] = files
php_value[session.save_path]    = /var/opt/rh/rh-php72/lib/php/session/

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[date.timezone] = Europe/Riga
php_value[date.timezone] = Asia/shanghai     #手动添加时区
      
6.启动Zabbix server和agent进程;并查看服务状态
[root@zabbix ~]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@zabbix ~]# 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.
Created symlink from /etc/systemd/system/multi-user.target.wants/rh-php72-php-fpm.service to /usr/lib/systemd/system/rh-php72-php-fpm.service.
[root@zabbix ~]# systemctl status zabbix-server zabbix-agent httpd rh-php72-php-fpm 
● zabbix-server.service - Zabbix Server
   Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; enabled; vendor preset: disabled)
   Active: active (running) since 一 2023-03-20 14:14:53 CST; 23s ago
 Main PID: 67890 (zabbix_server)
   CGroup: /system.slice/zabbix-server.service
           ├─67890 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
           ├─67897 /usr/sbin/zabbix_server: configuration syncer [synced configu...
           ├─67910 /usr/sbin/zabbix_server: alert manager #1 [sent 0, failed 0 a...
           ├─67911 /usr/sbin/zabbix_server: alerter #1 started
           ├─67912 /usr/sbin/zabbix_server: alerter #2 started
           ├─67913 /usr/sbin/zabbix_server: alerter #3 started
           ├─67915 /usr/sbin/zabbix_server: preprocessing manager #1 [queued 0, ...
           ├─67916 /usr/sbin/zabbix_server: preprocessing worker #1 started
           ├─67922 /usr/sbin/zabbix_server: preprocessing worker #2 started
           ├─67923 /usr/sbin/zabbix_server: preprocessing worker #3 started
           ├─67924 /usr/sbin/zabbix_server: lld manager #1 [processed 0 LLD rule...
           ├─67927 /usr/sbin/zabbix_server: lld worker #1 started
           ├─67928 /usr/sbin/zabbix_server: lld worker #2 started
           ├─67929 /usr/sbin/zabbix_server: housekeeper [startup idle for 30 min...
           ├─67930 /usr/sbin/zabbix_server: timer #1 [updated 0 hosts, suppresse...
           ├─67934 /usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.00...
           ├─67936 /usr/sbin/zabbix_server: discoverer #1 [processed 0 rules in ...
           ├─67937 /usr/sbin/zabbix_server: history syncer #1 [processed 0 value...
           ├─67939 /usr/sbin/zabbix_server: history syncer #2 [processed 0 value...
           ├─67940 /usr/sbin/zabbix_server: history syncer #3 [processed 0 value...
           ├─67945 /usr/sbin/zabbix_server: history syncer #4 [processed 0 value...
           ├─67946 /usr/sbin/zabbix_server: escalator #1 [processed 0 escalation...
           ├─67951 /usr/sbin/zabbix_server: proxy poller #1 [exchanged data with...
           ├─67952 /usr/sbin/zabbix_server: self-monitoring [processed data in 0...
           ├─67956 /usr/sbin/zabbix_server: task manager [processed 0 task(s) in...
           ├─67957 /usr/sbin/zabbix_server: poller #1 [got 0 values in 0.000033 ...
           ├─67962 /usr/sbin/zabbix_server: poller #2 [got 0 values in 0.000045 ...
           ├─67963 /usr/sbin/zabbix_server: poller #3 [got 0 values in 0.000026 ...
           ├─67967 /usr/sbin/zabbix_server: poller #4 [got 1 values in 0.000432 ...
           ├─67968 /usr/sbin/zabbix_server: poller #5 [got 0 values in 0.000017 ...
           ├─67971 /usr/sbin/zabbix_server: unreachable poller #1 [got 0 values ...
           ├─67972 /usr/sbin/zabbix_server: trapper #1 [processed data in 0.0035...
           ├─67975 /usr/sbin/zabbix_server: trapper #2 [processed data in 0.0000...
           ├─67976 /usr/sbin/zabbix_server: trapper #3 [processed data in 0.0000...
           ├─67977 /usr/sbin/zabbix_server: trapper #4 [processed data in 0.0000...
           ├─67978 /usr/sbin/zabbix_server: trapper #5 [processed data in 0.0000...
           ├─67982 /usr/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.00...
           └─67983 /usr/sbin/zabbix_server: alert syncer [queued 0 alerts(s), fl...

3月 20 14:14:53 zabbix systemd[1]: Starting Zabbix Server...
3月 20 14:14:53 zabbix systemd[1]: Started Zabbix Server.

● zabbix-agent.service - Zabbix Agent
   Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: disabled)
   Active: active (running) since 一 2023-03-20 14:14:53 CST; 23s ago
 Main PID: 67903 (zabbix_agentd)
   CGroup: /system.slice/zabbix-agent.service
           ├─67903 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
           ├─67904 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
           ├─67905 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]...
           ├─67906 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]...
           ├─67907 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]...
           └─67909 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

3月 20 14:14:53 zabbix systemd[1]: Starting Zabbix Agent...
3月 20 14:14:53 zabbix systemd[1]: Started Zabbix Agent.

● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since 一 2023-03-20 14:14:53 CST; 23s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 67900 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─67900 /usr/sbin/httpd -DFOREGROUND
           ├─67917 /usr/sbin/httpd -DFOREGROUND
           ├─67918 /usr/sbin/httpd -DFOREGROUND
           ├─67919 /usr/sbin/httpd -DFOREGROUND
           ├─67921 /usr/sbin/httpd -DFOREGROUND
           └─67926 /usr/sbin/httpd -DFOREGROUND

3月 20 14:14:53 zabbix systemd[1]: Starting The Apache HTTP Server...
3月 20 14:14:53 zabbix httpd[67900]: AH00558: httpd: Could not reliably deter...ge
3月 20 14:14:53 zabbix systemd[1]: Started The Apache HTTP Server.

● rh-php72-php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/rh-php72-php-fpm.service; enabled; vendor preset: disabled)
   Active: active (running) since 一 2023-03-20 14:14:53 CST; 23s ago
 Main PID: 67901 (php-fpm)
   Status: "Processes active: 0, idle: 10, Requests: 0, slow: 0, Traffic: 0req/sec"
   CGroup: /system.slice/rh-php72-php-fpm.service
           ├─67901 php-fpm: master process (/etc/opt/rh/rh-php72/php-fpm.conf)
           ├─67933 php-fpm: pool www
           ├─67938 php-fpm: pool www
           ├─67943 php-fpm: pool www
           ├─67948 php-fpm: pool www
           ├─67949 php-fpm: pool www
           ├─67955 php-fpm: pool zabbix
           ├─67959 php-fpm: pool zabbix
           ├─67965 php-fpm: pool zabbix
           ├─67969 php-fpm: pool zabbix
           └─67973 php-fpm: pool zabbix

3月 20 14:14:53 zabbix systemd[1]: Starting The PHP FastCGI Process Manager...
3月 20 14:14:53 zabbix systemd[1]: Started The PHP FastCGI Process Manager.
Hint: Some lines were ellipsized, use -l to show in full.

7.在浏览器访问:192.168.127.22/zabbix

IP地址是安装zabbix监控服务的虚拟机的地址

在这里插入图片描述

检查先决条件是否正常,正常点击下一步

在这里插入图片描述

修改数据库端口号为3306,密码为前面创建的密码 123456

在这里插入图片描述

名字自行定义

在这里插入图片描述

配置没有问题直接下一步

在这里插入图片描述

点击安装完成

在这里插入图片描述

输入用户名 Admin,密码是zabbix,即可登录平台,然后就可以看到管理界面

在这里插入图片描述

在这里插入图片描述

三、ensp网络配置对接zabbix

8.在ensp上绘制拓扑图和基本设置

拓扑图

AR1和AR2的型号是AR2220

LSW1型号是S5700

LSW2和LSW3型号是S3700

在这里插入图片描述

cloud配置

在这里插入图片描述

配置四台PC的IP地址

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

9.网络设备的配置,其中路由器和三层交换机用ospf协议。

AR1

AR1
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip add 192.168.1.1 24
[R1-GigabitEthernet0/0/0]qu
[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 192.168.2.1 24
[R1-GigabitEthernet0/0/1]qu
[R1]int g0/0/2
[R1-GigabitEthernet0/0/2]ip add 192.168.137.10 24
[R1-GigabitEthernet0/0/2]qu
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 192.168.137.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]qu
[R1-ospf-1]qu
[R1]

AR2

AR2
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R2
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 192.168.2.2 24
[R2-GigabitEthernet0/0/0]qu
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 192.168.3.2 24
[R2-GigabitEthernet0/0/1]qu
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 192.168.3.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]qu
[R2-ospf-1]qu
[R2]

LSW1

L3SW1
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname L3SW1
[L3SW1]vlan 10
[L3SW1-vlan10]qu

[L3SW1]int g0/0/3
[L3SW1-GigabitEthernet0/0/3]port link-type trunk 
[L3SW1-GigabitEthernet0/0/3]port trunk allow-pass vlan 10 20
[L3SW1-GigabitEthernet0/0/3]qu

[L3SW1]int vlan 10
[L3SW1-Vlanif10]ip add 192.168.4.254 24
[L3SW1-Vlanif10]qu

[L3SW1]vlan 20
[L3SW1-vlan20]qu

[L3SW1]int g0/0/4
[L3SW1-GigabitEthernet0/0/4]port link-type trunk 
[L3SW1-GigabitEthernet0/0/4]port trunk allow-pass vlan 10 20
[L3SW1-GigabitEthernet0/0/4]qu

[L3SW1]int vlan 20
[L3SW1-Vlanif20]ip add 192.168.5.254 24
[L3SW1-Vlanif20]qu

[L3SW1]int g0/0/1
[L3SW1-GigabitEthernet0/0/1]port link-type access 
[L3SW1-GigabitEthernet0/0/1]qu

[L3SW1]vlan 30
[L3SW1-vlan30]port g0/0/1
[L3SW1-vlan30]qu 

[L3SW1]int vlan 30
[L3SW1-Vlanif30]ip add 192.168.1.2 24
[L3SW1-Vlanif30]qu

[L3SW1]int g0/0/2
[L3SW1-GigabitEthernet0/0/2]port link-type access 
[L3SW1-GigabitEthernet0/0/2]qu

[L3SW1]vlan 40
[L3SW1-vlan40]port g0/0/2
[L3SW1-vlan40]qu 

[L3SW1]int vlan 40
[L3SW1-Vlanif40]ip add 192.168.3.1 24
[L3SW1-Vlanif40]qu

[L3SW1]ospf 1 router-id 3.3.3.3
[L3SW1-ospf-1]area 0
[L3SW1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[L3SW1-ospf-1-area-0.0.0.0]network 192.168.3.0 0.0.0.255
[L3SW1-ospf-1-area-0.0.0.0]network 192.168.4.0 0.0.0.255
[L3SW1-ospf-1-area-0.0.0.0]network 192.168.5.0 0.0.0.255
[L3SW1-ospf-1-area-0.0.0.0]qu
[L3SW1-ospf-1]qu
[L3SW1]

LSW2

L2SW1
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname L2SW1
[L2SW1]int Ethernet0/0/3
[L2SW1-Ethernet0/0/3]port link-type access 
[L2SW1-Ethernet0/0/3]qu

[L2SW1]vlan 10
[L2SW1-vlan10]port Ethernet 0/0/3
[L2SW1-vlan10]qu

[L2SW1]int Ethernet0/0/4
[L2SW1-Ethernet0/0/4]port link-type access 
[L2SW1-Ethernet0/0/4]qu

[L2SW1]vlan 20
[L2SW1-vlan20]port Ethernet 0/0/4
[L2SW1-vlan20]qu

[L2SW1]int Ethernet 0/0/1
[L2SW1-Ethernet0/0/1]port link-type trunk 
[L2SW1-Ethernet0/0/1]port trunk allow-pass vlan 10 20
[L2SW1-Ethernet0/0/1]qu

[L2SW1]int Ethernet 0/0/2
[L2SW1-Ethernet0/0/1]port link-type trunk 

[L2SW1-Ethernet0/0/2]port trunk allow-pass vlan 10 20
[L2SW1-Ethernet0/0/2]qu
[L2SW1]

LSW3

L2SW2
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname L2SW2
[L2SW2]int Ethernet0/0/3
[L2SW2-Ethernet0/0/3]port link-type access 
[L2SW2-Ethernet0/0/3]qu

[L2SW2]vlan 10	
[L2SW2-vlan10]port Ethernet 0/0/3
[L2SW2-vlan10]qu

[L2SW2]int Ethernet 0/0/4
[L2SW2-Ethernet0/0/4]port link-type access
[L2SW2-Ethernet0/0/4]qu

[L2SW2]vlan 20
[L2SW2-vlan20]port Ethernet 0/0/4
[L2SW2-vlan20]qu

[L2SW2]int Ethernet 0/0/1
[L2SW2-Ethernet0/0/1]port link-type trunk 	
[L2SW2-Ethernet0/0/1]port trunk allow-pass vlan 10 20
[L2SW2-Ethernet0/0/1]qu
10.在R1上查看路由表并尝试ping下方PC1的主机,检查连通性
<R1>system-view 
Enter system view, return user view with Ctrl+Z.
[R1]dis ip rou	
[R1]dis ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 16       Routes : 17       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
    192.168.1.0/24  Direct  0    0           D   192.168.1.1     GigabitEthernet
0/0/0
    192.168.1.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
  192.168.1.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
    192.168.2.0/24  Direct  0    0           D   192.168.2.1     GigabitEthernet
0/0/1
    192.168.2.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
  192.168.2.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
    192.168.3.0/24  OSPF    10   2           D   192.168.2.2     GigabitEthernet
0/0/1
                    OSPF    10   2           D   192.168.1.2     GigabitEthernet
0/0/0
    192.168.4.0/24  OSPF    10   2           D   192.168.1.2     GigabitEthernet
0/0/0
    192.168.5.0/24  OSPF    10   2           D   192.168.1.2     GigabitEthernet
0/0/0
  192.168.137.0/24  Direct  0    0           D   192.168.137.10  GigabitEthernet
0/0/2
 192.168.137.10/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/2
192.168.137.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/2
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0



<R1>sys	
<R1>system-view 
Enter system view, return user view with Ctrl+Z.
[R1]ping 192.168.4.1
  PING 192.168.4.1: 56  data bytes, press CTRL_C to break
    Reply from 192.168.4.1: bytes=56 Sequence=1 ttl=127 time=120 ms
    Reply from 192.168.4.1: bytes=56 Sequence=2 ttl=127 time=70 ms
    Reply from 192.168.4.1: bytes=56 Sequence=3 ttl=127 time=80 ms
    Reply from 192.168.4.1: bytes=56 Sequence=4 ttl=127 time=50 ms
    Reply from 192.168.4.1: bytes=56 Sequence=5 ttl=127 time=80 ms

  --- 192.168.4.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 50/80/120 ms
11.各设备配置snmp协议

LSW1

第三条命令是这样的,复制过来的时候自动换行了。 snmp-agent target-host trap address udp-domain 192.168.137.22 params securityname huawei@123

<L3SW1>system-view 
Enter system view, return user view with Ctrl+Z.
[L3SW1]snmp-agent community read cipher huawei@123
[L3SW1]snmp-agent sys-info version v2c
[L3SW1]snmp-agent target-host trap address udp-domain 192.168.137.22 params secu
rityname huawei@123
[L3SW1]snmp-agent trap enable 
Warning: All switches of SNMP trap/notification will be open. Continue? [Y/N]:y
[L3SW1]

AR1

命令 snmp-agent target-host trap-hostname huawei@123 address 192.168.137.22 udp-port 161 trap-paramsname huawei@123

<R1>system-view 
Enter system view, return user view with Ctrl+Z.
[R1]snmp-agent community read huawei@123
[R1]snmp-agent sys-info version all
[R1]snmp-agent target-host trap-hostname huawei@123 address 192.168.137.22 udp-p
ort 161 trap-paramsname huawei@123
[R1]snmp-agent trap enable 
Info: All switches of SNMP trap/notification will be open. Continue? [Y/N]:y
[R1]

AR2

snmp-agent target-host trap-hostname huawei@123 address 192.168.137.22 udp-port 161 trap-paramsname huawei@123

<R2>system-view 
Enter system view, return user view with Ctrl+Z.
[R2]snmp-agent community read huawei@123
[R2]snmp-agent sys-info version all
[R2]snmp-agent target-host trap-hostname huawei@123 address 192.168.137.22 udp-p
ort 161 trap-paramsname huawei@123
[R2]snmp-agent trap enable
Info: All switches of SNMP trap/notification will be open. Continue? [Y/N]:y
[R2]
12.在zabbix主机上安装snmp协议
[root@zabbix ~]# yum -y install net-snmp net-snmp-utils
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.bfsu.edu.cn
 * centos-sclo-rh: mirrors.bfsu.edu.cn
 * centos-sclo-sclo: mirrors.bfsu.edu.cn
 * extras: mirrors.bfsu.edu.cn
 * updates: mirrors.bfsu.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 net-snmp.x86_64.1.5.7.2-49.el7_9.2 将被 安装
--> 正在处理依赖关系 net-snmp-agent-libs = 1:5.7.2-49.el7_9.2,它被软件包 1:net-snmp-5.7.2-49.el7_9.2.x86_64 需要
--> 正在处理依赖关系 libnetsnmptrapd.so.31()(64bit),它被软件包 1:net-snmp-5.7.2-49.el7_9.2.x86_64 需要
--> 正在处理依赖关系 libnetsnmpmibs.so.31()(64bit),它被软件包 1:net-snmp-5.7.2-49.el7_9.2.x86_64 需要
--> 正在处理依赖关系 libnetsnmpagent.so.31()(64bit),它被软件包 1:net-snmp-5.7.2-49.el7_9.2.x86_64 需要
---> 软件包 net-snmp-utils.x86_64.1.5.7.2-49.el7_9.2 将被 安装
--> 正在检查事务
---> 软件包 net-snmp-agent-libs.x86_64.1.5.7.2-49.el7_9.2 将被 安装
--> 解决依赖关系完成

依赖关系解决

====================================================================
 Package              架构    版本                   源        大小
====================================================================
正在安装:
 net-snmp             x86_64  1:5.7.2-49.el7_9.2     updates  325 k
 net-snmp-utils       x86_64  1:5.7.2-49.el7_9.2     updates  201 k
为依赖而安装:
 net-snmp-agent-libs  x86_64  1:5.7.2-49.el7_9.2     updates  707 k

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

总下载量:1.2 M
安装大小:3.3 M
Downloading packages:
(1/3): net-snmp-5.7.2-49.el7_9.2.x86_64.rpm    | 325 kB   00:00     
(2/3): net-snmp-utils-5.7.2-49.el7_9.2.x86_64. | 201 kB   00:00     
(3/3): net-snmp-agent-libs-5.7.2-49.el7_9.2.x8 | 707 kB   00:01     
--------------------------------------------------------------------
总计                                   927 kB/s | 1.2 MB  00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : 1:net-snmp-agent-libs-5.7.2-49.el7_9.2.x86_64   1/3 
  正在安装    : 1:net-snmp-5.7.2-49.el7_9.2.x86_64              2/3 
  正在安装    : 1:net-snmp-utils-5.7.2-49.el7_9.2.x86_64        3/3 
  验证中      : 1:net-snmp-utils-5.7.2-49.el7_9.2.x86_64        1/3 
  验证中      : 1:net-snmp-5.7.2-49.el7_9.2.x86_64              2/3 
  验证中      : 1:net-snmp-agent-libs-5.7.2-49.el7_9.2.x86_64   3/3 

已安装:
  net-snmp.x86_64 1:5.7.2-49.el7_9.2                                
  net-snmp-utils.x86_64 1:5.7.2-49.el7_9.2                          

作为依赖被安装:
  net-snmp-agent-libs.x86_64 1:5.7.2-49.el7_9.2                     

完毕!

修改第41行,添加第55行

[root@zabbix ~]# vim /etc/snmp/snmpd.conf 
[root@zabbix ~]# cat -n /etc/snmp/snmpd.conf 
     1	###############################################################################
     2	#
     3	# snmpd.conf:
     4	#   An example configuration file for configuring the ucd-snmp snmpd agent.
     5	#
     6	###############################################################################
     7	#
     8	# This file is intended to only be as a starting point.  Many more
     9	# configuration directives exist than are mentioned in this file.  For 
    10	# full details, see the snmpd.conf(5) manual page.
    11	#
    12	# All lines beginning with a '#' are comments and are intended for you
    13	# to read.  All other lines are configuration commands for the agent.
    14	
    15	###############################################################################
    16	# Access Control
    17	###############################################################################
    18	
    19	# As shipped, the snmpd demon will only respond to queries on the
    20	# system mib group until this file is replaced or modified for
    21	# security purposes.  Examples are shown below about how to increase the
    22	# level of access.
    23	
    24	# By far, the most common question I get about the agent is "why won't
    25	# it work?", when really it should be "how do I configure the agent to
    26	# allow me to access it?"
    27	#
    28	# By default, the agent responds to the "public" community for read
    29	# only access, if run out of the box without any configuration file in 
    30	# place.  The following examples show you other ways of configuring
    31	# the agent so that you can change the community names, and give
    32	# yourself write access to the mib tree as well.
    33	#
    34	# For more information, read the FAQ as well as the snmpd.conf(5)
    35	# manual page.
    36	
    37	####
    38	# First, map the community name "public" into a "security name"
    39	
    40	#       sec.name  source          community
    41	com2sec notConfigUser  default       huawei@123
    42	
    43	####
    44	# Second, map the security name into a group name:
    45	
    46	#       groupName      securityModel securityName
    47	group   notConfigGroup v1           notConfigUser
    48	group   notConfigGroup v2c           notConfigUser
    49	
    50	####
    51	# Third, create a view for us to let the group have rights to:
    52	
    53	# Make at least  snmpwalk -v 1 localhost -c public system fast again.
    54	#       name           incl/excl     subtree         mask(optional)
    55	view	systemview    included   .1
    56	view    systemview    included   .1.3.6.1.2.1.1
    57	view    systemview    included   .1.3.6.1.2.1.25.1.1
    58	
    59	####
    60	# Finally, grant the group read-only access to the systemview view.
    61	
    62	#       group          context sec.model sec.level prefix read   write  notif

[root@zabbix ~]# systemctl start snmpd
[root@zabbix ~]# systemctl enable snmpd
Created symlink from /etc/systemd/system/multi-user.target.wants/snmpd.service to /usr/lib/systemd/system/snmpd.service.
[root@zabbix ~]# 
13.修改真机本地网卡的网关指向拓扑的R1中的G0/0/2接口IP地址,虚拟机内的网卡配置文件也要修改

在这里插入图片描述

在这里插入图片描述

14.添加主机

先把三层的交换机添加进去

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

添加路由器R1,步骤类似

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
点进去修改时间间隔
在这里插入图片描述
SNMP已经开启
在这里插入图片描述

添加其他主机(R2),方法与上面类似

在这里插入图片描述

15.测试

先查看最近R1主机最近一分钟的图形视图的变化

在这里插入图片描述

在这里插入图片描述

在R1上用ping命令一直ping L3SW1

<R1>sy	
<R1>system-view 
Enter system view, return user view with Ctrl+Z.
[R1]ping -c 10000 192.168.3.1
  PING 192.168.3.1: 56  data bytes, press CTRL_C to break
    Reply from 192.168.3.1: bytes=56 Sequence=1 ttl=255 time=20 ms
    Reply from 192.168.3.1: bytes=56 Sequence=2 ttl=255 time=20 ms
    Reply from 192.168.3.1: bytes=56 Sequence=3 ttl=255 time=20 ms
    Reply from 192.168.3.1: bytes=56 Sequence=4 ttl=255 time=20 ms
    Reply from 192.168.3.1: bytes=56 Sequence=5 ttl=255 time=20 ms
    Reply from 192.168.3.1: bytes=56 Sequence=6 ttl=255 time=10 ms
    Reply from 192.168.3.1: bytes=56 Sequence=7 ttl=255 time=20 ms
    Reply from 192.168.3.1: bytes=56 Sequence=8 ttl=255 time=20 ms
    Reply from 192.168.3.1: bytes=56 Sequence=9 ttl=255 time=30 ms
    Reply from 192.168.3.1: bytes=56 Sequence=10 ttl=255 time=30 ms
    Reply from 192.168.3.1: bytes=56 Sequence=11 ttl=255 time=20 ms
    Reply from 192.168.3.1: bytes=56 Sequence=12 ttl=255 time=30 ms
    Reply from 192.168.3.1: bytes=56 Sequence=13 ttl=255 time=20 ms
    Reply from 192.168.3.1: bytes=56 Sequence=14 ttl=255 time=20 ms
    Reply from 192.168.3.1: bytes=56 Sequence=15 ttl=255 time=30 ms

  (省略)

然后查看图形

在这里插入图片描述

有流量显示

四、LNMP架构部署

16.修改主机名和修改防火墙
[root@lc3 ~]# hostnamectl set-hostname LNMP
[root@lc3 ~]# bash
[root@lnmp ~]# systemctl stop firewalld.service 
[root@lnmp ~]# systemctl disable firewalld.service 
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@lnmp ~]# setenforce 0
[root@lnmp ~]# vim /etc/selinux/config 
[root@lnmp ~]# cat /etc/selinux/config 

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted 

#重启
[root@lnmp ~]# reboot 
17.创建nginx用户,并安装nginx依赖环境和开发组件包
[root@lnmp ~]# useradd -r -M -s /sbin/nologin nginx
[root@lnmp ~]# id nginx
uid=988(nginx) gid=982(nginx) 组=982(nginx)


[root@lnmp ~]# yum -y install pcre-devel openssl openssl-devel gd-devel gcc gcc-c++ make
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
base                                                  | 3.6 kB     00:00     
extras                                                | 2.9 kB     00:00     
updates                                               | 2.9 kB     00:00     
正在解决依赖关系
--> 正在检查事务
---> 软件包 gcc.x86_64.0.4.8.5-44.el7 将被 安装
--> 正在处理依赖关系 libgomp = 4.8.5-44.el7,它被软件包 gcc-4.8.5-44.el7.x86_64 需要
--> 正在处理依赖关系 cpp = 4.8.5-44.el7,它被软件包 gcc-4.8.5-44.el7.x86_64 需要
   (省略)
    libss.x86_64 0:1.42.9-19.el7                                               
  libstdc++.x86_64 0:4.8.5-44.el7                                            
  libuuid.x86_64 0:2.23.2-65.el7_9.1                                         
  openssl-libs.x86_64 1:1.0.2k-25.el7_9                                      
  util-linux.x86_64 0:2.23.2-65.el7_9.1                                      
  zlib.x86_64 0:1.2.7-21.el7_9                                               
完毕!

18.创建日志存放位置,下载nginx源码包并解压执行编译安装
[root@lnmp ~]# mkdir /var/log/nginx
[root@lnmp ~]# chown -R nginx.nginx /var/log/nginx/
[root@lnmp ~]# wget http://nginx.org/download/nginx-1.22.1.tar.gz
--2023-03-21 15:50:10--  http://nginx.org/download/nginx-1.22.1.tar.gz
正在解析主机 nginx.org (nginx.org)... 3.125.197.172, 52.58.199.22, 2a05:d014:edb:5704::6, ...
正在连接 nginx.org (nginx.org)|3.125.197.172|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1073948 (1.0M) [application/octet-stream]
正在保存至: “nginx-1.22.1.tar.gz”

100%[===================================>] 1,073,948    949KB/s 用时 1.1s   

2023-03-21 15:50:12 (949 KB/s) - 已保存 “nginx-1.22.1.tar.gz” [1073948/1073948])

[root@lnmp ~]# ls
anaconda-ks.cfg       nginx-1.22.1.tar.gz  模板  图片  下载  桌面
initial-setup-ks.cfg  公共                 视频  文档  音乐
[root@lnmp ~]# tar xf nginx-1.22.1.tar.gz -C /usr/src/
[root@lnmp ~]# cd /usr/src/
[root@lnmp src]# ls
debug  kernels  nginx-1.22.1

这条命令很长,请手敲

./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log
[root@lnmp nginx-1.22.1]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log
checking for OS
 + Linux 3.10.0-862.el7.x86_64 x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
checking for gcc -pipe switch ... found
      
      (省略)
      
creating objs/Makefile

Configuration summary
  + using system PCRE library
  + using system OpenSSL library
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/var/log/nginx/error.log"
  nginx http access log file: "/var/log/nginx/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

[root@lnmp nginx-1.22.1]# make -j8 && make install
make -f objs/Makefile
make[1]: 进入目录“/usr/src/nginx-1.22.1”
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/nginx.o \
        src/core/nginx.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_log.o \
        src/core/ngx_log.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_palloc.o \
        src/core/ngx_palloc.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_array.o \
        src/core/ngx_array.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_list.o \
        src/core/ngx_list.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_hash.o \
    (省略)
test -d '/usr/local/nginx/sbin' \
        || mkdir -p '/usr/local/nginx/sbin'
test ! -f '/usr/local/nginx/sbin/nginx' \
        || mv '/usr/local/nginx/sbin/nginx' \
                '/usr/local/nginx/sbin/nginx.old'
cp objs/nginx '/usr/local/nginx/sbin/nginx'
test -d '/usr/local/nginx/conf' \
        || mkdir -p '/usr/local/nginx/conf'
cp conf/koi-win '/usr/local/nginx/conf'
cp conf/koi-utf '/usr/local/nginx/conf'
cp conf/win-utf '/usr/local/nginx/conf'
test -f '/usr/local/nginx/conf/mime.types' \
        || cp conf/mime.types '/usr/local/nginx/conf'
cp conf/mime.types '/usr/local/nginx/conf/mime.types.default'
test -f '/usr/local/nginx/conf/fastcgi_params' \
        || cp conf/fastcgi_params '/usr/local/nginx/conf'
cp conf/fastcgi_params \
        '/usr/local/nginx/conf/fastcgi_params.default'
test -f '/usr/local/nginx/conf/fastcgi.conf' \
        || cp conf/fastcgi.conf '/usr/local/nginx/conf'
cp conf/fastcgi.conf '/usr/local/nginx/conf/fastcgi.conf.default'
test -f '/usr/local/nginx/conf/uwsgi_params' \
        || cp conf/uwsgi_params '/usr/local/nginx/conf'
cp conf/uwsgi_params \
        '/usr/local/nginx/conf/uwsgi_params.default'
test -f '/usr/local/nginx/conf/scgi_params' \
        || cp conf/scgi_params '/usr/local/nginx/conf'
cp conf/scgi_params \
        '/usr/local/nginx/conf/scgi_params.default'
test -f '/usr/local/nginx/conf/nginx.conf' \
        || cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf'
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs' \
        || mkdir -p '/usr/local/nginx/logs'
test -d '/var/log/nginx' \
        || mkdir -p '/var/log/nginx'
test -d '/usr/local/nginx/html' \
        || cp -R html '/usr/local/nginx'
test -d '/var/log/nginx' \
        || mkdir -p '/var/log/nginx'
make[1]: 离开目录“/usr/src/nginx-1.22.1”

[root@lnmp nginx-1.22.1]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' >/etc/profile.d/nginx.sh
[root@lnmp nginx-1.22.1]# source /etc/profile.d/nginx.sh 
[root@lnmp nginx-1.22.1]# nginx
[root@lnmp nginx-1.22.1]# ss -antl
State       Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN      0      128        *:111                    *:*                  
LISTEN      0      128        *:80                     *:*                  
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       :::111                   :::*                  
LISTEN      0      128       :::22                    :::*                  
LISTEN      0      128      ::1:631                   :::*                  
LISTEN      0      100      ::1:25                    :::*             
19.浏览器测试Nginx默认测试页是否能正常访问

在这里插入图片描述

20.安装数据库并设置为开机自启
[root@lnmp ~]# yum -y install mariadb*
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 mariadb.x86_64.1.5.5.68-1.el7 将被 安装
---> 软件包 mariadb-bench.x86_64.1.5.5.68-1.el7 将被 安装
--> 正在处理依赖关系 perl(GD),它被软件包 1:mariadb-bench-5.5.68-1.el7.x86_64 需要
       (省略)                      
  perl-Net-Daemon.noarch 0:0.48-5.el7                                        
  perl-PlRPC.noarch 0:0.2020-14.el7                                          
  perl-Test-Harness.noarch 0:3.28-3.el7                                      
  perl-Test-Simple.noarch 0:0.98-243.el7                                     

更新完毕:
  mariadb-libs.x86_64 1:5.5.68-1.el7                                         

完毕!


[root@lnmp ~]# systemctl restart mariadb.service 
[root@lnmp ~]# systemctl enable mariadb.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
21.初始化数据库
[root@lnmp ~]# mysql_secure_installation 

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):    #直接回车
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y    #是否给root设置密码   y=是
New password:                 #设置密码为123456
Re-enter new password:        #确认密码123456
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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? [Y/n] 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? [Y/n] y    #不允许root用户远程登录
 ... Success!

By default, MariaDB 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? [Y/n] 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? [Y/n] y    #重新加载特权表

 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

22.安装PHP相关软件包
[root@lnmp ~]# yum -y install php* --skip-broken
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn

正在解决依赖关系
--> 正在检查事务
---> 软件包 php.x86_64.0.5.4.16-48.el7 将被 安装
--> 正在处理依赖关系 httpd-mmn = 20120211x8664,它被软件包 php-5.4.16-48.el7.x86_64 需要
--> 正在处理依赖关系 httpd,它被软件包 php-5.4.16-48.el7.x86_64 需要
---> 软件包 php-bcmath.x86_64.0.5.4.16-48.el7 将被 安装
---> 软件包 php-cli.x86_64.0.5.4.16-48.el7 将被 安装
     (省略)                            
  recode.x86_64 0:3.6-38.el7                                                 
  t1lib.x86_64 0:5.1.2-14.el7                                                
  tokyocabinet.x86_64 0:1.4.48-3.el7                                         
  unixODBC.x86_64 0:2.3.1-14.el7                                             

作为依赖被升级:
  net-snmp-libs.x86_64 1:5.7.2-49.el7_9.2                                    

跳过(依赖问题):
  php-mysql.x86_64 0:5.4.16-48.el7                                           

完毕!

23.修改Nginx默认测试页并测试访问
[root@lnmp ~]# cd /usr/local/nginx/html/
[root@lnmp html]# ls
50x.html  index.html
[root@lnmp html]# vim index.php
[root@lnmp html]# cat index.php
<?php
phpinfo();
?>

修改配置文件

修改第44、45行,将65-71行的#号去掉,注意第69行还有信息要修改

[root@lnmp html]# chown -R nginx.nginx /usr/local/nginx/html/
[root@lnmp html]# vim /usr/local/nginx/conf/nginx.conf
[root@lnmp html]# cat -n /usr/local/nginx/conf/nginx.conf
     1  
     2  #user  nobody;
     3  worker_processes  1;
     4  
     5  #error_log  logs/error.log;
     6  #error_log  logs/error.log  notice;
     7  #error_log  logs/error.log  info;
     8  
     9  #pid        logs/nginx.pid;
    10  
    11  
    12  events {
    13      worker_connections  1024;
    14  }
    15  
    16  
    17  http {
    18      include       mime.types;
    19      default_type  application/octet-stream;
    20  
    21      #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    22      #                  '$status $body_bytes_sent "$http_referer" '
    23      #                  '"$http_user_agent" "$http_x_forwarded_for"';
    24  
    25      #access_log  logs/access.log  main;
    26  
    27      sendfile        on;
    28      #tcp_nopush     on;
    29  
    30      #keepalive_timeout  0;
    31      keepalive_timeout  65;
    32  
    33      #gzip  on;
    34  
    35      server {
    36          listen       80;
    37          server_name  localhost;
    38  
    39          #charset koi8-r;
    40  
    41          #access_log  logs/host.access.log  main;
    42  
    43          location / {
    44              root   /usr/local/nginx/html;
    45              index  index.php index.html index.htm;
    46          }
    47  
    48          #error_page  404              /404.html;
    49  
    50          # redirect server error pages to the static page /50x.html
    51          #
    52          error_page   500 502 503 504  /50x.html;
    53          location = /50x.html {
    54              root   html;
    55          }
    56  
    57          # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    58          #
    59          #location ~ \.php$ {
    60          #    proxy_pass   http://127.0.0.1;
    61          #}
    62  
    63          # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    64          #
    65          location ~ \.php$ {
    66              root           html;
    67              fastcgi_pass   127.0.0.1:9000;
    68              fastcgi_index  index.php;
    69              fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    70              include        fastcgi_params;
    71          }

    72  
    73          # deny access to .htaccess files, if Apache's document root
    74          # concurs with nginx's one
    75          #
    76          #location ~ /\.ht {
    77          #    deny  all;
    78          #}
    79      }
    80  
    81  
    82      # another virtual host using mix of IP-, name-, and port-based configuration
    83      #
    84      #server {
    85      #    listen       8000;
    86      #    listen       somename:8080;
    87      #    server_name  somename  alias  another.alias;
    88  
    89      #    location / {
    90      #        root   html;
    91      #        index  index.html index.htm;
    92      #    }
    93      #}
    94  
    95  
    96      # HTTPS server
    97      #
    98      #server {
    99      #    listen       443 ssl;
   100      #    server_name  localhost;
   101  
   102      #    ssl_certificate      cert.pem;
   103      #    ssl_certificate_key  cert.key;
   104  
   105      #    ssl_session_cache    shared:SSL:1m;
   106      #    ssl_session_timeout  5m;
   107  
   108      #    ssl_ciphers  HIGH:!aNULL:!MD5;
   109      #    ssl_prefer_server_ciphers  on;
   110  
   111      #    location / {
   112      #        root   html;
   113      #        index  index.html index.htm;
   114      #    }
   115      #}
   116  
   117  }


[root@lnmp html]# nginx -s reload

24.修改PHP监听端口和用户组

修改第39和41行

[root@lnmp ~]# vim /etc/php-fpm.d/www.conf 
[root@lnmp ~]# cat -n /etc/php-fpm.d/www.conf 
     1  ; Start a new pool named 'www'.
     2  [www]
     3  
     4  ; The address on which to accept FastCGI requests.
     5  ; Valid syntaxes are:
      (省略)
    36  ; Note: The user is mandatory. If the group is not set, the default user's group
    37  ;       will be used.
    38  ; RPM: apache Choosed to be able to access some dir as httpd
    39  user = nginx
    40  ; RPM: Keep a group allowed to write in log dir.
    41  group = nginx
    42  
    43  ; Choose how the process manager will control the number of child processes.
    (省略)
    218  ;php_flag[display_errors] = off
   219  php_admin_value[error_log] = /var/log/php-fpm/www-error.log
   220  php_admin_flag[log_errors] = on
   221  ;php_admin_value[memory_limit] = 128M
   222  
   223  ; Set session path to a directory owned by process user
   224  php_value[session.save_handler] = files
   225  php_value[session.save_path] = /var/lib/php/session
   226  
[root@lnmp ~]# systemctl restart php-fpm.service 
[root@lnmp ~]# ss -antl
State       Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN      0      128    127.0.0.1:9000                   *:*                  
LISTEN      0      50         *:3306                   *:*                  
LISTEN      0      128        *:111                    *:*                  
LISTEN      0      128        *:80                     *:*                  
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       :::111                   :::*                  
LISTEN      0      128       :::22                    :::*                  
LISTEN      0      128      ::1:631                   :::*                  
LISTEN      0      100      ::1:25                    :::*    

在这里插入图片描述

25.删除index.php页面
[root@lnmp html]# ls
50x.html  index.html  index.php
[root@lnmp html]# rm -rf index.php 
[root@lnmp html]# ls
50x.html  index.html

在真机上找到下载的discuz论坛源码拖拽上传到Linux系统中

在这里插入图片描述

[root@lnmp html]# ls
50x.html  Discuz_X3.4_SC_UTF8_20230315.zip  index.html
[root@lnmp html]# unzip Discuz_X3.4_SC_UTF8_20230315.zip 
Archive:  Discuz_X3.4_SC_UTF8_20230315.zip
  inflating: readme.html             
  inflating: LICENSE                 
  inflating: qqqun.png               
   creating: readme/
  inflating: readme/changelog.txt    
  inflating: readme/convert.txt      
  inflating: readme/license.txt      
  inflating: readme/readme.txt       
  inflating: readme/screenshot.png   
  inflating: readme/upgrade.txt      
   creating: upload/
  
   
(省略)
[root@lnmp html]# ls
50x.html                          LICENSE    readme.html
Discuz_X3.4_SC_UTF8_20230315.zip  qqqun.png  upload
index.html                        readme     utility.html
[root@lnmp html]# rm -rf LICENSE qqqun.png readme.html utility.html 
[root@lnmp html]# ls
50x.html  Discuz_X3.4_SC_UTF8_20230315.zip  index.html  readme  upload
[root@lnmp html]# mv upload/* ./
[root@lnmp html]# ls
50x.html         data                              install     search.php
admin.php        Discuz_X3.4_SC_UTF8_20230315.zip  m           source
api              favicon.ico                       member.php  static
api.php          forum.php                         misc.php    template
archiver         group.php                         plugin.php  uc_client
config           home.php                          portal.php  uc_server
connect.php      index.html                        readme      upload
crossdomain.xml  index.php                         robots.txt
[root@lnmp html]# mv Discuz_X3.4_SC_UTF8_20230315.zip /root/
[root@lnmp html]# ls /root/
anaconda-ks.cfg                   nginx-1.22.1.tar.gz  视频  下载
Discuz_X3.4_SC_UTF8_20230315.zip  公共                 图片  音乐
initial-setup-ks.cfg              模板                 文档  桌面
[root@lnmp html]# ls
50x.html   config           forum.php   install     portal.php  static
admin.php  connect.php      group.php   m           readme      template
api        crossdomain.xml  home.php    member.php  robots.txt  uc_client
api.php    data             index.html  misc.php    search.php  uc_server
archiver   favicon.ico      index.php   plugin.php  source      upload

在这里插入图片描述

在这里插入图片描述

26.根据上图的报错修改权限即可
[root@lnmp html]# chown -R nginx.nginx /usr/local/nginx/html/
[root@lnmp html]# ll /usr/local/nginx/html/
总用量 76
-rw-r--r--  1 nginx nginx  497 3月  21 16:09 50x.html
-rw-r--r--  1 nginx nginx 2848 3月  15 23:47 admin.php
drwxr-xr-x  9 nginx nginx  135 3月  15 23:47 api
-rw-r--r--  1 nginx nginx  727 3月  15 23:47 api.php
drwxr-xr-x  2 nginx nginx   23 3月  15 23:47 archiver
drwxr-xr-x  2 nginx nginx   90 3月  15 23:47 config
-rw-r--r--  1 nginx nginx 1040 3月  15 23:47 connect.php
-rw-r--r--  1 nginx nginx  106 3月  15 23:47 crossdomain.xml
drwxr-xr-x 12 nginx nginx  178 3月  15 23:47 data
-rw-r--r--  1 nginx nginx 5558 3月  15 14:32 favicon.ico
-rw-r--r--  1 nginx nginx 2245 3月  15 23:47 forum.php
-rw-r--r--  1 nginx nginx  821 3月  15 23:47 group.php
-rw-r--r--  1 nginx nginx 1280 3月  15 23:47 home.php
-rw-r--r--  1 nginx nginx  615 3月  21 16:09 index.html
-rw-r--r--  1 nginx nginx 6822 3月  15 23:47 index.php
drwxr-xr-x  5 nginx nginx   64 3月  15 23:47 install
drwxr-xr-x  2 nginx nginx   23 3月  15 23:47 m
-rw-r--r--  1 nginx nginx  998 3月  15 23:47 member.php
-rw-r--r--  1 nginx nginx 2371 3月  15 23:47 misc.php
-rw-r--r--  1 nginx nginx 1788 3月  15 23:47 plugin.php
-rw-r--r--  1 nginx nginx  977 3月  15 23:47 portal.php
drwxr-xr-x  2 nginx nginx  124 3月  15 23:47 readme
-rw-r--r--  1 nginx nginx  615 3月  15 23:47 robots.txt
-rw-r--r--  1 nginx nginx 1274 3月  15 23:47 search.php
drwxr-xr-x 10 nginx nginx  168 3月  15 23:47 source
drwxr-xr-x  7 nginx nginx   86 3月  15 23:47 static
drwxr-xr-x  3 nginx nginx   38 3月  15 23:47 template
drwxr-xr-x  7 nginx nginx  106 3月  15 23:47 uc_client
drwxr-xr-x 13 nginx nginx  241 3月  15 23:47 uc_server
drwxr-xr-x  2 nginx nginx    6 3月  21 17:53 upload
[root@lnmp html]# 

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

27.添加数据库登录账户并授权
[root@lnmp html]# mysql -uroot -p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
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)]> grant all privileges on *.* to 'licong'@'192.168.137.33' identified by '123456' with grant option;
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> grant all privileges on *.* to 'licong'@'localhost' identified by '123456' with grant option;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

五,在LNMP架构部署zabbix-agent进行对接zabbix-server

28.安装zabbix-agent软件包
[root@lnmp ~]# wget https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm --no-check-certificate
--2023-03-21 18:13:34--  https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
正在解析主机 repo.zabbix.com (repo.zabbix.com)... 178.128.6.101, 2604:a880:2:d0::2062:d001
正在连接 repo.zabbix.com (repo.zabbix.com)|178.128.6.101|:443... 已连接。
警告: 无法验证 repo.zabbix.com 的由 “/C=US/O=Let's Encrypt/CN=R3” 颁发的证书:
  颁发的证书已经过期。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:14532 (14K) [application/x-redhat-package-manager]
正在保存至: “zabbix-release-5.0-1.el7.noarch.rpm”

100%[===================================>] 14,532      --.-K/s 用时 0s      
2023-03-21 18:13:35 (461 MB/s) - 已保存 “zabbix-release-5.0-1.el7.noarch.rpm” [14532/14532])



[root@lnmp ~]# ls
anaconda-ks.cfg                      公共  下载
Discuz_X3.4_SC_UTF8_20230315.zip     模板  音乐
initial-setup-ks.cfg                 视频  桌面
nginx-1.22.1.tar.gz                  图片
zabbix-release-5.0-1.el7.noarch.rpm  文档
[root@lnmp ~]# 



[root@lnmp ~]# rpm -Uvh zabbix-release-5.0-1.el7.noarch.rpm
警告:zabbix-release-5.0-1.el7.noarch.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:zabbix-release-5.0-1.el7         ################################# [100%]


[root@lnmp ~]# yum clean all
已加载插件:fastestmirror, langpacks
正在清理软件源: base extras updates zabbix zabbix-non-supported
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@lnmp ~]# yum -y install zabbix-agent
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
base                                                  | 3.6 kB     00:00     
extras                                                | 2.9 kB     00:00     
updates                                               | 2.9 kB     00:00     
zabbix                                                | 2.9 kB     00:00     
zabbix-non-supported                                  | 2.9 kB     00:00     
(1/6): extras/7/x86_64/primary_db                       | 249 kB   00:00     
(2/6): base/7/x86_64/group_gz                           | 153 kB   00:00     
(3/6): zabbix-non-supported/x86_64/primary_db           | 3.7 kB   00:00     
(4/6): zabbix/x86_64/primary_db                         | 207 kB   00:01     
(5/6): updates/7/x86_64/primary_db                      |  20 MB   00:02     
(6/6): base/7/x86_64/primary_db                         | 6.1 MB   00:06     
正在解决依赖关系
--> 正在检查事务
---> 软件包 zabbix-agent.x86_64.0.5.0.32-1.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

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

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

总下载量:482 k
安装大小:1.9 M
Downloading packages:
警告:/var/cache/yum/x86_64/7/zabbix/packages/zabbix-agent-5.0.32-1.el7.x86_64.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
zabbix-agent-5.0.32-1.el7.x86_64.rpm 的公钥尚未安装
zabbix-agent-5.0.32-1.el7.x86_64.rpm                    | 482 kB   00:01     
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 检索密钥
导入 GPG key 0xA14FE591:
 用户ID     : "Zabbix LLC <packager@zabbix.com>"
 指纹       : a184 8f53 52d0 22b9 471d 83d0 082a b56b a14f e591
 软件包     : zabbix-release-5.0-1.el7.noarch (installed)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
  正在安装    : zabbix-agent-5.0.32-1.el7.x86_64                         1/1 
  验证中      : zabbix-agent-5.0.32-1.el7.x86_64                         1/1 

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

完毕!
29.修改zabbix-agent配置文件

修改第117 125 142 174这几行

[root@lnmp ~]# vim /etc/zabbix/zabbix_agentd.conf 
[root@lnmp ~]# cat -n /etc/zabbix/zabbix_agentd.conf 
     1  # This is a configuration file for Zabbix agent daemon (Unix)
     2  # To get more information about Zabbix, visit http://www.zabbix.com
     3  
     4  ############ GENERAL PARAMETERS #################
     5  
     6  ### Option: PidFile
     7  #       Name of PID file.
     8  #
     9  # Mandatory: no
     (省略)
   112  #
   113  # Mandatory: yes, if StartAgents is not explicitly set to 0
   114  # Default:
   115  # Server=
   116  
   117  Server=192.168.137.22      #对应的zabbix-server的ip地址
   118  
   119  ### Option: ListenPort
   120  #       Agent will listen on this port for connections from the server.
   121  #
   122  # Mandatory: no
   123  # Range: 1024-32767
   124  # Default:
   125   ListenPort=10050      #agent接受指令监听的端口
   126  
   127  ### Option: ListenIP
   128  #       List of comma delimited IP addresses that the agent should listen on.
   129  #       First IP address is sent to Zabbix server if connecting to it to retrieve list of active checks.
   130  #
   131  # Mandatory: no
   132  # Default:
   133  # ListenIP=0.0.0.0
   134  
   135  ### Option: StartAgents
   136  #       Number of pre-forked instances of zabbix_agentd that process passive checks.
   137  #       If set to 0, disables passive checks and the agent will not listen on any TCP port.
   138  #
   139  # Mandatory: no
   140  # Range: 0-100
   141  # Default:
   142   StartAgents=3        #默认的启动的实例数(进程数) 
   143  
   144  ##### Active checks related
   145  
   (省略)
   169  #
   170  # Mandatory: no
   171  # Default:
   172  # Hostname=
   173  
   174  Hostname=192.168.137.22     #zabbix server的ip地址
   175  
   176  ### Option: HostnameItem
   177  #       Item used for generating Hostname if it is undefined. 
   
   (省略)
   521  #
   522  # Mandatory: no
   523  # Range: 0 - INT_MAX (depends on system, too large values may be silently truncated to implementation-specified maximum)
   524  # Default: SOMAXCONN (hard-coded constant, depends on system)
   525  # ListenBacklog=
[root@lnmp ~]# 

[root@lnmp ~]# systemctl restart zabbix-agent.service
[root@lnmp ~]# systemctl enable zabbix-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
30.开始对接zabbix-server进行监控,登录用户名为Admin,密码为zabbix

在这里插入图片描述

在这里插入图片描述

修改更新间隔

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

另外三个以此类推

31.测试是否可以监控

CPU、磁盘、网络的使用变化都可以监测到

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

LcWanf

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值