CentOS 构建本地源YUM服务

简介:

 想必大家对linux下的YUM服务并不陌生吧,之前有将linux下redhat构建YUM的步骤有写出来,今天主要写一下如何在centos下构建YUM,尽管centos是redhat的克隆版,但也有很多的不同之处;

此链接是讲解如何在redhat上构建YUM,http://www.linuxdiyf.com/bbs/viewthread.php?tid=204212&extra=page%3D2%26amp%3Borderby%3Ddateline
下面是CentOS下构建YUM的步骤
1.首先把镜像盘挂在上:mount /dev/cdrom /media/cdrom/
2.安装http的包,  rpm -ivh /media/cdrom/CentOS/httpd-2.2.3-43.el5.centos.i386.rpm
 3.安装YUM常用的RPM包(有的包是默认已经安装的,但也要查一下是否安装)
  rpm -ivh /media/cdrom/CentOS/yum-3.2.22-26.el5.centos.noarch.rpm
   rpm -ivh /media/cdrom/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
   rpm -ivh /media/cdrom/CentOS/yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm
   rpm -ivh /media/cdrom/CentOS/yum-updatesd-0.9-2.el5.noarch.rpm
 4.新建一个自定义的目录,用来放置你的RPM包,也是http访问的目录: /data/CentOS/i386/
将挂在的rpm包的集合复制一份到/data/CentOS/i386/下,(因为你不可能挂在你的镜像盘一辈子)
 \cp -rf /media/cdrom/CentOS/ /data/CentOS/i386/
5.将/media/cdrom下的repodata/ 拷贝到/data/CentOS/i386/CentOS下
 cp -rf /media/cdrom/repodata/ /data/CentOS/i386/CentOS/       (后面会用到的)
6.安装 rpm -ivh /media/cdrom/CentOS/createrepo-0.4.11-3.el5.noarch.rpm  (此包是用来安装服务端设置软件仓库及信息文件)
 rpm -ivh /media/cdrom/CentOS/createrepo-0.4.11-3.el5.noarch.rpm
7.先把http服务启动,service httpd start ,如果这个服务不能搞定,其他的一切都是做无用功)
 netstat -anpt | grep 80
tcp        0      0 :::80                       :::*                        LISTEN      8389/httpd
 8.生成客户端所需的信息文件
createrepo  -g /media/cdrom/repodata/comps.xml /data/CentOS/i386/
9.将key文件(用于客户端与服务端的认证)拷入指定目录/data/CentOS/i386 下
cp /media/cdrom/RPM-GPG-KEY-CentOS-5 /data/CentOS/i386/
10.修改http服务的配置文件,如何你是默认安装的httpd,其配置文件路径为:
vi /etc/httpd/conf/httpd.conf
 修改一下两行即可:(显示的是更改后的)
DocumentRoot "/data/CentOS/"
<Directory "/data/CentOS/">
之后保存,退出。。重启httpd服务、、、service httpd restart

11.用你的IE浏览器浏览下,看能不能访问 http://172.16.17.140/i386/CentOS/ 下面显示的是rpm包算是正却的

12.更改yum的配置文件,更改之前要做好备份
、cp CentOS-Base.repo CentOS-Base.repo.bak
 之后清空你的CentOS-Base.repo 文件
方法:> CentOS-Base.repo  即可
vi CentOS-Base.repo
 [base]
name=CentOS5.3-base
baseurl=http://172.16.17.140/i386/
enable=1
gpgcheck=1
gpgkey=http://172.16.17.140/i386/RPM-GPG-KEY-CentOS-5
这样即可了
下面就是测试了。。。
先执行下yum clean all
之后验证下

[root@centos yum.repos.d]# yum install gcc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base                                                                                    | 1.1 kB     00:00     
base/primary                                                                            | 912 kB     00:00     
base                                                                                                 2599/2599
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc.i386 0:4.1.2-48.el5 set to be updated
--> Processing Dependency: libgomp >= 4.1.2-48.el5 for package: gcc
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc
--> Running transaction check
---> Package glibc-devel.i386 0:2.5-49 set to be updated
--> Processing Dependency: glibc-headers = 2.5-49 for package: glibc-devel
--> Processing Dependency: glibc-headers for package: glibc-devel
---> Package libgomp.i386 0:4.4.0-6.el5 set to be updated
--> Running transaction check
---> Package glibc-headers.i386 0:2.5-49 set to be updated
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers
--> Processing Dependency: kernel-headers for package: glibc-headers
--> Running transaction check
---> Package kernel-headers.i386 0:2.6.18-194.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package                        Arch                 Version                        Repository            Size
===============================================================================================================
Installing:
 gcc                            i386                 4.1.2-48.el5                   base                 5.2 M
