1.设备: 两台主机
ip | 节点 |
10.1.1.2 | server02(Server) |
10.1.1.4 | server04(client) |
2.下载httpd包,并将防火墙关闭,启动httpd服务
[root@server02 ~]# yum -y install httpd
[root@server02 ~]#systemctl disable firewalld
[root@server02 ~]#systemctl enable --now httpd.service
3.在/var/www/html下,创建文件夹/var/www/html/centos/7/centosplus,将光盘/dev/sr0挂载在文件夹/var/www/html/centos/7/centosplus下。
[root@server02 html]# mkdir -pv /var/www/html/centos/7/centosplus
[root@server02 html]#mount /dev/sr0 /var/www/html/centos/7/centosplus/
mount: /dev/sr0 写保护,将以只读方式挂载
4.打开Chrome浏览器,输入10.1.1.2/centos/7/,回车
5.在作为客户端(client)的机器上,将/etc/yum.repos.d/下所有文件移动到/etc/yum.repos.d/backup下,
[root@server04 yum.repos.d]# mkdir -p backup
[root@server04 yum.repos.d]# mv *.repo /etc/yum.repos.d/backup
6. 在作为客户端(client)的机器上,在文件/etc/yum.repos.d/下,创建 Package.repo
[root@server04 yum.repos.d]# touch Package.repo
7.在Package.repo添加内容如下,
[root@server04 yum.repos.d]# cat >> Package.repo << EOF
> [BaseOS]
>name=BaseOS
>baseurl=http://10.1.1.2/centos/7/centosplus/
>gpgcheck=1
>gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>enable=1>EOF
8.清理缓存,并用yum repolist 查看一下这个库下有多少个包。
[root@server04 yum.repos.d]# yum clean all
[root@server04 yum.repos.d]# yum repolist
结果如下:
9.要创建extras仓库,server端应该要有extras仓库,yum repolist下
[root@server04 yum.repos.d]# yum repolist
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
源标识 源名称 状态
BaseOS BaseOS 4,070
repolist: 4,076
10.要reposync --repoid=resourceid --download-metadata -p filename 这条命令下载extras仓库,必须要下载yum-utils包,下载 deltarpm, 下载 createrepo 包
[root@server04 yum.repos.d]# yum -y install yum-utils
[root@server04 yum.repos.d]# yum -y install deltarpm
[root@server04 yum.repos.d]# yum -y install createrepo
11.将extras 仓库 下载 到 /var/www/html/centos/7/,
[root@server02 html]# reposync --repoid=extras --download-metadata -p p/var/www/html/centos/7/
12.下载成功后,在/var/www/html/centos/7/extras 下,是没有看到repodata时,需要使用createrepo 创建元数据
[root@server02 html]# createrepo /var/www/html/centos/7/extras
13.在 Package.repo添加内容如下:
[extras]
name=extras
baseurl=http://10.1.1.2/centos/7/extras/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
14.yum repolist 查看库的是否更新
[root@server04 yum.repos.d]# yum repolist
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
源标识 源名称 状态
BaseOS BaseOS 4,070
extras extras 526
repolist: 4,596
15.将epel库下载到/var/www/html/ ,也是同样的方法,然后用yum repolist 查看一下epel库是否更新,
[root@server02 html]# reposync --repoid=epel --download-metadata -p p/var/www/html/
[root@server02 html]# createrepo /var/www/html/epel
16.yum -y install httpd ,下载包是不是可用!!!
[root@server04 yum.repos.d]# yum -y install httpd
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
BaseOS | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-95.el7.centos 将被 安装
--> 正在处理依赖关系 httpd-tools = 2.4.6-95.el7.centos,它被软件包 httpd-2.4.6-95.el7.centos.x86_64 需要
--> 正在处理依赖关系 /etc/mime.types,它被软件包 httpd-2.4.6-95.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 httpd-tools.x86_64.0.2.4.6-95.el7.centos 将被 安装
---> 软件包 mailcap.noarch.0.2.1.41-2.el7 将被 安装
--> 解决依赖关系完成依赖关系解决
===========================================================================================================================
Package 架构 版本 源 大小
===========================================================================================================================
正在安装:
httpd x86_64 2.4.6-95.el7.centos BaseOS 2.7 M
为依赖而安装:
httpd-tools x86_64 2.4.6-95.el7.centos BaseOS 93 k
mailcap noarch 2.1.41-2.el7 BaseOS 31 k事务概要
===========================================================================================================================
安装 1 软件包 (+2 依赖软件包)总下载量:2.8 M
安装大小:9.6 M
Downloading packages:
(1/3): httpd-tools-2.4.6-95.el7.centos.x86_64.rpm | 93 kB 00:00:00
(2/3): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:00
(3/3): httpd-2.4.6-95.el7.centos.x86_64.rpm | 2.7 MB 00:00:00
---------------------------------------------------------------------------------------------------------------------------
总计 14 MB/s | 2.8 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : mailcap-2.1.41-2.el7.noarch 1/3
正在安装 : httpd-tools-2.4.6-95.el7.centos.x86_64 2/3
正在安装 : httpd-2.4.6-95.el7.centos.x86_64 3/3
验证中 : httpd-tools-2.4.6-95.el7.centos.x86_64 1/3
验证中 : mailcap-2.1.41-2.el7.noarch 2/3
验证中 : httpd-2.4.6-95.el7.centos.x86_64 3/3已安装:
httpd.x86_64 0:2.4.6-95.el7.centos作为依赖被安装:
httpd-tools.x86_64 0:2.4.6-95.el7.centos mailcap.noarch 0:2.1.41-2.el7完毕!