为CentOS7和CentOS6配置yum

为CentOS7和CentOS6配置yum

本次设置的操作系统是CentOS7,方法也适用于CentOS6。

1. 上传ISO文件
sftp> lcd E:\ISO
sftp> put CentOS-7.6-x86_64-DVD-1810.iso

2. 挂载ISO文件
[root@C76 ~]# mkdir /media/CentOS/
说明:/media/CentOS/目录是C7和C6的3个YUM缺省目录之一

[root@C76 ~]# mount -t iso9660 -o loop CentOS-7.6-x86_64-DVD-1810.iso /media/CentOS/
mount: /dev/loop0 is write-protected, mounting read-only
[root@C76 ~]#

3. 移走多余的repo文件
[root@C76 ~]# cd /etc/yum.repos.d/

[root@C76 yum.repos.d]# ll
total 44
-rw-r--r--. 1 root root 1664 Nov 23 2018 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Nov 23 2018 CentOS-CR.repo
-rw-r--r--. 1 root root 649 Nov 23 2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 Nov 23 2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 Nov 23 2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Nov 23 2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 5701 Nov 23 2018 CentOS-Vault.repo
[root@C76 yum.repos.d]#

[root@C76 yum.repos.d]# mkdir bk_repo
[root@C76 yum.repos.d]# mv *.repo bk_repo/

[root@C76 yum.repos.d]# cp bk_repo/CentOS-Media.repo ./

[root@C76 yum.repos.d]# ll
total 4
drwxr-xr-x. 2 root root 251 Feb 7 11:28 bk_repo
-rw-r--r--. 1 root root 630 Feb 7 11:31 CentOS-Media.repo
[root@C76 yum.repos.d]#

4. 修改repo文件

[root@C76 yum.repos.d]# vi CentOS-Media.repo

修改enabled=0,变成enabled=1
去掉或注释掉.repo中多余的行
file:///media/cdrom/
file:///media/cdrecorder/

修改后,结果是:
[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

5. 清理yum,建立缓存

[root@C76 yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: c7-media
Cleaning up list of fastest mirrors
Other repos take up 1.3 G of disk space (use --verbose for details)

[root@C76 yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
c7-media | 3.6 kB 00:00:00
(1/4): c7-media/group_gz | 166 kB 00:00:00
(2/4): c7-media/primary_db | 3.1 MB 00:00:00
(3/4): c7-media/other_db | 1.3 MB 00:00:00
(4/4): c7-media/filelists_db | 3.2 MB 00:00:00
Metadata Cache Created

6. 检验yum

[root@C76 yum.repos.d]# yum list |grep gcc

上一篇:scala高阶函数之枚举类


下一篇:scala包对象