镜像下载、域名解析、时间同步请点击阿里云开源镜像站
linux配置yum源的三种方法:
1.配置网络yum源
2.通过上传镜像文件配置本地yum源
3.通过连接存储或本地镜像文件配置本地yum源(虚拟机)
配置各种yum源的时候,需要提前知道自己的linux系统是什么版本的,以方便后面的配置
// ##查看系统版本
[root@test ~]#cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.4 (Santiago)
[root@test ~]#
1.配置网络yum源
首先进入到/etc/yum.repos.d/,将此目录下的内容全部挪到一个其他的目录里,这里我将他们挪到新建的/etc/yum.repos.d/old下
// ##获得网络yum的包
curl -o /etc/yum.repos.d/Rhel-Base.repo http://file.kangle.odata.cc/repo/Centos-6.repo
编辑repo文件
将repo文件里的$releasever替换成6(如果操作系统版本是7就替换成7)
用此命令即可替换:
// ##获得网络yum的包
%s/$releasever/6/g
保存退出后
运行yum clean all和yum makecache命令
2.通过上传镜像文件配置本地yum源
首先将自己搞到的镜像文件上传到自己的机器上,我这里上传到了/tmp目录下。
!!!上传的镜像文件要和操作系统的版本一样
创建挂载目录并将此映像挂载到该目录
[En]
Create a mount directory and mount this image to the directory
转到挂载目录并确认挂载成功
[En]
Go to the mount directory and confirm that the mount is successful
进入到 /etc/yum.repos.d/ 目录下把以前自带的repo文件移走,自己新建一个repo文件,这里我新建的 local-rehl.repo,编辑此文件
填入以下内容:
/mnt/cdrom 为自己刚刚建的挂载目录
yum clean all
yum makecache
这种挂载只是一次性的,重启机器后将会丢失,如果想要开机自动挂载则需要修改 /etc/fstab 文件,添加自己的挂载信息
vi /etc/fstab
3.通过连接存储或本地镜像文件配置本地yum源(虚拟机)
首先将本地或存储上的镜像文件连接到您自己的虚拟机
[En]
First connect the image file on the local or storage to your own virtual machine
连接后,转到虚拟机命令行检查磁盘挂载,可以看到磁盘介质已经显示。
[En]
After connecting, go to the virtual machine command line to check the disk mount, and you can see that the disk media has been displayed.
将 /dev/sr0 挂载到自己新建的挂载目录 /dev/cdrom 上
检查挂载情况并新建和编写repo文件
// repo文件内容
[RHEL6u3]
name=RHEL 6.4
gpgcheck=0
enabled=1
baseurl=file:///mnt/cdrom
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release
保存退出后 yum clean all 和 yum makecache
如果您需要一直使用它,可以参考第二种方法中的开启自动挂载。
[En]
If you need to use it all the time, you can refer to the turn-on automatic mount in the second method.
本文转自:https://blog.csdn.net/weixin_44418421/article/details/121765120
Original: https://www.cnblogs.com/helong-123/p/16054732.html
Author: 萌褚
Title: linux配置yum源的三种方法
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/523954/
转载文章受原作者版权保护。转载请注明原作者出处!