建立本地yum仓库

[root@ks-server ~]# cd /etc/yum.repos.d/[root@ks-server yum.repos.d]# ls
CentOS-Base.repo       CentOS-Media.repo
CentOS-CR.repo         CentOS-Sources.repo
CentOS-Debuginfo.repo  CentOS-Vault.repo
CentOS-fasttrack.repo
[root@ks-server yum.repos.d]# mkdir bak
[root@ks-server yum.repos.d]# ls
bak                    CentOS-fasttrack.repo
CentOS-Base.repo       CentOS-Media.repo
CentOS-CR.repo         CentOS-Sources.repo
CentOS-Debuginfo.repo  CentOS-Vault.repo
[root@ks-server yum.repos.d]# mv *.repo bak/
[root@ks-server yum.repos.d]# ls
bak

#将原先/etc/yum.repos.d/里存在的都移除(备份)

[root@ks-server yum.repos.d]# mount /dev/sr0 /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@ks-server yum.repos.d]# ls /mnt
CentOS_BuildTag  LiveOS
EFI              Packages
EULA             repodata
GPL              RPM-GPG-KEY-CentOS-7
images           RPM-GPG-KEY-CentOS-Testing-7
isolinux         TRANS.TBL

#挂载光盘镜像

[root@ks-server yum.repos.d]# cat local.repo 
[localrepo]
name=localrepo
baseurl=file:///mnt
gpgcheck=0
enabled=1

编写repo文件

[root@ks-server yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: localrepo
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@ks-server yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
localrepo               | 3.6 kB     00:00     
(1/2): localrepo/group_gz | 166 kB   00:00     
(2/2): localrepo/primary_ | 3.1 MB   00:00     
repo id             repo name            status
localrepo           localrepo            3,971
repolist: 3,971

#清理检测

posted @ 2019-08-13 16:49  25℃  阅读(208)  评论(0编辑  收藏  举报