|
一、本地光盘yum源配置
1、创建挂载点- [root@localhost ~]# mkdir /mnt/cdrom
复制代码 2、配置自动挂载本地光盘- [root@localhost ~]# vim /etc/fstab
- #
- # /etc/fstab
- # Created by anaconda on Sun Oct 20 16:02:54 2024
- ……省略部分内容……
- sysfs /sys sysfs defaults 0 0
- proc /proc proc defaults 0 0
- #添加开机自动挂载系统光盘
- /dev/cdrom /mnt/cdrom iso9660 defaults 0 0
复制代码 3、配置yum源- #创建备份原有yum源文件的目录
- [root@localhost yum.repos.d]# mkdir bak
- #移动原有yum源文件到bak目录
- [root@localhost yum.repos.d]# mv *.repo bak
- #进入bak目录
- [root@localhost yum.repos.d]# cd bak
- #复制光盘yum源文件到/etc/yum.repos.d目录
- [root@localhost bak]# cp CentOS-Media.repo ..
- #返回到/etc/yum.repos.d目录
- [root@localhost bak]# cd ..
- #打开光盘yum源文件
- [root@localhost yum.repos.d]# vim CentOS-Media.repo
- # CentOS-Media.repo
- ……省略部分内容……
- # yum --disablerepo=\* --enablerepo=c6-media [command]
- [c6-media]
- name=CentOS-$releasever - Media
- baseurl=file:///mnt/cdrom/ #配置挂载点目录
- # file:///media/cdrom/
- # file:///media/cdrecorder/
- gpgcheck=1
- enabled=1 #开启。把默认值0修改为1
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
复制代码 4、清理并生成缓存- [root@localhost ~]# yum clean all && yum makecache
- 已加载插件:fastestmirror, security
- Cleaning repos: c6-media
- 清理一切
- Cleaning up list of fastest mirrors
- 已加载插件:fastestmirror, security
- Determining fastest mirrors
- c6-media | 4.0 kB 00:00 ...
- c6-media/group_gz | 226 kB 00:00 ...
- c6-media/filelists_db | 6.3 MB 00:00 ...
- c6-media/primary_db | 4.7 MB 00:00 ...
- c6-media/other_db | 2.8 MB 00:00 ...
- 元数据缓存已建立
复制代码 5.查看yum源- [root@localhost ~]# yum repolist
- 已加载插件:fastestmirror, security
- Loading mirror speeds from cached hostfile
- 仓库标识 仓库名称 状态
- c6-media CentOS-6 - Media 6,696
- repolist: 6,696
复制代码 二、阿里云yum源配置
1、备份系统原有的源配置文件- #进入yum源文件存放目录
- [root@localhost ~]# cd /etc/yum.repos.d/
- #创建备份原yum源文件目录
- [root@localhost yum.repos.d]# mkdir bak
- #移动原yum源文件到备份目录
- [root@localhost yum.repos.d]# mv *.repo bak
复制代码 2、下载阿里云yum源配置文件- #CentOS6
- wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
- #CentOS7
- wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
- #CentOS8
- wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
复制代码 使用CentOS6为例演示- #下载CentOS6的阿里云yum配置文件
- [root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
- --2024-10-18 22:51:10-- https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
- 正在解析主机 mirrors.aliyun.com... 39.174.58.234, 39.174.58.233, 39.174.58.231, ...
- 正在连接 mirrors.aliyun.com|39.174.58.234|:443... 已连接。
- 已发出 HTTP 请求,正在等待回应... 200 OK
- 长度:2533 (2.5K) [application/octet-stream]
- 正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”
- 100%[=====================================>] 2,533 --.-K/s in 0s
- 2024-10-18 22:51:11 (422 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2533/2533])
- #查看是否下载完成
- [root@localhost yum.repos.d]# ll
- 总用量 8
- drwxr-xr-x. 2 root root 4096 10月 18 22:47 bak
- -rw-r--r--. 1 root root 2533 8月 4 2022 CentOS-Base.repo
复制代码 3、清理缓存并生成新的缓存- #清理缓存并生成新的缓存
- [root@localhost ~]# yum clean all && yum makecache
- 已加载插件:fastestmirror, security
- Cleaning repos: base extras updates
- 清理一切
- Cleaning up list of fastest mirrors
- 已加载插件:fastestmirror, security
- Determining fastest mirrors
- * base: mirrors.aliyun.com
- * extras: mirrors.aliyun.com
- * updates: mirrors.aliyun.com
- base | 3.7 kB 00:00
- base/group_gz | 242 kB 00:00
- base/filelists_db | 6.4 MB 00:02
- base/primary_db | 4.7 MB 00:00
- base/other_db | 2.8 MB 00:00
- extras | 3.4 kB 00:00
- extras/filelists_db | 24 kB 00:00
- extras/prestodelta | 2.2 kB 00:00
- extras/primary_db | 29 kB 00:00
- extras/other_db | 14 kB 00:00
- updates | 3.4 kB 00:00
- updates/filelists_db | 8.4 MB 00:01
- updates/prestodelta | 357 kB 00:00
- updates/primary_db | 12 MB 00:01
- updates/other_db | 479 kB 00:00
- 元数据缓存已建立
复制代码 4、查看yum源- #查看yum源
- [root@localhost ~]# yum repolist
- 已加载插件:fastestmirror, security
- Loading mirror speeds from cached hostfile
- * base: mirrors.aliyun.com
- * extras: mirrors.aliyun.com
- * updates: mirrors.aliyun.com
- 仓库标识 仓库名称 状态
- base CentOS-vault-6.10 - Base - mirrors.aliyun.com 6,713
- extras CentOS-vault-6.10 - Extras - mirrors.aliyun.com 47
- updates CentOS-vault-6.10 - Updates - mirrors.aliyun.com 1,193
- repolist: 7,953
复制代码 来源:https://www.cnblogs.com/roc-time/p/18493370
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作! |
|