centos 的yum倉庫搭建

來源:互聯網
上載者:User

標籤:yum centos 倉庫

一、yum倉庫說明
1、搭建yum倉庫必要性內網環境下,為了實現自動化和自訂的人性化便捷快速的增加部署服務,搭建yum倉庫是首選,可以公司網環境下搭建yum源,供公司內部員工使用,並且能夠通過定製rpm包,完成一件安裝。
2、yum倉庫簡介
yum(全稱為 Yellow dog Updater, Modified)是一個在Fedora和RedHat中的Shell前端軟體包管理器。基於RPM包管理,能夠從指定的伺服器自動下載RPM包並且安裝,可以自動處理依賴性關係,並且一次安裝所有依賴的軟體包,無須繁瑣地一次次下載、安裝。yum提供了尋找、安裝、刪除某一個、一組甚至全部軟體包的命令,而且命令簡潔而又好記。
二、yum倉庫搭建安裝實戰
1、安裝環境:
[1 [email protected] ~]# uname -r
2.6.32-504.el6.x86_64
[2 [email protected] ~]# uname -m
x86_64
[3 [email protected] ~]# cat /etc/redhat-release
CentOS release 6.6 (Final)3、yum倉庫及http網站準備
註:這裡需要一個http環境,能夠訪問檔案。我們可以使用輕便的python模組提供,在網站目錄下執行:
python -m
SimpleHTTPServer
80
&
依賴包,我們可以調整/etc/yum.conf檔案,將keepcache的值改為1,然後就可以保留yum的包緩衝;如果是沒有子依賴的依賴包,我們可以通過yumdownloader下載相關依賴包,yumdownloader在yum-utils的工具集中。
2、此處以之前的fpm打包環境為例,連結如下
http://bbs.51cto.com/thread-1167544-1.html
3、安裝createrepo並建立repo
#安裝createrepo
yum install createrepo
-y
#建立倉庫repo資訊
[[email protected]
~]# createrepo -pdo /data0/repo/ /data0/repo/
Spawning worker
0
with
4
pkgs
Workers Finished
Gathering worker results
Saving Primary metadata
Saving file
lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
#如果之後有rpm包新增或者刪除,需要更新repo檔案
createrepo
--update
/data0/repo/
#查看倉庫下的檔案
[[email protected]
~]# tree /data0/repo/
/data0/repo/
|--
nginx_erma-1.6.0-1.x86_64.rpm
|--
openssl-1.0.1e-42.el6.x86_64.rpm
|--
openssl-devel-1.0.1e-42.el6.x86_64.rpm
|--
pcre-devel-7.8-7.el6.x86_64.rpm
--
repodata
   
|--
0c407e9494d459d4496e7d24c2e6a93bbb9bb60e009dcc97aa1efef9010bf64a-filelists.xml.gz
   
|--
43a3cc03f7fc3e69e32c7d6a2795229596a32469d0924bab815e3f50cb5b0be6-other.sqlite.bz2
   
|--
510ce97c74a7119f8850016b7e6a5be19fc2bd716fa084e46aeb585686223f80-filelists.sqlite.bz2
   
|--
60f80504e1a080df7b05200f1c6ffb56a4563c51f9038deb733eaf5279c569d0-primary.xml.gz
   
|--
84c87598ed82a081e86dfc93d5e76379ce75bc04729e5f3395f6d62e6950b3fa-primary.sqlite.bz2
   
|--
eaff97435829909a39f0abb8446167947e90f23dafec2132e338fbb25db996ec-other.xml.gz
   
--
repomd.xml

1
directory,
11
files
4、在另外一台機器上配置yum源
添加配置yum源檔案:
[email protected] application]# cat /etc/yum.repos.d/erma.repo
[maker]
name=ErmaRepo
baseurl=http://repo.trnux.com/
enable=1
gpgcheck=0
我們可以通過repo檔案的enable的值來控制設定檔是否生效;但是此方法麻煩,如果私人yum倉庫中的包和base包衝突,會有問題;想要訪問公網yum源,還需要修改設定檔,重建緩衝等操作;我們可以用另一種方法,就是使用yum時指定啟用的源和關閉的源:
yum --enablerepo=maker --disablerepo=base,extras,updates,epel list
安裝時可以也是如此:
yum --enablerepo=maker --disablerepo=base,extras,updates,epel install nginx_erma.x86_64
#使用時,我們最好將私人的源改為enable=0,其他的源改為1,這樣直接yum就不會出現問題。

本文出自 “chuck's blog” 部落格,請務必保留此出處http://chuck.blog.51cto.com/10232880/1712797

centos 的yum倉庫搭建

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.