本地搭建yum源方法【二】

1. 搭建本地光盘YUM源

[[email protected] ~]# mkdir /mnt/cdrom/  ------》创建光盘挂载目录

[[email protected] ~]# mount /dev/cdrom /mnt/cdrom/  --------》挂在光盘

[[email protected] ~]# cd /etc/yum.repos.d/    --------》切换到YUM配置目录

[[email protected] yum.repos.d]# tar czf repo.tar.gz ./*  --------》将原来所有的文件进行打包备份

[[email protected]yum yum.repos.d]# rm -f CentOS*   --------》删除原文件

[[email protected] yum.repos.d]# vim CentOS-Media.repo   --------》配置光盘源文件

[c6-media]

name=CentOS-$releasever - Media

baseurl=file:///mnt/cdrom    --------》这里为你光盘的挂载目录

gpgcheck=1    --------》是否启动检查GPG-KEY

enabled=1      --------》是否启用YUM源

gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-6  --》指定挂载目录下的GPG-KEY文件

验证:

2. 如果要让公司所有的Linux主机可用内部源服务,可以用FTP/HTTP搭建一个YUM服务器,由于Http较为简便,我这里就以HTTP的方式搭建一个YUM服务了。

继上面的操作,我借用本地光盘源搭建一个HTTP的YUM服务!

2.1

HTTP我在上面已经通过YUM的方式安装了,如果大家没有安装可以通过光盘里面的安装包进行安装,联网也可以通过网络的YUM进行安装。启动http服务!关闭防火墙和SELinux!

[[email protected] ~]# service  httpd start

Starting httpd: httpd: apr_sockaddr_info_get() failed for yum.server    [  OK  ]

[[email protected] ~]# chkconfig httpd on

[[email protected] ~]# service iptables stop

[[email protected] ~]# chkconfig iptables off

[[email protected] ~]# setenforce 0

2.2

在Apache根目录下建立子文件夹,如果想让本YUM服务器为不同版本的Linux服务,可根据情况创建目录,然后将光盘内所有的文件CP至该目录!

注:一般使用DVD1即可,当然也可以合并DVD1和DVD2来作为源。

[[email protected] ~]# mkdir -p /var/www/html/yum

[[email protected] ~]# mkdir -p /var/www/html/yum/CentOS-6

[[email protected] ~]# cp -prf /mnt/cdrom/* /var/www/html/yum/CentOS-6/

2.3

客户端修改CentOS-Base.repo,建议先备份一个副本哦,这样以后要从外网更新的话,可以再用。

[[email protected] yum.repos.d]# cp CentOS-Base.repo CentOS-Base.repo.bak1

[[email protected] yum.repos.d]# vim CentOS-Base.repo

###################CentOS-Base.repo内容修改后,如下#####################


# CentOS-Base.repo

#

# The mirror system uses the connecting IP address of the client and the

# update status of each mirror to pick mirrors that are updated to and

# geographically close to the client.  You should use this for CentOS updates

# unless you are manually picking other mirrors.

#

# If the mirrorlist= does not work for you, as a fall back you can try the

# remarked out baseurl= line instead.

#

#

[base]

name=CentOS-$releasever - Base

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os

baseurl=http://172.20.1.11/yum/CentOS-6

enable=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#released updates

[updates]

name=CentOS-$releasever - Updates

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates

baseurl=http://172.20.1.11/yum/CentOS-6

enable=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras

baseurl=http://172.20.1.11/yum/CentOS-6

enable=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus

#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users

[contrib]

name=CentOS-$releasever - Contrib

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib

#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

centosplus][contrib]的内容不需要修改,它们的enabled值默认值是0,即模块不启用。

2.4

客户端测试!

附加:

DVD1和DVD2文件合并的步骤:

1.将DVD2光盘中Packages目录下所有的rpm文件CP到DVD1的目录下。

