yum之如何手动创建本地yum仓库

简介:
  1. 首先先安装createrepo-0.9.9-17.el6.noarch.rpm
           我之前搭建过yum,所以我直接用yum install直接安装

           我的系统是redhat6

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
[root@localhost rpm-gpg] # yum install createrepo
Loaded plugins: product- id , refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package createrepo.noarch 0:0.9.9-17.el6 will be installed
--> Processing Dependency: python-deltarpm  for  package: createrepo-0.9.9-17.el6.noarch
--> Running transaction check
---> Package python-deltarpm.x86_64 0:3.5-0.5.20090913git.el6 will be installed
--> Processing Dependency: deltarpm = 3.5-0.5.20090913git.el6  for  package: python-deltarpm-3.5-0.5.20090913git.el6.x86_64
--> Running transaction check
---> Package deltarpm.x86_64 0:3.5-0.5.20090913git.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
  Package            Arch      Version                      Repository      Size
================================================================================
Installing:
  createrepo         noarch    0.9.9-17.el6                 rhel- source      94 k
Installing  for  dependencies:
  deltarpm           x86_64    3.5-0.5.20090913git.el6      rhel- source      71 k
  python-deltarpm    x86_64    3.5-0.5.20090913git.el6      rhel- source      27 k
Transaction Summary
================================================================================
Install       3 Package(s)
Total download size: 192 k
Installed size: 518 k
Is this ok [y /N ]: y
Downloading Packages:
--------------------------------------------------------------------------------
Total                                           667 kB /s  | 192 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
   Installing : deltarpm-3.5-0.5.20090913git.el6.x86_64                      1 /3
   Installing : python-deltarpm-3.5-0.5.20090913git.el6.x86_64               2 /3
   Installing : createrepo-0.9.9-17.el6.noarch                               3 /3
rhel- source /productid                                     | 1.7 kB     00:00 ...
   Verifying  : python-deltarpm-3.5-0.5.20090913git.el6.x86_64               1 /3
   Verifying  : createrepo-0.9.9-17.el6.noarch                               2 /3
   Verifying  : deltarpm-3.5-0.5.20090913git.el6.x86_64                      3 /3
Installed:
   createrepo.noarch 0:0.9.9-17.el6
Dependency Installed:
   deltarpm.x86_64 0:3.5-0.5.20090913git.el6
   python-deltarpm.x86_64 0:3.5-0.5.20090913git.el6
Complete!
You have new mail  in  /var/spool/mail/root
1
2
[root@localhost rpm-gpg] # rpm -qa | grep createrepo
createrepo-0.9.9-17.el6.noarch

我已经安装成功

2.  在/root下mkdir一个文件夹epel,我把我之前挂载在/mnt/Packages下的*.rpm  copy到/root/epel

3. 在/etc/yum.repos.d下修改rhel-source.repo文件(可能文件名称不同)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@localhost yum.repos.d] # pwd
/etc/yum .repos.d
[root@localhost yum.repos.d] # ls
rhel- source .repo
[root@localhost yum.repos.d] # cat rhel-source.repo
[rhel-Base]
name=Red Hat
baseurl= file : ///mnt
enabled=1
gpgcheck=0
[epel]
name=epel
baseurl= file : ///root/epel
enabled=1
gpgcheck=0
[root@localhost yum.repos.d] #

【epel】是我新添加的配置

4. 我们执行 yum repolist命令看一下

1
2
3
4
5
6
7
8
9
10
[root@localhost yum.repos.d] # yum repolist
Loaded plugins: product- id , refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
file : ///root/epel/repodata/repomd .xml: [Errno 14] Could not  open /read  file : ///root/epel/repodata/repomd .xml
Trying other mirror.
repo  id                                repo name                           status
epel                                  epel                                0
rhel-Base                             Red Hat                             0
repolist: 0
[root@localhost yum.repos.d] #

repo id  和repo name已经显示出了新添加的epel,但是出错了缺少repomd.xml,下面我来创建一个repomd.xml

5.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[root@localhost yum.repos.d] # createrepo /root/epel/
Spawning worker 0 with 15 pkgs
Workers Finished
Gathering worker results
Saving Primary metadata
Saving  file  lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@localhost yum.repos.d] # ls /root/epel/
php-5.3.3-22.el6.x86_64.rpm         php-pear-1.9.4-4.el6.noarch.rpm
php-cli-5.3.3-22.el6.x86_64.rpm     php-pecl-apc-3.1.9-2.el6.x86_64.rpm
php-common-5.3.3-22.el6.x86_64.rpm  php-pecl-memcache-3.0.5-4.el6.x86_64.rpm
php-gd-5.3.3-22.el6.x86_64.rpm      php-pgsql-5.3.3-22.el6.x86_64.rpm
php-ldap-5.3.3-22.el6.x86_64.rpm    php-soap-5.3.3-22.el6.x86_64.rpm
php-mysql-5.3.3-22.el6.x86_64.rpm   php-xml-5.3.3-22.el6.x86_64.rpm
php-odbc-5.3.3-22.el6.x86_64.rpm    php-xmlrpc-5.3.3-22.el6.x86_64.rpm
php-pdo-5.3.3-22.el6.x86_64.rpm     repodata
[root@localhost yum.repos.d] #

   我先yum clean all清除下缓存并yum repolist下看有没有出错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@localhost yum.repos.d] # yum clean all
