Linux 之配置本地yum 源

配置本地yum 源

Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装。

第一步:安装盘打开 mount /dev/cdrom /mnt

mount:you must specify the filesystem type

cd /etc/yum.repos.d/

会有四个文件

CentOS-Base.repo 是yum 网络源的配置文件

CentOS-Media.repo 是yum 本地源的配置文件

备份/etc/yum.repos.d/目录下所有文件
cd /etc/yum.repos.d/
rename .repo .repo.bak *

新建一个 touch  centos6.5-dvd.repo

第二步:vim /etc/yum.repos.d/centos6.5-dvd.repo

[centos]

name=centos6.6

baseurl=file:///mnt

gpgcheck=0

enabled=1

第三步:清空yum源 yum clean all

第四步:加载yum源 yum repolist all

----------------------------------

bug:

1.安装盘打开 mount /dev/cdrom /mnt

mount: you must specify the filesystem type

检查一下 cdrom 是不是cdrom1

-------------------------------------------------------------------

1.6配置本地yum源(源码安装才要求配置)
1.6.1 在虚拟软件上 --My Computer -> 选中虚拟机 -> 右键 -> settings -> CD/DVD(IDE) -> Connected和Connect at power on 都选上 -> ok
1.6.2 挂载cdrom
mount /dev/cdrom /mnt
1.6.3 备份/etc/yum.repos.d/目录下所有文件
cd /etc/yum.repos.d/
rename .repo .repo.bak *

1.6.4 配置本地yum源
vim /etc/yum.repos.d/Centos6.6-dvd.repo
内容如下:
[centos6.6]
name=centos6.6-dvd
baseurl=file:///mnt
gpgcheck=0
enabled=1
1.6.5 清空yum缓存
yum clean all
重新加载yum源
yum repolist all

1.6.6 安装httpd服务(用于共享网络linux安装盘内容)
yum install httpd
#查看是否已httpd服务状态
service httpd status
#启动/关闭httpd服务
service httpd start/stop
1.6.7 在/var/www/html文件夹下创建一个iso目录
mkdir /var/www/html/iso
复制光盘内到到httpd web服务下进行共享
cp -r /mnt/* /var/www/html/iso
1.6.8 把yum源改成网络共享方式
vim /etc/yum.repos.d/Centos6.6-dvd.repo
把baseurl=file:///mnt改成
baseurl=http://192.168.0.2/iso

1.6.9 重新清空和加载yum源
yum clean all
yum repolist all

chkconfig httpd on 配置开机启动

1.7 配置局域网访问的yum源。
将上述配置好的考到节点中;
scp /etc/yum.repos.d/entos-6_byzzy.repo root@192.168.122.211:/et/yum .repos.d/
在该节点上,重新清空和加载yum 源

二. yum 配置网易源

1,进入yum源配置目录
cd /etc/yum.repos.d

2,备份系统自带的yum源
mv CentOS-Base.repo CentOS-Base.repo.bk
下载163网易的yum源:
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

3,更新玩yum源后,执行下边命令更新yum配置,使操作立即生效
yum makecache

4,除了网易之外,国内还有其他不错的yum源,比如中科大和搜狐的,大家可以根据自己需求下载
中科大的yum源:
wget http://centos.ustc.edu.cn/CentOS-Base.repo
sohu的yum源
wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo

理论上讲,这些yum源redhat系统以及fedora也是可以用 的,但是没有经过测试,需要的站长可以自己测试一下。

原文地址:https://www.cnblogs.com/chaoren399/p/2965012.html