一、简述
系统:centos7
环境:VMware虚拟机
二、配置步骤
配置过程(挂在虚拟机默认虚拟光驱的iso镜像)
1 Last login: Mon Jan 8 08:51:00 2024 from 192.168.84.1 2 [root@localhost ~]# ls /mnt/ 3 hgfs 4 [root@localhost ~]# mkdir /mnt/cdrom 5 [root@localhost ~]# ls /dev/cdrom 6 /dev/cdrom 7 [root@localhost ~]# ll /dev/cdrom 8 lrwxrwxrwx. 1 root root 3 Jan 5 19:07 /dev/cdrom -> sr0 9 [root@localhost ~]# mount -t auto /dev/cdrom /mnt/cdrom/ 10 mount: /dev/sr0 is write-protected, mounting read-only 11 [root@localhost ~]# ls /mnt/cdrom/ 12 CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7 13 EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL 14 [root@localhost ~]# cd /etc/yum.repos.d/ 15 [root@localhost yum.repos.d]# ls 16 CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo 17 CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo CentOS-x86_64-kernel.repo 18 [root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.backup
如果虚拟机存储了ISO镜像,则可以
1 通过以下命令将ISO镜像挂载到本地yum目录/yum/local下。 2 3 mount -o loop /yum/iso/CentOS-7-x86_64-DVD-1804.iso /yum/local/
创建本地yum源文件
1 [root@localhost yum.repos.d]# vi Local.repo 2 [centos7-local] 3 name=Centos 7.0 4 baseurl=file:///mnt/cdrom 5 enabled=1 6 gpgcheck=0 7 gpgkey=
1 [root@localhost yum.repos.d]# yum clean all 2 Loaded plugins: fastestmirror 3 Cleaning repos: centos7-local 4 Cleaning up list of fastest mirrors 5 Other repos take up 201 M of disk space (use --verbose for details) 6 [root@localhost yum.repos.d]# yum makecache 7 Loaded plugins: fastestmirror 8 Determining fastest mirrors 9 centos7-local | 3.6 kB 00:00:00 10 (1/4): centos7-local/group_gz | 166 kB 00:00:00 11 (2/4): centos7-local/primary_db | 5.9 MB 00:00:00 12 (3/4): centos7-local/filelists_db | 6.9 MB 00:00:00 13 (4/4): centos7-local/other_db | 2.5 MB 00:00:00 14 Metadata Cache Created 15 [root@localhost yum.repos.d]# yum install net-tools
三、更改默认源为国内阿里源
1、安装wget
1 yum install -y wget
2、下载CentOS 7的repo文件
1 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 2 3 或者 4 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 5
3、更新镜像源
1 清除缓存: 2 yum clean all 3 生成缓存: 4 yum makecache
更改配置文件(很重要)
1、备份CentOS 7系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.repo命令:
1 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、找到yum源的配置路径
1 cd /etc/yum.repos.d标签:00,CentOS,repos,配置,repo,yum,本地,ISO,root From: https://www.cnblogs.com/mehome/p/17971262