1 将光盘中的内容COPY到本地硬盘,例中为/yum目录
mount /dev/cdrom /mnt
mkdir /yum
cp /mnt/* /yum/
2 新建repo文件
vi /etc/yum.repos.d/centos-local.repo
输入如下内容
[local]
name=Local Yum
baseurl=file:///yum/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
保存退出
3 修改repodata数据库文件名
mv /yum/repodata/52ad0604bc6f4555d84bb0c32e2213a3a8008091993eae46d8100ade6117fbe4 /yum/repodata/52ad0604bc6f4555d84bb0c32e2213a3a8008091993eae46d8100ade6117fbe4-c6-x86_64-comps.xml.gz
mv /yum/repodata/5abe055f4bf7a1670d7b48a8172bec678861f2bcb8bc001ec3afa934638edc91 /yum/repodata/5abe055f4bf7a1670d7b48a8172bec678861f2bcb8bc001ec3afa934638edc91-other.sqlite.bz2
mv /yum/repodata/80381e2b79fcd2ca61a289c783fcf29e6715912fa2e28b3e955b94c6e6725691 /yum/repodata/80381e2b79fcd2ca61a289c783fcf29e6715912fa2e28b3e955b94c6e6725691-primary.sqlite.bz2
mv /yum/repodata/947c06b3449529ce6dea6c2610150b5c6f029094ab83093210765a866a528c6c /yum/repodata/947c06b3449529ce6dea6c2610150b5c6f029094ab83093210765a866a528c6c-c6-x86_64-comps.xml
mv /yum/repodata/b5f258df6a887534bb37ef8de488f238726ef2e0b4ded2180d756c45c6d843dd /yum/repodata/b5f258df6a887534bb37ef8de488f238726ef2e0b4ded2180d756c45c6d843dd-primary.xml.gz
mv /yum/repodata/c3797545a90f38e0738506e2b19c9a61e465f777156e0e1418a094d9ee08f23a /yum/repodata/c3797545a90f38e0738506e2b19c9a61e465f777156e0e1418a094d9ee08f23a-filelists.xml.gz
mv /yum/repodata/d30e7a407b0f019826c949cbc814944e6d178242abcadb5e79a891002cfb0107 /yum/repodata/d30e7a407b0f019826c949cbc814944e6d178242abcadb5e79a891002cfb0107-filelists.sqlite.bz2
mv /yum/repodata/d4b0b37148f088ff02731d7c5d12af279fc6bfa1bde26aa2c4ccf18f2ac0d493 /yum/repodata/d4b0b37148f088ff02731d7c5d12af279fc6bfa1bde26aa2c4ccf18f2ac0d493-other.xml.gz
mv /yum/repodata/ef31b9351dab1a0ae826b0f1ca136059acdb81227fd7ff7d78099c5c58cfa035 /yum/repodata/ef31b9351dab1a0ae826b0f1ca136059acdb81227fd7ff7d78099c5c58cfa035-c6-x86_64-comps.xml.gz
(注意:文件可能因为版本不同而略有差异)
4 yum更新
yum clean all
5 本地安装软件方法
yum --disablerepo=\* --enablerepo=local <Command>
比如:yum --disablerepo=\* --enablerepo=local search httpd
如果不从其他源安装软件,则可以将/etc/yum.repos.d目录下其他源设置文件中enabled=0