Installing for dependencies:
 glibc-devel                    i386                 2.5-49                         base                 2.0 M
 glibc-headers                  i386                 2.5-49                         base                 601 k
 kernel-headers                 i386                 2.6.18-194.el5                 base                 1.0 M
 libgomp                        i386                 4.4.0-6.el5                    base                  70 k

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

Total download size: 8.9 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): libgomp-4.4.0-6.el5.i386.rpm                                                     |  70 kB     00:00     
(2/5): glibc-headers-2.5-49.i386.rpm                                                    | 601 kB     00:00     
(3/5): kernel-headers-2.6.18-194.el5.i386.rpm                                           | 1.0 MB     00:00     
(4/5): glibc-devel-2.5-49.i386.rpm                                                      | 2.0 MB     00:00     
(5/5): gcc-4.1.2-48.el5.i386.rpm                                                        | 5.2 MB     00:00     
---------------------------------------------------------------------------------------------------------------
Total                                                                           14 MB/s | 8.9 MB     00:00     
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
base/gpgkey                                                                             | 1.5 kB     00:00     
Importing GPG key 0xE8562897 "CentOS-5 Key (CentOS 5 Official Signing Key) <centos-5-key@centos.org>" from http://172.16.17.140/i386/RPM-GPG-KEY-CentOS-5
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : libgomp                                                                                 1/5
   Installing     : kernel-headers                                                                          2/5
   Installing     : glibc-headers                                                                           3/5
   Installing     : glibc-devel                                                                             4/5
   Installing     : gcc                                                                                     5/5

 Installed:
  gcc.i386 0:4.1.2-48.el5                                                                                      

Dependency Installed:
  glibc-devel.i386 0:2.5-49        glibc-headers.i386 0:2.5-49       kernel-headers.i386 0:2.6.18-194.el5      
  libgomp.i386 0:4.4.0-6.el5      

Complete!

OK、、、、、没有问题的,以上如有问题,请QQ联系,QQ群:140704742 

推荐学习论坛:http://www.linuxdiyf.com/bbs/?fromuid=346054



      本文转自天真花语  51CTO博客,原文链接:http://blog.51cto.com/caibird/631226,如需转载请自行联系原作者




相关文章
|
16天前
|
缓存 Linux Docker
CentOS 7 下安装 Docker 及配置阿里云加速服务
CentOS 7 下安装 Docker 及配置阿里云加速服务
293 1
|
8天前
|
关系型数据库 MySQL Linux
Linux部署实战前言,MySQL在CentOS安装【单机软件】,MySQL的安装需要root权限,yum install mysql,systemctl enable mysqld开机自启的意思
Linux部署实战前言,MySQL在CentOS安装【单机软件】,MySQL的安装需要root权限,yum install mysql,systemctl enable mysqld开机自启的意思
|
10天前
|
缓存 Linux 开发工具
centos设置ntp服务同步目标服务器时间
【7 月更文挑战第 1天】linux+centos设置ntp服务同步目标服务器时间
|
11天前
|
缓存 Linux 开发工具
docker的centos容器使用yum报错
docker的centos容器使用yum报错
46 0
|
15天前
|
网络协议 Linux Shell
如何在 CentOS 中配置 SSH 服务的 TCP 端口转发
如何在 CentOS 中配置 SSH 服务的 TCP 端口转发
26 0
|
2月前
|
Shell Linux 应用服务中间件
centos系统内容器部署服务访问不到是因为run后面加了bash
centos系统内容器部署服务访问不到是因为run后面加了bash
|
2月前
|
安全 Linux 虚拟化
解决Centos7 yum 出现could not retrieve mirrorlist 错误
在新安装的CentOS7.x通过VMware后,遇到无法通过`ip addr`获取IP地址以及`yum`安装软件时加载镜像列表失败的问题。
258 2
|
1月前
|
缓存 Linux
CentOS7添加阿里云yum源
CentOS7添加阿里云yum源
819 0
|
1月前
|
弹性计算 Linux
(已解决) centos6.5 yum源 失效 The whole CentOS 6 is dead and shouldn’t be used anywhere at all
(已解决) centos6.5 yum源 失效 The whole CentOS 6 is dead and shouldn’t be used anywhere at all
66 0
|
1月前
|
开发工具
centos8 yum安装mysql8 流程配置
centos8 yum安装mysql8 流程配置
213 0