我现在在学用 yum 创建本地软件仓库 当我把镜像文件挂载进来后 发现找不到yum的配置文件 请教高手 linux虚拟机如何安装本地yum源?

\u6c42\u52a9\uff0c\u672c\u4eba\u7cfb\u7edf\u662fCentos 5.4\u73b0\u5728\u5df2\u7ecf\u628a\u955c\u50cf\u6302\u8f7d\u5230\u4e86media\u76ee\u5f55\u4e0b\uff0c\u5982\u4f55\u628a\u672c\u5730\u7684\u955c\u50cf\u914d\u7f6e\u6210yum\u6e90\u5462\uff1f

\u6211\u7684\u662f6.2\u7684

\u5148\u6302\u8f7d\u5149\u76d8
mount -t iso9660 /dev/cdrom /mnt/cdrom
\u6302\u955c\u50cf
mount -t iso9660 -o loop /mnt/winf/centos6.iso /mnt/cdrom

\u7f16\u8f91/etc/yum.repos.d/CentOS-Media.repo
[c6-media] //\u8fd9\u91cc\u4f60\u7684\u53ef\u80fd\u662f[c5-media]\u4e0b\u9762\u4e5f\u8981\u968f\u7740\u6539\u6210\u8fd9\u4e2a

\u6539baseurl=file:///mnt/cdrom
\u6267\u884cyum --disablerepo=* --enablerepo=c6-media install xxx
\u5c31\u53ea\u4f7f\u7528\u672c\u5730\u5149\u76d8\u6e90\u6765yum
\u7f16\u8f91~/.bashrc \u8ffd\u52a0\u4e2aalias yu='yum --disablerepo=* --enablerepo=c6-media'
\u6267\u884csource ~/.bashrc
\u4ee5\u540e\u7528yu install xxx\u5c31\u80fd\u5b89\u88c5\u4e86

1.\u521b\u5efa\u4e2a\u76ee\u5f55
mkdir /var/yum
\u5e76\u4ece\u5149\u76d8\u4ecb\u8d28\u4e2d\u628aServer\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u6587\u4ef6\u62f7\u8d1d\u5230\u521a\u521b\u5efa\u7684\u76ee\u5f55\u91cc(/var/yum)\u3002
cp -r /media/cdrom /var/yum
2.\u5b89\u88c5createrepo
createrepo\u662f\u914d\u7f6eYUM\u6e90\u7684\u914d\u7f6e\u5de5\u5177\uff0c\u68c0\u67e5\u5f53\u524d\u662f\u5426\u5df2\u7ecf\u5b89\u88c5createrepo\u5305\u7684\u5b89\u88c5\u60c5\u51b5\uff1a
# rpm -qa |grep createrepo
\u5982\u679c\u663e\u793a\u4e3a\u5c1a\u672a\u5b89\u88c5\uff0c\u5219\u9700\u8981\u6267\u884c\u5982\u4e0b\u7684\u547d\u4ee4\u5b8c\u6210\u5b89\u88c5\uff1a
# rpm -ivh /media/cdrom/Server/createrepo-0.4.4-2.fc6.noarch.rpm
ps\uff1a\u7248\u672c\u56e0\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c\u6709\u6240\u533a\u522b\uff0c\u8bf7\u67e5\u627e\u5f53\u524d\u7cfb\u7edf\u7684createrepo\u7248\u672crpm\u5305\u8fdb\u884c\u5b89\u88c5
3.\u521b\u5efayum repository\u7684xml-rpm-metadata
\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff1a
# createrepo -g /var/yum/Server/repodata/comps-rhel5-server-core.xml /var/yum/Server/
# createrepo -g /var/yum/VT/repodata/comps-rhel5-vt.xml /var/yum/VT/
# createrepo -g /var/yum/Cluster/repodata/comps-rhel5-cluster.xml /var/yum/Cluster/
# createrepo -g /var/yum/ClusterStorage/repodata/comps-rhel5-cluster-st.xml /var/yum/ClusterStorage/

\u6267\u884ccreaterepo\u547d\u4ee4\u540e\u7cfb\u7edf\u4f1a\u81ea\u52a8\u626b\u63cf\u76f8\u5173\u76ee\u5f55\uff0c\u5c06rpm\u5305\u52a0\u5165\u5230YUM\u6e90\u7684\u6570\u636e\u5e93\u4e2d\u3002
4.\u521b\u5efa\u672c\u5730yum\u5ba2\u6237\u7aef\u7684repo\u6587\u4ef6
\u914d\u7f6e\u4f7f\u7528\u672c\u5730yum repository\uff1a
# cd /etc/yum.repos.d/
# vim local.repo \uff08\u540d\u5b57\u53ef\u4ee5\u968f\u4fbf\u8d77\uff0c\u4f46\u662f\u8981\u4ee5.repo\u4e3a\u540e\u7f00\uff09

