CentOS 7配置本地yum源

1、虚拟机添加CD/DVD,添加CentOS镜像。

2、创建挂载目录

        mkdir -p /mnt/cdrom

3、挂载

        mount /dev/sr0 /mnt/cdrom

4、备份repo

        将/etc/yum.repo.d/*.repo移动到backup目录:

        mv /etc/yum.repo.d/*.repo backup

5、添加local.repo(名字不重要)

       

[local]
name=local repo
baseurl=file:///mnt/cdrom
enable=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PM-GPG-KEY-CentOS-7

6、使用生效

        yum clean all 

        yum makecache

7、开机启动

       vim /etc/fstab

        添加内容:

                /dev/sr0 /mnt/cdrom iso9660 defaults 0 0

1.查看系统本身存在的版本 rpm -qa | grep yum 2.卸载centos7上存在的yum安装源包 rpm -e 源包 --nodeps 3.下载yum源包(http://mirrors.163.com/centos/7/os/x86_64/Packages/) yum-metadata-parser-1.1.4-10.el7.x86_64 PackageKit-yum-1.0.7-6.el7.centos.x86_64 yum-utils-1.1.31-40.el7.noarch 下方两个一起装 yum-plugin-fastestmirror-1.1.31-40.el7.noarch yum-langpacks-0.4.2-7.el7.noarch yum-3.4.3-150.el7.centos.noarch yum-rhn-plugin-2.0.1-6.el7.noarch 4.安装yum源包 rpm -ivh yum* 5.创建配置文件(/etc/yum.repos.d/CentOS-Base.repo) vi /etc/yum.repos.d/CentOS-Base.repo [base] name=CentOS-$releasever - Base - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch;=$basearch&repo=os baseurl=http://mirrors.163.com/centos/(系统版本号)7/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch;=$basearch&repo=updates baseurl=http://mirrors.163.com/centos/7/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch;=$basearch&repo=extras baseurl=http://mirrors.163.com/centos/7/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=$releasever - Plus - 163.com baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 每一个baseurl的centos后都改成自己系统的版本号 6.执行命令 yum clean all yum makecache yum install telnet
回答: 当配置本地yum源时,如果在生成缓存或者查看yum源列表时出现错误,可能有几个原因导致。首先,错误信息"Couldn't open file /mnt/local/repodata/repomd.xml"表明无法打开文件,可能是文件路径不正确或者文件不存在。其次,如果出现"Cannot find a valid baseurl for repo: base/7/x86_6"的错误,可能是本地源没有正确挂载或者没有从/etc/yum.repo.d/目录下移除。解决这些问题的方法是,首先确保本地源的路径和文件名正确,并且文件存在。其次,检查是否正确挂载了本地源,可以通过编辑/etc/fstab文件并添加正确的挂载信息来解决。最后,确保已经从/etc/yum.repo.d/目录下移除了不需要的源文件。这些步骤可以帮助解决centos7配置本地yum源报错的问题。\[1\]\[2\] #### 引用[.reference_title] - *1* [解决CentOS7制作本地yum源报错 “Couldn‘t open file /mnt/local/repodata/repomd.xml](https://blog.csdn.net/Steven_Start/article/details/117852093)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [centos7配置yum源出现的问题](https://blog.csdn.net/weixin_46470342/article/details/105833133)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值