制作yum源安装kubeadm(二)

一、环境准备

1.虚拟机准备

[root@localhost repo]# systemctl stop firewalld    #关闭防火墙
[root@localhost repo]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost repo]# systemctl stop iptables
Failed to stop iptables.service: Unit iptables.service not loaded.
[root@localhost repo]# systemctl disable iptables
Failed to execute operation: No such file or directory
[root@localhost repo]# 

2.安装createrepo

[root@localhost ~]# yum install -y createrepo
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.lzu.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 createrepo.noarch.0.0.9.9-28.el7 将被 安装
--> 正在处理依赖关系 python-deltarpm,它被软件包 createrepo-0.9.9-28.el7.noarch 需要
--> 正在处理依赖关系 libxml2-python,它被软件包 createrepo-0.9.9-28.el7.noarch 需要
--> 正在处理依赖关系 deltarpm,它被软件包 createrepo-0.9.9-28.el7.noarch 需要
--> 正在检查事务
---> 软件包 deltarpm.x86_64.0.3.6-3.el7 将被 安装
---> 软件包 libxml2-python.x86_64.0.2.9.1-6.el7_9.6 将被 安装
--> 正在处理依赖关系 libxml2 = 2.9.1-6.el7_9.6,它被软件包 libxml2-python-2.9.1-6.el7_9.6.x86_64 需要
---> 软件包 python-deltarpm.x86_64.0.3.6-3.el7 将被 安装
--> 正在检查事务
---> 软件包 libxml2.x86_64.0.2.9.1-6.el7.5 将被 升级
---> 软件包 libxml2.x86_64.0.2.9.1-6.el7_9.6 将被 更新
--> 解决依赖关系完成

依赖关系解决

=================================================================================================================================================================================================
 Package                                           架构                                     版本                                                 源                                         大小
=================================================================================================================================================================================================
正在安装:
 createrepo                                        noarch                                   0.9.9-28.el7                                         base                                       94 k
为依赖而安装:
 deltarpm                                          x86_64                                   3.6-3.el7                                            base                                       82 k
 libxml2-python                                    x86_64                                   2.9.1-6.el7_9.6                                      updates                                   247 k
 python-deltarpm                                   x86_64                                   3.6-3.el7                                            base                                       31 k
为依赖而更新:
 libxml2                                           x86_64                                   2.9.1-6.el7_9.6                                      updates                                   668 k

事务概要
=================================================================================================================================================================================================
安装  1 软件包 (+3 依赖软件包)
升级           ( 1 依赖软件包)

总下载量:1.1 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/5): createrepo-0.9.9-28.el7.noarch.rpm                                                                                                                                 |  94 kB  00:00:00     
(2/5): python-deltarpm-3.6-3.el7.x86_64.rpm                                                                                                                               |  31 kB  00:00:00     
(3/5): deltarpm-3.6-3.el7.x86_64.rpm                                                                                                                                      |  82 kB  00:00:00     
(4/5): libxml2-python-2.9.1-6.el7_9.6.x86_64.rpm                                                                                                                          | 247 kB  00:00:00     
(5/5): libxml2-2.9.1-6.el7_9.6.x86_64.rpm                                                                                                                                 | 668 kB  00:00:01     
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                                             996 kB/s | 1.1 MB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : deltarpm-3.6-3.el7.x86_64                                                                                                                                                    1/6 
  正在安装    : python-deltarpm-3.6-3.el7.x86_64                                                                                                                                             2/6 
  正在更新    : libxml2-2.9.1-6.el7_9.6.x86_64                                                                                                                                               3/6 
  正在安装    : libxml2-python-2.9.1-6.el7_9.6.x86_64                                                                                                                                        4/6 
  正在安装    : createrepo-0.9.9-28.el7.noarch                                                                                                                                               5/6 
  清理        : libxml2-2.9.1-6.el7.5.x86_64                                                                                                                                                 6/6 
  验证中      : python-deltarpm-3.6-3.el7.x86_64                                                                                                                                             1/6 
  验证中      : libxml2-2.9.1-6.el7_9.6.x86_64                                                                                                                                               2/6 
  验证中      : deltarpm-3.6-3.el7.x86_64                                                                                                                                                    3/6 
  验证中      : createrepo-0.9.9-28.el7.noarch                                                                                                                                               4/6 
  验证中      : libxml2-python-2.9.1-6.el7_9.6.x86_64                                                                                                                                        5/6 
  验证中      : libxml2-2.9.1-6.el7.5.x86_64                                                                                                                                                 6/6 