\u63a5\u4e0b\u6765\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u5982\u4e0b\u5185\u5bb9\u540e\u4fdd\u5b58\uff1a
[local] #\uff08yum\u5757\u533a\u57df\uff09
name=aaa # (\u540d\u5b57\u53ef\u4ee5\u968f\u4fbf\u8d77)
baseurl=file:///var/yum/Server #\uff08\u641c\u7d22\u8def\u5f84\uff0c\u5fc5\u987b\u6307\u5411\u4f60\u672c\u673a\u7684yum\u6e90\u8def\u5f84\uff09
gpgcheck=0 #\uff08gpgcheck\u662fgpg\u9a8c\u8bc1\u662f\u5426\u5f00\u542f\u7684\u9009\u9879\uff0c1\u662f\u5f00\u542f\uff0c0\u662f\u4e0d\u5f00\u542f\uff0c\u4e00\u822c\u60c5\u51b5\u53ef\u4ee5\u5173\u6389\uff09
enabled=1 #(\u662f\u5426\u542f\u7528\uff0c0\u4e3a\u4e0d\u542f\u7528\uff0c1\u4e3a\u542f\u7528\uff0c\u8fc7\u6ca1\u8fd9\u4e00\u9879\uff0c\u5c31\u662f\u542f\u7528\uff09

[VT]
name=VT
baseurl=file:///var/yum/VT
gpgcheck=0

[Cluster]
name= Cluster
baseurl=file:///var/yum/Cluster
gpgcheck=0

[CS]
name= ClusterStorage
baseurl=file:///var/yum/ClusterStorage
gpgcheck=0


5.\u6d4b\u8bd5\u4f7f\u7528yum\u6765\u5b89\u88c5\u8f6f\u4ef6\u5305

下面的文章应该能够帮到你:

用安装 CD 建立本地 yum 源

对于 RHEL4 或者其它相对旧的发行版,或者仅有安装 CD 的情况下,还可以通过类似的方式补装 RPM 包吗?答案是肯定的,不过需要一个多余的步骤,即手工创建 repo 数据。

下面的示例,通过把 RHEL4u6 的 5CD 中的 RPMS 混合到一个目录中,然后用 createrepo 命令建立 repo 数据。

首先混装 CD:

[root@localhost root]# mkdir -p /mnt/dvd
# insert CD1
[root@localhost root]# mount /dev/hdc /media/cdrom/
[root@localhost root]# cp -prf /media/cdrom/Server /mnt/dvd/RPMS
[root@localhost root]# umount /media/cdrom

# insert CD2
...
# insert CD3
...
# insert CD4
...

# insert CD5
[root@localhost root]# mount /dev/hdc /media/cdrom/
[root@localhost root]# cp -prf /media/cdrom/Server /mnt/dvd/RPMS
[root@localhost root]# umount /media/cdrom

# remove unused files
[root@localhost root]# find /mnt/dvd/RPMS -name TRANS.TBL -exec rm -f {} \;

然后通过 createrepo 命令创建 yum 源数据。这正是“空间换时间”的预处理过程,视 RPM 数据的多少,大约需要几分钟。"-d" 参数表示在生成 xml 索引的同时生成 sqlite 格式的索引。完成过后,这两种索引文件均以压缩格式存放于 repodata 目录中,供 yum 查询所用。

[root@localhost root]# cd /mnt/dvd

[root@localhost dvd]# createrepo -d .
1/2399 - RPMS/plymouth-theme-charge-0.8.0-0.2009.29.09.18.fc12.i686.rpm
2/2399 - RPMS/aspell-0.60.6-7.fc12.i686.rpm
3/2399 - RPMS/xml-common-0.6.3-30.fc12.noarch.rpm

......

2397/2399 - RPMS/mythes-en-3.0-5.fc12.noarch.rpm
2398/2399 - RPMS/hunspell-mi-0.20080630-3.fc12.noarch.rpm
2399/2399 - RPMS/hicolor-icon-theme-0.11-1.fc12.noarch.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

[root@localhost dvd]# ls -l repodata/
total 10004
-rw-r--r--. 1 root root 2974902 2009-12-06 09:48 filelists.sqlite.bz2
-rw-r--r--. 1 root root 2618445 2009-12-06 09:48 filelists.xml.gz
-rw-r--r--. 1 root root 912087 2009-12-06 09:48 other.sqlite.bz2
-rw-r--r--. 1 root root 951651 2009-12-06 09:48 other.xml.gz
-rw-r--r--. 1 root root 1809806 2009-12-06 09:48 primary.sqlite.bz2
-rw-r--r--. 1 root root 958302 2009-12-06 09:48 primary.xml.gz
-rw-r--r--. 1 root root 2726 2009-12-06 09:48 repomd.xml

最后,编辑 yum 源配置文件,添加一个本地 yum 源。注意对应的目录,这次是 /mnt/dvd,因为 repodata 是在此路径下创建的。

[root@localhost dvd]# cat > /etc/yum.repos.d/dvd.repo <<END
[dvd]
name=install dvd
baseurl=file:///mnt/dvd
enabled=1
gpgcheck=0
END

对于 RHEL4 一类不带 repodata 的安装 DVD,去掉混装 RPM 的一步,直接用 createrepo 命令建立源数据即可。

扩展阅读:推特网红song ... centos创建本地yum源 ... song老师 twitter ... linux创建yum源步骤 ... 创建本地yum仓库的步骤 ... linux创建本地yum仓库 ... 新建本地yum源文件并挂载 ... 创建yum仓库的命令 ... 创建yum仓库配置文件 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网