Configure yum source in linux

Configure 163 or Alibaba Cloud yum source:


Aliyun yum source address: https://mirrors.aliyun.com/centos/6.9/os/x86_64/Packages/

The solution given by Alibaba Cloud: https://mirrors.aliyun.com/centos Click on the help behind centos to see:

1. Backup

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2. Download the new CentOS-Base.repo to /etc/yum.repos.d/

Cent OS 5

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
or
 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo Cent OS 6
 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo You can download it locally by visiting the url and upload it to the linux directory. If This method can be used when wget is not supported in linux.
or
 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo Cent OS 7
 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
Or curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 3. Then run yum makecache to generate the cache

 Specific operation:

[root@localhost zyj]# cd /etc/yum.repos.d/ //The configuration file of the yum source, check the default yum source, generally the default is the yum source under the centos official website.
[root@localhost yum.repos.d]# ll
total 24
-rw-r--r--. 1 root root 1991 Mar 28 2017 CentOS-Base.repo
-rw-r--r--. 1 root root 647 Mar 28 2017 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 630 Mar 28 2017 CentOS-Media.repo -rw-r--r--. 1 root root 7989 Mar 28 2017 CentOS-Vault.repo -rw-r--r--. 1 root root 289 Mar 28 2017 CentOS- fasttrack.repo [root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.backup //Backup[ root@localhost yum .repos.d]# ll total 24 -rw-r--r--. 1 root root 1991 Mar 28 2017 CentOS- Base.repo.backup -rw-r--r--. 1 root root 647 Mar 28 2017 CentOS- Debuginfo.repo -rw-r--r--. 1 root root 630 Mar 28 2017 CentOS- Media.repo -rw-r--r--. 1 root root 7989 Mar 28 2017 CentOS- Vault.repo -rw-r--r--. 1 root root 289 Mar 28 2017 CentOS-fasttrack.repo -rw-r--r-- . 1 root root 0 Apr 29 11:58 my.repos [root@ localhost yum .repos.d]# [root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos- 6.repo //Download the new yum source to the local % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 102 2572 102 2572 0 0 7505 0 --:--:-- --:--:-- --:--:-- 11482 [root@localhost yum.repos.d]# ll total 28 -rw-r--r--. 1 root root 2572 Apr 30 03:07 CentOS-Base.repo [root@localhost yum.repos.d]# yum clean all //清除之前的缓存 Failed to set locale, defaulting to C Loaded plugins: fastestmirror, refresh-packagekit, security Cleaning repos: base extras updates Cleaning up Everything Cleaning up list of fastest mirrors [root@localhost yum.repos.d]# yum makecache //生成缓存 Failed to set locale, defaulting to C Loaded plugins: fastestmirror, refresh-packagekit, security Determining fastest mirrors * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com base | 3.7 kB 00:00 base/group_gz | 226 kB 00:00 base/filelists_db | 6.4 MB 00:05 base/primary_db | 4.7 MB 00:06 base/other_db | 2.8 MB 00:03 extras | 3.4 kB 00:00 extras/filelists_db | 26 kB 00:00 extras/prestodelta | 1.7 kB 00:00 extras/primary_db | 30 kB 00:00 extras/other_db | 32 kB 00:00 updates | 3.4 kB 00:00 updates/filelists_db | 4.3 MB 00:05 updates/prestodelta | 245 kB 00:00 updates/primary_db | 7.0 MB 00:05 updates/other_db | 100 MB 01:27

 Build a local yum source : Use the existing rpm file in the CD as an object to make a local yum source;


1. Insert the full version of the IOS file into the CD-ROM; select the mini version of the linux virtual machine in the virtual machine as the full version image through the CD in the settings;

2. Mount the CD; mount /dev/cdrom /mnt

[root@localhost ~]# cd /mnt/ //View mount point directory
[root@localhost mnt]# ls
[root@localhost mnt]# mount /dev/cdrom /mnt //mount the CD
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@localhost mnt]# cd /dev 
[root@localhost dev]# ls -l cdrom lrwxrwxrwx. 1 root root 3 4月 30 18:52 cdrom -> sr0 [root@localhost dev]# [root@localhost dev]# cd /mnt/ //View mount files [root@localhost mnt]# ls CentOS_BuildTag GPL Packages RPM-GPG-KEY-CentOS-6 RPM-GPG-KEY-CentOS-Testing-6 EFI images RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-Debug-6 TRANS.TBL EULA isolinux repodata RPM-GPG-KEY-CentOS-Security-6 [root@localhost mnt]# cd Packages/ //查看挂载后的rpm文件 [root@localhost Packages]# ls 389-ds-base-1.2.11.15-89.el6.x86_64.rpm libreoffice-math-4.3.7.2-2.el6.x86_64.rpm 389-ds-base-libs-1.2.11.15-89.el6.x86_64.rpm libreoffice-ogltrans-4.3.7.2-2.el6.x86_64.rpm abrt-2.0.8-43.el6.centos.x86_64.rpm libreoffice-opensymbol-fonts-4.3.7.2-2.el6.noarch.rpm abrt-addon-ccpp-2.0.8-43.el6.centos.x86_64.rpm libreoffice-pdfimport-4.3.7.2-2.el6.x86_64.rpm abrt-addon-kerneloops-2.0.8-43.el6.centos.x86_64.rpm libreoffice-pyuno-4.3.7.2-2.el6.x86_64.rpm abrt-addon-python-2.0.8-43.el6.centos.x86_64.rpm libreoffice-ure-4.3.7.2-2.el6.x86_64.rpm abrt-cli-2.0.8-43.el6.centos.x86_64.rpm libreoffice-wiki-publisher-4.3.7.2-2.el6.x86_64.rpm abrt-desktop-2.0.8-43.el6.centos.x86_64.rpm libreoffice-writer-4.3.7.2-2.el6.x86_64.rpm abrt-gui-2.0.8-43.el6.centos.x86_64.rpm libreoffice-xsltfilter-4.3.7.2-2.el6.x86_64.rpm abrt-libs-2.0.8-43.el6.centos.x86_64.rpm libreport-2.0.9-33.el6.centos.x86_64.rpm abrt-python-2.0.8-43.el6.centos.x86_64.rpm libreport-cli-2.0.9-33.el6.centos.x86_64.rpm abrt-tui-2.0.8-43.el6.centos.x86_64.rpm libreport-compat-2.0.9-33.el6.centos.x86_64.rpm abyssinica-fonts-1.0-5.1.el6.noarch.rpm libreport-filesystem-2.0.9-33.el6.centos.x86_64.rpm acl-2.2.49-7.el6.x86_64.rpm libreport-gtk-2.0.9-33.el6.centos.x86_64.rpm acpid-1.0.10-3.el6.x86_64.rpm libreport-newt-2.0.9-33.el6.centos.x86_64.rpm adcli-0.8.1-1.el6.x86_64.rpm libreport-plugin-kerneloops-2.0.9-33.el6.centos.x86_64.rpm aic94xx-firmware-30-2.el6.noarch.rpm libreport-plugin-logger-2.0.9-33.el6.centos.x86_64.rpm aide-0.14-11.el6.x86_64.rpm libreport-plugin-mailx-2.0.9-33.el6.centos.x86_64.rpm akonadi-1.2.1-3.el6.x86_64.rpm libreport-plugin-reportuploader-2.0.9-33.el6.centos.x86_64.rpm alacarte-0.12.4-1.el6.noarch.rpm libreport-plugin-rhtsupport-2.0.9-33.el6.centos.x86_64.rpm alsa-lib-1.1.0-4.el6.x86_64.rpm libreport-plugin-ureport-2.0.9-33.el6.centos.x86_64.rpm alsa-lib-devel-1.1.0-4.el6.x86_64.rpm libreport-python-2.0.9-33.el6.centos.x86_64.rpm alsa-plugins-pulseaudio-1.1.0-1.el6.x86_64.rpm librepository-1.0.0-2.OOo31.1.el6.x86_64.rpm alsa-utils-1.1.0-10.el6.x86_64.rpm libreswan-3.15-7.3.el6.x86_64.rpm

 3. Modify /etc/yum.repos.d/CentOS-Base.repo;

 4. Delete other configuration files in this directory, clear cache files and generate cache;

 5. After the yum source configuration is complete, you can use yum install to install the application.

