• linux 搭建局域网YUM源仓库服务器


     yum简介

      Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装。

      借助于YUM软件仓库,可以完成安装、卸载、自动升级rpm软件包等任务,能够自动查找并解决rpm包之间的依赖关系,而无需管理员,手工去安装每个rpm包,使管理员在维护大量Linux服务器时更加轻松自如。特别是拥有大量Linux主机的本地网络中,构建一台源服务器可以大大缓解软件安装、升级等对lnterner的依赖。

      yum服务器搭建

      yum服务器概述

      yum软件仓库通常借助HTTP或FTP协议来进行发布,这样可以面向网络中的所有客户机提供软件源服务。为了便于客户机查询软件包,获取依赖关系等信息,在软件仓库中需要提供仓库数据(Repodata),其中收集了目录下所有rpm包的头部信息。

      准备网络安装源(服务器端)

      (1)准备软件仓库目录

      光盘中的软件包拷贝CentOS6.5第一张光盘内容到本地FTP服务器匿名访问用户的根目录下

      [root@localhost ~]# cd /var/ftp/

      [root@localhost ftp]# mkdir centos6

      [root@localhost ftp]# cp -rf /media/CentOS_6.5_Final/* /var/ftp/centos6/ &

      [1] 45717

      [root@localhost ftp]# jobs

      [1]+ Done cp -i -rf /media/CentOS_6.5_Final/* /var/ftp/centos6/

      [root@localhost ksh]# cp /media/CentOS_6.5_Final/Packages/ksh-20120801-10.el6.x86_64.rpm /var/ftp/ksh/

      [root@localhost ksh]# cp /media/CentOS_6.5_Final/Packages/mksh-39-7.el6_4.1.x86_64.rpm /var/ftp/ksh/

      [root@localhost ksh]# ls

      ksh-20120801-10.el6.x86_64.rpm mksh-39-7.el6_4.1.x86_64.rpm

      未安装createrepo包需要先安装

      [root@localhost ksh]# yum -y install createrepo

      [root@localhost ksh]# createrepo -v ./

      Spawning worker 0 with 2 pkgs

      Worker 0: reading ksh-20120801-10.el6.x86_64.rpm

      Worker 0: reading mksh-39-7.el6_4.1.x86_64.rpm

      Workers Finished

      Gathering worker results

      Saving Primary metadata

      Saving file lists metadata

      Saving other metadata

      Generating sqlite DBs

      Starting other db creation: Thu May 31 18:20:51 2018

      Ending other db creation: Thu May 31 18:20:51 2018

      Starting filelists db creation: Thu May 31 18:20:51 2018

      Ending filelists db creation: Thu May 31 18:20:51 2018

      Starting primary db creation: Thu May 31 18:20:51 2018

      Ending primary db creation: Thu May 31 18:20:51 2018

      Sqlite DBs complete

      [root@localhost ksh]# ls

      ksh-20120801-10.el6.x86_64.rpm mksh-39-7.el6_4.1.x86_64.rpm repodata

      安装并启动vsftpd服务(详见FTP服务内容)

      [root@localhost ksh]# service vsftpd restart

      关闭 vsftpd: [确定]

      为 vsftpd 启动 vsftpd: [确定]

      [root@localhost ksh]# chkconfig vsftpd on

      [root@localhost ksh]# chkconfig vsftpd --list

      vsftpd 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭

      配置yum软件仓库位置(客户机端)

      典型仓库配置

      内网YUM源

      [root@n2 ~]# cd /etc/yum.repos.d/

      [root@n2 yum.repos.d]# ls

      CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo

      [root@n2 yum.repos.d]# mkdir bak

      [root@n2 yum.repos.d]# mv *o ./bak/

      [root@n2 yum.repos.d]# ls

      bak

      [root@n2 yum.repos.d]# vim amber.repo

      [yum]

      name=centos 6.5

      baseurl=ftp://192.168.28.128/centos6/

      gpgcheck=0

      enabled=1

      [ksh]

      name=ksh

      baseurl=ftp://192.168.28.128/ksh/

      gpgcheck=0

      enabled=1

      ~

      [root@n2 ~]# yum -y clean all

      Loaded plugins: fastestmirror, refresh-packagekit, security

      Cleaning repos: ksh yum

      Cleaning up Everything

      Cleaning up list of fastest mirrors

      [root@n2 ~]# yum makecache

      Loaded plugins: fastestmirror, refresh-packagekit, security

      Determining fastest mirrors

      ksh | 2.9 kB 00:00

      ksh/filelists_db | 1.1 kB 00:00

      ksh/primary_db | 3.3 kB 00:00

      ksh/other_db | 2.2 kB 00:00

      yum | 4.0 kB 00:00

      yum/group_gz | 220 kB 00:00

      yum/filelists_db | 5.8 MB 00:00

      yum/primary_db | 4.4 MB 00:00

      yum/other_db | 2.7 MB 00:00

      Metadata Cache Created

      查看yum缓存是否生成

      [root@n2 ~]# ls /var/cache/yum/x86_64/6/

      base extras ksh timedhosts.txt updates yum

      [root@n2 ~]# ls /var/cache/yum/x86_64/6/yum/

      0dafccfdbf892f02acca8267ade4bdcee7280a682e65dc7e29145f3341fd7a8c-primary.sqlite

      594d4bb4a79ed01d66635adbcf76c45ca4a85b30fc3e3c3c28316e64f0a83f21-filelists.sqlite

      ca525c73086186bfcb81ad9edd45796026dac7e4e50524e0f2daf901532aaf66-c6-x86_64-comps.xml.gz

      cachecookie

      fdd542ef36b0cde54ee0521fae90b98911db06483163aa1c049995b6d109349b-other.sqlite

      gen

      packages

      repomd.xml

      [root@n2 ~]# ls /var/cache/yum/x86_64/6/ksh

      046862454d1aa798eb72c70668a54e25905c276a613fd0cc15abdf13fc20d6de-filelists.sqlite

      38c945c0799d8cfb481c6145b8c227b1f2ef91100f3b7bc8cad97645594f4643-primary.sqlite

      cachecookie

      fe7ae063ad2b6e2c4bcdbc676581ac33eb74c0645132fb0c4bac78f24300ffb5-other.sqlite

      packages

      repomd.xml

      测试

      [root@n2 ~]# yum -y install dhcp

      Loaded plugins: fastestmirror, refresh-packagekit, security

      Loading mirror speeds from cached hostfile

      Setting up Install Process

      Resolving Dependencies

      --> Running transaction check

      ---> Package dhcp.x86_64 12:4.1.1-38.P1.el6.centos will be installed

      --> Finished Dependency Resolution

      Dependencies Resolved

      ========================================================================================================================================================

      Package Arch Version Repository Size

      ========================================================================================================================================================

      Installing:

      dhcp x86_64 12:4.1.1-38.P1.el6.centos yum 817 k

      Transaction Summary

      ========================================================================================================================================================

      Install 1 Package(s)

      Total download size: 817 k

      Installed size: 1.9 M

      Downloading Packages:

      dhcp-4.1.1-38.P1.el6.centos.x86_64.rpm | 817 kB 00:00

      Running rpm_check_debug

      Running Transaction Test

      Transaction Test Succeeded

      Running Transaction

      Warning: RPMDB altered outside of yum.

      Installing : 12:dhcp-4.1.1-38.P1.el6.centos.x86_64 1/1

      Verifying : 12:dhcp-4.1.1-38.P1.el6.centos.x86_64 1/1

      Installed:

      dhcp.x86_64 12:4.1.1-38.P1.el6.centos

      Complete!

      注意;因为ksh包在光盘中存在,所以需先修改repo文件后重建yum缓存再进行安装测试,否则安装的是光盘中的包。

  • 相关阅读:
    hdu4734 F(x)
    hdu2089 不要62 两解
    luogu2602 [ZJOI2010]数字计数 两解
    lemon
    UVA1218 完美的服务 Perfect Service
    luogu HNOI2003消防局的设立
    uva10891 game of sum
    uva10635 Prince and Princess
    UVA1394 And Then There Was One
    uva10003切木棍
  • 原文地址:https://www.cnblogs.com/guarderming/p/11570669.html
Copyright © 2020-2023  润新知