本地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)
上一篇 2016-08-23 21:46
下一篇 2016-08-23 22:41

相关推荐

  • 进程管理,计划任务

    一、进程相关概念及系统管理工具     进程概念         内核的功用:进程管理、文件系统、网络功能、内存管理、驱动程序、 安全功能等         P…

    Linux干货 2016-09-18
  • 探索这个“男人”

    一、前言 正所谓了解一个命令就得了解他的用法,正好是要了解一个人就得了解他的兴趣爱好,处事态度以及为人是怎么样的。 二、man是什么 man – an interface to the on-line reference manuals Man是manual(手册)的缩写,使用权限是所有用户,man命令提供为linux系统在线提供了很好的帮助手册…

    Linux干货 2016-05-03
  • Linux基础知识(四)

    1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限 [root@bogon ~]# cp -r /etc/skel/ /home/tuser1 [root@bogon ~]# chmod -R 700 /home/tuser1 2、编辑/etc/group文件,添加组hadoo…

    Linux干货 2016-10-17
  • N26-第七周

    1、创建一个10G分区,并格式为ext4文件系统;   (1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl;    (2) 挂载至/data/mydata目录,要求挂载时禁止程序自动运行,且不更新文件的访问时间戳; [root@localhost ~]# fdi…

    Linux干货 2017-03-05
  • 26期全程班-第五周博客作业

      1、显示/boot/grub/grub.conf中以至少一个空白字符开头的行; # grep “^[[:space:]]\+” /boot/grub/grub.conf 2、显示/etc/rc.d/rc.sysinit文件中以#开头,后面跟至少一个空白字符,而后又有至少一个非空白字符的行; # grep “^…

    Linux干货 2017-03-09