[root@localhost yum.repos.d]# cp CentOS-Base.repo CentOS-Base.repo.backup //Back up the original configuration file
[root@localhost yum.repos.d]# ll
Total dosage 28
-rw-r - r--. 1 root root 1991 3 月 28 2017 CentOS- Base.repo
-rw-r--r--. 1 root root 1991 4月  30 19:03 CentOS-Base.repo.backup
-rw-r--r--. 1 root root  647 3月  28 2017 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 289 3月 28 2017 CentOS-fasttrack.repo -rw-r--r--. 1 root root 630 Mar 28 2017 CentOS- Media.repo -rw-r--r--. 1 root root 7989 Mar 28 2017 CentOS- Vault.repo [root@localhost yum .repos.d]# [root@localhost yum .repos.d]# [root@localhost yum.repos.d]# vi CentOS-Base.repo //Modify the configuration file [base] name=CentOS-$releasever - Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra //Modify the original comment and copy a line mirrorlist=file:///mnt/ / /file://indicates local access #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 //Enable detection of gpg signatures to verify the security of rpm files. gpgkey=file:///mnt/RPM-GPG-KEY-CentOS-6 //gpg signature file path #released updates [updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6  #additional packages that may be useful [extras] name=CentOS-$releasever - Extras mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6  #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever -Plus mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/gpgcheck =1 enabled=0 //means not enabled. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6: wq //Exit after saving [root@localhost yum.repos.d]# yum clean all Loaded plugin: fastestmirror Cleaning repos: base extras updates Cleaning up list of fastest mirrors [root@localhost yum.repos.d]# [root@localhost yum.repos.d]# yum makecache Plugin loaded: fastestmirror Determining fastest mirrors Error: Cannot find a valid baseurl for repo: base [root@localhost yum .repos.d]# [root@localhost yum.repos.d]# vi CentOS- Base.repo baseurl=file:///mnt/ 
: wq //after saving quit
[root@localhost yum.repos.d]# yum makecache //Generating cache has loaded plugin: fastestmirror Loading mirror speeds from cached hostfile * extras: mirrors.sohu.com * updates: mirrors.aliyun.com base | 4.0 kB 00: 00 ... base/group_gz | 226 kB 00:00 ... base/filelists_db | 6.3 MB 00:01 ... base/primary_db | 4.7 MB 00:00 ... base/other_db | 2.7 MB 00:00 . .

Note: Use the rpm file in the mounted CD as the yum source. Since the CD cannot be written and may need to be remounted after restarting, you can download all the rpm files on the network to the local directory, such as the /opt file. Can.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325113923&siteId=291194637