yum.conf 配置文件說明php
yum 的配置文件分爲兩部分:main 和repository main 部分定義了全局配置選項,整個yum 配置文件應該只有一個main。常位於/etc/yum.conf 中。 repository 部分定義了每一個源/服務器的具體配置,能夠有一到多個。常位於/etc/yum.repo.d 目錄下的各文件中。 yum.conf 文件通常位於/etc目錄下,通常其中只包含main部分的配置選項。
root@localhost yum.repos.d]# cat /etc/yum.conf [main]
//全局配置文件 cachedir=/var/cache/yum/$basearch/$releasever
//yum 緩存目錄,yum 在這儲存緩存的rpm 包和數據庫 keepcache=0
//keepcache 安裝完成後是否保留下載的rpm 包,0爲不保留(1 爲保留),默認爲0 debuglevel=2
//Debug 信息輸出等級,默認爲2 logfile=/var/log/yum.log
//log 輸出位置 exactarch=1
//有0 和 1 兩個選項,設置爲1 表示yum 只會安裝和系統硬件架構匹配的軟件包,默認爲1 obsoletes=1
// 這是一個update 參數,容許更新舊的軟件包 gpgcheck=1
//是否進行gpg效驗,1 表明進行效驗 plugins=1
//是否啓用插件 installonly_limit=5 bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum distroverpkg=centos-release # This is the default, if you make this bigger yum won't see if the metadata # is newer on the remote and so you'll "gain" the bandwidth of not having to # download the new metadata and "pay" for it by yum not having correct # information. # It is esp. important, to have correct metadata, for distributions like # Fedora which don't keep old packages around. If you don't like this checking # interupting your command line usage, it's much better to have something # manually check the metadata once an hour (yum-updatesd will do this). # metadata_expire=90m # PUT YOUR REPOS HERE OR IN separate files named file.repo # in /etc/yum.repos.d [root@localhost yum.repos.d]#
repo 文件docker
全部repository 服務器設置都應該遵循以下格式:數據庫
[serverid] name=Some name for this server baseurl=url://path/to/repository/
baseurl=url://server1/path/to/repository/ url://server2/path/to/repository/ url://server3/path/to/repository/
其中url 支持的協議有 http:// ftp:// file:// 三種。baseurl 後能夠跟多個url,你能夠本身改成速度比較快的鏡像站,但baseurl 只能有一個,也就是說不能像以下格式:centos
baseurl=url://server1/path/to/repository/ baseurl=url://server2/path/to/repository/ baseurl=url://server3/path/to/repository/
其中url 指向的目錄必須是這個repository header 目錄的上一級,它也支持$releasever $basearch 這樣的變量。緩存
關於變量bash
b. 導入GPG KEY服務器
yum 可使用gpg 對包進行校驗,確保下載包的完整性,因此咱們先要到各個repository 站點找到gpg key,通常都會放在首頁的醒目位置,一些名字諸如RPM-GPG-KEY-CentOS-5 之類的純文本文件,把它們下載下來,而後用rpm --import RPM-GPG-KEY-CentOS-5 命令將key 導入。架構
repo 自定義編輯工具
在定義repo 文件時,baseurl 路徑指定的就是軟件信息獲取的位置,指定爲 repodata 的上一級目錄this
[root@localhost yum.repos.d]# cat kubernetes.repo [kubernetes] name=Kubernetes repo edit baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/ gpgcheck=1
//啓用gpg 效驗 gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
//指定效驗配置文件,不指定就經過rpm --import 文件導入 enable=1
//啓用倉庫 [root@localhost yum.repos.d]#
root@localhost yum.repos.d]# yum remove all Loaded plugins: fastestmirror No Match for argument: all No Packages marked for removal [root@localhost yum.repos.d]# yum makecache Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile base | 3.6 kB 00:00:00 docker-ce-stable | 3.5 kB 00:00:00 extras | 3.4 kB 00:00:00 kubernetes | 1.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/3): kubernetes/primary | 50 kB 00:00:00 (2/3): kubernetes/filelists | 18 kB 00:00:00 (3/3): kubernetes/other | 33 kB 00:00:00 kubernetes 363/363 kubernetes 363/363 kubernetes 363/363 Metadata Cache Created [root@localhost yum.repos.d]# yum repolist Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile repo id repo name status base/7/x86_64 CentOS-7 - Base - 163.com 10,019 docker-ce-stable/x86_64 Docker CE Stable - x86_64 46 extras/7/x86_64 CentOS-7 - Extras - 163.com 419 kubernetes Kubernetes repo edit 363 updates/7/x86_64 CentOS-7 - Updates - 163.com 2,146 repolist: 12,993