前言:想要在伺服器Redhat7 安裝gcc 使用yum install gcc 報錯:
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
原因是Redhat的yum需要注冊。這裡想辦法安裝了CentOS的yum源
一、解除安裝原來的yum
#檢視原來是否安裝
rpm -qa |grep yum
#解除安裝本機yum
rpm -qa|grep yum|xargs rpm -e --nodeps
# 檢視yum是否解除安裝幹淨
rpm -qa |grep yum
二、下載下傳yum替換包
這裡要說明一下,因為要替換,是以一定要是一整套,還有一個rhel-debuginfo.repo檔案要配置。
我這裡準備了yum包,已上傳到csdn資源。在公司Redhat伺服器已經安裝成功。下載下傳路徑:https://download.csdn.net/download/kzdwts/10586712
可以先建一個檔案夾,然後把5個安裝包拷貝到 yum 這個檔案下面
執行:
rpm -ivh *.rpm
一次性執行依賴包,因為包之間會互相依賴。
第三步:建立配置 .repo檔案
vim /etc/yum.repos.d/CentOS-Base.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-$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 clear all
yum list
好了,到這裡就可用了。附上我在公司Redhat安裝執行的指令