Linux使用在线YUM源

1.首先保证Linux可以通外网

2.清空/etc/yum.repo下的文件

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost ~]# mkdir  bak
[root@localhost ~]# mv *.repo  bak

3.下载repo文件

腾讯云镜像地址

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo

根据系统版本下载对应的文件:

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

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

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

也可以下载163的镜像源

wget     http://mirrors.163.com/.help/CentOS7-Base-163.repo

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2022-09-15 22:50:54--  http://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 111.31.118.239, 111.19.224.238, 111.19.224.241, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|111.31.118.239|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”

100%[=================================================>] 2,523       --.-K/s 用时 0s      

2022-09-15 22:50:59 (39.2 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])

4.检查

[root@localhost ~]# yum repolist
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
源标识                                        源名称                                                               状态
base/7/x86_64                                 CentOS-7 - Base - mirrors.aliyun.com                                 10,072
extras/7/x86_64                               CentOS-7 - Extras - mirrors.aliyun.com                                  516
updates/7/x86_64                              CentOS-7 - Updates - mirrors.aliyun.com                               4,156
repolist: 14,744

 5、如果出现如下报错:

Loaded plugins: fastestmirror
Existing lock /var/run/yum.pid: another copy is running as pid 1622.
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: yum
    Memory :  24 M RSS (961 MB VSZ)
    Started: Tue Jun 20 23:10:41 2023 - 10:50 ago
    State  : Sleeping, pid: 1622
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: yum
    Memory :  24 M RSS (961 MB VSZ)
    Started: Tue Jun 20 23:10:41 2023 - 10:52 ago
    State  : Sleeping, pid: 1622
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: yum
    Memory :  24 M RSS (961 MB VSZ)
    Started: Tue Jun 20 23:10:41 2023 - 10:54 ago
    State  : Sleeping, pid: 1622
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: yum
    Memory :  24 M RSS (961 MB VSZ)
    Started: Tue Jun 20 23:10:41 2023 - 10:56 ago
    State  : Sleeping, pid: 1622
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: yum
    Memory :  24 M RSS (961 MB VSZ)
    Started: Tue Jun 20 23:10:41 2023 - 10:58 ago
    State  : Sleeping, pid: 1622
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: yum
    Memory :  24 M RSS (961 MB VSZ)
    Started: Tue Jun 20 23:10:41 2023 - 11:00 ago
    State  : Sleeping, pid: 1622
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: yum
    Memory :  24 M RSS (961 MB VSZ)
    Started: Tue Jun 20 23:10:41 2023 - 11:03 ago
    State  : Sleeping, pid: 1622
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: yum
    Memory :  24 M RSS (961 MB VSZ)
    Started: Tue Jun 20 23:10:41 2023 - 11:05 ago
    State  : Sleeping, pid: 1622

解决如下:

yum只能支持一个例程运行,所以如果有一个例程已经在运行,其他的必须等待该进程退出释放lock。出现这种情况时,可以用以下命令来恢复:

1、rm -f /var/run/yum.pid
2、/sbin/service yum-updatesd restart

 

posted @ 2022-09-15 22:59  中仕  阅读(28)  评论(0编辑  收藏  举报