我正在使用centos 7.在一些测试中,我不小心删除了yum.repo.d中的所有文件。有没有办法,下载和配置centos 7中的所有基本回购
答案 0 :(得分:9)
假设您正在运行CentOS-7.3,您可以通过以下方式取回repo文件,
op :-
keyword(a),
( keyword(b) ->
( keyword(c) ->
write('Answer A, B and C'), nl
; write('Answer A and B'), nl )
; write('Answer A'), nl ).
# ReInstall the centos-release rpm
~]# rpm -Uvh --force \
http://mirror.centos.org/centos-7/7/os/x86_64/Packages/centos-release-7-3.1611.el7.centos.x86_64.rpm
# Clean YUM cache
~]# yum clean all
# Try an update
~]# yum update
RPM包含所有repo文件,
centos-release
答案 1 :(得分:4)
#!/bin/bash
install-centos-release() {
releasever="$(rpm -q --qf '%{VERSION}' "$(rpm -q --whatprovides centos-release)")" \
&& releasever="$(printf "%s" "$releasever" | sed -e 's/\..*$//g')" \
&& basearch="$(uname -m)" \
&& reposurl=$(printf "%s" "http://mirror.centos.org/centos/$releasever/os/$basearch/Packages/") \
&& releaserpm=$(curl --silent "$reposurl" | grep -oP '(?<=")centos-release.*.rpm(?=")') \
&& releaseuri=$(printf "%s%s" "$reposurl" "$releaserpm") \
&& rpm -Uvh --force "$releaseuri"
}
用法:
# Either launch a new terminal and copy `install-centos-release` into the current shell process,
# or create a shell script and add it to the PATH to enable command invocation with bash.
install-centos-release
# Refresh YUM repository(ies)
yum clean all
yum -y update
答案 2 :(得分:0)
旧的好的复制/粘贴方法有权使用:
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/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
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/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
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7