Centos中利用光碟片建立本地yum源

來源:互聯網
上載者:User


實驗用的是CentOS6.9和CentOs7.3系統 1.掛載系統光碟片

掛載光碟片有兩種方法,一種是使用/misc/cd這個神奇的目錄,另一種方法就是我們通常用的mount方法了。

1.1 mount方式掛載

[root@centos7 ~]# mkdir /mnt/cdrom                          #建立掛載目錄

1.2 /misc這個神奇目錄 /misc這個神奇目錄在CentOS6.9中是內建的 Centos7.3需要安裝autofs這個服務

//我已經安裝這個服務了,如果你沒按裝,需要使用上面方法來安裝這個安裝包,或者使用其他方法//有人只安裝了這個安裝包,還是不行,發現需要解決依賴問題,如果你也不行,那麼建議先使用網路yum安裝autofs解決依賴問題[root@CentOS7 ~]# rpm -ivh /misc/cd/Packages/autofs-5.0.7-56.el7.x86_64.rpm [root@CentOS7 ~]# systemctl enable autofs            #加入開機啟動[root@CentOS7 ~]# systemctl restart autofs           #啟動服務[root@CentOS7 ~]# cd /misc/cd                        #切換到這個目錄,看是否成功,必須是cd這個目錄[root@CentOS7 cd]# pwd/misc/cd[root@CentOS7 cd]#
2.修改yum檔案

2.1 查看yum源檔案

[root@CentOS7 cd]# ll /etc/yum.repos.d/total 28-rw-r--r--. 1 root root 1664 Nov 30  2016 CentOS-Base.repo  #網路yum源-rw-r--r--. 1 root root 1309 Nov 30  2016 CentOS-CR.repo-rw-r--r--. 1 root root  649 Nov 30  2016 CentOS-Debuginfo.repo-rw-r--r--. 1 root root  314 Nov 30  2016 CentOS-fasttrack.repo-rw-r--r--. 1 root root  648 Jun  3 16:25 CentOS-Media.repo #可以配置本地yum 源-rw-r--r--. 1 root root 1331 Nov 30  2016 CentOS-Sources.repo-rw-r--r--. 1 root root 2893 Nov 30  2016 CentOS-Vault.repo

2.2修改CentOS-Media.repo檔案
修改前:

[root@CentOS7 ~]# vi /etc/yum.repos.d/CentOS-Media.repo# CentOS-Media.repo##  This repo can be used with mounted DVD media, verify the mount point for#  CentOS-7.  You can use this repo and yum to install items directly off the#  DVD ISO that we release.## To use this repo, put in your DVD and use it with the other repos too:#  yum --enablerepo=c7-media [command]#  # or for ONLY the media repo, do this:##  yum --disablerepo=\* --enablerepo=c7-media [command][c7-media]name=CentOS-$releasever - Mediabaseurl=file:///media/CentOS/   #這裡有修改        file:///media/cdrom/        file:///media/cdrecorder/gpgcheck=1enabled=0                       #這裡有修改gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

修改後:

# CentOS-Media.repo##  This repo can be used with mounted DVD media, verify the mount point for#  CentOS-7.  You can use this repo and yum to install items directly off the#  DVD ISO that we release.## To use this repo, put in your DVD and use it with the other repos too:#  yum --enablerepo=c7-media [command]#  # or for ONLY the media repo, do this:##  yum --disablerepo=\* --enablerepo=c7-media [command][c7-media]name=CentOS-$releasever - Mediabaseurl=file:///misc/cd/        file:///media/CentOS/        file:///media/cdrom/        file:///media/cdrecorder/gpgcheck=1enabled=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

2.3設定不從網路擷取yum源

#把這個檔案重新命名加上.bak繞過網路yum源[root@centos7 ~]# mv /etc/yum.repos.d/CentOS-Base.repo{,.bak}
3. 檢測本地源是否成功
#[root@centos7 ~]# yum listzlib-devel.i686                                                         1.2.7-17.el7                                        c7-media zlib-devel.x86_64                                                       1.2.7-17.el7                                        c7-media zlib-static.i686                                                        1.2.7-17.el7                                        c7-media zlib-static.x86_64                                                      1.2.7-17.el7                                        c7-media zsh.x86_64                                                              5.0.2-25.el7                                        c7-media zsh-html.x86_64                                                         5.0.2-25.el7                                        c7-media zziplib.i686                                                            0.13.62-5.el7                                       c7-media zziplib.x86_64                                                          0.13.62-5.el7                                       c7-media zziplib-devel.i686                                                      0.13.62-5.el7                                       c7-media zziplib-devel.x86_64                                                    0.13.62-5.el7                                       c7-media zziplib-utils.x86_64                                                    0.13.62-5.el7                                       c7-media
本地yum源已經完成了,可以使用yum命令來安裝軟體了
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.