Centos 6.5本地Yum和网络Yum

网络yum源

 

yum源和epel源


/etc/yum.repos.d/CentOS-Base.repo

  1. # CentOS-Base.repo  
  2. #  
  3. # The mirror system uses the connecting IP address of the client and the  
  4. # update status of each mirror to pick mirrors that are updated to and  
  5. # geographically close to the client.  You should use this for CentOS updates  
  6. # unless you are manually picking other mirrors.  
  7. #  
  8. # If the mirrorlist= does not work for you, as a fall back you can try the   
  9. # remarked out baseurl= line instead.  
  10. #  
  11. #  
  12.    
  13. [base]  
  14. name=CentOS-$releasever - Base - mirrors.aliyun.com  
  15. failovermethod=priority  
  16. baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/  
  17.         http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/  
  18. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os  
  19. gpgcheck=1  
  20. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7  
  21.    
  22. #released updates   
  23. [updates]  
  24. name=CentOS-$releasever - Updates - mirrors.aliyun.com  
  25. failovermethod=priority  
  26. baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/  
  27.         http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/  
  28. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates  
  29. gpgcheck=1  
  30. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7  
  31.    
  32. #additional packages that may be useful  
  33. [extras]  
  34. name=CentOS-$releasever - Extras - mirrors.aliyun.com  
  35. failovermethod=priority  
  36. baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/  
  37.         http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/  
  38. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras  
  39. gpgcheck=1  
  40. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7  
  41.    
  42. #additional packages that extend functionality of existing packages  
  43. [centosplus]  
  44. name=CentOS-$releasever - Plus - mirrors.aliyun.com  
  45. failovermethod=priority  
  46. baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/  
  47.         http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/  
  48. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus  
  49. gpgcheck=1  
  50. enabled=0  
  51. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7  
  52.    
  53. #contrib - packages by Centos Users  
  54. [contrib]  
  55. name=CentOS-$releasever - Contrib - mirrors.aliyun.com  
  56. failovermethod=priority  
  57. baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/  
  58.         http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/  
  59. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib  
  60. gpgcheck=1  
  61. enabled=0  
  62. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 

/etc/yum.repos.d/epel.repo

  1. [epel]  
  2. name=Extra Packages for Enterprise Linux 7 - $basearch  
  3. baseurl=http://mirrors.aliyun.com/pub/epel/7/$basearch  
  4. mirrorlist=https://mirrors.aliyun.com/metalink?repo=epel-7&arch=$basearch  
  5. failovermethod=priority  
  6. enabled=1  
  7. gpgcheck=1  
  8. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7  
  9.   
  10. [epel-debuginfo]  
  11. name=Extra Packages for Enterprise Linux 7 - $basearch - Debug  
  12. baseurl=http://mirrors.aliyun.com/pub/epel/7/$basearch/debug  
  13. mirrorlist=https://mirrors.aliyun.com/metalink?repo=epel-debug-7&arch=$basearch  
  14. failovermethod=priority  
  15. enabled=0  
  16. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7  
  17. gpgcheck=1  
  18.   
  19. [epel-source]  
  20. name=Extra Packages for Enterprise Linux 7 - $basearch - Source  
  21. baseurl=http://mirrors.aliyun.com/pub/epel/7/SRPMS  
  22. mirrorlist=https://mirrors.aliyun.com/metalink?repo=epel-source-7&arch=$basearch  
  23. failovermethod=priority  
  24. enabled=0  
  25. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7  
  26. gpgcheck=1  

/etc/yum.repos.d/epel-testing.repo

  1. [epel-testing]  
  2. name=Extra Packages for Enterprise Linux 7 - Testing - $basearch  
  3. #baseurl=http://download.fedoraproject.org/pub/epel/testing/7/$basearch  
  4. mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-epel7&arch=$basearch  
  5. failovermethod=priority  
  6. enabled=0  
  7. gpgcheck=1  
  8. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7  
  9.   
  10. [epel-testing-debuginfo]  
  11. name=Extra Packages for Enterprise Linux 7 - Testing - $basearch - Debug  
  12. #baseurl=http://download.fedoraproject.org/pub/epel/testing/7/$basearch/debug  
  13. mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-debug-epel7&arch=$basearch  
  14. failovermethod=priority  
  15. enabled=0  
  16. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7  
  17. gpgcheck=1  
  18.   
  19. [epel-testing-source]  
  20. name=Extra Packages for Enterprise Linux 7 - Testing - $basearch - Source  
  21. #baseurl=http://download.fedoraproject.org/pub/epel/testing/7/SRPMS  
  22. mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-source-epel7&arch=$basearch  
  23. failovermethod=priority  
  24. enabled=0  
  25. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7  
  26. gpgcheck=1  



yum仓库中的元数据文件

