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]#

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章