网络yum源和制作本地光盘yum源

配置CENTOS YUM更新源

yum安装rpm包安装后本地不清除的方法

sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf

rpm -aq 包名  检查是否安装包

yum --exclude 命令参数的使用

使用该参数,跳过某些软件包后升级,参见文章《yum 命令跳过特定(指定)软件包升级方法》如下:

# yum --exclude=package* update
# yum --exclude=php* update
# yum --exclude=kernel* update
# yum -x 'kernel*' -x 'php*' update

1.下载repo文件

  1. wget http://mirrors.163.com/.help/CentOS6-Base-163.repo   (centos6)
  2. wget http://mirrors.163.com/.help/CentOS7-Base-163.repo    (centos7)

2.备份并替换系统的repo文件

  1. [root@localhost ~]# cd /etc/yum.repos.d/
  2. [root@localhost ~]# mv CentOS-Base.repo CentOS-Base.repo.bak
  3. [root@localhost ~]# mv CentOS6-Base-163.repo CentOS-Base.repo

3.执行yum源更新

  1. [root@localhost ~]# yum clean all
  2. [root@localhost ~]# yum makecache
  3. [root@localhost ~]# yum update
yum只下载不安装(下载rpm包):通过yum自带一个工具:yumdownloader
yum -y install yum-utils*
yumdownloade这个工具是由yum-utils这个软件安装生成的 通过 rpm -ql yum-utils 可以查到
 yumdownloader 需要安装的软件 如:yumdownloader squid*  再ls一下看看
 

CentOS使用yum update更新时不升级内核           
           cp /etc/yum.conf    /etc/yum.confbak
           方法一、修改yum的配置文件

vi /etc/yum.conf  在[main]的最后添加 exclude=kernel*
           方法二、直接在yum的命令后面加上如下的参数:
                        yum --exclude=kernel* update

查看系统版本  cat /etc/issue
           查看内核版本  uname -a

众所周知,Centos 有个很方便的软件安装工具  yum,但是默认安装完centos,系统里使用的是国外的centos更新源,这就造成了我们使用默认更新源安装或者更新软件时速度很慢的问题。

为了使用yum工具能快速的安装更新软件,我们需要将默认的yum更新源配置为国内的更新源。yum更新源配置文件位于centos目录  /etc/yum.repos.d/  下。

首先提供几个国内快速的更新源:

教育网资源:

1 上海交大: http://ftp.sjtu.edu.cn/centos/

服务器位于北京,中国教育网网络中心,下载速度高达十M。
北方用户与教育网用户推荐,速度飞快。

需要手动创建 CentOS-Base.repo文件。

2 中国科技大学:http://centos.ustc.edu.cn

服务器位于合肥。 南方用户推荐。 同样的,CenOS版本非常丰富,适合长期使用。

非教育网资源:

1 sohu的开源镜像服务器:http://mirrors.sohu.com/

服务器位于山东省联通

2 网易的开源服务器镜像: http://mirrors.163.com/centos
速度也不错,全国用户推荐

3 度娘?   怎么没有度娘的开源镜像。度娘每年坑骗这么多血汗钱,难道连个开源也供不起么? 百分鄙视!

总之,大家在使用前可以 ping 一下一上更新源,看哪个快就用哪个。


测试

[zzx@ZZXOS ~]$ vim /etc/yum.repos.d/CentOS-Base.repo
[zzx@ZZXOS ~]$ cat !$
cat /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 - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&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-$releasever - Extras - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

以上配置结束之后,要清空yum 缓存,并重建yum缓存,执行以下命令:

yum clean all && yum clean metadata && yum clean dbcache && yum makecache && yum update

最新文章

  1. 时间服务器:NTP 服务器
  2. [win]系统优化工具dism++
  3. 绿色通道(codevs 3342)
  4. jQuery:如何验证某个元素是否为空
  5. 1. what is Lua?
  6. linux磁盘设备知识
  7. LA 3263 欧拉定理
  8. Mysql MERGE 引擎在分表环境下得使用
  9. 汉诺塔III 汉诺塔IV 汉诺塔V (规律)
  10. 关于Staruml与powerdesigner启动使用中的问题
  11. mySQL中replace的用法
  12. 协同编辑多人word一个小技巧文件
  13. 关于c语言中栈和堆释放的问题
  14. ajax请求多次刷新
  15. vue集成环信IM
  16. C语言异常处理之 setjmp()和longjmp()
  17. 对于nginx配置文件中的fastcgi_param的配置错误
  18. secure CRT常用的查看服务器日志命令
  19. 《Linux性能及调优指南》第二章:监控和基准工具2.1-2.2
  20. nginx 访问频率控制

热门文章

  1. LINUX——LVM逻辑卷管理
  2. 如何将本地项目推送到Github
  3. 二十六、JavaScript之查找子字符串substring和slice和substr
  4. Floyd--P2419 [USACO08JAN]牛大赛Cow Contest
  5. Flutter如何引用第三方库并使用
  6. canvas背景粒子动态变化动画
  7. 设置此div的子元素居中显示
  8. python --- excel文件处理
  9. windows内核安全编程书籍
  10. 刷题31. Next Permutation