1. 挂载centos6.4 DVD镜像
[root@centos64 ~]# mount /dev/cdrom /mnt

2. 安装vsftp软件,启动vsftpd服务,拷贝centos6.4 DVD内容到ftp的匿名用户某一目录。
[root@centos64 Packages]# rpm -ivh vsftpd-2.2.2-11.el6_3.1.x86_64.rpm
Preparing...                ########################################### [100%]
   1:vsftpd                 ########################################### [100%]
[root@centos64 Packages]#
[root@centos64 Packages]#
[root@centos64 Packages]# chkconfig vsftpd on
[root@centos64 Packages]#
[root@centos64 Packages]# cd /var/ftp/
[root@centos64 ftp]#
[root@centos64 ftp]#
[root@centos64 ftp]# ls
pub
[root@centos64 ftp]# rm -rf pub/
[root@centos64 ftp]# service vsftpd start
Starting vsftpd for vsftpd:                                [  OK  ]
[root@centos64 ftp]# mkdir centos6.4-x86_64 centos5.9-x86_64 ##顺便练centos5.9的软件源也一起搭建起来
[root@centos64 ftp]# cd centos6.4-x86_64/
[root@centos64 centos6.4-x86_64]#
[root@centos64 centos6.4-x86_64]# cp -rp /mnt/* .

3. 创建依赖关系数据库
[root@centos64 ~]# cd /mnt/Packages/
[root@centos64 Packages]# rpm -ivh createrepo-0.9.9-17.el6.noarch.rpm
[root@centos64 Packages]# createrepo -g /var/ftp/centos6.4-x86_64/repodata/repomd.xml /var/ftp/centos6.4-x86_64/
Spawning worker 0 with 3955 pkgs
Workers Finished
Gathering worker results

Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@centos64 Packages]#

