制作本地yum源

1. 挂载镜像

[root@localhost ~]# mkdir -p /mnt/cdrom    //创建目录
[root@localhost ~]# mount /dev/sr0 /mnt/cdrom    //挂载镜像

2. 进入挂载目录找到要安装的软件包

[root@localhost ~]# cd /mnt/cdrom/Packages/
[root@localhost Packages]# ls | grep tree**
tree-1.6.0-10.el7.x86_64.rpm
[root@localhost ~]#

3. 备份配置文件

[root@localhost Packages]# cd /etc/yum.repos.d/   //切换到yum.repos.d目录
[root@localhost yum.repos.d]# rename .repo .repo.bak *   //备份所有配置文件
[root@localhost yum.repos.d]# ll      //查看备份是否完成
总用量 4
-rw-r--r--. 1 root root 69 3月  14 15:32 local.repo.bak
[root@localhost yum.repos.d]# 

4. 新增本地yum源

[root@localhost yum.repos.d]# vim CentOS-Local.repo

5. 编辑以下内容(把备注内容去掉)

[base]
name=CentOS-Local   //yum名称
baseurl=file:///mnt/cdrom   //协议类型和软件包目录地址
gpgcheck=0   //要不要检查
enabled=1   //要不要使用

6.  yum源仓库查看

[root@localhost yum.repos.d]# yum repolist 
已加载插件:fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Loading mirror speeds from cached hostfile
源标识                        源名称                              状态
!base                         CentOS-Local                        10,072
repolist: 10,072
[root@localhost yum.repos.d]#

7.  清空缓存

[root@localhost yum.repos.d]# yum clean all 
已加载插件:fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
正在清理软件源: base
Cleaning up list of fastest mirrors
Other repos take up 739 M of disk space (use --verbose for details)
[root@localhost yum.repos.d]# 

8.  卸载 tree 软件

[root@localhost yum.repos.d]# yum -y remove tree 
已加载插件:fastestmirror, langpacks
正在解决依赖关系
--> 正在检查事务
---> 软件包 tree.x86_64.0.1.6.0-10.el7 将被 删除
--> 解决依赖关系完成

依赖关系解决

==========================================================================================================
 Package               架构                    版本                          源                      大小
==========================================================================================================
正在删除:
 tree                  x86_64                  1.6.0-10.el7                  @base                   87 k

事务概要
==========================================================================================================
移除  1 软件包

安装大小:87 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在删除    : tree-1.6.0-10.el7.x86_64                                                              1/1 
  验证中      : tree-1.6.0-10.el7.x86_64                                                              1/1 

删除:
  tree.x86_64 0:1.6.0-10.el7                                                                              

完毕!
[root@localhost yum.repos.d]#

9.  安装tree软件查看是否成功

[root@localhost yum.repos.d]# yum -y install tree
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
base                                                                    | 3.6 kB  00:00:00     
(1/2): base/group_gz                                                    | 153 kB  00:00:00     
(2/2): base/primary_db                                                  | 3.3 MB  00:00:00     
正在解决依赖关系
--> 正在检查事务
---> 软件包 tree.x86_64.0.1.6.0-10.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

===============================================================================================
 Package            架构                 版本                         源                  大小
===============================================================================================
正在安装:
 tree               x86_64               1.6.0-10.el7                 base                46 k

事务概要
===============================================================================================
安装  1 软件包

总下载量:46 k
安装大小:87 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : tree-1.6.0-10.el7.x86_64                                                   1/1 
  验证中      : tree-1.6.0-10.el7.x86_64                                                   1/1 

已安装:
  tree.x86_64 0:1.6.0-10.el7                                                                   

完毕!
[root@localhost yum.repos.d]# 

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值