本地yum源,首先挂载iso文件,确保光盘挂载点有文件
如果在配置yum源过程中遇到yum被another app lock使用下面命令
rm -f /var/run/yum.pid
创建挂载点
mkdir -p /mnt/local
将iso文件挂载到指定挂载点
mount /dev/cdrom /mnt/local
[root@xuexi yum.repos.d]# ls /mnt/local
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
2、yum的一切配置信息都存储在一个叫yum.repos.d目录下的配置文件中。所以跳转到/etc/yum.repos.d目录下
cd /etc/yum.repos.d
3、创建一个新的yum源配置文件,yum源配置文件的结尾必须是.repo
vim CentOS7.repo
内容如下:
[CentOS7] //yum的ID,本地唯一,用于区分不同yum源
name=CentOS-server //描述信息
baseurl=file:///mnt/local //前面的file://是协议,
后面的/mnt是光盘挂载点
enabled=1 //1启用yum源,0禁用yum源
gpgcheck=0 //1使用公钥验证rpm包的正确性,0不验证
保存退出后就可以开始验证了。
如果启用公钥验证,需要配置公钥gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
4、接着清空yum已存在的源信息(缓存)
yum clean all yum makecache yum repolist //验证local yum源是否配置成功 [root@localhost yum.repos.d]# yum clean all Loaded plugins: fastestmirror, langpacks Cleaning repos: centos7 Cleaning up list of fastest mirrors Other repos take up 865 M of disk space (use --verbose for details) [root@localhost yum.repos.d]# yum makecache Loaded plugins: fastestmirror, langpacks Determining fastest mirrors centos7 | 3.6 kB 00:00:00 (1/4): centos7/group_gz | 153 kB 00:00:00 (2/4): centos7/filelists_db | 3.3 MB 00:00:01 (3/4): centos7/primary_db | 3.3 MB 00:00:00 (4/4): centos7/other_db | 1.3 MB 00:00:00 Metadata Cache Created [root@localhost yum.repos.d]# yum re reinstall remove repolist [root@localhost yum.repos.d]# yum repolist Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile repo id repo name status centos7 centos7 4,070 repolist: 4,070 [root@localhost yum.repos.d]# yum mdadm Loaded plugins: fastestmirror, langpacks No such command: mdadm. Please use /usr/bin/yum --help [root@localhost yum.repos.d]# yum install mdadm Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile Package mdadm-4.1-6.el7.x86_64 already installed and latest version Nothing to do [root@localhost yum.repos.d]#
————————————————
版权声明:本文为CSDN博主「sky wide」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_44652591/article/details/127627557