8月2日 yum客戶端創(chuàng)建倉庫

1、centos6創(chuàng)建倉庫

[root@centos6 app]#cd /etc/yum.repos.d/  
[root@centos6 yum.repos.d]#ls
CentOS-Base.repo       CentOS-fasttrack.repo  CentOS-Vault.repo
CentOS-Debuginfo.repo  CentOS-Media.repo
[root@centos6 yum.repos.d]#mkdir backup
[root@centos6 yum.repos.d]#ls
backup            CentOS-Debuginfo.repo  CentOS-Media.repo
CentOS-Base.repo  CentOS-fasttrack.repo  CentOS-Vault.repo
[root@centos6 yum.repos.d]#mv *.repo backup
[root@centos6 yum.repos.d]#ls
backup
[root@centos6 yum.repos.d]#vim base.repo
  1 [centos6]
  2 name=centos6 repo
  3 baseurl=file:///misc/cd ---路徑為repodata的父目錄,三個///最后一個表示的是根
  4 gpgcheck=0
[root@centos6 yum.repos.d]#yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
centos6                                                      | 4.0 kB     00:00 ... 
centos6/primary_db                                           | 4.7 MB     00:00 ... 
repo id                             repo name                                 
centos6                             centos6 repo                              6,706
repolist: 6,706
[root@centos6 yum.repos.d]#rpm -e tree
[root@centos6 yum.repos.d]#tree
-bash: /usr/bin/tree: No such file or directory
[root@centos6 yum.repos.d]#yum install tree

總結(jié):創(chuàng)建倉庫時要先進(jìn)入/etc/yum.repos.d/ ,查看有沒有其他以.repo結(jié)尾的文件,如果有要把他們刪除,或者移動到一個新建的目錄下,避免倉庫之間的互相干擾;倉庫的路徑為repodata的父目錄。

2、centos7創(chuàng)建倉庫

[root@centos7 yum.repos.d]#cat base.repo 
[centos7]
name=centos7.3
baseurl=http://172.16.0.1/centos/7/
gpgcheck=1  
gpgkey=http://172.16.0.1/centos/7/RPM-GPG-KEY-CentOS-7  ---如果已經(jīng)通過rpm--import導(dǎo)入了公鑰,此行不要再寫
enabled=0


[base]
name=base
baseurl=file:///misc/cd
gpgcheck=0




[epel]
name=epel for centos7
baseurl=http://172.16.0.1/fedora-epel/7/x86_64/
gpgcheck=0
enabled=0

總結(jié):一個文件中可以創(chuàng)建多個倉庫,用enabled=0可以禁用某個倉庫,實驗環(huán)境下最好使用本地光盤,速度比較穩(wěn)定,生產(chǎn)中沒有本地光盤,只能使用網(wǎng)絡(luò)路徑。

3、yum靜默和自動回答yes

[root@centos7 test]#rpm -e tree ---用rpm卸載
[root@centos7 test]#yum -y -q install tree ---無法靜默安裝
Warning: RPMDB altered outside of yum.
[root@centos7 test]#rpm -e tree
[root@centos7 test]#yum -q -y install tree
Warning: RPMDB altered outside of yum.
[root@centos7 test]#yum remove tree--用yum卸載
yum -y -q install tree ---可以靜默和自動回答yes安裝

總結(jié):用yum自動回答yes和靜默安裝可以用腳本中,-y和-q哪個在前面都可以,前提是這包之前是用yum卸載的或者之前就沒有這個包

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容