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

相关推荐

  • vim文本编辑器小结

    vi=vim打开文件 alias vi =vim vim -m 只读方式打开文件 修改文件时则会无法保存   -b 二进制打开文件 -d file1 file2  比较两个文件 Command(normal)默认模式:  ZZ 保存并退出 ZQ 不保存并退出Insert:编辑模式&nbsp…

    2017-08-05
  • shell中测试命令

    shell中测试命令        test命令提供了if–than语句中测试不同条件的途径。如果test命令中列出的条件成立,test命令就会退出并返回退出状态吗0 。这样if–than语句就与其他编程语言中的if–than语句类似的方式工作了。如果条件不成立,…

    Linux干货 2017-04-16
  • Linux中的网络功能概念介绍(一)

      在操作系统中,进程之间的通信是用ipc(内存基本通信)以及内存共享shm来实现本地的通信,那么如果跨主机间通信或者说是不同之间的主机用rpc(远程过程调用)以及socket套接字,用一个主机在socket中写数据,另一个主机在socket之间读数据,以实现进程通信的最终目的。   在网络功能出现之前,基本都是用电话…

    Linux干货 2016-11-23
  • HAProxy

    LB Cluster: 四层:lvs, nginx(stream),haproxy(mode tcp) 七层:http: nginx(http, ngx_http_upstream_module), haproxy(mode http), httpd, ats, perlbal, pound… HAProxy 程序环境: 主程序:/usr/sbi…

    Linux干货 2017-07-03
  • linux三剑客之grep

    linux三剑客之grep        所谓三剑客的工具有“grep”、“sed” 、“awk”,他们都是不谋而合的文本搜索查找处理的强大工具。grep 是 Ken Thompson 写的,他也是 Unix 的创造者。 gerp及正则表达式    grep全称(GLobal search Regu…

    Linux干货 2016-08-08
  • LNMP

    1、源码编译安装LNMP架构环境 OS版本:2.6.32-431.el6.x86_64 Nginx版本:nginx-1.6.1 mariadb版本:mariadb-10.0.13 php版本:php-5.4.26 1、安装编译安装所需系统环境 ~]# yum groupinstall "Development Tools" "S…

    Linux干货 2017-02-09