centos7 本地yum源

使用光盤鏡像作爲軟件yum源:

[1]上傳centos7光盤鏡像到/usr/local/src目錄下;(工具Xftp)

wKiom1PV5XbCBLw4AAHFOIhJnuI773.jpg

[2]掛載系統文件

mkdir /media/cdrom   # 習慣用這個目錄名稱了;
cd /usr/local/src
ls
CentOS-7.0-1406-x86_64-DVD.iso

# mount -t iso9660 -o loop /usr/local/src/CentOS-7.0-1406-x86_64-DVD.iso /media/cdrom/
mount: /dev/loop0 is write-protected, mounting read-only
# cd /media/cdrom/
[root@mariadb cdrom]# ls
CentOS_BuildTag  EULA  p_w_picpaths    LiveOS    repodata              RPM-GPG-KEY-CentOS-Testing-7
EFI              GPL   isolinux  Packages  RPM-GPG-KEY-CentOS-7  TRANS.TBL

[3]設置開機自動掛載系統鏡像文件

vim /etc/fstab
/usr/local/src/CentOS-7.0-1406-x86_64-DVD.iso /media/cdrom/ iso9660 defaults,ro,loop 0 0
:x #保存並退出

備註:iso9660 CD-ROM光盤的標準文件系統

mount -l
/usr/local/src/CentOS-7.0-1406-x86_64-DVD.iso on /media/cdrom type iso9660 (ro,relatime) [CentOS 7 x86_64]

[4]配置本地yum源文件;

vim /etc/yum.repos.d/centos7-media.repo
[centos7-media]
name=Red Hat Centos linux 7.0        # 自己定義
baseurl=file:///media/cdrom          # 本地鏡像文件路徑  
enabled=1                            # 1爲啓動yum源,0爲禁用
gpgcheck=1                           # 1爲檢查GPG-KEY,0爲不檢查
gpgkey=file:///media/cdrom/RPM-GPG-KEY-CentOS-7    #GPG-KEY文件路徑
yum clean all    #清除緩存
Loaded plugins: fastestmirror
Cleaning repos: base centos7-media epel extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
[root@mariadb ~]# yum makecache        #緩存本地yum源包信息
Loaded plugins: fastestmirror
base                                                                                    | 3.6 kB  00:00:00     
centos7-media                                                                           | 3.6 kB  00:00:00     
epel/x86_64/metalink                                                                    | 5.3 kB  00:00:00     
epel                                                                                    | 4.4 kB  00:00:00     
extras                                                                                  | 3.3 kB  00:00:00     
updates                                                                                 | 3.4 kB  00:00:00     
(1/20): centos7-media/group_gz                                                          | 157 kB  00:00:00     
(2/20): centos7-media/filelists_db                                                      | 2.8 MB  00:00:00     
(3/20): base/7/x86_64/group_gz                                                          | 157 kB  00:00:00     
(4/20): centos7-media/primary_db                                                        | 2.7 MB  00:00:00     
(5/20): centos7-media/other_db                                                          | 1.1 MB  00:00:00

[5]使用本地yum源安裝軟件:

# yum --enablerepo=centos7-media search httpd    # 查看是否有httpd軟件包
...
httpd.x86_64 : Apache HTTP Server
httpd-devel.x86_64 : Development interfaces for the Apache HTTP server
httpd-itk.x86_64 : MPM Itk for Apache HTTP Server
httpd-manual.noarch : Documentation for the Apache HTTP server
httpd-tools.x86_64 : Tools for use with the Apache HTTP Server
...
# yum --enablerepo=centos7-media -y install httpd
Installed:
  httpd.x86_64 0:2.4.6-18.el7.centos
# rpm -qa httpd
httpd-2.4.6-18.el7.centos.x86_64

到此本地yum源已配置完畢!

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