yum 镜像

使用阿里云镜像服务器

最近本机访问 163.com 的 CentOS 镜像比较不稳定,体现在 ping 很低,但是 HTTP 连接很慢,yum 的 fastestmirror 也不太理想,所以一般都禁用之。

发现阿里云的镜像服务器,立马换了,便秘立刻就通了。

yum 镜像

官方源镜像

      
      
1
2
3
4
5
6
      
      
# 禁用 fastestmirror 插件
sed -i.backup 's/^enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf
# 备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# 使用阿里云镜像
wget -O /etc/yum.repos.d/CentOS-Base-aliyun.repo http://mirrors.aliyun.com/repo/Centos- 6.repo

EPEL 镜像

      
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
      
      
# 安装 EPEL 源
wget http://dl.fedoraproject.org/pub/epel/ 6/x86_64/epel-release- 6- 8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release- 6.rpm
rpm -Uvh remi-release- 6*.rpm epel-release- 6*.rpm
# 使用阿里云镜像
if [[ ! -f /etc/yum.repos.d/epel.repo.backup ]]; then
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup 2>/dev/null || :
fi
if [[ ! -f /etc/yum.repos.d/epel-testing.repo.backup ]]; then
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup 2>/dev/null || :
fi
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel- 6.repo

PyPi 镜像

      
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
      
      
mkdir -p ~/.pip
touch ~/.pip/pip.conf
sed -i.backup -r \
's/^index-url\s*=\s*.+$/index-url = http:\/\/mirrors.aliyun.com\/pypi\/simple\//' \
~/.pip/pip.conf
# If file not changed, write contents back to pip.conf
diff "~/.pip/pip.conf" "~/.pip/pip.conf.backup" &> /dev/null
if [ $? -eq 0 ]; then
cat > ~/.pip/pip.conf <<EOF
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
EOF
fi

RubyGems 镜像

      
      
1
2
      
      
gem source -r https://rubygems.org/
gem source -a http://mirrors.aliyun.com/rubygems/



yum 清缓存和更新缓存
yum clean all
yum makecache
http://mirrors.163.com/.help/centos.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要设置yum镜像,可以按照以下步骤进行操作: 1. 挂载光盘:使用命令`mount /dev/sr0 /mnt`将光盘挂载到/mnt目录下。如果出现写保护错误,可以使用只读方式挂载。 2. 配置yum本地源:进入/etc/yum.repos.d/目录,创建一个备份文件夹back,并将所有的.repo文件移动到back文件夹中。然后创建一个新的文件mtn.repo,并在其中添加以下内容: ``` \[mnt\] name=mnt baseurl=file:///mnt gpgcheck=0 enabled=1 ``` 3. 使用yum安装软件:可以使用以下命令来更新yum资源、清除资源、建立yum资源缓存和显示列表: ``` yum clean all yum makecache yum list ``` 4. 上传或传输镜像:可以使用scp命令将镜像文件CentOS-7-x86_64-DVD-1908.iso从其他服务器传输到目标服务器的/mnt目录下。例如: ``` scp -P 1024 -r CentOS-7-x86_64-DVD-1908.iso root@192.168.67.200:/mnt/ ``` 5. 创建挂载目录:使用命令`mkdir /mnt/iso`创建一个名为iso的目录。 6. 挂载镜像:使用命令`mount CentOS-7-x86_64-DVD-1908.iso /mnt/iso/`将镜像文件挂载到/mnt/iso目录下。如果出现写保护错误,可以使用只读方式挂载。 7. 备份系统自带yum源配置文件:使用命令`mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup`备份系统自带的yum源配置文件。 这样就完成了设置yum镜像的过程。 #### 引用[.reference_title] - *1* *3* [linux配置yum镜像源](https://blog.csdn.net/qq_36709906/article/details/120299497)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Linux配置本地yum源(光盘镜像挂载)](https://blog.csdn.net/qq_58281447/article/details/127496222)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值