已安装:
  createrepo.noarch 0:0.9.9-28.el7      

二、制作yum源

1.创建文件夹和上传对应包

[root@localhost ~]# cd /opt/    #进入opt
[root@localhost opt]# pwd
/opt
[root@localhost opt]# 
[root@localhost opt]# mkdir repo    #opt下创建repo目录
[root@localhost opt]#  createrepo /opt/repo/    #命令执行后,会在该目录下创建一个repodata目录,如果报错需要安装createrepo
-bash: createrepo: 未找到命令 
[root@localhost opt]#  createrepo /opt/repo/    #安装后在执行createrepo /opt/repo/
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@localhost opt]# ls    
repo
[root@localhost opt]# cd repo/    #进入repo目录
[root@localhost repo]# 
[root@localhost repo]# pwd
/opt/repo
[root@localhost repo]# ls        #查看执行createrepo /opt/repo/生成的目录
repodata
[root@localhost repo]# pwd
/opt/repo
[root@localhost repo]# 
[root@localhost repo]# pwd
/opt/repo
[root@localhost repo]# ll    #查看上传的Packages.zip文件
总用量 9244120
-rw-r--r--. 1 root root 9465971802 4月  27 11:42 Packages.zip
drwxr-xr-x. 2 root root       4096 4月  27 11:22 repodata
[root@localhost repo]# 
[root@localhost repo]# unzip Packages.zip    #解压上传的包文件
[root@localhost repo]#
[root@localhost repo]# createrepo --update /opt/repo    #更新createrepo
Spawning worker 0 with 5015 pkgs
Spawning worker 1 with 5015 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@localhost repo]# 
[root@localhost repo]# cd /opt/repo    #进入/opt/repo
[root@localhost repo]# yum install -y httpd    #安装httpd
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.lzu.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-98.el7.centos.7 将被 安装
--> 正在处理依赖关系 httpd-tools = 2.4.6-98.el7.centos.7,它被软件包 httpd-2.4.6-98.el7.centos.7.x86_64 需要
--> 正在处理依赖关系 /etc/mime.types,它被软件包 httpd-2.4.6-98.el7.centos.7.x86_64 需要
--> 正在处理依赖关系 libaprutil-1.so.0()(64bit),它被软件包 httpd-2.4.6-98.el7.centos.7.x86_64 需要
--> 正在处理依赖关系 libapr-1.so.0()(64bit),它被软件包 httpd-2.4.6-98.el7.centos.7.x86_64 需要
--> 正在检查事务
---> 软件包 apr.x86_64.0.1.4.8-7.el7 将被 安装
---> 软件包 apr-util.x86_64.0.1.5.2-6.el7 将被 安装
---> 软件包 httpd-tools.x86_64.0.2.4.6-98.el7.centos.7 将被 安装
---> 软件包 mailcap.noarch.0.2.1.41-2.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=================================================================================================================================================================================================
 Package                                       架构                                     版本                                                     源                                         大小
=================================================================================================================================================================================================
正在安装:
 httpd                                         x86_64                                   2.4.6-98.el7.centos.7                                    updates                                   2.7 M
为依赖而安装:
 apr                                           x86_64                                   1.4.8-7.el7                                              base                                      104 k
 apr-util                                      x86_64                                   1.5.2-6.el7                                              base                                       92 k
 httpd-tools                                   x86_64                                   2.4.6-98.el7.centos.7                                    updates                                    94 k
 mailcap                                       noarch                                   2.1.41-2.el7                                             base                                       31 k

事务概要
=================================================================================================================================================================================================
安装  1 软件包 (+4 依赖软件包)

