首頁 > 軟體

yum更換國內源及yum下載rpm包

2020-06-16 16:35:40

一、yum更換國內源

1、前往yum檔案路徑地址

[root@web1 ~]# cd /etc/yum.repos.d/
[root@web1 yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo
[root@web1 yum.repos.d]#

2、下載相應的原包地址

[root@web1 yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
--2019-05-21 22:36:41--  http://mirrors.163.com/.help/CentOS7-Base-163.repo
Resolving mirrors.163.com (mirrors.163.com)... 59.111.0.251
Connecting to mirrors.163.com (mirrors.163.com)|59.111.0.251|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1572 (1.5K) [application/octet-stream]
Saving to: ‘CentOS7-Base-163.repo.1’

100%[===============================================================================================>] 1,572      --.-K/s  in 0.001s 

2019-05-21 22:36:41 (2.84 MB/s) - ‘CentOS7-Base-163.repo.1’ saved [1572/1572]

[root@web1 yum.repos.d]#

3、列出所有可安裝的包

[root@web1 yum.repos.d]# yum list

4、如果一個163和base的源不夠用的情況下,可以安裝一個擴充套件源epel

yum install -y epel-release
yum list |grep epel

二、yum下載rpm包

1、下載包不安裝

[root@web1 yum.repos.d]# yum install -y 包名 --downloadonly --downloaddir=路徑

2、已經安裝的包要重新安裝

[root@web1 yum.repos.d]# yum reinstall -y 包名 --downloadonly --downloaddir=路徑

****將需要的rpm包打包好以後再使用時便可直接呼叫了****


IT145.com E-mail:sddin#qq.com