簡(jiǎn)單寫一寫,用作倉(cāng)庫(kù)的虛擬機(jī)IP為192.168.149.129。我計(jì)劃將/usr/local/src這個(gè)目錄下的軟件當(dāng)做YUM源。首先確保http服務(wù)正常。
1、我用的是apache,默認(rèn)根目錄是/var/www/html,所以在這個(gè)目錄下做了一個(gè)軟鏈接:
[root@bogon html]# ln -s /usr/local/src .
[root@bogon html]# ll
total 3
lrwxrwxrwx 1 root root 14 Nov 2 11:13 src -> /usr/local/src
2、使用createrepo命令格式化倉(cāng)庫(kù):
[root@bogon src]# createrepo .
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@bogon src]# ls
repodata
[root@bogon src]# cd repodata/
[root@bogon repodata]# ls
01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523-filelists.sqlite.bz2 6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz repomd.xml
401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz 7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4-other.sqlite.bz2
5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945-primary.sqlite.bz2 dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz
3、將rpm包放在src目錄下,更新一下,在客戶端應(yīng)該就能看到這個(gè)包了:
[root@bogon src]# createrepo --update .
Spawning worker 0 with 1 pkgs
Spawning worker 1 with 0 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
4、驗(yàn)證,在客戶端/etc/yum.repos.d下創(chuàng)建一個(gè)以.repo結(jié)尾的文件:
[root@localhost yum.repos.d]# cat test.repo
[TestYum]
name=TestYum
baseurl=http://192.168.149.129/src
gpgcheck=0
enabled=1
5、運(yùn)行yum clean all && yum repolist,嗯,確實(shí)有1個(gè)包,完成。

總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接