linux yum换源(国内阿里源)

因网络限制,不让访问国外的ip,换yum的源。

1. 输入:mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak

备份/etc/yum.repos.d/CentOS-Base.repo,将其文件改名为:/etc/yum.repos.d/CentOS-Base.repo-bak。

2. 输入:wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 获取阿里的yum源配置文件。

3. 输入:yum makecache 更新cache

4. 输入:yum -y update 查看。

换源后,安装nodejs, redis都会出现下面的问题:应是阿里云的数据源不够。

One of the configured repositories failed (Unknown), and yum doesn't have enough cached data to continue. At this point the only safe thing yum can do is fail. There are a few ways to work "fix" this:

linux yum换源(国内阿里源)_第1张图片

 解法:

1. 输入:vi /etc/resolv.conf,添加下面一行:nameserver 114.114.114.114  进行保存。这是国内较好用的的dns系统。

linux yum换源(国内阿里源)_第2张图片

 2.输入:vi /etc/yum.repos.d/epel.repo,修改将baseurl值换成CentOS-Base.repo里的值,并将metalink的值注释掉。下面红色字是加的,灰色字是注释掉的。

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/

#metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/

#metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/

#metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

3. 输入:yum update   进行更新。

linux yum换源(国内阿里源)_第3张图片

 

你可能感兴趣的:(linux,linux,换源)