一、 本地yum源配置
在VMmare中把镜像挂载在redhat8.2系统上。
方法:选择对应的虚拟机,在虚拟机设置中选择硬件:CD/DVD ,在右侧选择设备状态选择:启动时链接,链接选择使用ISO文件,添加上镜像在本机的地址,如图:

1、创建挂载点/mnt/cdrom
[root@rhel-server ~]# mkdir -p /mnt/chrom
挂载光盘镜像到挂载点/mnt/cdrom
[root@rhel-server mnt]# mount /dev/cdrom cdrom/
mount: /mnt/cdrom: WARNING: device write-protected, mounted read-only.
----------
error:mount: /mnt/cdrom: WARNING: device write-protected, mounted read-only.
原因:即从一个文件夹挂载到 另一个文件夹时,在运行挂载程序时,文件夹必须处于关闭状态,才不会出现 read-only 这个“只读”’错误。
解决措施:需要挂载的文件夹,以及挂载到的文件夹都要全部关闭。
----------
[root@rhel-server mnt]# cd ..
[root@rhel-server /]# mount /dev/cdrom /mnt/cdrom/
mount: /mnt/cdrom: /dev/sr0 already mounted on /mnt/cdrom. #已挂载
2、查看挂载的内容
[root@rhel-server /]# cd /mnt/cdrom/
[root@rhel-server cdrom]# ls
AppStream EULA images RPM-GPG-KEY-redhat-beta
BaseOS extra_files.json isolinux RPM-GPG-KEY-redhat-release
EFI GPL media.repo TRANS.TBL
3、备份/etc/yum.repos.d/中内容
[root@rhel-server ~]# mkdir -p /etc/yum$(date "+%F")bak
[root@rhel-server ~]# cp /etc/yum.repos.d/* /etc/yum2023-08-05bak/
4、配置local.repo
[root@rhel-server yum.repos.d]# vim redhat.repo
[root@rhel-server yum.repos.d]# cat redhat.repo
#
# Certificate-Based Repositories
# Managed by (rhsm) subscription-manager
#
# *** This file is auto-generated. Changes made here will be over-written. ***
# *** Use "subscription-manager repo-override --help" if you wish to make changes. ***
#
# If this file is empty and this system is subscribed consider
# a "yum repolist" to refresh available repos
[AppStream]
name=AppStream
baseurl=file:///mnt/cdrom/AppStream
enabled=1
gpgcheck=0
[BaseOS]
name=BaseOS
baseurl=file:///mnt/cdrom/BaseOS
enabled=1
gpgcheck=0
-----------------
在RHEL8中把软件源分成了两部分一个是BaseOS,一个是AppStream.
在Red Hat Enterprise Linux 8.0中,统一的ISO自动加载BaseOS和AppStream安装源存储库。
存储库介绍
(1).BaseOS存储库旨在提供一套核心的底层操作系统的功能,为基础软件安装库
(2).AppStream存储库中包括额外的用户空间应用程序、运行时语言和数据库,以支持不同的工作负载和用例。AppStream中的内容有两种格式——熟悉的RPM格式和称为模块的RPM格式扩展。
------------------
5、清理缓存
[root@rhel-server yum.repos.d]# yum clean all
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
0 files removed
6、创建新的缓存
[root@rhel-server yum.repos.d]# yum makecache
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
AppStream 189 MB/s | 5.8 MB 00:00
BaseOS 85 MB/s | 2.3 MB 00:00
Metadata cache created.
7、测试,安装mariadb
[root@rhel-server yum.repos.d]# yum install mariadb
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:00:30 ago on Sat 05 Aug 2023 09:57:01 AM CST.
Dependencies resolved.
================================================================================================
Package Arch Version Repository Size
================================================================================================
Installing:
mariadb x86_64 3:10.3.17-1.module+el8.1.0+3974+90eded84 AppStream 6.1 M
Installing dependencies:
mariadb-common x86_64 3:10.3.17-1.module+el8.1.0+3974+90eded84 AppStream 62 k
mariadb-connector-c x86_64 3.0.7-1.el8 AppStream 148 k
mariadb-connector-c-config noarch 3.0.7-1.el8 AppStream 13 k
Enabling module streams:
mariadb 10.3
Transaction Summary
================================================================================================
Install 4 Packages
Total size: 6.3 M
Installed size: 40 M
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Running scriptlet: mariadb-connector-c-3.0.7-1.el8.x86_64 1/1
Preparing : 1/1
Installing : mariadb-connector-c-config-3.0.7-1.el8.noarch 1/4
Installing : mariadb-common-3:10.3.17-1.module+el8.1.0+3974+90eded84.x86_64 2/4
Installing : mariadb-connector-c-3.0.7-1.el8.x86_64 3/4
Installing : mariadb-3:10.3.17-1.module+el8.1.0+3974+90eded84.x86_64 4/4
Running scriptlet: mariadb-3:10.3.17-1.module+el8.1.0+3974+90eded84.x86_64 4/4
Verifying : mariadb-3:10.3.17-1.module+el8.1.0+3974+90eded84.x86_64 1/4
Verifying : mariadb-common-3:10.3.17-1.module+el8.1.0+3974+90eded84.x86_64 2/4
Verifying : mariadb-connector-c-3.0.7-1.el8.x86_64 3/4
Verifying : mariadb-connector-c-config-3.0.7-1.el8.noarch 4/4
Installed products updated.
Installed:
mariadb-3:10.3.17-1.module+el8.1.0+3974+90eded84.x86_64
mariadb-common-3:10.3.17-1.module+el8.1.0+3974+90eded84.x86_64
mariadb-connector-c-3.0.7-1.el8.x86_64
mariadb-connector-c-config-3.0.7-1.el8.noarch
Complete!
[root@rhel-server yum.repos.d]#
二、配置阿里云yum源
1、虚拟机已配置好网络
[root@rehl-client ~]# ping baidu.com
PING baidu.com (39.156.66.10) 56(84) bytes of data.
64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=1 ttl=128 time=87.6 ms
64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=2 ttl=128 time=80.3 ms
^C
--- baidu.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 190ms
rtt min/avg/max/mdev = 80.256/83.930/87.605/3.685 ms
2、备份已有的yum配置文件
[root@rehl-client ~]# ls /etc/yum.repos.d/
redhat.repo
[root@rehl-client ~]# cp /etc/yum.repos.d/redhat.repo /etc/yum.repos.d/redhat.repo.bak
3、配置阿里云yum源
[root@rehl-client ~]# vim /etc/yum.repos.d/aliyun.repo
[root@rehl-client ~]# cat /etc/yum.repos.d/aliyun.repo
[BaseOS]
name=BaseOS
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os
enabled=1
gpgcheck=0
[AppStream]
name=AppStream
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os
enabled=1
gpgcheck=0
4、清理yum缓存
[root@rehl-client ~]# yum clean all
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
0 files removed
5、生成新的yum缓存
[root@rehl-client ~]# yum makecache
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
BaseOS 507 kB/s | 4.6 MB 00:09
AppStream 782 kB/s | 8.4 MB 00:11
Last metadata expiration check: 0:00:01 ago on Sat 05 Aug 2023 04:30:29 PM CST.
Metadata cache created.
6、测试,安装httpd服务
[root@rehl-client ~]# yum install httpd -y
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:00:22 ago on Sat 05 Aug 2023 04:30:29 PM CST.
Dependencies resolved.
================================================================================================
Package Arch Version Repository Size
================================================================================================
Installing:
httpd x86_64 2.4.37-43.module_el8.5.0+1022+b541f3b1 AppStream 1.4 M
Installing dependencies:
apr x86_64 1.6.3-12.el8 AppStream 129 k
apr-util x86_64 1.6.1-6.el8 AppStream 105 k
centos-logos-httpd noarch 85.8-2.el8 BaseOS 75 k
httpd-filesystem noarch 2.4.37-43.module_el8.5.0+1022+b541f3b1 AppStream 39 k
httpd-tools x86_64 2.4.37-43.module_el8.5.0+1022+b541f3b1 AppStream 107 k
mod_http2 x86_64 1.15.7-3.module_el8.4.0+778+c970deab AppStream 154 k
Installing weak dependencies:
apr-util-bdb x86_64 1.6.1-6.el8 AppStream 25 k
apr-util-openssl x86_64 1.6.1-6.el8 AppStream 27 k
Enabling module streams:
httpd 2.4
Transaction Summary
================================================================================================
Install 9 Packages
Total download size: 2.1 M
Installed size: 5.6 M
Downloading Packages:
(1/9): centos-logos-httpd-85.8-2.el8.noarch.rpm 106 kB/s | 75 kB 00:00
(2/9): apr-1.6.3-12.el8.x86_64.rpm 175 kB/s | 129 kB 00:00
(3/9): apr-util-openssl-1.6.1-6.el8.x86_64.rpm 152 kB/s | 27 kB 00:00
(4/9): apr-util-bdb-1.6.1-6.el8.x86_64.rpm 98 kB/s | 25 kB 00:00
(5/9): httpd-filesystem-2.4.37-43.module_el8.5.0+1022+b541f3b1. 105 kB/s | 39 kB 00:00
(6/9): httpd-tools-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_6 358 kB/s | 107 kB 00:00
(7/9): mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64.rp 266 kB/s | 154 kB 00:00
(8/9): apr-util-1.6.1-6.el8.x86_64.rpm 40 kB/s | 105 kB 00:02
(9/9): httpd-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64.rpm 516 kB/s | 1.4 MB 00:02
------------------------------------------------------------------------------------------------
Total 565 kB/s | 2.1 MB 00:03
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : apr-1.6.3-12.el8.x86_64 1/9
Running scriptlet: apr-1.6.3-12.el8.x86_64 1/9
Installing : apr-util-bdb-1.6.1-6.el8.x86_64 2/9
Installing : apr-util-openssl-1.6.1-6.el8.x86_64 3/9
Installing : apr-util-1.6.1-6.el8.x86_64 4/9
Running scriptlet: apr-util-1.6.1-6.el8.x86_64 4/9
Installing : httpd-tools-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64 5/9
Running scriptlet: httpd-filesystem-2.4.37-43.module_el8.5.0+1022+b541f3b1.noarch 6/9
Installing : httpd-filesystem-2.4.37-43.module_el8.5.0+1022+b541f3b1.noarch 6/9
Installing : centos-logos-httpd-85.8-2.el8.noarch 7/9
Installing : mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64 8/9
Installing : httpd-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64 9/9
Running scriptlet: httpd-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64 9/9
Verifying : centos-logos-httpd-85.8-2.el8.noarch 1/9
Verifying : apr-1.6.3-12.el8.x86_64 2/9
Verifying : apr-util-1.6.1-6.el8.x86_64 3/9
Verifying : apr-util-bdb-1.6.1-6.el8.x86_64 4/9
Verifying : apr-util-openssl-1.6.1-6.el8.x86_64 5/9
Verifying : httpd-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64 6/9
Verifying : httpd-filesystem-2.4.37-43.module_el8.5.0+1022+b541f3b1.noarch 7/9
Verifying : httpd-tools-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64 8/9
Verifying : mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64 9/9
Installed products updated.
Installed:
apr-1.6.3-12.el8.x86_64
apr-util-1.6.1-6.el8.x86_64
apr-util-bdb-1.6.1-6.el8.x86_64
apr-util-openssl-1.6.1-6.el8.x86_64
centos-logos-httpd-85.8-2.el8.noarch
httpd-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64
httpd-filesystem-2.4.37-43.module_el8.5.0+1022+b541f3b1.noarch
httpd-tools-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64
mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64
Complete!
[root@rehl-client ~]#
本文详细介绍了在Red Hat 8.2系统上配置本地yum源的步骤,包括镜像挂载、挂载点创建、内容查看、备份配置文件、配置repo、清理和创建缓存等,还对BaseOS和AppStream存储库进行了介绍,最后通过安装mariadb和httpd进行测试。
3144

被折叠的 条评论
为什么被折叠?