primary.xml.gz

 所有RPM包的列表

 依赖关系

 每个RPM安装生成的文件列表

filelists.xml.gz

 当仓库中所有RPM包的所有可以生成的文件列表。

other.xml.gz

 额外信息

 RPM包的修改日志

repomd.xml

记录上面三个文件的时间戳和校验和

配置一个简单的yum源:

[Base]

name=Centos6.5 Server

baseurl=容器地址

enable=1

gpgcheck=1

list:列表

     all

     available:可用的,仓库中有但未安装的

     installed:已经安装的

     update:可用的升级

clean:清理缓存

repolist:显示repo列表极其简要信息

     all    

     enabled:默认

     disabled:

installl:安装

yum install PACKAGE_NAME

update

update_to:升级为指定版本

remove | erase:卸载

info:

    

Provides | whatprovides

yum grouplist:

编译安装:

RPM安装:

     二进制格式:

     源程序→编译→二进制格式

          1、有些特性是编译选定的,如果编译时未选定此特性,我们将无法使用;

          2、RPM包的版本会落后于源码包的版本,甚至有时候会落后很多;

编译需要具备的条件:

     编译环境:开发环境

     开发库:开发工具

    

make:项目管理工具;

     makefile : 定义了make(gcc、g++)按何种次序去编译这些源程序文件中的源程序

automake:可以生成一个名为makefile.in的半成品文件

autoconfig:生成一个名为configure的文件。

编译安装三步骤:(一下步骤需要在安装包目录下进行)

     1、./configure

          --prefix=文件安装路径

          --sysconfdir=指定配置文件路径

          --help:获取脚本使用格式

     2、make

     3、make install

1、修改PATH环境变量,以能够识别此程序的位二进制文件路径;

2、在默认情况下,系统所有库文件的路径/lib,/usr/lib;要增添额外搜索路径;

     在/etc/ld.so.conf.d/中创建以.conf为后缀名的文件,而后把要增添的路径直接写至此文件中;

     #ldconfig通知系统重新搜索库文件

          -v:显示重新搜索库文件的过程

3、头文件:输出给系统

     默认:/usr/include

     增添头文件搜寻路径,使用链接进行;

本地yum配置:

          

1.       创建目录、挂载光盘以及安装createrepo

 

[root@centos6 ~]# mkdir/mnt/cdrom                  用于挂载光盘

[root@centos6 ~]# mkdir-vp /yum/localrepo    用于存放光盘中的rpm

mkdir: 已创建目录 "/yum"

mkdir: 已创建目录 "/yum/localrepo"

 

[root@centos6 ~]# mount/dev/cdrom /mnt/cdrom/

mount: block device /dev/sr0 is write-protected, mounting read-only

 

[root@centos6 ~]# cp/mnt/cdrom/Packages/* /yum/localrepo/            将光盘中所有rpm包复制到/yum/localrepo

 

[root@centos6 Packages]#rpm -ivh createrepo-0.9.9-18.el6.noarch.rpm

warning: createrepo-0.9.9-18.el6.noarch.rpm: Header V3 RSA/SHA1Signature, key ID c105b9de: NOKEY

error: Failed dependencies:

         python-deltarpm is needed by createrepo-0.9.9-18.el6.noarch

 

注:从上面我们可以看出存在依赖关系,我们需要先安装python-deltarpm包,那接下来我们就把它装上!

 

[root@centos6 Packages]#rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm

warning: python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm: HeaderV3 RSA/SHA256 Signature, key ID c105b9de: NOKEY

error: Failed dependencies:

         deltarpm = 3.5-0.5.20090913git.el6 is needed bypython-deltarpm-3.5-0.5.20090913git.el6.x86_64

 

注:我们发现这个包也有依赖包,继续装!

 

[root@centos6 Packages]#rpm -ivh deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm

warning: deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm: Header V3RSA/SHA256 Signature, key ID c105b9de: NOKEY

Preparing...               ########################################### [100%]

  1:deltarpm               ###########################################[100%]

 

注:deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm这个包安装成功了,继续安装上一个包。

 

[root@centos6 Packages]#rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm

warning: python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm: HeaderV3 RSA/SHA256 Signature, key ID c105b9de: NOKEY

Preparing...               ########################################### [100%]

   1:python-deltarpm       ########################################### [100%]

 

注:解决依赖关系后尝试安装createrepo这个包。

 

[root@centos6 Packages]#rpm -ivh createrepo-0.9.9-18.el6.noarch.rpm

warning: createrepo-0.9.9-18.el6.noarch.rpm: Header V3 RSA/SHA1Signature, key ID c105b9de: NOKEY

Preparing...               ########################################### [100%]

   1:createrepo            ########################################### [100%]

 

注:createrepo安装成功。(由于每个操作系统安装的环境、系统版本的不同,依赖关系可能也不相同,大家按照我的方法安装就好了)

 

  2.       创建以.repo结尾的文件

 

