欢迎光临
我们一直在努力

CentOS更新源设置及系统更新 不更新内核和版本号的设置方法

一、使用更新源的国内镜像

CentOS 安装完毕,首先应该修改更新源,并升级到最新的系统。
国内速度较快的常用更新源:

http://centos.ustc.edu.cn/centos/
http://mirrors.163.com/centos/
http://mirrors.sohu.com/centos/

首先备份CentOS-Base.repo,然后再编辑 yum 的配置文件:
[piaoyun@piaoyun-pc ~]sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
[piaoyun@piaoyun-pc ~]
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/
http://centos.ustc.edu.cn/centos/releasever/os/basearch/
http://mirrors.163.com/centos/releasever/os/basearch/
http://mirrors.sohu.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/
http://centos.ustc.edu.cn/centos/releasever/updates/basearch/
http://mirrors.163.com/centos/releasever/updates/basearch/
http://mirrors.sohu.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/
http://centos.ustc.edu.cn/centos/releasever/addons/basearch/
http://mirrors.163.com/centos/releasever/addons/basearch/
http://mirrors.sohu.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/
http://centos.ustc.edu.cn/centos/releasever/extras/basearch/
http://mirrors.163.com/centos/releasever/extras/basearch/
http://mirrors.sohu.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/
http://centos.ustc.edu.cn/centos/releasever/centosplus/basearch/
http://mirrors.163.com/centos/releasever/extras/basearch/
http://mirrors.sohu.com/centos/releasever/extras/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/
http://ftp.sjtu.edu.cn/centos/releasever/contrib/basearch/
http://mirrors.163.com/centos/releasever/extras/basearch/
http://mirrors.sohu.com/centos/releasever/extras/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。

执行命令:
[piaoyun@piaoyun-pc ~]$ 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的软件包。
[piaoyun@piaoyun-pc ~]sudo wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
[piaoyun@piaoyun-pc ~]
sudo rpm -ivh rpmforge-release-0.3.6-1.el5.rf.i386.rpm
[piaoyun@piaoyun-pc ~]$ sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-*

安装rpmforge-release软件包之后,就可以看到/etc/yum.repos.d/rpmforge.repo文件,以后yum就可以使用这个更新源了。

三、使用如下命令更新到最新系统:

yum check-update
yum -y update
yum upgrade

使用yum update更新时,默认会升级内核。但有些服务器硬件(特别是组装的机器)在升级内核后,新的内核可能会认不出某些硬件,要重新安装驱动,很麻烦。所以在生产环境中不要轻易的升级内核,除非你确定升级内核后不会出现麻烦的问题。

CentOS使用yum update升级时,默认包含升级内核!比如从CentOS 6.2升级到CentOS 6.4
如果不想升级内核而只更新其他软件包,有两种方法:
1、修改yum的配置文件 vim /etc/yum.conf,在[main]的最后添加

exclude=kernel* centos-release*

2、直接在yum的命令后面加上如下的参数:

yum --exclude=kernel* centos-release* update

四、安装必要的软件工具

yum -y install --skip-broken yum-fastestmirror build-essential gcc gcc-c++ bzip2 make vixie-cron flex ncurses-devel wget patch ntp libxml2 libxml2-devel libevent m4 autoconf zip unzip libjpeg libjpeg-devel gd gd-devel freetype freetype-devel libpng libpng-devel openssl openssl-devel file libtool libtool-libs libtool-ltdl-devel gmp-devel pspell-devel parted zlib mod_perl-devel ftp readline-devel apr apr-util curl-devel pam pam-devel lynx libmcrypt-devel libmhash-devel sudo glibc glibc-devel perl perl*

赞(0)
未经允许不得转载:飘云 » CentOS更新源设置及系统更新 不更新内核和版本号的设置方法
分享到: 更多 (0)