更換yum源、創建本地yum源
阿新 • • 發佈:2018-08-14
配置 本地yum yun 實驗 2.6 備份 下載 base file 系統版本:
[root@centos67d1 ~]# cat /etc/redhat-release
CentOS release 6.7 (Final)
[root@centos67d1 ~]# uname -r
2.6.32-573.el6.x86_64
[root@centos71d1 ~]# cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)
[root@centos71d1 ~]# uname -r
3.10.0-229.el7.x86_64
應用yum源的3種方式:
更換使用阿裏雲yum源
[root@centos71d1 ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak #備份原repo文件 [root@centos71d1 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo #下載阿裏雲的repo文件 [root@centos71d1 ~]# yum clean all [root@centos71d1 ~]# yum makecache #清除本地緩存,並重建緩存 [root@centos71d1 ~]# yum repolist all repo id repo name status base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com enabled: 9,911 extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com enabled: 369 updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com enabled: 1,041 ....
使用CentOS安裝光盤作為本地yum源
[root@centos71d1 ~]# mkdir /media/cdrom [root@centos71d1 ~]# mount -r /dev/cdrom /media/cdrom #掛載CentOS安裝光盤 [root@centos71d1 ~]# cp -a /etc/yum.repos.d /tmp/yum.repo.d.bak #備份/etc/yum.repos.d目錄 [root@centos71d1 ~]# rm -f /etc/yum.repos.d/* [root@centos71d1 ~]# vim /etc/yum.repos.d/local.repo [base] name=CentOS 7 Release 7.1.1503 baseurl=file:///media/cdrom enable=1 gpgcheck=0 #創建repo文件,添加以上內容 [root@centos71d1 ~]# yum clean all [root@centos71d1 ~]# yum makecache #重新生成緩存 [root@centos71d1 ~]# yum repolist [root@centos71d1 ~]# yum list all #顯示所有程序包 [root@centos71d1 ~]# yum grouplist #顯示包組信息
創建本地yum repository
[root@centos67d1 ~]# mount -r /dev/cdrom /media/cdrom [root@centos67d1 ~]# mkdir -p /yum/repo [root@centos67d1 ~]# cp /media/cdrom/Packages/r* /yum/repo #拷貝一些rpm包來做實驗 [root@centos67d1 ~]# yum install -y createrepo #使用createrepo命令創建yum源,先確保系統中已安裝createrepo [root@centos67d1 ~]# createrepo /yum/repo [root@centos67d1 ~]# ll /yum/repo/repodata #可以看到repodata目錄被自動創建,目錄下有幾個自動生成的文件 [root@centos67d1 ~]# vim /etc/yum.repos.d/centos-local.repo [YumRepoTest] name=Yum Repo Test baseurl=file:///yum/repo gpgcheck=0 #在/etc/yum.repos.d目錄下添加並配置repo文件 [root@centos67d1 ~]# yum repolist YumRepoTest | 2.9 kB 00:00 ... YumRepoTest/primary_db | 59 kB 00:00 ... repo id repo name status YumRepoTest Yum Repo Test 75
更換yum源、創建本地yum源