4. yum的客户端需要修改yum配置文件:
移走/etc/yum.repos.d/所有的.repo文件。
[root@centos64 ~]# cd /etc/yum.repos.d/
[root@centos64 yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo  epel.repo  epel-testing.repo
[root@centos64 yum.repos.d]# mkdir bak
[root@centos64 yum.repos.d]# mv CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo bak/
[root@centos64 yum.repos.d]# ls
bak  epel.repo  epel-testing.repo
[root@centos64 yum.repos.d]# vi centos6.4.repo
[root@centos64 yum.repos.d]#
[root@centos64 yum.repos.d]# more centos6.4.repo
[centos6.4]
name=centos6.4
baseurl=ftp://192.168.1.64/centos6.4-x86_64/
enabled=1
[root@centos64 yum.repos.d]#
[root@centos64 yum.repos.d]# yum list all
如果出现如下带有centos6.4的标记,说明成功
......
yum-plugin-aliases.noarch                                      1.1.30-14.el6                             centos6.4                               
yum-plugin-changelog.noarch                                    1.1.30-14.el6                             centos6.4                               
yum-plugin-downloadonly.noarch                                 1.1.30-14.el6                             centos6.4                               
yum-plugin-security.noarch                                     1.1.30-14.el6                             centos6.4  
......

5. 同样的方法搭建centos5.9的yum源
说明:这里有个大大的陷阱,当你把centos5.9的DVD源复制到centos6的系统,然后用centos6的createrepo命令创建依赖数据库的时候,发现虽然没有报错,但是这样的源,在centos5客户端yum 安装的时候,报效验错误的提示。如下:
[root@centos59 yum.repos.d]# yum list all
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
centos5.9/primary_db                                                                                                                            | 2.0 MB     00:00     
ftp://192.168.1.64/centos5.9-x86_64/repodata/d219ce6ac81a48dc4b3295d72b6e26ea0cecd3b03f9a1c1655132d53508ad965-primary.sqlite.bz2: [Errno -3] Error performing checksum
Trying other mirror.
Error: failure: repodata/d219ce6ac81a48dc4b3295d72b6e26ea0cecd3b03f9a1c1655132d53508ad965-primary.sqlite.bz2 from centos5.9: [Errno 256] No more mirrors to try.
[root@centos59 yum.repos.d]#
原因是:centos6中的createrepo 命令,是用的是 光碟 Rackages/路径,而centos5中用的是 CentOS/路径,所以问题就出来了。原来校验的时候,centos5的软件包只能用centos5中的createrepos命令。
解决方法是: 把centos6中的/var/ftp/ 用nfs挂载到 centos5的 /var/ftp/ 同样路径下,用centos5的createrepo命令生成依赖数据库。
在centos6下面,装上nfs并挂载,如下:
[root@centos64 centos5.9-x86_64]# more /etc/exports
/var/ftp *(rw,sync)
[root@centos64 centos5.9-x86_64]#
centos5.9上面挂载命令如下:  mount  192.168.1.65:/var/ftp   /var/ftp

下面是在centos5中执行的createrepo命令:

[root@centos59 CentOS]# createrepo -g /var/ftp/centos5.9-x86_64/repodata/repomd.xml /var/ftp/centos5.9-x86_64/
3579/3579 - CentOS/patch-2.5.4-31.el5.x86_64.rpm                                x86_64.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata
[root@centos59 CentOS]#
执行上面的命令后,还是发现错误依旧
[root@centos59 yum.repos.d]# yum list all
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
centos5.9/primary_db                                                                                                                           
| 2.0 MB     00:00     
ftp://192.168.1.64/centos5.9-x86_64/repodata/d219ce6ac81a48dc4b3295d72b6e26ea0cecd3b03f9a1c1655132d53508ad965-primary.sqlite.bz2:
[Errno -3] Error performing checksum
Trying other mirror.
Error:
failure:
repodata/d219ce6ac81a48dc4b3295d72b6e26ea0cecd3b03f9a1c1655132d53508ad965-primary.sqlite.bz2
from centos5.9: [Errno 256] No more mirrors to try.
[root@centos59 yum.repos.d]#
然后直接在centos6中清空掉 centos5.9-x86_64/repodata/ 中的垃圾数据,对比centos5.9 DVD源光盘镜像中的 repodata/ 目录,清空掉以前 centos6 的createrepo命令生成的垃圾文件,并且在centos5 中重命名一下centos5.9.repo 就好了。因为可能在centos5.9中有缓存的缘故。

===============以后碰到了如下问题:

以上方法只是解决了yum -y install XXXXX的 安装问题,但是对于 yum groupinstall 安装的时候,就会报错,如下:

[root@BG-DB:/etc/yum.repos.d]$yum grouplist
Setting up Group Process
centos5.9/group                                                                                         | 1.1 kB     00:00     
ftp://192.168.1.202/repodata/repomd.xml: [Errno -1] Metadata file does not match checksum
Trying other mirror.
Failed to add groups file for repository: centos5.9 - None
Error: No group data available for configured repositories
[root@BG-DB:/etc/yum.repos.d]$

原来没有在yum端创建组数据库,需要在yum源中

【centos5.X】需要如下方法执行:
[root@server202:/var/ftp/centos5.9-x86_64]$createrepo -g  repodata/comps.xml .   ##注意,这里和上面的不同,这个是组的数据库配置。
3579/3579 - CentOS/xorg-x11-drv-cirrus-1.1.0-2.fc6.x86_64.rpm                   pm6_64.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata
[root@server202:/var/ftp/centos5.9-x86_64]$

【centos6.X】需要如下方法执行:

[root@centos65dvd centos6.5-x86_64]# createrepo -g repodata/b4e0b9342ef85d3059ff095fa7f140f654c2cb492837de689a58c581207d9632-c6-x86_64-comps.xml .    ## centos6.X这里面的组文件和centos5.X 不一样
Spawning worker 0 with 3995 pkgs

--------------------------------------------------------------------------------------
做完上面的后,yum客户端用如下三条命令后,然后就可以“列出组软件包”了
yum clean all
yum makecache
yum list
如下:
[root@BG-DB:/etc/yum.repos.d]$more centos5.9.repo
[centos5.9]
name=centos5.9
baseurl=ftp://192.168.1.202/
enabled=1
gpgcheck=0
[root@BG-DB:/etc/yum.repos.d]$
[root@BG-DB:/etc/yum.repos.d]$yum grouplist
Setting up Group Process
Installed Groups:
   Administration Tools
   Dialup Networking Support
   Editors
   FTP Server
   Legacy Network Server
   Mail Server
   MySQL Database
   Network Servers
   System Tools
Available Groups:
   Authoring and Publishing
   Base
   Cluster Storage
   Clustering
   DNS Name Server
   Development Libraries
   Development Tools
   Eclipse
   Engineering and Scientific
   GNOME Desktop Environment
   GNOME Software Development
   Games and Entertainment
   Graphical Internet
   Graphics
   HyperV
   Java Development
   KDE (K Desktop Environment)
   KDE Software Development
   KVM
   Legacy Software Development
   Legacy Software Support
   News Server
   Office/Productivity
   OpenFabrics Enterprise Distribution
   PostgreSQL Database
   Printing Support
   Server Configuration Tools
   Sound and Video
   Text-based Internet
   Web Server
   Windows File Server
   X Software Development
   X Window System
   Xen
Done
[root@BG-DB:/etc/yum.repos.d]$

centos6.4搭建基于ftp的yum源让本地局域网服务器使用的更多相关文章

  1. 实验:基于http的yum源

    实验:基于http的yum源 selinux,firewalld已经关闭',系统为CentOS7 repodata所在的目录就是yum源 下面介绍了如何把本地光盘通过httpd服务器变成yum源:多个 ...

  2. 如何搭建ftp的yum源

                ftp的yum的搭建步骤 第一步:安装vsftpd程序包(系统已经安装) [root@station40 ~]# rpm -qa |grep vsftpd vsftpd-2.2 ...

  3. 内网环境上部署k8s+docker集群:集群ftp的yum源配置

    接触docker已经有一年了,想把做的时候的一些知识分享给大家. 因为公司机房是内网环境无法连接外网,所以这里所有的部署都是基于内网环境进行的. 首先,需要通过ftp服务制作本地的yum源,可以从ht ...

  4. centos配置网络yum源 和本地yum源

    一,网络yum源 1.备份 yum文件 cd /etc/ cp -r  yum.repos.d  yum.repos.d.bak 2.在系统联网的情况下执行下面命令下载 wget -O /etc/yu ...

  5. CentOS6.7搭建部署FTP服务 (详解主配置文件)

    FTP传输 三种解析: username -->UID  :/etc/passwd    将用户名转换成UID的库. hostname--->        IP   :DNS服务,/et ...

  6. 基于光盘配置yum源

    #开启自动挂载服务 systemctl start autofs #设置开机自动挂载 systemctl enable autofs #光盘自动挂载路径/misc/cd       “包含repoda ...

  7. yum管理——搭建iso镜像私有yum源仓库(1)

    在服务器上一般是没有光驱的,那么我们怎么制作iso本地repo镜像源仓库? 通过本地iso镜像,copy到linux系统中一个目录中,进行伪文件系统挂载,执行如下命令: 挂载:mount -o loo ...

  8. 搭建基于Docker社区版的Kubernetes本地集群

    Kubernetes的本地集群搭建是一件颇费苦心的活,网上有各种参考资源,由于版本和容器的不断发展,搭建的方式也是各不相同,这里基于Docker CE的18.09.0版本,在Mac OS.Win10下 ...

  9. 【Linux】YUM源搭建

    YUM是什么? YUM是什么 基于rpm但更胜于rpm的软件管理工具: YUM有服务端和客户端: 如果服务端和客户端在同一台机器,这是本地YUM: 如果服务端和客户端不在同一台机器,这是网络YUM. ...

随机推荐

  1. EDIUS和会声会影的区别

    最近经常听到大家讨论会声会影和EDIUS哪个好,有人说会声会影就相当于傻瓜相机,EDIUS相当于手动的相机:也有人说拍着玩的,简单玩玩的用会声会影,做出来画面很绚丽:剪辑片子,特效合成专业的就用EDI ...

  2. @Resource注解

    原文地址:http://blog.sina.com.cn/s/blog_a795a96f01016if1.html   @Resource 注解被用来激活一个命名资源(named resource)的 ...

  3. JQuery Pagenation 知识点整理——$.extend(),与$.fn.extend()应用(20150517)

    jQuery为开发插件提拱了两个方法,分别是: jQuery.fn.extend(); jQuery.extend(); 一. $.extend()方法 $.extend()方法在JQuery中有两个 ...

  4. oracle的listener.ora sqlnet.ora tnsnames.ora三个文件的关联性

    学习:http://www.cnblogs.com/william-lee/archive/2010/10/20/1856261.html 之前因为安装的是windows server 2008 r2 ...

  5. php 添加redis扩展(一)

    phpredis 下载地址 http://pan.baidu.com/s/1dFFK0gh  提取码:见评论,(~..)亲身试验,可行 1.下载到目录 cd /usr/local/src 2.解压 t ...

  6. HackerRank "Bike Racer"

    Just for study from its editorial~ Lesson learnt: an optimized Hungarian Algorithm: Hopcroft-Karp Al ...

  7. LintCode "Triangle Count"

    Should be "Medium" or even "Easy".. Just with a little Greedy. class Solution { ...

  8. Python 通过pickle标准库加载和保存数据对象

    import pickle with open('mydata.pickle','wb') as mysavedata: pickle.dump([1,2,'three'], mysavedata) ...

  9. windows类书的学习心得(转载)

    原文网址:http://www.blogjava.net/sound/archive/2008/08/21/40499.html 现在的计算机图书发展的可真快,很久没去书店,昨日去了一下,真是感叹万千 ...

  10. android学习笔记35——AnimationDrawable资源

    AnimationDrawable资源 AnimationDrawable,代表一个动画. android既支持传统的逐帧动画(类似于电影方式,一张图片一张图片的切换),也支持通过平移.变换计算出来的 ...