本地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
下一篇 2016-08-23

相关推荐

  • Linux-Centos7编译内核

    编译内核     前提:         (1)准备好开发环境         (2) 获取目标主机上硬件设备的相关信息         (3) 获取目标主机系统功能的相关信息       …

    2017-07-16
  • Linux Service and Security(Part 1)

    一、知识整理 1、不安全的传统协议: telnet、FTP、POP3等:不安全的密码; http、smtp、NFS等:不安全信息; Ldap、NIS、rsh等:不安全验证。 设计基本原则: 使用成熟的安全系统; 以小人之心度输入数据; 外部系统是不安全的; 最小授权; 减少外部接口; 缺省使用安全模式; 在入口处检查; 安全不是似是而非; 从管理上保护好系统…

    Linux干货 2016-10-09
  • N22-第五周作业-冥界之王

    1、显示/boot/grub/grub.conf中以至少一个空白字符开头的行;    [root@CentOS6 ~]# cat /boot/grub/grub.conf | grep -E  "^[[:space:]]{1,}"…

    Linux干货 2016-09-19
  • 管理systemd

    管理systemd init(系统的第一个进程): CentOS 5: SysV initCentOS 6: UpstartCentOS 7: Systemd Systemd:系统启动和服务器守护进程管理器,负责在系统启动或运行时,激活系统资源,服务器进程和其它进程 Systemd新特性: 系统引导时实现服务并行启动 按需启动守护进程 系统状态快照 自动化的…

    Linux干货 2016-09-22
  • 学习linux第四天

    Linux学习第4天   Linux内部命令和外部命令    内部命令:实际上是shell程序的一部分,其中包含的是一些比较简单的linux系统命令,这些命令由shell程序识别并在shell程序内部完成运行,通常在linux系统加载运行时shell就被加载并驻留在系统内存中。内部命令是写在bashy源码里面的,其执行速度比外部…

    Linux干货 2016-10-29
  • 马哥教育网络班22期+第1周课程练习

    问题1: 计算机组成如下:CPU、存储器、输入设备、输出设备1、中央处理器(Central Processing Unit,简称 CPU)。它主要由控制器、运算器等组成,并采用大规模集成电路工艺制成的芯片,又称微处理器芯片。   CPU又由运算器和控制器组成。1)运算器 运算器又称算术逻辑单元(Arithmetic Logic Unit简…

    Linux干货 2016-08-15