Loaded plugins: product- id , refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: epel rhel-Base
Cleaning up Everything
[root@localhost yum.repos.d] # yum repolist
Loaded plugins: product- id , refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
epel                                                     | 2.9 kB     00:00 ...
epel /primary_db                                           |  14 kB     00:00 ...
rhel-Base                                                | 3.9 kB     00:00 ...
rhel-Base /primary_db                                      | 3.1 MB     00:02 ...
repo  id                                repo name                           status
epel                                  epel                                   15
rhel-Base                             Red Hat                             3,648
repolist: 3,663
[root@localhost yum.repos.d] #

yum repolist没有出错,看来我们创建成功了。

6.  测试

        yum list

        yum list all   

        yum install 安装一个软件

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
31
32
[root@localhost epel] # yum install php-5.3.3-22.el6.x86_64.rpm
Loaded plugins: product- id , refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-m   anager to register.
Setting up Install Process
Examining php-5.3.3-22.el6.x86_64.rpm: php-5.3.3-22.el6.x86_64
Marking php-5.3.3-22.el6.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:5.3.3-22.el6 will be installed
--> Processing Dependency: php-cli(x86-64) = 5.3.3-22.el6  for  package: php-5.3.3-22.el6.x86_   64
--> Processing Dependency: php-common(x86-64) = 5.3.3-22.el6  for  package: php-5.3.3-22.el6.x   86_64
--> Running transaction check
---> Package php-cli.x86_64 0:5.3.3-22.el6 will be installed
---> Package php-common.x86_64 0:5.3.3-22.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================
  Package           Arch          Version              Repository                       Size
============================================================================================
Installing:
  php               x86_64        5.3.3-22.el6          /php-5 .3.3-22.el6.x86_64        3.5 M
Installing  for  dependencies:
  php-cli           x86_64        5.3.3-22.el6         epel                            2.2 M
  php-common        x86_64        5.3.3-22.el6         epel                            524 k
Transaction Summary
============================================================================================
Install       3 Package(s)
Total size: 6.2 M
Total download size: 2.7 M
Installed size: 13 M
Is this ok [y /N ]: ^CExiting on user Command
[root@localhost epel] #




本文转自 zhangguangyihttp://blog.51cto.com/bosszhang/1678304  51CTO博客,原文链接:

相关文章
|
11月前
|
缓存
详解CentOS8更换yum源后出现同步仓库缓存失败的问题
详解CentOS8更换yum源后出现同步仓库缓存失败的问题
450 0
|
Linux 应用服务中间件 nginx
CentOS7搭建yum源仓库(阿里源)
CentOS7搭建yum源仓库(阿里源)
2519 0
|
1月前
|
关系型数据库 MySQL Linux
MySQL8官方YUM仓库使用指南
MySQL 8 是广受欢迎的开源关系数据库管理系统,引入了诸多新特性和性能提升。本文介绍如何在 Linux 上通过 MySQL 官方 YUM 仓库安装和管理 MySQL 8。首先配置 YUM 仓库并安装 MySQL,启动服务后获取临时密码并登录。接着创建数据库与用户,使用 SQL 命令创建表格、插入及查询数据。此方法简便高效,适合快速上手 MySQL 8 的基本操作。
139 13
|
8月前
|
缓存 Linux 网络安全
解决 CentOS 7 官方 yum 仓库无法使用的最佳实践
【8月更文挑战第18天】若 CentOS 7 的官方 YUM 仓库无法使用,可按以下步骤解决: 1. **检查网络连接**: - 确认服务器能正常上网,可通过访问外部网站或网络诊断测试。 - 检查防火墙设置,避免其阻挡 YUM 的网络访问。 2. **检查 YUM 配置**: - 核实 `/etc/yum.repos.d/` 下的 `CentOS-Base.repo` 文件中仓库地址正确无误。 - 确认配置文件内的 `enabled` 选项设为 `1` 以启用仓库。
3115 0
|
10月前
|
Ubuntu Python
银河麒麟-麒麟软件操作系统 kylin 搭建yum源 ubuntu搭建yum源 yum软件仓库搭建ftp源、python源、硬盘源
银河麒麟-麒麟软件操作系统 kylin 搭建yum源 ubuntu搭建yum源 yum软件仓库搭建ftp源、python源、硬盘源
1123 1
|
11月前
|
存储 缓存 Unix
|
11月前
|
缓存 Linux 测试技术
搭建本地YUM仓库
在Redhat 9系统中,通过挂载系统安装盘到/mnt,然后创建本地YUM仓库以实现软件包管理。首先查看磁盘挂载情况,将ISO镜像挂载到/mnt。接着,备份`/etc/yum.repos.d/`目录内容,删除原有仓库,创建`loaclhost.repo`文件并配置指向/mnt中的Package目录。运行`yum clean all`清除缓存,`yum makecache`建立元数据。最后,成功通过新配置的本地仓库安装了bind软件及其依赖。
356 3
|
11月前
|
缓存
简易yum仓库搭建
简易yum仓库搭建,实验准备,获取yum仓库、安装httpd,客户机配置yum源,测试、验证
177 0
|
缓存 安全 网络协议
部署YUM仓库及NFS共享服务
部署YUM仓库及NFS共享服务
266 0
|
缓存 运维
【运维知识进阶篇】一键部署yum本地仓库
【运维知识进阶篇】一键部署yum本地仓库
512 0