站长资讯网
最全最丰富的资讯网站

CentOS7u4本地yum源配置

如果使用CentOS进行本地yum源进行安装,请使用CentOS-7-x86_64-Everything-1708.iso的镜像
进行yum源的制作,否则会缺少32位依赖包

1、在虚拟机里创建/home/CentOS7u4目录,并将CentOS7u4的安装包从光驱拷贝到虚拟机本地

  [root@localhost ~]# df -h  Filesystem                  Size  Used Avail Use% Mounted on  /dev/mapper/centos-root     223G  3.1G  220G   2% /  devtmpfs                    3.9G     0  3.9G   0% /dev  tmpfs                       3.9G     0  3.9G   0% /dev/shm  tmpfs                       3.9G  9.4M  3.9G   1% /run  tmpfs                       3.9G     0  3.9G   0% /sys/fs/cgroup  /dev/vda1                  1014M  179M  836M  18% /boot  /dev/mapper/centos-var_log   60G   37M   60G   1% /var/log  tmpfs                       782M   44K  782M   1% /run/user/1000  /dev/sr0                    4.3G  4.3G     0 100% /run/media/wwt/CentOS 7 x86_64  tmpfs                       782M     0  782M   0% /run/user/0
  [root@localhost ~]# mkdir /home/CentOS7u4  [root@localhost ~]# cp -r /run/media/wwt/CentOS 7 x86_64/ /home/CentOS7u4/
  [root@localhost yum.repos.d]# cd /home/CentOS7u4/  [root@localhost CentOS7u4]# ll  total 0  drwxr-xr-x. 8 root root 254 Aug 22 17:37 CentOS 7 x86_64  [root@localhost CentOS7u4]# cd CentOS 7 x86_64/  [root@localhost CentOS 7 x86_64]# mv * ../  [root@localhost CentOS 7 x86_64]# ll  total 0  [root@localhost CentOS 7 x86_64]# cd ..  [root@localhost CentOS7u4]# ll  total 312  -rw-r--r--. 1 root root     14 Aug 22 17:37 CentOS_BuildTag  drwxr-xr-x. 3 root root     35 Aug 22 17:37 EFI  -rw-r--r--. 1 root root    227 Aug 22 17:37 EULA  -rw-r--r--. 1 root root  18009 Aug 22 17:37 GPL**重点内容**  drwxr-xr-x. 3 root root     57 Aug 22 17:37 images  drwxr-xr-x. 2 root root    198 Aug 22 17:37 isolinux  drwxr-xr-x. 2 root root     43 Aug 22 17:37 LiveOS  drwxr-xr-x. 2 root root 217088 Aug 22 17:37 Packages  drwxr-xr-x. 2 root root   4096 Aug 22 17:37 repodata  -rw-r--r--. 1 root root   1690 Aug 22 17:37 RPM-GPG-KEY-CentOS-7  -rw-r--r--. 1 root root   1690 Aug 22 17:37 RPM-GPG-KEY-CentOS-Testing-7  -r--r--r--. 1 root root   2883 Aug 22 17:37 TRANS.TBL  [root@localhost CentOS7u4]#

2、CentOS-Base.repo文件备份

  [root@localhost ~]# cd /etc/yum.repos.d/  [root@localhost yum.repos.d]# ll  total 32  -rw-r--r--. 1 root root 1664 Aug 30  2017 CentOS-Base.repo  -rw-r--r--. 1 root root 1309 Aug 30  2017 CentOS-CR.repo  -rw-r--r--. 1 root root  649 Aug 30  2017 CentOS-Debuginfo.repo  -rw-r--r--. 1 root root  314 Aug 30  2017 CentOS-fasttrack.repo  -rw-r--r--. 1 root root  630 Aug 30  2017 CentOS-Media.repo  -rw-r--r--. 1 root root 1331 Aug 30  2017 CentOS-Sources.repo  -rw-r--r--. 1 root root 3830 Aug 30  2017 CentOS-Vault.repo    [root@localhost yum.repos.d]# cp CentOS-Base.repo CentOS-Base.repo.bak  [root@localhost yum.repos.d]# ll  total 32  -rw-r--r--. 1 root root 1664 Aug 30  2017 CentOS-Base.repo  -rw-r--r--. 1 root root 1664 Aug 22 17:40 CentOS-Base.repo.bak  -rw-r--r--. 1 root root 1309 Aug 30  2017 CentOS-CR.repo  -rw-r--r--. 1 root root  649 Aug 30  2017 CentOS-Debuginfo.repo  -rw-r--r--. 1 root root  314 Aug 30  2017 CentOS-fasttrack.repo  -rw-r--r--. 1 root root  630 Aug 30  2017 CentOS-Media.repo  -rw-r--r--. 1 root root 1331 Aug 30  2017 CentOS-Sources.repo  -rw-r--r--. 1 root root 3830 Aug 30  2017 CentOS-Vault.repo  [root@localhost yum.repos.d]#

3、修改yum源配置

修改CentOS-Base.repo的内容,注释文档中的所有mirrorlist属性,把baseurl属性打开注释,并设置baseurl的属性值为挂载点
baseurl=file:///home/CentOS7u4/

如下所示:

  [base]  name=CentOS-$releasever - Base  #mirrorlist=http://mirrorlist.centos.org/release=$releasever&arch=$basearch&repo=os&infra=$infra  #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/  baseurl=file:///home/CentOS7u4/  gpgcheck=1  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7    #released updates  [updates]  name=CentOS-$releasever - Updates  #mirrorlist=http://mirrorlist.centos.org/release=$releasever&arch=$basearch&repo=updates&infra=$infra  #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/  baseurl=file:///home/CentOS7u4/  gpgcheck=1  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7    #additional packages that may be useful  [extras]  name=CentOS-$releasever - Extras  #mirrorlist=http://mirrorlist.centos.org/release=$releasever&arch=$basearch&repo=extras&infra=$infra  #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/  baseurl=file:///home/CentOS7u4/  gpgcheck=1  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7    #additional packages that extend functionality of existing packages  [centosplus]  name=CentOS-$releasever - Plus  #mirrorlist=http://mirrorlist.centos.org/release=$releasever&arch=$basearch&repo=centosplus&infra=$infra  #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/  baseurl=file:///home/CentOS7u4/  gpgcheck=1  enabled=0  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

保存,退出编辑。

4.清空yum已存在的所有源信息

  yum clean all

5.查看本地源的所有软件

  yum list

6.如果想要恢复使用网络上的源,把CentOS-Base.repo.bak重命名为CentOS-Base.repo就可以了

赞(0)
分享到: 更多 (0)
网站地图   沪ICP备18035694号-2    沪公网安备31011702889846号