使用发行版光盘搭建本地yum源

简介:

在Linux主机中使用YUM工具在线安装、更新软件时,往往会因网速不稳定或者中途网络中断而导致无法正常升级或安装软件,而搭建本地YUM源就无需为此而苦恼,因为其资源就存放在本地,而不受Internet的网络限制,从而可以提升局域网内更新软件的效率


一、首先挂在光盘镜像

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@1inux /]#  mkdir  /mnt/cdrom
[root@1inux /]# mount -r /dev/cdrom /mnt/cdrom
[root@1inux /]# mount
/dev/mapper/vg0-root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
/dev/mapper/vg0-usr on /usr type ext4 (rw)
/dev/mapper/vg0- var  on / var  type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sr0 on /mnt/cdrom type iso9660 (ro)
[root@1inux /]#


二、创建本地目录/yum ,然后将光盘内的文件复制到此目录

1
2
3
4
5
6
7
8
[root@1inux /]#  mkdir  /yum
[root@1inux /]# cp -R /mnt/cdrom/* /yum
[root@1inux yum]# ls /yum
CentOS_BuildTag  isolinux                  RPM-GPG-KEY-CentOS-Debug-6
EFI              Packages                  RPM-GPG-KEY-CentOS-Security-6
EULA             RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-Testing-6
GPL              repodata                  TRANS.TBL
images           RPM-GPG-KEY-CentOS-6


三、新建yum repo配置文件

---------repo文件详解---------------------------

[repositoryid]

# 对于当前系统的yum来讲,此repositoryid用于惟一标识此repository指向,因此,其必须惟一;

name= 

# 当前仓库描述信息;

baseurl=url://path/to/repository/

# 指明repository的访问路径;通常为一个文件服务器上输出的某repository;

url:

ftp服务

ftp://SERVER/PATH/TO/REPOSITORY

http服务

http://SERVER/PATH/TO/REPOSITORY

本地目录:

file:///PATH/TO/REPOSTIROY


enabled={1|0}

此仓库是否可被使用

gpgcheck={1|0}

是否对程序包做校验

gpgkey=url://path/to/keyfile

指明gpgkey文件路径;

cost=#

指明当前repository的访问开销,默认为1000;

-------------------------------------

1
2
3
4
5
6
7
[root@1inux /]# vim /etc/yum.repos.d/CD-Local.repo
[CD-Local]
name=CentOS 6.6 X86_64 on dvd1
baseurl=file: ///yum
gpgcheck=0
enabled=1
~

      

四、清除并删除记录,然后查看 yum 源的配置


清除记录

1
2
3
4
5
[root@1inux /]# yum clean all
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: CD-Local
Cleaning up Everything
Cleaning up list of fastest mirrors

删除就记录

1
2
[root@1inux /]# rm -rf / var /cache/yum/*
[root@1inux /]#


查看yum 配置

1
2
3
4
5
6
[root@1inux yum]# yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
repo id                                                    repo name                                                                    status
CD-Local                                                   CentOS 6.6 X86_64 on dvd1                                                    6,518
repolist: 6,518

至此 我们的本地yum源已经搭建完毕,


五、为了验证我们使用发行光盘制作的yum源可用,接下来我们使用我们本地搭建的yum 源安装zsh软件


1、首先我们查看本机是否已经安装了zsh软件

1
2
[root@1inux /]# rpm -qa zsh
[root@1inux /]#

发现并没有安装

2、使用本地搭建的yum源安装zsh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
[root@1inux /]# yum install zsh
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package zsh.x86_64 0:4.3.10-7.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================
  Package                    Arch                          Version                             Repository                       Size
====================================================================================================================================
Installing:
  zsh                        x86_64                        4.3.10-7.el6                        CD-Local                        2.1 M
Transaction Summary
====================================================================================================================================
Install       1 Package(s)
Total download size: 2.1 M
Installed size: 4.8 M
Is this ok [y/N]: y     //输入Y 确认安装
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
   Installing : zsh-4.3.10-7.el6.x86_64                                                                                          1/1 
   Verifying  : zsh-4.3.10-7.el6.x86_64                                                                                          1/1 
Installed:
   zsh.x86_64 0:4.3.10-7.el6                                                                                                         
Complete!

显示已将安装完毕


验证是否安装完毕:

1
2
3
4
5
6
7
8
9
10
11
[root@1inux yum]# cat /etc/shells 
/bin/sh
/bin/bash
/sbin/nologin
/bin/dash
/bin/tcsh
/bin/csh
/bin/zsh
[root@1inux /]# rpm -qa zsh
zsh-4.3.10-7.el6.x86_64
[root@1inux /]#



OK  至此 我们使用发行光盘创建的本地yum源已经搭建完毕

本文转自 1inux 51CTO博客,原文链接:http://blog.51cto.com/1inux/1630801
相关文章
|
9天前
|
Linux C语言
linux yum安装ffmpeg 图文详解
linux yum安装ffmpeg 图文详解
27 0