yum源配置(本地镜像)

yum info xxx,
yum list,yum list xxx、yum list updates
yum search xxx, yum search all xxx,yum search all

yum install
yum remove

yum clean all
yum makecache
yum repolist all

yum 的软件群组功能 yum grouplist|groupinstall|groupremove

常用命令
[root@zxjoracle ~]# yum search tree
[root@zxjoracle ~]# yum list tree
[root@zxjoracle ~]# yum info tree

[root@zxjoracle ~]# yum install tree
[root@zxjoracle ~]# yum remove tree

[root@zxjoracle ~]# yum clean all
[root@zxjoracle ~]# yum makecache
[root@CentOS6 yum.repos.d]# yum repolist all

#国内镜像源
http://mirrors.163.com/
http://mirrors.163.com/centos/
http://mirrors.163.com/centos/5/os/x86_64/CentOS/
http://mirrors.163.com/centos/6/
http://mirrors.163.com/centos/6/os/x86_64/Packages/
http://mirrors.sohu.com/
http://ftp.twaren.net/Linux/CentOS/

http://ftp.sjtu.edu.cn/
http://ftp.sjtu.edu.cn/centos/6/
http://ftp.sjtu.edu.cn/centos/6/os/x86_64/Packages/
http://ftp.sjtu.edu.cn/centos/6/updates/x86_64/Packages/
http://ftp.sjtu.edu.cn/centos/6/extras/x86_64/Packages/
http://ftp.sjtu.edu.cn/centos/6/centosplus/x86_64/Packages/
http://ftp.riken.jp/Linux/dag/redhat/el5/en/

3、VMware虚拟机CentOS的yum在线安装配置文件
[root@myoracle yum.repos.d]# cat karter_centos5.4_x64.repo
[Karter_CentOS_5.4_64bit_yum_conf]
name=Karter CentOS 5.4_64bit Soft Install By yum with Local&Internet Repository
baseurl=http://mirrors.163.com/centos/5/os/x86_64
#baseurl=http://mirrors.sohu.com/centos/5/os/x86_64/
#baseurl=http://ftp.twaren.net/Linux/CentOS/5/os/x86_64/
gpgcheck=0
enabled=1

*特别注意***:[name]字段中不能有空格,此见鬼问题让人折腾半天。

4、VMware虚拟机CentOS的本机ISO镜像yum安装配置文件
[root@myoracle yum.repos.d]# cat karter_centos5.4_x64_local.repo
[Karter_CentOS_5.4_64bit_yum_conf]
name=Karter CentOS 5.4_64bit Soft Install By yum with Local Repository
baseurl=file:///media/CentOS_5.4_Final/
gpgcheck=0
enabled=1

root@www ~]# vi /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
baseurl=http://ftp.twaren.net/Linux/CentOS/5/os/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

[root@www ~]# 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/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

挂载本地光盘镜像为yum源
mount /dev/hdc /mnt 重新绑定光盘到/mnt目录上。
进入cd /etc/yum.repos.d/目录,复制rhel-debuginfo.repo文件如为rhel5.repo后编辑
vi rhel5.repo
[server]标题也是随意起
name=随意起
baseurl=file:///mnt/server
enable=1
gpgcheck=0

或者
baseurl=file:///rhel6.5
更改为baseurl=file:///rhel6.5/Packages不行
更改为baseurl=file:///rhel6.5/Server可以
看来只要只想有repodata的上层目录即可

[root@zxjoracle yum.repos.d]# mv packagekit-media.repo packagekit-media.repo.old
[root@zxjoracle yum.repos.d]# cp public-yum-ol6.repo.old karter.repo
[root@zxjoracle yum.repos.d]# ll
-rw-r--r-- 1 root root 1953 Oct 2 00:34 karter.repo
-rw-r--r-- 1 root root 196 Feb 26 2013 packagekit-media.repo.old
-rw-r--r--. 1 root root 1953 Feb 24 2013 public-yum-ol6.repo.old
[root@zxjoracle yum.repos.d]# vi karter.repo
[root@zxjoracle yum.repos.d]# cat karter.repo
[ol6_latest]
name=Karter Oracle Linux Soft Install Local($basearch)
baseurl=file:///media/OL6.4\ x86_64\ Disc\ 1\ 20130225/Server/
gpgcheck=0
enabled=1
[root@zxjoracle yum.repos.d]# pwd
/etc/yum.repos.d

注意:路径名中间有空格时用\转移才行

-----------------rhel5.5使用centos的yum源----------------
[root@RHEL5 ~]# cat /etc/yum.repos.d/rhel-debuginfo.repo
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[rhel-debuginfo-beta]
name=Red Hat Enterprise Linux $releasever Beta - $basearch - Debug
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/beta/$releasever/en/os/$basearch/Debuginfo/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[base]
name=Red Hat Enterprise Linux $releasever -Base
baseurl=http://ftp.twaren.net/Linux/CentOS/5/os/$basearch/
gpgcheck=1
gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5

[update]
name=Red Hat Enterprise Linux $releasever -Updates
baseurl=http://ftp.twaren.net/Linux/CentOS/5/updates/$basearch/
gpgcheck=1
gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5

[extras]
name=Red Hat Enterprise Linux $releasever -Extras
baseurl=http://ftp.twaren.net/Linux/CentOS/5/extras/$basearch/
gpgcheck=1
gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5

[addons]
name=Red Hat Enterprise Linux $releasever -Addons
baseurl=http://ftp.twaren.net/Linux/CentOS/5/addons/$basearch/
gpgcheck=1
gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5

[root@CentOS6 sysconfig]# yum --help
Loaded plugins: fastestmirror, refresh-packagekit, security
Usage: yum [options] COMMAND

