配置rpm源

一.搭建本地源

1.挂载镜像文件

临时挂载

[root@A ~]# mount /dev/sr0 /mnt mount: /mnt: WARNING: source write-protected, mounted read-only.

永久挂载

# 修改系统开机会自动运行的脚本
# 最后一行添加 mount 挂载命令

# 给文件添加可执行权限

[root@A ~]# vim /etc/rc.d/rc.local #!/bin/bash # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES # # It is highly advisable to create own systemd services or udev rules # to run scripts during boot instead of using this file. # # In contrast to previous versions due to parallel execution during boot # this script will NOT be run after all other services. # # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure # that this script will be executed during boot. touch /var/lock/subsys/local mount /dev/sr0 /mnt ~ ~ [root@A ~]# chmod +x /etc/rc.d/rc.local

2.建立本地yum源配置文件

[root@A ~]# vim /etc/yum.repos.d/rhel10.repo [BaseOS] name=BaseOS baseurl=file:///mnt/BaseOS gpgcheck=0 [AppStream] name=AppStream baseurl=file:///mnt/AppStream gpgcheck=0

写入内容

[BaseOS]
name=BaseOS
baseurl=file:///mnt/BaseOS
gpgcheck=0

[AppStream]
name=AppStream
baseurl=file:///mnt/AppStream
gpgcheck=0

[BaseOS]
name=BaseOS
baseurl=file:///mnt/BaseOS
gpgcheck=0

[AppStream]
name=AppStream
baseurl=file:///mnt/AppStream
gpgcheck=0

[BaseOS]
name=BaseOS
baseurl=file:///mnt/BaseOS
gpgcheck=0

[AppStream]
name=AppStream
baseurl=file:///mnt/AppStream
gpgcheck=0

# 清空缓存

[root@A ~]# yum clean all 正在更新 Subscription Management 软件仓库。 无法读取客户身份 本系统尚未在权利服务器中注册。可使用 "rhc" 或 "subscription-manager" 进行注册。 0 个文件已删除

# 生成新的 yum 缓存

[root@A ~]# yum makecache 正在更新 Subscription Management 软件仓库。 无法读取客户身份 本系统尚未在权利服务器中注册。可使用 "rhc" 或 "subscription-manager" 进行注册。 BaseOS 75 MB/s | 1.5 MB 00:00 AppStream 158 MB/s | 1.5 MB 00:00 元数据缓存已建立。

二.网络源

#找到公开网络源

#在 /etc/yum.repos.d 目录下创建 .repo 结尾的配置文件

#重建缓存生效

[root@A ~]# vim /etc/yum.repos.d/ali.repo [ali-BaseOS] name=ali-BaseOS baseurl=https://mirrors.aliyun.com/rockylinux/10/BaseOS/x86_64/os/ gpgcheck=0 [ali-AppStream] name=ali-AppStream baseurl=https://mirrors.aliyun.com/rockylinux/10/AppStream/x86_64/os/ gpgcheck=0 ~ ~ ~ [root@A ~]# yum clean all [root@A ~]# yum makecache

三.EPEL拓展源

[root@A ~]# vim /etc/yum.repos.d/epel.repo [epel] name=epel baseurl=https://mirrors.aliyun.com/epel/10/Everything/x86_64/ gpgcheck=0 ~ ~ ~ ~ [root@A ~]# yum clean all [root@A ~]# yum makecache