LINUX制做本地YUM源

1.  先启动HTTPD服务,挂载光驱, 并拷贝光盘中所有目录到指定的目录下。

[root@localhost ~]# service httpd start
Starting httpd:                                            [  OK  ]
[root@localhost ~]# chkconfig httpd on

[root@localhost ~]# mount /dev/cdrom /mnt
mount: block device /dev/cdrom is write-protected, mounting read-only

[root@localhost ~]# mkdir -p /var/www/html/yum
[root@localhost ~]# mkdir -p /var/www/html/yum/CentOS
[root@localhost ~]# cp /mnt/CentOS/* /var/www/html/yum/CentOS/



2. 安装索引创建程序:

[root@localhost ~]# rpm -ivh /mnt/CentOS/createrepo-0.4.11-3.el5.noarch.rpm 
warning: /mnt/CentOS/createrepo-0.4.11-3.el5.noarch.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
   1:createrepo             ########################################### [100%]


3. 生成XML METEDATA

[root@localhost ~]# createrepo /var/www/html/yum/CentOS/
3535/3535 - xjavadoc-javadoc-1.1-4jpp.1.x86_64.rpm                              pm
Saving Primary metadata
Saving file lists metadata
Saving other metadata


4. 修改CentOS-Base.repo 文件

[root@localhost etc]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo
[root@localhost yum.repos.d]# cp CentOS-Base.repo CentOS-Base.repo.bak

[root@localhost yum.repos.d]# echo "" > CentOS-Base.repo
[root@localhost yum.repos.d]# vi 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
baseurl=http://192.168.102.120/yum/CentOS
enabled=1
gpgcheck=0
 
#released updates 
[updates]
name=CentOS-$releasever - Updates
baseurl=http://192.168.102.120/yum/CentOS
gpgcheck=1
enabled=1
gpgcheck=0
 
#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
baseurl=http://192.168.102.120/yum/CentOS
enabled=1
gpgcheck=0
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://192.168.102.120/yum/CentOS
enabled=1
gpgcheck=0
 
 
#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-5
 
#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-5


配置完毕, 测试安装:

[root@localhost yum.repos.d]# yum install mc
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
addons                                                                                                                        |  951 B     00:00     
addons/primary                                                                                                                | 1.2 MB     00:00     
addons                                                                                                                                     3535/3535
base                                                                                                                          |  951 B     00:00     
base/primary                                                                                                                  | 1.2 MB     00:00     
base                                                                                                                                       3535/3535
extras                                                                                                                        |  951 B     00:00     
extras/primary                                                                                                                | 1.2 MB     00:00     
extras                                                                                                                                     3535/3535
updates                                                                                                                       |  951 B     00:00     
updates/primary                                                                                                               | 1.2 MB     00:00     
updates                                                                                                                                    3535/3535
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mc.x86_64 1:4.6.1a-35.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================================
 Package                       Arch                              Version                                     Repository                         Size
=====================================================================================================================================================
Installing:
 mc                            x86_64                            1:4.6.1a-35.el5                             addons                            2.1 M

Transaction Summary
=====================================================================================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 2.1 M
Is this ok [y/N]: y
Downloading Packages:
mc-4.6.1a-35.el5.x86_64.rpm                                                                                                   | 2.1 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : mc                                                                                                                            1/1 

Installed:
  mc.x86_64 1:4.6.1a-35.el5                                                                                                                          

Complete!


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值