0%

Centos7配置本地的yum源

准备以下几个文件:

http://mirrors.163.com/centos/7.7.1908/os/x86_64/Packages/deltarpm-3.6-3.el7.x86_64.rpm
http://mirrors.163.com/centos/7.7.1908/os/x86_64/Packages/python-deltarpm-3.6-3.el7.x86_64.rpm
http://mirrors.163.com/centos/7.7.1908/os/x86_64/Packages/createrepo-0.9.9-28.el7.noarch.rpm
http://mirrors.163.com/centos/7.7.1908/os/x86_64/Packages/libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm

本地安装

1
2
yum localinstall createrepo-0.9.9-28.el7.noarch.rpm
yum localinstall libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm

创建本地yum地址

1
2
3
4
5
6
7
8
vi /etc/yum.repos.d/local-yum.repo

[local-yum]
name=local-yum
baseurl=file:///opt/
enabled=1
gpgcheck=0

创建iso文件夹及cdrom文件夹

1
mkdir /mnt/{iso,cdrom}

上传iso文件到/mnt/iso

将/mnt/iso/CentOS-7-x86_64-DVD-1908.iso挂载到/mnt/cdrom/下

1
mount -o loop /mnt/iso/CentOS-7-x86_64-DVD-1908.iso /mnt/cdron/

将/mnt/cdron/目录下的所用文件复制到/opt/下

1
cp -rv /mnt/cdrom/* /opt/

切换到/opt/目录下:删除*.html、删除CentOS/repodata/TRANS.TBL

1
2
3
cd /opt/
rm -rf *.html
rm -rf repodata/TRANS.TBL

执行createrepo命令生成YUM通用数据库

1
createrepo -g /opt/repodata/521f322f05f9802f2438d8bb7d97558c64ff3ff74c03322d77787ade9152d8bb-c7-x86_64-comps.xml /opt/

清除缓存

1
yum clean all