当前位置: > Linux教程 > linux基础 >

LINUX制做本地YUM源

时间:2015-01-21 17:51来源:linux.it.net.cn 作者:IT
1.  先启动HTTPD服务,挂载光驱, 并拷贝光盘中所有目录到指定的目录下。
[sql] view plaincopy在CODE上查看代码片派生到我的代码片
[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. 安装索引创建程序:
[sql] view plaincopy在CODE上查看代码片派生到我的代码片
[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
[delphi] view plaincopy在CODE上查看代码片派生到我的代码片
[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 文件
[sql] view plaincopy在CODE上查看代码片派生到我的代码片
[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  
 
配置完毕, 测试安装:
[sql] view plaincopy在CODE上查看代码片派生到我的代码片
[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!  
 
(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容