1.创建挂载点并挂载CentOS5.4光盘镜像ISO
mkdir /mnt/CentOS5.4
mount -o loop CentOS-5.4-x86_-bin-DVD.iso /mnt/CentOS5.4
2.修改xxx.repo的内容
cat > /etc/yum.repos.d/CentOS-Base.repo < name=CentOS-Base baseurl=file:///mnt/Centos5.4 gpgcheck=1 enable=0 gpgkey=file:///mnt/CentOS5.4/RPM-GPG-KEY-CentOS-5 EOF 3.导入证书文件 rpm --import /mnt/CentOS5.4/RPM-GPG-KEY-CentOS-5 4.yum list 列出所有文件列表 Centos5.4 远程搭建 若没有搭建本地yum源,直接搭建远程yum源的话,需要做上面第三部操作 rpm --import /mnt/CentOS5.4/RPM-GPG-KEY-CentOS-5 修改CentOS 5.4的yum源为上海交大FTP2010-01-14 20:461.修改/etc/yum.repos.d/CentOS-Base.repo为: # 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-$releasever – Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os baseurl=http://ftp.sjtu.edu.cn/centos/5.4/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #released updates [updates] name=CentOS-$releasever – Updates #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates baseurl=http://ftp.sjtu.edu.cn/centos/5.4/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #packages used/produced in the build but not released [addons] name=CentOS-$releasever – Addons #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons baseurl=http://ftp.sjtu.edu.cn/centos/5.4/addons/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #additional packages that may be useful [extras] name=CentOS-$releasever – Extras #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras baseurl=http://ftp.sjtu.edu.cn/centos/5.4/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever – Plus #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus baseurl=http://ftp.sjtu.edu.cn/centos/5.4/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #contrib – packages by Centos Users [contrib] name=CentOS-$releasever – Contrib #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib baseurl=http://ftp.sjtu.edu.cn/centos/5.4/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 2.执行 yum update Ok了,搞定。 注: centos yum 错误 Error: Cannot find a valid baseurl for repo: addons 装了个CentOS 5.x,使用yum时出现了下面的错误提示。 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=i386&repo=addons error was [Errno 4] IOError: Error: Cannot find a valid baseurl for repo: addons 可以尝试去 ping mirrorlist.centos.org 若发现ping不通。可能是dns设置问题。 ping www.ctohome.com 也出现 unknown host www.ctohome.com 的错误。 多试一试偶尔会ping通,说明dns的确有问题。于是,我们来修改dns配置: vi /etc/resolv.conf 或者使用echo "nameserver 8.8.8.8" >> /etc/resolv.conf 搞定,ping www.baidu.com 顺畅了,yum可以用了!删除 /etc/resolv.conf 里面有问题的dns服务器。