一、使用更新源的国内镜像
CentOS 安装完毕,首先应该修改更新源,并升级到最新的系统。
国内速度较快的常用更新源:
http://mirror.be10.com/centos/
http://centos.candishosting.com.cn/
http://ftp.sjtu.edu.cn/centos/
http://ftp.hostrino.com/pub/centos/
http://mirrors.ta139.com/centos/
http://ftp.iasi.roedu.net/mirrors/centos.org/centos/
http://centos.ustc.edu.cn/centos/
http://mirrors.163.com/centos/
首先备份CentOS-Base.repo,然后再编辑 yum 的配置文件
[admingu@googe ~]$ sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
[admingu@googe ~]$ sudo vi /etc/yum.repos.d/CentOS-Base.repo
[base] name=CentOS-$releasever - Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ baseurl=http://centos.candishosting.com.cn/$releasever/os/$basearch/ http://mirrors.ta139.com/centos/$releasever/os/$basearch/ http://mirror.be10.com/centos/$releasever/os/$basearch/ http://ftp.sjtu.edu.cn/centos/$releasever/os/$basearch/ http://ftp.hostrino.com/pub/centos/$releasever/os/$basearch/ http://centos.ustc.edu.cn/centos/$releasever/os/$basearch/ http://mirrors.163.com/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/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://mirror.centos.org/centos/$releasever/updates/$basearch/ baseurl=http://centos.candishosting.com.cn/$releasever/updates/$basearch/ http://mirrors.ta139.com/centos/$releasever/updates/$basearch/ http://mirror.be10.com/centos/$releasever/updates/$basearch/ http://ftp.sjtu.edu.cn/centos/$releasever/updates/$basearch/ http://ftp.hostrino.com/pub/centos/$releasever/updates/$basearch/ http://centos.ustc.edu.cn/centos/$releasever/updates/$basearch/ http://mirrors.163.com/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/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://mirror.centos.org/centos/$releasever/addons/$basearch/ baseurl=http://centos.candishosting.com.cn/$releasever/addons/$basearch/ http://mirrors.ta139.com/centos/$releasever/addons/$basearch/ http://mirror.be10.com/centos/$releasever/addons/$basearch/ http://ftp.sjtu.edu.cn/centos/$releasever/addons/$basearch/ http://ftp.hostrino.com/pub/centos/$releasever/addons/$basearch/ http://centos.ustc.edu.cn/centos/$releasever/addons/$basearch/ http://mirrors.163.com/centos/$releasever/addons/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/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://mirror.centos.org/centos/$releasever/extras/$basearch/ baseurl=http://centos.candishosting.com.cn/$releasever/extras/$basearch/ http://mirrors.ta139.com/centos/$releasever/extras/$basearch/ http://mirror.be10.com/centos/$releasever/extras/$basearch/ http://ftp.sjtu.edu.cn/centos/$releasever/extras/$basearch/ http://ftp.hostrino.com/pub/centos/$releasever/extras/$basearch/ http://centos.ustc.edu.cn/centos/$releasever/extras/$basearch/ http://mirrors.163.com/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/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://mirror.centos.org/centos/$releasever/centosplus/$basearch/ baseurl=http://centos.candishosting.com.cn/$releasever/centosplus/$basearch/ http://mirrors.ta139.com/centos/$releasever/centosplus/$basearch/ http://mirror.be10.com/centos/$releasever/centosplus/$basearch/ http://ftp.sjtu.edu.cn/centos/$releasever/centosplus/$basearch/ http://ftp.hostrino.com/pub/centos/$releasever/centosplus/$basearch/ http://centos.ustc.edu.cn/centos/5$releasever/centosplus/$basearch/ http://mirrors.163.com/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/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://mirror.centos.org/centos/$releasever/contrib/$basearch/ baseurl=http://centos.candishosting.com.cn/$releasever/contrib/$basearch/ http://mirrors.ta139.com/centos/$releasever/contrib/$basearch/ http://mirror.be10.com/centos/$releasever/contrib/$basearch/ http://ftp.sjtu.edu.cn/centos/$releasever/contrib/$basearch/ http://ftp.hostrino.com/pub/centos/$releasever/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 |
其中:
repositoryid:用于指定一个仓库
name:用于指定易读的仓库名称
baseurl:用于指定本仓库的URL,可以是以下的3种类型,如http,ftp,file
mirrorlist:用于指定仓库的镜像站点
enable:用于指定是否使用本仓库,默认值为1,即可用。
gpgcheck:用于指定是否检查软件包的GPG签名。
gpgkey:用于指定GPG签名文件的URL。
执行命令:
[admingu@googe ~]$ sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
二、使用非官方更新源
下面以安装rpmforge和DAG软件包为例添加非官方更新源
I、添加rmpforge软件库
1)到http://dag.wieers.com/rpm/packages/rpmforge-release/查找适用于RHEL5/CentOS5的软件包。
2)下载适用于RHEL5/CentOS5的软件包。
[admingu@googe ~]$ sudo wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
[admingu@googe ~]$ sudo rpm -ivh rpmforge-release-0.3.6-1.el5.rf.i386.rpm
[admingu@googe ~]$ sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-*
安装rpmforge-release软件包之后,就可以看到/etc/yum.repos.d/rpmforge.repo文件,以后yum就可以使用这个更新源了。
II、添加DAG更新仓库 。//这个库我更新时总是出现问题,望达人帮我一下!
1)在/etc/yum.repos.d/下建立dag.repo
2)编辑dag.repo
[admingu@googe ~]$ sudo vi /etc/yum.repos.d/dag.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el5/en/i386/dag/
gpgcheck=1
enabled=1
gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
保存退出。
然后导入Key,
[admingu@googe ~]$ wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
[admingu@googe ~]$ sudo rpm --import RPM-GPG-KEY.dag.txt
[admingu@googe ~]$ sudo rm -f RPM-GPG-KEY.dag.txt //这个可以先移除也可以不移除
以下是好友Nick提供的解决方法,非常感谢他!
在定义 yum 非官方库 dag.repo 后,使用 yum 安装非官方库里定义的软件是,如果出现错误:
Reading repository metadata in from local files
primary.xml.gz 100% |=========================| 883 kB 00:59
http://apt.sw.be/redhat/el5/en/i386/dag/repodata/primary.xml.gz: [Errno -1] Metadata file does not match checksum
Trying other mirror.
Error: failure: repodata/primary.xml.gz from dag: [Errno 256] No more mirrors to try.
这个错误应该是因为"/var/cache/yum/dag/”里的 primary.xml.gz 不能通过校验导致的。(暂时找不到原因,用多线程软件下载就没问题,如'myget')
这个错误我自己的解决方法是:是用软件'myget'下载 primary.xml.gz 到 "/var/cache/yum/dag/” ;然后再重新用yum安装软件。
三、使用如下命令更新到最新系统
# yum upgrade
四、安装必要的软件工具
# yum install wget bzip2 unzip zip nmap tree lynx fileutils ncftp lftp
若您需要在本机编译源代码的软件,请安装开发工具组的软件包
# yum groupinstall "Development Tools"