List of Commands:

check Check for problems in the rpmdb
check-update Check for available package updates
clean Remove cached data
deplist List a package's dependencies
distribution-synchronization Synchronize installed packages to the latest available versions
downgrade downgrade a package
erase Remove a package or packages from your system
groupinfo Display details about a package group
groupinstall Install the packages in a group on your system
grouplist List available package groups
groupremove Remove the packages in a group from your system
help Display a helpful usage message
history Display, or use, the transaction history
info Display details about a package or group of packages
install Install a package or packages on your system
list List a package or groups of packages
load-transaction load a saved transaction from filename
makecache Generate the metadata cache
provides Find what package provides the given value
reinstall reinstall a package
repolist Display the configured software repositories
resolvedep Determine which package provides the given dependency
search Search package details for the given string
shell Run an interactive yum shell
update Update a package or packages on your system
update-minimal Works like update, but goes to the 'newest' package match which fixes a problem that affects your system
updateinfo Acts on repository update information
upgrade Update packages taking obsoletes into account
version Display a version for the machine and/or available repos.

root@CentOS6 yum.repos.d]# pwd
/etc/yum.repos.d
[root@CentOS6 yum.repos.d]# ll
total 28
-rw-r--r--. 1 root root 2006 Jan 1 2018 CentOS6-Base-163.repo
-rw-r--r--. 1 root root 1991 Oct 23 2014 CentOS-Base.repo.old
-rw-r--r--. 1 root root 647 Oct 23 2014 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 289 Oct 23 2014 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 Oct 23 2014 CentOS-Media.repo
-rw-r--r--. 1 root root 5394 Oct 23 2014 CentOS-Vault.repo

[root@CentOS6 yum.repos.d]# cat CentOS6-Base-163.repo
[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
[root@CentOS6 yum.repos.d]#

[root@www ~]# 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/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

[base]:代表容器的名字!中刮号一定要存在,里面的名称则可以随意取。但是不能有两个相同的容器名称, 否则 yum 会不晓得该到哪里去找容器相关软件清单文件。
name:只是说明一下这个容器的意义而已,重要性不高!
mirrorlist=:列出这个容器可以使用的映射站台,如果不想使用,可注解到这行;
baseurl=:这个最重要,因为后面接的就是容器的实际网址! mirrorlist 是由 yum 程序自行去捉映射站台, baseurl 则是指定固定的一个容器网址!我们刚刚找到的网址放到这里来啦!
enable=1:就是让这个容器被启动。如果不想启动可以使用 enable=0 喔!
gpgcheck=1:还记得 RPM 的数码签章吗?这就是指定是否需要查阅 RPM 文件内的数码签章!
gpgkey=:就是数码签章的公钥档所在位置!使用默认值即可。

RHEL5.5下配置Centos的yum源
了解决红帽没有注册导致yum不能更新的问题

1.确保RHEL5中已经安装了yum
[root@lvs-master ~]# rpm -qa |grep yum
yum-metadata-parser-1.1.2-3.el5
yum-updatesd-0.9-2.el5
yum-3.2.22-26.el5
yum-security-1.1.16-13.el5
yum-rhn-plugin-0.5.4-15.el5

[root@RHEL5 ~]# rpm -qa|grep yum
yum-3.2.22-26.el5
yum-rhn-plugin-0.5.4-15.el5
yum-metadata-parser-1.1.2-3.el5
yum-updatesd-0.9-2.el5
yum-downloadonly-1.1.16-13.el5
yum-security-1.1.16-13.el5

2.修改源配置文件 #vim /etc/yum.repos.d/rhel-debuginfo.repo
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[rhel-debuginfo-beta]
name=Red Hat Enterprise Linux $releasever Beta - $basearch - Debug
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/beta/$releasever/en/os/$basearch/Debuginfo/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[base]
name=Red Hat Enterprise Linux $releasever -Base
baseurl=http://ftp.twaren.net/Linux/CentOS/5/os/$basearch/
gpgcheck=1
gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5

[update]
name=Red Hat Enterprise Linux $releasever -Updates
baseurl=http://ftp.twaren.net/Linux/CentOS/5/updates/$basearch/
gpgcheck=1
gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5

[extras]
name=Red Hat Enterprise Linux $releasever -Extras
baseurl=http://ftp.twaren.net/Linux/CentOS/5/extras/$basearch/
gpgcheck=1
gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5

[addons]
name=Red Hat Enterprise Linux $releasever -Addons
baseurl=http://ftp.twaren.net/Linux/CentOS/5/addons/$basearch/
gpgcheck=1
gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5

然后
#yum update
#yum clean all

[root@CentOS6 yum.repos.d]# yum repolist all
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
repo id repo name status
base CentOS-6 - Base - 163.com enabled: 6,713
centosplus CentOS-6 - Plus - 163.com disabled
contrib CentOS-6 - Contrib - 163.com disabled
extras CentOS-6 - Extras - 163.com disabled
updates CentOS-6 - Updates - 163.com disabled
repolist: 6,713

[root@CentOS6 yum.repos.d]# pwd
/etc/yum.repos.d
[root@CentOS6 yum.repos.d]# ll
total 8
-rw-r--r-- 1 root root 2037 Dec 14 05:01 CentOS6-Base-163.repo
drwxr-xr-x 2 root root 4096 Dec 14 05:05 old
[root@CentOS6 yum.repos.d]# cat CentOS6-Base-163.repo

[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
#enabled=0

#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
enabled=0

#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
enabled=0

#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
[root@CentOS6 yum.repos.d]#

转载于:https://blog.51cto.com/karter/2330260

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值