总下载量:3.0 M
安装大小:10 M
Downloading packages:
(1/5): apr-1.4.8-7.el7.x86_64.rpm                                                                                                                                         | 104 kB  00:00:00     
(2/5): apr-util-1.5.2-6.el7.x86_64.rpm                                                                                                                                    |  92 kB  00:00:00     
(3/5): httpd-tools-2.4.6-98.el7.centos.7.x86_64.rpm                                                                                                                       |  94 kB  00:00:00     
(4/5): mailcap-2.1.41-2.el7.noarch.rpm                                                                                                                                    |  31 kB  00:00:00     
(5/5): httpd-2.4.6-98.el7.centos.7.x86_64.rpm                                                                                                                             | 2.7 MB  00:00:00     
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                                             3.3 MB/s | 3.0 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : apr-1.4.8-7.el7.x86_64                                                                                                                                                       1/5 
  正在安装    : apr-util-1.5.2-6.el7.x86_64                                                                                                                                                  2/5 
  正在安装    : httpd-tools-2.4.6-98.el7.centos.7.x86_64                                                                                                                                     3/5 
  正在安装    : mailcap-2.1.41-2.el7.noarch                                                                                                                                                  4/5 
  正在安装    : httpd-2.4.6-98.el7.centos.7.x86_64                                                                                                                                           5/5 
  验证中      : httpd-tools-2.4.6-98.el7.centos.7.x86_64                                                                                                                                     1/5 
  验证中      : mailcap-2.1.41-2.el7.noarch                                                                                                                                                  2/5 
  验证中      : apr-1.4.8-7.el7.x86_64                                                                                                                                                       3/5 
  验证中      : httpd-2.4.6-98.el7.centos.7.x86_64                                                                                                                                           4/5 
  验证中      : apr-util-1.5.2-6.el7.x86_64                                                                                                                                                  5/5 

已安装:
  httpd.x86_64 0:2.4.6-98.el7.centos.7                                                                                                                                                           

作为依赖被安装:
  apr.x86_64 0:1.4.8-7.el7                 apr-util.x86_64 0:1.5.2-6.el7                 httpd-tools.x86_64 0:2.4.6-98.el7.centos.7                 mailcap.noarch 0:2.1.41-2.el7                

完毕!
[root@localhost repo]# 
[root@localhost repo]# systemctl start httpd && systemctl enable httpd    #创建开机启动
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@localhost repo]# ln -s /opt/repo /var/www/html/    #软连接指向/opt/repo /var/www/html/目录
[root@localhost repo]# 

 三、测试yum源

1.浏览器测试 

2.系统测试 

[root@centos01 ~]# cd /etc/yum.repos.d/
[root@centos01 yum.repos.d]# 
[root@centos01 yum.repos.d]# ll
总用量 40
-rw-r--r--. 1 root root 1664 10月 23 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 10月 23 2020 CentOS-CR.repo
-rw-r--r--. 1 root root  649 10月 23 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 10月 23 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 10月 23 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 10月 23 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 10月 23 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root  616 10月 23 2020 CentOS-x86_64-kernel.repo
[root@centos01 yum.repos.d]# rm -rf *
[root@centos01 yum.repos.d]# ll
总用量 0
[root@centos01 yum.repos.d]# cat > /etc/yum.repos.d/local.repo << EOF
> [local]
> name=local
> baseurl=http://192.168.200.20/repo/   # 目录地址很重要,一定要加对 必须加上/
> enabled=1
> gpgcheck=0
> EOF
[root@centos01 yum.repos.d]# 
[root@centos01 yum.repos.d]# 
[root@centos01 yum.repos.d]# ll
总用量 4
-rw-r--r--. 1 root root 134 4月  27 12:04 local.repo
[root@centos01 yum.repos.d]# more local.repo 
[local]
name=local
baseurl=http://192.168.200.20/repo/   # 目录地址很重要,一定要加对 必须加上/
enabled=1
gpgcheck=0
[root@centos01 yum.repos.d]# vi local.repo 
[root@centos01 yum.repos.d]# 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值