本地yum仓库配置以及创建yum仓库

如何使用光盘当做本地yum仓库?

    1.挂载光盘至某目录,例如/media/cdrom

    

[root@CentOS7 ~]# mount /dev/cdrom /media/cdrom/
mount: /dev/sr0 is write-protected, mounting read-only
[root@CentOS7 ~]# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda2       52403200 3793592  48609608   8% /
devtmpfs          486144       0    486144   0% /dev
tmpfs             500664     144    500520   1% /dev/shm
tmpfs             500664    7244    493420   2% /run
tmpfs             500664       0    500664   0% /sys/fs/cgroup
/dev/sda5       20961280 6858720  14102560  33% /testdir
/dev/sda1         201388  141668     59720  71% /boot
tmpfs             100136      20    100116   1% /run/user/0
/dev/sr0         7587292 7587292         0 100% /media/cdrom
[root@CentOS7 ~]#

    2.创建配置文件

[root@CentOS7 ~]# cat /etc/yum.repos.d/base.repo 
[base]
name=CentOS 7 (local)
baseurl=file:///media/cdrom
gpgcheck=0
enabled=1
[root@CentOS7 ~]#

    3.查看所配置的仓库是否生效

[root@CentOS7 ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id                                              repo name                                                     status
base                                                 CentOS 7 (local)                                              9,007
repolist: 9,007
[root@CentOS7 ~]#

    4.配置成功即可从仓库中安装程序包

[root@CentOS7 ~]# yum -y install tree
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
Resolving Dependencies
--> Running transaction check
---> Package tree.x86_64 0:1.6.0-10.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================================================================
 Package                              Arch                                   Version                                        Repository                            Size
=======================================================================================================================================================================
Installing:
 tree                                 x86_64                                 1.6.0-10.el7                                   base                                  46 k
Transaction Summary
=======================================================================================================================================================================
Install  1 Package
Total download size: 46 k
Installed size: 87 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : tree-1.6.0-10.el7.x86_64                                                                                                                            1/1 
  Verifying  : tree-1.6.0-10.el7.x86_64                                                                                                                            1/1 
Installed:
  tree.x86_64 0:1.6.0-10.el7                                                                                                                                           
Complete!
[root@CentOS7 ~]#

如何创建yum仓库?

    1.在指定的程序包路径当中运行createrepo命令创建yum仓库

[root@CentOS7 repodb]# pwd
/testdir/repodb
[root@CentOS7 repodb]# createrepo .
Spawning worker 0 with 9007 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@CentOS7 repodb]#

    2.配置所指向的yum仓库

[root@CentOS7 ~]# cat /etc/yum.repos.d/base.repo 
[base]
name=CentOS 7 (local)
baseurl=file:///testdir/repodb
gpgcheck=0
enabled=1
[root@CentOS7 ~]#

    3.yum仓库即可使用

[root@CentOS7 ~]# yum -y install tree
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package tree.x86_64 0:1.6.0-10.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================================================================
 Package                              Arch                                   Version                                        Repository                            Size
=======================================================================================================================================================================
Installing:
 tree                                 x86_64                                 1.6.0-10.el7                                   base                                  46 k
Transaction Summary
=======================================================================================================================================================================
Install  1 Package
Total download size: 46 k
Installed size: 87 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : tree-1.6.0-10.el7.x86_64                                                                                                                            1/1 
  Verifying  : tree-1.6.0-10.el7.x86_64                                                                                                                            1/1 
Installed:
  tree.x86_64 0:1.6.0-10.el7                                                                                                                                           
Complete!
[root@CentOS7 ~]#

原创文章,作者:zhai796898,如若转载,请注明出处:http://www.178linux.com/39403

(0)
zhai796898zhai796898
上一篇 2016-08-23 21:46
下一篇 2016-08-23 22:41

相关推荐

  • 初学Linux

       已经学习了Linux一周了,从原来的设计网页、动画影视制作、3D模型到现在的黑白界面虚拟世界,从原来吃睡由我到现在重回高三生活,说实话,一开始还是不太能适应的,尤其是眼睛,酸胀痛。不过,越努力越幸运,也觉得linux其实很有意思。。以下是我第一篇微博的内容,也是我学习linux一周所总结的知识。 首先,学习一门知识就要先了解他的历史…

    Linux干货 2017-07-15
  • 宣言

    我是一个新手  但是我想认真努力学好linux     有朝一日能成为别人眼中的大牛再回头看看现在 不会后悔  付出必然会有回报  虽千万人吾往矣!

    Linux干货 2016-10-24
  • Linux(Debian系)常用运维命令节选之一

    用硬件检测程序kuduz探测新硬件:service kudzu start ( or restart) 查看CPU信息:cat /proc/cpuinfo 查看板卡信息:cat /proc/pci 查看PCI信息:lspci (相比cat /proc/pci更直观) 查看内存信息:cat /proc/meminfo 查看USB设备:cat /proc/bus…

    Linux干货 2016-10-30
  • Linux网络属性配置—iproute命令家族

    ip命令: show / manipulate routing, devices, policy routing and tunnels ip [ OPTIONS ] OBJECT { COMMAND | help } OBJECT := { link | addr | route | netns  } ip  OBJECT: ip li…

    Linux干货 2016-12-04
  • 高级文件系统管理

    为用户设定配额  执行开始或取消配额:quotaon quotaoff  取消编辑配额:edqouta username  在shell中直接编辑:setquota usename 80000 100000 0 0 /foo  定义原始标准用户 :edquota -p user1 user2 实例如下: 配额的实现 1…

    Linux干货 2017-05-02
  • VPS服务器的购买使用

           Virtual Host Server(虚拟主机)是一个云计算服务,相比于传统的购买服务器硬件方式搭建服务器,有着价格便宜,个性化定制配置,使用灵活等特点。按需求购买计算资源,只需要几分钟时间就可以在公网配置一个属于自己的服务器。         最著名的云计算服务提供商国外有Amazon,Google,vultr等等,国内有阿里云,腾讯云等等…

    2018-03-26