一、配置YUM本地源
1.挂载镜像
[root@linuxidc ~]# mount /dev/cdrom /mnt
2.查看是否挂载成功
[root@linuxidc ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 49G 1.3G 48G 3% /
devtmpfs 479M 0 479M 0% /dev
tmpfs 489M 0 489M 0% /dev/shm
tmpfs 489M 6.6M 482M 2% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sda1 497M 112M 385M 23% /boot
tmpfs 98M 0 98M 0% /run/user/0
/dev/sr0 3.8G 3.8G 0 100% /mnt
3.备份原来的仓库
[root@linuxidc ~]# cp -r /etc/yum.repos.d /etc/yum.repos.d_bak
[root@linuxidc ~]# rm -f /etc/yum.repos.d/*
4.创建新的repo配置文件
[root@linuxidc ~]# vi /etc/yum.repos.d/dvd.repo
[dvd]
name=install dvd
baseurl=file:///mnt
enabled=1
gpgcheck=0
5.刷新repos生成缓存
[root@linuxidc ~]# yum makecache
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
dvd | 4.1 kB 00:00:00
(1/5): dvd/group_gz | 137 kB 00:00:00
(2/5): dvd/filelists_db | 3.4 MB 00:00:00
(3/5): dvd/primary_db | 4.0 MB 00:00:00
(4/5): dvd/other_db | 1.5 MB 00:00:00
(5/5): dvd/productid | 1.6 kB 00:00:00
Metadata Cache Created
二、使用CentOS源
1、执行 rpm -qa|grep yum|xargs rpm -e --nodeps 删除原始的yum包。执行完成后,再次执行1.1中命令,如果为空即为成功。
2、配置DNS,用阿里的DNS:
vi /etc/resolv.conf 加入如下
nameserver 223.5.5.5
nameserver 223.6.6.6
3、 下载163镜像站中CentOS 7下的 yum相关包:
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
网址可能会变,如果下载失败 则进入http://mirrors.163.com/centos/7/os/x86_64/Packages/
检查一下,网址中的版本号替换为目标版本,目前163是把7版本的包都放在下面,并且随时更新
4、为避免依赖问题,建议执行 rpm -ivh yum-*,一次性安装下载的三个软件包
5 、执行rpm -qa |grep yum 检查安装是否成功
6、替换原有的源地址文件,在/etc/yum.repos.d/目录下备份系统自带的源地址文件
例如:本地文件名称是rhel-source.repo,执行备份
```
mv /etc/yum.repos.d/rhel-source.repo /etc/yum.repos.d/rhel-source.repo.backup
7、 同样在/etc/yum.repos.d/目录下,下载163镜像站内的镜像源文件8、将下载的CentOS7-Base-163.repo文件中的 $releasever 全部修改为目标版本7。修改完成后 如图:
CentOS-Base.repo
#
The mirror system uses the connecting IP address of the client and the
update status of each mirror to pick mirrors that are updated to and
geographically close to the client. You should use this for CentOS updates
unless you are manually picking other mirrors.
#
If the mirrorlist= does not work for you, as a fall back you can try the
remarked out baseurl= line instead.
#
#
[base]
name=CentOS-7- Base - 163.com
#released updates
[updates]
name=CentOS-7 - Updates - 163.com
#additional packages that may be useful
[extras]
name=CentOS-7 - Extras - 163.com
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/x86_64/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
9、 执行 yum clean all,清理之前的缓存,这时候 有可能会有 替换之前的报错,可以不用理会
10、执行 yum makecache,重新生成缓存。
11、 执行 yum repolist all,检查源是否已经更新
12、 安装gcc
yum install gcc
安装telnet
yum install telnet
```