centos挂载本地镜像作为yum源
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px">1、安装Centos后默认的Yum源如下</span></div><div style="white-space: pre-wrap; text-indent: 28px; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px; font-weight: bold"> ll /etc/yum.repos.d/</span></div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"> </div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="color: rgba(77, 128, 191, 1); font-weight: bold"># ll /etc/yum.repos.d/</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="color: rgba(77, 128, 191, 1); font-weight: bold">total 32</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="color: rgba(77, 128, 191, 1); font-weight: bold">-rw-r--r--. 1 root root 1664 Nov 23 21:16 CentOS-Base.repo</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="color: rgba(77, 128, 191, 1); font-weight: bold">-rw-r--r--. 1 root root 1309 Nov 23 21:16 CentOS-CR.repo</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="color: rgba(77, 128, 191, 1); font-weight: bold">-rw-r--r--. 1 root root 649 Nov 23 21:16 CentOS-Debuginfo.repo</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="color: rgba(77, 128, 191, 1); font-weight: bold">-rw-r--r--. 1 root root 314 Nov 23 21:16 CentOS-fasttrack.repo</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="color: rgba(77, 128, 191, 1); font-weight: bold">-rw-r--r--. 1 root root 630 Nov 23 21:16 CentOS-Media.repo</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="color: rgba(77, 128, 191, 1); font-weight: bold">-rw-r--r--. 1 root root 1331 Nov 23 21:16 CentOS-Sources.repo</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="color: rgba(77, 128, 191, 1); font-weight: bold">-rw-r--r--. 1 root root 5701 Nov 23 21:16 CentOS-Vault.repo</span></div>
</div>
<p><img src="https://img2018.cnblogs.com/blog/1364390/201905/1364390-20190531151901793-1301609399.png"></p>
<p> </p>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px">2、把默认Yum源备份(可选)</span></div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"> </div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="color: rgba(77, 128, 191, 1); font-weight: bold"># mkdir /opt/centos-yum.bak</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="color: rgba(77, 128, 191, 1); font-weight: bold"># mv /etc/yum.repos.d/* /opt/centos-yum.bak/</span></div>
</div>
<p><img src="https://img2018.cnblogs.com/blog/1364390/201905/1364390-20190531151931820-152236835.png"></p>
<p> </p>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px">3、将iso镜像上传到虚机上</span></div>
<div style="white-space: pre-wrap; text-indent: 28px; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px; font-weight: bold">mkdir /mnt/iso 放到该目录下</span></div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"> </div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px">4、然后挂载:</span></div>
<div style="white-space: pre-wrap; text-indent: 28px; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px; font-weight: bold">mount -t iso9660 /mnt/iso/CentOS-7-x86_64-DVD-1810.iso /opt/centos</span></div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="font-size: 16px; font-weight: bold">mount -t iso9660 /mnt/iso/CentOS-7-x86_64-DVD-1810.iso /opt/centos</span></div>
</div>
<p><img src="https://img2018.cnblogs.com/blog/1364390/201905/1364390-20190531152008727-506085338.png"></p>
<p> </p>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px">5、编写repo文件并指向镜像的挂载目录</span></div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"> </div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px; font-weight: bold"># vi /etc/yum.repos.d/local.repo</span></div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px">添加下面的内容:</span></div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"> </div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="color: rgba(77, 128, 191, 1); font-weight: bold"></span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="color: rgba(77, 128, 191, 1); font-weight: bold">name=local</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="color: rgba(77, 128, 191, 1); font-weight: bold">baseurl=file:///opt/centos</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="color: rgba(77, 128, 191, 1); font-weight: bold">enabled=1</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="color: rgba(77, 128, 191, 1); font-weight: bold">gpgcheck=0</span></div>
</div>
<p><img src="https://img2018.cnblogs.com/blog/1364390/201905/1364390-20190531152049044-800469732.png"></p>
<p> </p>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px">6、清除缓存</span></div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px; font-weight: bold"># yum clean all </span></div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px; font-weight: bold"># yum makecache <span style="font-size: 16px">把Yum源缓存到本地,加快软件的搜索好安装速度</span></span></div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px; font-weight: bold"># yum list <span style="font-size: 16px">列出了yum包</span></span></div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"> </div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="font-size: 16px"># <span style="font-size: 16px; color: rgba(77, 128, 191, 1); font-weight: bold">yum clean all</span></span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="font-size: 16px">Loaded plugins: fastestmirror</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="font-size: 16px">Cleaning repos: local</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="font-size: 16px">Cleaning up list of fastest mirrors</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="font-size: 16px">Other repos take up 68 M of disk space (use --verbose for details)</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="font-size: 16px"># <span style="font-size: 16px; color: rgba(77, 128, 191, 1); font-weight: bold">yum makecache</span></span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="font-size: 16px">Loaded plugins: fastestmirror</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="font-size: 16px">Determining fastest mirrors</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="font-size: 16px">local | 3.6 kB 00:00:00</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="font-size: 16px">(1/4): local/group_gz | 166 kB 00:00:00</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="font-size: 16px">(2/4): local/primary_db | 6.0 MB 00:00:00</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="font-size: 16px">(3/4): local/filelists_db | 7.1 MB 00:00:00</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="font-size: 16px">(4/4): local/other_db | 2.6 MB 00:00:00</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"><span style="font-size: 16px">Metadata Cache Created</span></div>
</div>
<div>
<div style="white-space: pre-wrap; padding: 0 10px 0 17px; border-left: 3px solid rgba(232, 232, 232, 1); margin: 0 5px"> </div>
</div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"> </div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px">7、查看yum仓库列表</span></div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"> </div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px; font-weight: bold"># yum repolist</span></div>
<p><img src="https://img2018.cnblogs.com/blog/1364390/201905/1364390-20190531152126338-945345582.png"></p>
<p> </p>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px">8、开机自动挂载</span></div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px">在/etc/fstab表中,添加最后的一行,将iso文件永久挂载到系统中</span></div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"> </div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"> </div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px; font-weight: bold"># vi /etc/fstab</span></div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px; font-weight: bold">/mnt/iso/CentOS-7-x86_64-DVD-1810.iso /opt/centos iso9660 loop 0 0</span></div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"> </div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px">9、取消挂载(需要的时候再执行):</span></div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"><span style="font-size: 16px">卸载挂载目录:<span style="font-size: 16px; font-weight: bold"> # umount /opt/centos </span></span></div>
<div style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px"> </div>
<p> </p><br><br>
来源:https://www.cnblogs.com/jylee/p/10955434.html
頁:
[1]