[root@centos6 Packages]# cd /etc/yum.repos.d/             

[root@centos6 yum.repos.d]# ls

  CentOS-Base.repo       CentOS-Media.repo

  CentOS-Debuginfo.repo  CentOS-Vault.repo

[root@centos6 yum.repos.d]# rm ./*           删除所有系统自带的repo文件

  rm:是否删除普通文件 "./CentOS-Base.repo"y

  rm:是否删除普通文件 "./CentOS-Debuginfo.repo"y

  rm:是否删除普通文件 "./CentOS-Media.repo"y

  rm:是否删除普通文件 "./CentOS-Vault.repo"y

  [root@centos6 yum.repos.d]# vim local.repo    创建一个名为local.repo的文件并编辑

   [Base]

   name=localrepo

   baseurl=file:///yum/localrepo

   enable=1

   gpgcheck=0

 

注:

[Base]:代表容器的名字。中括号一定要存在,里面的名字可以随意修改,但是不能有两个相同的容器名称,否则yum会不知道该到哪里去找容器相关软件列表文件。

name:只是说明一下这个容器的意义而已,重要性不高!

baseurl:这个非常重要,应为后面接的是容器的实际地址。

         示例:

                   ftp://ftp容器地址

                   http://web容器地址

                   file:///本地容器地址(前两个/是协议分隔符最后一个/代表本地的根)

enable=1:就是让这个容器被启动,如果不想启动可以使用enable=0

gpgcheck=0:指定是否要查阅rpm文件内的数字证书我们这里不查阅!

其他内容请自行查阅!!!!!!.

[root@centos6 localrepo]#ls -l | grep repodata                  查看是否存在yum的索引文件

 

注:不存在yum的索引文件

 

[root@centos6yum.repos.d]# createrepo /yum/localrepo/    创建分组信息

Spawning worker 0 with 3995 pkgs

Workers Finished

Gathering worker results

 

Saving Primary metadata

Saving file lists metadata

Saving other metadata

Generating sqlite DBs

Sqlite DBs complete

 

[root@centos6 yum.repos.d]# cd /yum/localrepo/

[root@centos6 localrepo]# ls -l | grep repodata

drwxr-xr-x 2 root root    4096 7  23 01:04 repodata

 

注:我们可以发现通过createrepo创建出了yum的索引文件

 

[root@centos6 yum.repos.d]#yum clean all                清空缓存

Loaded plugins: fastestmirror, refresh-packagekit, security

Cleaning repos: Base

Cleaning up Everything

 

[root@centos6 localrepo]#yum makecache                        建立新缓存

Loaded plugins: fastestmirror, refresh-packagekit, security

Determining fastest mirrors

Base                                        | 2.9kB     00:00 ...

Base/filelists_db                           | 4.1 MB     00:00 ...

Base/primary_db                             | 3.3 MB     00:00 ...

Base/other_db                               | 1.8 MB     00:00 ...

Metadata Cache Created

 

[root@centos6 localrepo]#yum -y install mysql                   安装MySQL测试

Loaded plugins: fastestmirror, refresh-packagekit, security

Loading mirror speeds from cached hostfile

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package mysql.x86_64 0:5.1.71-1.el6 will be installed

--> Finished Dependency Resolution

 

Dependencies Resolved

 

===================================================================

 Package      Arch          Version              Repository   Size

===================================================================

Installing:

 mysql        x86_64        5.1.71-1.el6         Base        893 k

 

Transaction Summary

===================================================================

Install       1 Package(s)

 

Total download size: 893 k

Installed size: 2.4 M

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing :mysql-5.1.71-1.el6.x86_64                      1/1

  Verifying  : mysql-5.1.71-1.el6.x86_64                       1/1

Installed:

  mysql.x86_640:5.1.71-1.el6                                     

 

Complete!

 

注:MySQL安装成功,本地yum制作成功!

 

Centos配置国内yum源:

     

     网易(163)yum源是国内最好的yum源之一 ,无论是速度还是软件版本,都非常的不错,将yum源设置为163yum,可以提升软件包安装和更新的速度,同时避免一些常见软件版本无法找到。具体设置方法如下:

1,进入yum源配置目录

cd /etc/yum.repos.d

2,备份系统自带的yum源

mv CentOS-Base.repo CentOS-Base.repo.bk

下载163网易的yum源:

wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

3,更新完yum源后,执行下边命令更新yum配置,使操作立即生效

yum makecache

4,除了网易之外,国内还有其他不错的yum源,比如中科大和搜狐的,大家可以根据自己需求下载

中科大的yum源:

wget http://centos.ustc.edu.cn/CentOS-Base.repo

sohu的yum源

wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo


点击查看网络Yum原文


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值