一、下载网络上开源yum站文件
epel:https://dl.fedoraproject.org/pub/epel/
网易镜像源:http://mirrors.163.com/.help/centos.html
阿里镜像源地址:http://mirrors.aliyun.com/repo/Centos-7.repo
选在自己系统的镜像,点后边帮助(centos7)
点击centos7即可下载
二、下载完成后上传到/etc/yum.repos.d/下
使用lrzsz上传
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
aa CentOS7-Base-163.repo
三、epel安装
例:[root@localhost yum.repos.d]# ls
aa Centos-7_.repo epel-release-latest-7.noarch_(1).rpm
[root@localhost yum.repos.d]# rpm -ihv epel-release-latest-7.noarch_\(1\).rpm
warning: epel-release-latest-7.noarch_(1).rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:epel-release-7-11 ################################# [100%]
[root@localhost yum.repos.d]# ls
aa Centos-7_.repo epel-release-latest-7.noarch_(1).rpm epel.repo epel-testing.repo
四、出错分析
例一:
[root@localhost yum.repos.d]# yum -y clean all
Loaded plugins: fastestmirror, langpacks
Existing lock /var/run/yum.pid: another copy is running as pid 2464.
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 146 M RSS (481 MB VSZ)
Started: Wed Aug 21 19:53:18 2019 - 07:52 ago
State : Sleeping, pid: 2464
####出现如上错误,是因为有一个进程正在使用yum,使用kill杀死即可#######
[root@localhost yum.repos.d]# ps -aux | grep yum
root 2464 5.3 14.9 492572 149516 ? SN 19:53 0:33 /usr/bin/python /usr/share/PackageKit/helpers/yum/yumBackend.py
root 3417 0.2 2.2 347420 23060 pts/0 T 20:01 0:00 /usr/bin/python /usr/bin/yum -y clean all
root 3823 0.0 0.0 112640 960 pts/0 R+ 20:03 0:00 grep --color=auto yum #ps搜索进程
#把前两个全部杀死
[root@localhost yum.repos.d]# kill 2464
[root@localhost yum.repos.d]# kill 3417
[root@localhost yum.repos.d]# ps -aux | grep yum
root 3417 0.1 2.2 347420 22900 pts/0 T 20:01 0:00 /usr/bin/python /usr/bin/yum -y clean all
root 4135 0.0 0.0 112640 960 pts/0 R+ 20:05 0:00 grep --color=auto yum
[root@localhost yum.repos.d]# kill -9 3417
[root@localhost yum.repos.d]# ps -aux | grep yum
root 4145 0.0 0.0 112640 960 pts/0 R+ 20:06 0:00 grep --color=auto yum
[1]+ Killed yum -y clean all
************************************以下无用***********************************
[root@localhost yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
[root@localhost yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/12): base/7/x86_64/group_gz | 166 kB 00:00:00
(2/12): base/7/x86_64/filelists_db | 7.1 MB 00:00:01
(3/12): extras/7/x86_64/prestodelta | 73 kB 00:00:00
(4/12): extras/7/x86_64/primary_db | 215 kB 00:00:00
(5/12): extras/7/x86_64/other_db | 131 kB 00:00:00
(6/12): extras/7/x86_64/filelists_db | 249 kB 00:00:01
(7/12): base/7/x86_64/primary_db | 6.0 MB 00:00:02
(8/12): updates/7/x86_64/prestodelta | 945 kB 00:00:00
(9/12): updates/7/x86_64/primary_db | 7.4 MB 00:00:01
(10/12): updates/7/x86_64/other_db | 764 kB 00:00:00
(11/12): base/7/x86_64/other_db | 2.6 MB 00:00:05
(12/12): updates/7/x86_64/filelists_db | 5.2 MB 00:00:06
Determining fastest mirrors
Metadata Cache Created
#建立成功
例二:
[root@localhost yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00:00
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:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Disable the repository, so yum won't use it by default. Yum will then
just ignore the repository until you permanently enable it again or use
--enablerepo for temporary usage:
yum-config-manager --disable <repoid>
4. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again
##############这里报找不到仓库源的错#######################
解决:
[root@localhost yum.repos.d]# vim epel.repo
将文件中的baseurl#号去掉,表示使用baseurl下的仓库源
metalink前加#号注释掉
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$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
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
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
改后
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://download.fedoraproject.org/pub/epel/7/$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
#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
#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
成功安装