CentOS四种方法自建yum仓库
將ISO光盤鏡像作為yum本地倉庫(適用于不能聯(lián)外網(wǎng)的環(huán)境):
1、??禁用所有可用的yum倉庫,為方便演示,直接全部刪除:
# cd /etc/yum.repos.d
# ls
# rm -rf *
2、??創(chuàng)建光盤掛載點(diǎn),掛載光盤:
# mkdir -pv /mnt/localiso
# mount /dev/cdrom /mnt/localiso
3、??添加本地yum倉庫:
# cd /etc/yum.repos.d
# vim Local-ISO.repo
[CentOS6-iso]
name=CentOS-$releasever-$basearch-iso
baseurl=file:///mnt/localiso
enabled=1
gpgcheck=1
gpgkey=file:///mnt/localiso/RPM-GPG-KEY-CentOS-6
4、??重建元數(shù)據(jù)緩存,更新yum倉庫:
# yum clean all
# yum makecache
# yum repolist
# yum list
5、??使用本地yum倉庫:
# yum -y install tree
?
使用第三方aliyun的CentOS倉庫:
1、??備份原有倉庫:
# mv /etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.backup
2、??下載aliyun的repo:
-
CentOS 5:# wget-O /etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-5.repo
-
CentOS 6:# wget-O /etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-6.repo
-
CentOS 7:# wget-O /etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.repo
3、??生成元數(shù)據(jù)緩存:# yum makecache
?
使用http協(xié)議和ftp協(xié)議自建yum倉庫:
1、??關(guān)閉SELinux和iptables
2、??禁用所有可用的yum倉庫,為方便演示,直接全部刪除:
# cd /etc/yum.repos.d
# ls
# rm -rf *
3、??安裝相關(guān)軟件包(一定要按照此順序安裝):
# rpm -ivh deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm?????????? //createrepo依賴軟件包
# rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm???? //createrepo依賴軟件包
# rpm -ivh createrepo-0.9.9-24.el6.noarch.rpm??????????????????? //用于生成元數(shù)據(jù)
# rpm -ivh httpd-2.2.15-56.el6.centos.3.x86_64.rpm?????????????? //用于搭建http協(xié)議的文件服務(wù)器
# rpm -ivh vsftpd-2.2.2-21.el6.x86_64.rpm????????????????????? ?//用于搭建ftp協(xié)議的文件服務(wù)器
4、??創(chuàng)建存放軟件包的目錄:
# mkdir -pv /var/www/html/CentOS/6/x86_64/
# chown -R apache.apache /var/www/html
# mkdir -pv /var/ftp/pub/centos/6/x86_64/
5、??在軟件包存放目錄中上傳需要安裝的軟件包,此處為了演示,復(fù)制光盤ISO中的軟件包:
# mkdir -pv /mnt/dvd
# mount /dev/sr0 /mnt/dvd
# mount? -->? /dev/sr0 on /mnt/dvd type iso9660 (ro)
# cp -a /mnt/dvd/Packages/* /var/www/html/CentOS/6/x86_64/
# cp -a /mnt/dvd/Packages/* /var/ftp/pub/centos/6/x86_64/
6、??創(chuàng)建元數(shù)據(jù),生成repodata目錄:
# createrepo /var/www/html/CentOS/6/x86_64/
# createrepo /var/ftp/pub/centos/6/x86_64/
備注:repodata目錄是一個(gè)數(shù)據(jù)庫,描述了一個(gè)rpm包的詳細(xì)信息,如依賴關(guān)系、包含文件、校驗(yàn)碼信息等
7、??啟動(dòng)httpd服務(wù)和vsftpd服務(wù):
# vim /etc/httpd/conf/httpd.conf?-->? ServerName localhost:80
# service httpd start
# netstat -lntup|grep 80
# service vsftpd start
# netstat -lntup|grep 21
8、??配置自建的yum倉庫:
-
http協(xié)議文件服務(wù)器:
# cd /etc/yum.repos.d
# vim myhttp-CentOS6.repo
[myhttp-CentOS-6-x86_64]
name=myhttp-CentOS-$releasever-$basearch
baseurl=http://192.168.1.144/CentOS/6/x86_64/
enabled=1
gpgcheck=0
-
ftp協(xié)議文件服務(wù)器:
# cd /etc/yum.repos.d
# vim myftp-centos6.repo
[myftp-centos-6-x86_64]
name=myftp-centos-$releasever-$basearch
baseurl=ftp://192.168.1.144/pub/centos/6/x86_64
enabled=1
gpgcheck=0
9、??可以配置epel源,此處略
10、重建元數(shù)據(jù)緩存,更新yum倉庫:
# yum clean all
# yum makecache
# yum repolist
# yum list
11、測(cè)試使用:
# yum -y install zsh
本文轉(zhuǎn)自Marion0728 ?51CTO博客,原文鏈接:http://blog.51cto.com/qiuyue/1911297,如需轉(zhuǎn)載請(qǐng)自行聯(lián)系原作者
總結(jié)
以上是生活随笔為你收集整理的CentOS四种方法自建yum仓库的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jsp 中包含 一个路径为变量的文件
- 下一篇: 陈百强原来这么帅_朱一龙虽然很少玩手机,