Cp /mnt/dvd2/Packages/*.rpm /var/www/html/yum/CentOS-6/Packages/

2.合并TRANS.TBL,将DVD2中TRANS.TBL的信息追加到DVD1中TRANS.TBL后面, 并排序保存。

cat  mnt/dvd2/Packages/TRANS.TBL >> /var/www/html/yum/centos-6/Packages/TRANS.TBL

Mv  /var/www/html/yum/centos-6/Packages/{TRANS.TBL,TRANS.TBL.BAK}

Sort  /var/www/html/yum/centos-6/Packages/TRANS.TBL.BAK/var/www/html/yum/centos-6/Packages/TRANS.TBL

时间: 2024-08-04 18:16:47

本地搭建yum源方法【二】的相关文章

本地搭建yum源方法【一】

YUM源服务器搭建 1.创建文件夹 我们先创建存放 .RPM的目录 [[email protected] conf]# >>mkdir -p /var/www/html/centos/7/os/x86_64/Packages/ 2.我们可以将光盘镜像Packages目录里的 .rpm包复制到 /var/www/html/centos/7/os/x86_64/Packages/目录,这里我仅做测试,复制了几个包进去: 在浏览器上输入网址: 3.安装createrepo,此程序主要用于生成创建yu

VM中CentOS7本地配置yum源方法

因为虚拟机中安装CentOS7未联网,所以通过本地配置yun源来实现安装操作. 一.通过光盘当做本地yum仓库 1.挂载当前光盘至某目录 ]#mount /dev/cdrom  /mnt 或者# mount -r -t iso9660 /dev/cdrom /media/cdrom 2.创建配置文件 首先将以前的配置文件全都移至新建目录 ]#cd  /etc/yum.repos.d ]#mkdir repodir ]#mv CentOS* repodir 新建一个配置文件: ]#vim loca

三种方式搭建yum源

1.本地搭建yum源: [[email protected] x86_64]# vim /etc/yum.repos.d/mnt.repo [[email protected] x86_64]# cd /etc/yum.repos.d/ [[email protected] yum.repos.d]# ll total 36 -rw-r--r--. 1 root root 1664 Dec  9  2015 CentOS-Base.repo -rw-r--r--. 1 root root 130

Linux系统中搭建本地光盘yum源

搭建本地光盘yum源 第一步:放入CentOS安装光盘,并挂载光盘到指定位置:命令如下: [[email protected] ~]#mkdir /mnt/cdrom #创建cdrom目录,作为光盘的挂载点 [[email protected] ~]#mount -t iso9660 /dev/cdrom1 /mnt/cdrom/ mount: block device /dev/sr0 is write-protected mounting read-only #挂载光盘到/mnt/cdrom

本地光盘yum源的搭建

有时候由于网络等其他原因的限制,不能随时使用yum到网上去获取rpm包,这样我们可以配置本地光盘yum源. 下面简要介绍一下本地光盘yum源的搭建 1.挂载本地iso镜像文件mount /dev/sr0 /media/cdrom 2.修改yum源配置文件vim /etc/yum.repos.d/rhel-source.repo 修改内容如下[rhel-source]name=Red Hat Enterprise Linuxbaseurl=file:///media/cdrom      前两个/

搭建yum源,配置yum源

centos软件包不外乎有三大类: 镜像下载的dvd1 里面的 为base 基础包 镜像下载的dvd2 里面的 为Extra  扩展包 互联网上的其他的为  epel包 epel源的官方地址 http://fedoraproject.org/wiki/EPEL/zh-cn 不能说搭建yum源,应该是配置yum源:方法有两种: 方法一: 用网上的: repo源 一般是各大镜像站点把目标指向各大安装包, 你要确保你现在文件所指向的阿里源的路径下要有repodata目录 方法二: 自己搭建:

搭建YUM源

一.实求要求: 1. CentOS 6.4为YUM源, 实现CentOS 6.4从YUM源下载RPM包 二.实验环境: VMware + CentOS 6.4x64 (2台) 三.配置: 1. 开启CentOS 6.4, 配置静态IP地址 [[email protected] 桌面]# vim /etc/udev/rules.d/70-persistent-net.rules [[email protected] 桌面]# vim /etc/sysconfig/network-scripts/i

linux:网络yum源和制作本地光盘yum源

linux:存放yum源的位置:/etc/yum.repos.d/,该目录下全是一些yum源 一.网络yum源: 如图:下面全部都是yum源,后缀是".repo"都是合法的yum源,默认的是启动的CentOS-Base.repo这个yum源(网络yum源) [[email protected] yum.repos.d]# ls -l total 28 -rw-r--r--. 1 root root 1664 Dec 9 2015 CentOS-Base.repo --- 网络yum源

24. 文件系统——制作本地的yum源

之前使用的yum仓库,是直接将baseurl设置为官方镜像,或者是安装光盘.本节内容将介绍如何将互联网上下载到本地的rpm包制作成本地的yum源.定制yum源的命令是 createrepo: [[email protected] ~]# createrepo -bash: createrepo: command not found # 该命令尚未安装,可以使用yum安装 [[email protected] ~]# yum -y install createrepo Loaded plugins