使用光盘镜像作为软件yum源:
[1]上传centos7光盘镜像到/usr/local/src目录下;(工具Xftp)
[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 images 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源已配置完毕!
本文出自 “西伯利亚·狼” 博客,请务必保留此出处http://kernal.blog.51cto.com/8136890/1531366
原文地址:http://kernal.blog.51cto.com/8136890/1531366