本地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

相关推荐

  • Centos下实现多网卡绑定

    实现多网卡绑定在Centos6和Centos7可采用bonding方式,Centos7上team网络组也可实现,并且功能更强大。 Linux bonding 模块提供一种将多个网卡聚合成一块逻辑捆绑网卡的实现方法。 捆绑的网卡拥有多种模式,根据模式的特性,可实现网络负载均衡,网络冗余切换,提高网络吞吐量等功能。 大多流行Linux发行版都已装载bonding…

    Linux干货 2016-09-13
  • httpd功能配置之CGI程序

        httpd服务中有一个cgi-bin目录,此目录专门用于存放cgi脚本。CGI即网关通用接口,用于实现动态网页。下面简单编写一个CGI脚本来进行测试此功能:     1、在/var/www/cgi-bin/目录下创建一个脚本     2、重启服务     3、验证 &nb…

    Linux干货 2016-03-11
  • linux进程管理

    linux系统进程查看及管理工具 对于服务器来说重要的IO 设备磁盘网络 pstree,ps,pidof,pgrep,top,htop,glances,pmap,vmstat,dstat,kill,pkill,job,bg,fg,nohup,nice,renice,killall….. pstree命令: pstree-display …

    Linux干货 2016-09-09
  • 学习宣言

    如果自己都不愿意动,没有人能帮助我成功!

    Linux干货 2016-12-26
  • N22-第十周作业

    第十周    1、请详细描述CentOS系统的启动流程(详细到每个过程系统做了哪些事情)    POST–>BootSequence(BOIS)–>BootLoader(MBR)–>Kernel(ramfs或者ramdisk)–&gt…

    Linux干货 2016-11-07
  • shell脚本编写-1练习题

    1、编写脚本/root/bin/systeminfo.sh,显示当前主机系统信息,包括主机名,IPv4地址,操作系统版本,内核版本,CPU型号,内存大小,硬盘大小 #!/bin/bash echo “the hostname is:`hostname`” echo “the ip address is:`ifconfig | sed –n ‘2p’ |sed…

    Linux干货 2016-08-15