小红帽系统比较不优秀的地方就是自带的 yum 是收费的,不注册就不让装软件!
This system is not registered with an entitlement server. You can use subscription-manager to register.
所以要删掉自带的 yum:
rpm -qa|grep yum|xargs rpm -e --nodeps
下载这三个文件:wget -i url.txt
:
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
安装:
rpm -ivh yum-*
从 mirrors.163.com 下载对应版本的 repo 文件, 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 - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
官网上说把该文件放入 /etc/yum.repos.d/
。 但是没有说要要把 $releasever
替换为对应的版本,关于版本怎么查看:
uname -a # Linux haBigData1 3.10.0-693.el7.x86_64 #1 SMP Thu Jul 6 19:56:57 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux
看 el7.x86_64
中字母 x
前面的那个数字就是 $releasever
, 即现在我的 CentOS 使用的 Red Hat Linux 版本为 7(Red Hat Enterprise Linux 7.4(64-bit))。
我需要把 CentOS-Base.repo 文件中所有的 $releasever
都替换为数字 7,而不是傻傻的拿过来直接用。替换完之后:
# 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-7 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-7 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
清除和创建缓存:
yum clean all
yum makecache
但是执行 yum makecache
的时候又报错了:
Cannot find a valid baseurl for repo: atomic/$releasever/x86_64
发现 /etc/yum.repos.d
目录下面还有其它的 repo 文件:
ls /etc/yum.repos.d # atomic.repo CentOS-Base.repo redhat.repo
看报错信息,可能是 atomic.repo 这个文件中有 $releasever
没替换成 7,所以和上面一样,全部替换,再 yum makecache
就可以了!
# Name: Atomic Rocket Turtle RPM Repository for CentOS / Red Hat Enterprise Linux 7 -
# URL: http://www.atomicrocketturtle.com/
[atomic]
name = CentOS / Red Hat Enterprise Linux 7 - atomic
mirrorlist = http://updates.atomicorp.com/channels/mirrorlist/atomic/centos-7-$basearch
enabled = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY.art.txt
file:///etc/pki/rpm-gpg/RPM-GPG-KEY.atomicorp.txt
gpgcheck = 1
# Almost Stable, release candidates for [atomic]
[atomic-testing]
name = CentOS / Red Hat Enterprise Linux 7 - atomic - (Testing)
mirrorlist = http://updates.atomicorp.com/channels/mirrorlist/atomic-testing/centos-7-$basearch
enabled = 0
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY.art.txt
file:///etc/pki/rpm-gpg/RPM-GPG-KEY.atomicorp.txt
gpgcheck = 1
配置本地 yum 源
把 CDROM 里面的 Packages 和 repodata 和 RPM-GPG-KEY-CentOS-7 文件上传到服务器, Packages 里面是 .rpm 文件。
[root@bigdata1 cdrom]# ll
drwxr-xr-x. 2 root root 221184 12月 4 01:07 Packages
drwxrwxrwx. 2 root root 4096 12月 4 01:07 repodata
-rwxr-xr-x. 1 root root 1690 12月 4 01:06 RPM-GPG-KEY-CentOS-7
在 /etc/yum.repos.d
里面配置一个本地仓库:
[base-local]
name=CentOS-local
baseurl=file:///data/cdrom
keepcache=1
enabled=1
gpgcheck=0
gpgkey=file:///data/cdrom/RPM-GPG-KEY-CentOS-7
CentOS 7 安装 htop
验证一下:
yum -y install epel-release
yum -y install htop
网友评论