CentOS7.8 换清华源和阿里源

第一步,清空所有repo文件

cd /etc/yum.repos.d/

删除所有文件:

rm -f /etc/yum.repos.d/*

第二步:配置清华源

新建两个文件vim CentOS-Base.repo和vim epel.repo

vim CentOS-Base.repo

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

vim epel.repo

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch
#mirrorlist=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://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch/debug
#mirrorlist=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://mirrors.tuna.tsinghua.edu.cn/epel/7/SRPMS
#mirrorlist=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

添加RPM-GPG-KEY-EPEL-7

curl https://mirrors.tuna.tsinghua.edu.cn/epel/RPM-GPG-KEY-EPEL-7 > /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

运行以下命令生成缓存

yum clean all
yum makecache

配置阿里源

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

运行以下命令生成缓存

yum clean all
yum makecache
### 更改 Conda 默认清华源阿里 为了提高 `conda` 的安装效率,可以将默认的 Anaconda 更改为清华大学开软件镜像站或阿里云提供的镜像站点。 #### 方法一:更改配置文件 `.condarc` 通过编辑用户的 `.condarc` 文件来指定新的镜像。此文件通常位于用户主目录下: 对于 **清华源**: ```bash conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --set show_channel_urls yes ``` 对于 **阿里**: ```bash conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/ conda config --set show_channel_urls yes ``` 上述命令会向当前用户的 conda 设置中添加相应的中国区镜像仓库链接,并开启显示渠道 URL 功能以便于追踪包来[^1]。 #### 方法二:临时修改特定操作中的地址 如果只是希望一次性地使用某个镜像而不改变全局设置,则可以在执行具体指令时直接指明 channel 参数。例如,在创建新环境时指定清华源作为下载位置: ```bash conda create -n myenv python=3.8 --channel=https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ ``` 或者针对单次更新操作应用阿里: ```bash conda update --channel=https://mirrors.aliyun.com/anaconda/cloud/ ``` 这种方法适用于不想永久变更系统配置的情况[^2]。 #### 方法三:利用 Miniconda 或 Anaconda 安装脚本自定义安装路径 当首次安装 Miniconda 或 Anaconda 时可以选择从国内镜像获取资。以阿里云为例,可以通过访问其提供的下载页面找到适合的操作系统版本并按照说明完成本地化部署[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值