本文包括 rhel5配置yum源,rhel6.8 配置yum源,centos7配置yum源,使用本地iso文件配置yum源
rhel5配置yum
cd /etc/yum.repos.d
cp rhel-debuginfo.repo rhel-debuginfo.repo.bak
vi rhel-debuginfo.repo(将gpgcheck=1修改成gpgcheck=0)
[base]
name=CentOS-5-Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever5&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://ftp.sjtu.edu.cn/centos/5/os/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#released updates
[update]
name=CentOS-5-Updates
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updates
baseurl=http://ftp.sjtu.edu.cn/centos/5/updates/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#packages used/produced in the build but not released
[addons]
name=CentOS-5-Addons
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=addons
baseurl=http://ftp.sjtu.edu.cn/centos/5/addons/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#additional packages that may be useful
[extras]
name=CentOS-5-Extras
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=extras
baseurl=http://ftp.sjtu.edu.cn/centos/5/extras/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5-Plus
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=centosplus
baseurl=http://ftp.sjtu.edu.cn/centos/5/centosplus/$basearch/
gpgcheck=0
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#contrib - packages by Centos Users
[contrib]
name=CentOS-5-Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=contrib
baseurl=http://ftp.sjtu.edu.cn/centos/5/contrib/$basearch/
gpgcheck=0
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
vi vi dag.repo
[dag]
name=Dag RPM Repository for RHEL5
baseurl=http://ftp.riken.jp/Linux/dag/redhat/el5/en/$basearch/dag/
enabled=1
gpgcheck=0
gpgkey=http://ftp.riken.jp/Linux/dag/packages/RPM-GPG-KEY.dag.txt
导入key
rpm --import http://ftp.sjtu.edu.cn/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
6.8 配置yum源
一般安装好redhat后,不能注册的话,不能使用系统自带的yum源。但是们可以配置yum源来解决这一问题。下面介绍下redhat配置163yum源。
1. 检查是否安装yum包
rpm -qa |grep yum
2. 删除自带的yum包
rpm -qa|grep yum|xargs rpm -e --nodeps
因为一些包之间可能会有依赖关系,所以们需要加上参数 --nodeps 无视依赖关系。
3. 下载yum包
Yum包下载地址http://mirrors.163.com/centos/
在这个网站里,可以选择需要下载的文件,进入形如5/或者6/的文件下载,其他的无法下载。 (rpm 版本会更新)
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-73.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm
4. 解压yum包
rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
rpm -ivh yum-3.2.29-73.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm
5. 替换yum源
cd /etc/yum.repos.d/ wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
vi CentOS6-Base-163.repo
注意原来的yum源配置文件是rhel-source.repo。
这里把CentOS6-Base-163.repo替换掉rhel-source.repo。
mv rhel-source.repo rhel-source.repo.bak
mv CentOS6-Base-163.repo rhel-source.repo
6. 编辑替换后的rhel-source.repo
#rhel-source.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-6 - Base - 163.com
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-6 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-6 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
7. 清理并重建缓存
yum clean all
yum makecache
8. 更新yum
yum update
至此,redhat配置163yum源完成
设置DVD作为软件安装源
修改后可以从本地DVD升级系统
[root@superman myconfig]# mount -o loop /mnt/rhel-5.2-server-i386-dvd.iso /mnt/cdrom/
[root@superman myconfig]# mkdir /etc/yum.repos.d/back
[root@superman myconfig]# cp /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/back/
[root@superman myconfig]# gedit /etc/yum.repos.d/rhel-debuginfo.repo
修改为以下内容:
[base]
name=base RPM Repository for RHEL5
baseurl=file:/mnt/cdrom/Server/
enabled=1
gpgcheck=0
继续
[root@superman myconfig]# cd /usr/lib/python2.4/site-packages/yum/
[root@superman yum]# cp yumRepo.py yumRepo.py.myback
[root@superman yum]# gedit yumRepo.py
修改修改607行为:
remote = 'file:/mnt/cdrom/Server/' + '/' + relative
或者使用方法
[root@mylinix ~]# umount /media/RHEL_5.6\ i386\ DVD/
[root@mylinix ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda3 8.7G 4.6G 3.7G 56% /
/dev/sda1 99M 12M 83M 12% /boot
tmpfs 252M 0 252M 0% /dev/shm
[root@mylinix ~]# mount /dev/cdrom /mnt/
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@mylinix ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda3 8.7G 4.6G 3.7G 56% /
/dev/sda1 99M 12M 83M 12% /boot
tmpfs 252M 0 252M 0% /dev/shm
/dev/hdc 3.0G 3.0G 0 100% /mnt
cd /etc/yum.repos.d
[root@mylinix yum.repos.d]# vi rhel-debuginfo.repo
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///mnt/Server
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-releas
Centos7配置yum
1、测试网络。
2、进入yum路径下:
cd /etc/yum.repos.d/
3、下载repo文件
(在这里以阿里yum为例)
wget http://mirrors.aliyun.com/repo/Centos-7.repo
注:
①如果wget命令不生效,说明还没有安装wget工具,输入yum -y install wget 回车进行安装。然后再执行上面的命令。
②如果新安装的系统,没有配置yum源,那就无法执行yum命令,我们我可以从其他机器上scp到本机目录下。
4、备份系统原有的repo文件,并将下载的新源替换系统原来的repo文件
mv CentOs-Base.repo CentOs-Base.repo.bak
mv Centos-7.repo CentOs-Base.repo
5、yum源缓存更新
(依次执行)
yum clean all
yum makecache
yum update
Centos7本地yum源
挂载光盘文件
mount -o loop CentOS-7-x86_64-DVD-1810.iso /mnt
备份配置文件目录
mv yum.repos.d yum.repos.d.bak
新建配置文件目录
mkdir /etc/yum.repos.d
新建配置文件
cd yum.repos.d
vi CentOS-local.repo
#本源的名字(不能和其他重复)
[base-local]
name=CentOS7.6-local
#步骤2中挂载镜像创建的目录
baseurl=file:///mnt
#启动yum源:1-启用 0-不启用
enabled=1
#安全检测: 1-开启 0-不开启
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
欢迎关注我的公众号 扫描二维码或公众号搜索 “我的工作”





