Red Hat Subscription Manager

Red Hat 訂閱更新服務

Yum/Dnf & Rpm

yum/dnf

套件庫管裡
# 已啟用的套件庫清單
dnf repolist enabled

# 列出所有的套件庫包含 disabled 與 enabled
dnf repolist all
dnf repolist -v

# 已啟用套件庫的詳細資訊
dnf repoinfo

# 啟用指定的套件庫
dnf install yum-utils
dnf config-manager --enable <repositoryID>
# 停用指定的套件庫
dnf config-manager --disable <repositoryID>
系統更新
# 查詢所有可更新的套件
yum list updates
yum check-update
yum check-update --security

# 更新所有套件
yum update
yum update --disablerepo=epel

# 更新至指定的 release 版號
subscription-manager release --list
yum clean all
yum --releasever=8.6 update

# 更新與安全性相關的套件
yum update --security
yum update-minimal --security

# 更新指定套件
yum update sudo
yum --security update sudo
yum --security update-minimal sudo

# 系統更新驗證 (不做實際更新異動)
# NOTE: 這個驗證仍會下載更新檔至 cache 目錄,但不會有套件異動
yum update -y --setopt tsflags=test
yum clean packages

# 修補與 RHSA-XXX 相關的套件
yum update --advisory=RHSA-2019:0997
檢視套件清單
dnf list --all
dnf list --installed
dnf list --available
安裝/檢視指定版本套件
dnf --showduplicates list <package-name>
dnf list <package-name>-<version>
dnf install <package-name>-<version> 
歷史更新紀錄
# To display a list of all the latest yum transactions, use:
dnf history

# To display a list of all the latest operations for a selected package, use:
dnf history list <package-name>

# To examine a particular transaction, use:
dnf history info <transactionID>
# dnf history list
Updating Subscription Management repositories.
ID     | Command line                                                                     | Date and time    | Action(s)      | Altered
---------------------------------------------------------------------------------------------------------------------------------------
    12 | update                                                                           | 2022-03-18 16:57 | I, U           |  328 EE
    11 | install haproxy                                                                  | 2021-11-17 15:37 | Install        |    1
    10 | install chrony                                                                   | 2021-11-10 17:44 | Install        |    2
     9 | install vim-enhanced                                                             | 2021-11-10 17:44 | Install        |    4
     8 | install sysstat                                                                  | 2021-11-10 17:43 | Install        |    1
     7 | install yum-utils                                                                | 2021-11-10 17:43 | Install        |    1
     6 | install net-snmp-utils                                                           | 2021-11-10 17:43 | Install        |    1
     5 | install bind-utils net-snmp                                                      | 2021-11-10 17:42 | Install        |   30
     4 | install rsync mailx                                                              | 2021-11-10 17:42 | Install        |    1
     3 | install tmux                                                                     | 2021-11-10 17:41 | Install        |    1
     2 | install redhat-lsb-core                                                          | 2021-11-10 17:38 | Install        |   26
     1 |                                                                                  | 2021-11-10 17:27 | Install        |  396 EE
凍結套件版本

凍結特定套件版本可以避免在執行 yum update 系統更新時,特定套件也會被一起被更新。

# Install yum plugin: yum-versionlock
# The /etc/yum/pluginconf.d/versionlock.list will be created on the system.
# For RHEL 7.9
yum install yum-plugin-versionlock

# For RHEL 8 and 9
yum install python3-dnf-plugin-versionlock

# To install or lock the version of the gcc group of packages, run
yum versionlock gcc-*

# To display the list of locked packages, use:
yum versionlock list

# To discard the list of locked packages, use:
yum versionlock clear

# To discard the lock on a specific package, use:
yum versionlock delete <package_name>
凍結系統版本 (Release)
# To determine which releases are available:
subscription-manager release --list

# Temporary Setting
yum clean all
yum --releasever=8.6 update

# Permanent Setting
subscription-manager release --set=8.6
yum clean all
subscription-manager repos --list-enabled

# To determine which releases system is set to:
subscription-manager release --show

# To unset a specific release:
subscription-manager release --unset
yum clean all
subscription-manager repos

各種舊版本的套件庫位址

http://vault.centos.org/ 

清除套件庫清單及暫存的套件檔
dnf clean all
搜尋套件

搜尋檔案 libstdc++.so.6

dnf whatprovides "*/libstdc++.so.6" 
dnf provides "*/libstdc++.so.6"

搜尋套件

dnf search mypackage
dnf search --all mypackage
套件的相依性
dnf deplist <package-name>

repoquery --requires <package-name>
下載 RPM 套件
yum -y install yum-utils.noarch
yumdownloader <package-name>
yumdownloader --destdir /path/to/download <package-name>
# Includ all dependencies
yumdownloader --resolve --alldeps <package-name>

# Extract downloaded RPM
rpm2cpio dekiwiki-10.0.1-3.1.noarch.rpm | cpio -idmv 

yum -y install --downloadonly --downloaddir=/tmp/packages NetworkManager
一次性啟用套件庫位址
dnf --enablerepo=elrepo-kernel install kernel-ml kernel-ml-devel
使用光碟 ISO方式來安裝套件
# vi /etc/yum.repo.d/CentOS-Media.repo

[c6-local]
name=CentOS-$releasever - Media
baseurl=file:///mnt/disc/
gpgcheck=0
enabled=0

NOTE: enabled=0,不是 1。將 DVD 掛載為 /mnt/disc。 

# yum --disablerepo="*" --enablerepo=c6-local list available
# yum --disablerepo="*" --enablerepo=c6-local install nfs-utils
安裝本機端的 RPM 套件
dnf --nogpgcheck install htop-1.0.2-1.el5.rf.x86_64.rpm
匯出已安裝套件列表
yum list installed
yum list installed |tail -n +3|cut -d' ' -f1 > installed_packages.lst
# 或
rpm -qa > installed_packages.lst

yum -y install $(cat installed_packages.lst) 
安裝 EPEL 套件庫

EPEL - Extra Packages for Enterprise Linux

rpm -ivh http://mirror01.idc.hinet.net/EPEL/5/i386/epel-release-5-4.noarch.rpm
rpm -ivh http://mirror01.idc.hinet.net/EPEL/6/i386/epel-release-6-8.noarch.rpm 

TIPs:

錯誤: Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again
解決: sed -i "s/mirrorlist=https/mirrorlist=http/" /etc/yum.repos.d/epel.repo

安裝 ELRepo 套件庫

ELRepo - The Community Enterprise Linux Repository

rpm --import http://elrepo.org/RPM-GPG-KEY-elrepo.org

# for RHEL-5, CENTOS-5
rpm -Uvh http://elrepo.org/elrepo-release-5-2.el5.elrepo.noarch.rpm

# for RHEL-6, CENTOS-6
rpm -Uvh http://elrepo.org/elrepo-release-6-3.el6.elrepo.noarch.rpm
安裝 RPMforge/RepoForge 套件庫

RPMforge 是由 Dag 及其他包裝者合作維護的。他們為 CentOS 提供超過 5000 個套件,包括 wine、vlc、mplayer、xmms-mp3 及其他受歡迎的媒體工具。它並不是 Red Hat 或 CentOS 的一部份,但卻是為那些發行版本而設計的。

http://repoforge.org/use/

如何補安裝套件組

系統在第一次安裝時,都可以選擇要安裝哪些套件組,假使之後系統要補裝某套件組,例如 GNOME 視窗套件,可以使用這些指令,而不用一一找出有哪些相依性的套件名稱。

# 列出有哪些套件組可安裝
yum grouplist
# 安裝 GNOME 視窗套件組
yum groupinstall "GNOME Desktop Environment"
# 移除套件組
yum groupremove "Office Suite and Productivity" "Dial-up Networking Support"
Yum 設定

編輯 /etc/yum.conf

# Set Proxy
# proxy=http://<username>:<password>@<this.is.proxy.ip:<port>/
proxy=http://windowsad\username:password@proxy.server:port/

# Set Timeout
timeout=600


安裝本機上的 RPM
yum localinstall my.rpm

建立 YUM 套件庫主機 (with ISO)

安裝套件 createrepo
CetOS 5:

createrepo /source/path/reas5
createrepo -g  /source/path/reas5/repodata/comps.xml

CetOS 6/7:

# 建立套件索引
createrepo /yum-repo-packages/centos_6.4_x86_64
 
 # 建立套件群組索引
 # CentOS 6.4
 createrepo -g /yum-repo-packages/centos_6.4_x86_64/repodata/2727...cab6f72-c6-x86_64-comps.xml /yum-repo-packages/centos_6.4_x86_64
 # RedHat 7.9
 createrepo -g /mnt/yum-repo/redhat_7.9_x86_64/repodata/3df90817a193baef023d53222cc4ce8f4d15209e593bee361bf72016022008fb-comps-Server.x86_64.xml /mnt/yum-repo/redhat_7.9_x86_64

RHEL 8:

# for RHEL 8 only
yum install createrepo_c

cp -r /mnt/iso/* /mnt/yum-repo/redhat_8.3_x86_64 
createrepo /mnt/yum-repo/redhat_8.3_x86_64

rhel-local.repo:

[LocalRepo_BaseOS]
name=LocalRepo_BaseOS
metadata_expire=-1
enabled=1
gpgcheck=1
baseurl=ftp://10.1.115/LINUX_REPO/redhat_8.3_x86_64/BaseOS/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[LocalRepo_AppStream]
name=LocalRepo_AppStream
metadata_expire=-1
enabled=1
gpgcheck=1
baseurl=ftp://10.10.1.115/LINUX_REPO/redhat_8.3_x86_64/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

RPM

安裝套件

rpm -ivh vim-enhanced-*.x86_64.rpm

# Dry-run only without any changes
rpm -ivh --test vim-enhanced-*.x86_64.rpm

查詢指令

# 查詢已安裝的套件的詳細資訊
rpm -qi <package-name>

# 查詢已安裝套件是 32 或 64 bit
rpm -qa --qf "%{n}-%{v}-%{r}.%{arch}\n" | grep -i <package-name>

# 查詢未安裝的套件資訊
rpm -qpi your.rpm
less your.rpm

# 列出已安裝套件的相依性
rpm -q --requires <package-name>

# 列出未安裝的 RPM 的相依性
rpm -qp --requires your.rpm

# 列出一個尚未安裝的 RPM 所包含的檔案列表
rpm -qlp your.rpm

# 查詢檔案所屬的套件名稱
rpm -qf /usr/bin/ksh

# 查詢 RPM Public Key
rpm -q gpg-pubkey | sort | uniq -c | sort -nr

清查所有已安裝套件的名稱、版本、架構等資訊

rpm -qa --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n'| sort &> /tmp/rpm-qa.prod.output.txt

檢查指定套件的 Changelog

rpm -q --changelog sudo | grep -i cve-2021-3156
rpm -q --changelog -p sudo-1.8.6p3-29.0.2.el6_10.3.x86_64.rpm | grep -F CVE-2021

Rebuild source-rpm

yum install rpm-build
rpmbuild --rebuild something.src.rpm

GPG

# List all GPG keys
rpm -q gpg-pubkey | sort | uniq -c

# Get the information of a key
rpm -qi gpg-pubkey-2f86d6a1-5cf7cefb

清除 cache

yum clean all
rm /var/cache/yum/* -rf

常用管理工具安裝

使用 minimal ISO 安裝後,有些常用工具必須手動安裝。

RedHat 6
yum install setuptool system-config-network* system-config-securitylevel-tui system-config-keyboard \
  lvm2 lsof nfs-utils sysstat net-snmp net-snmp-utils vim-enhanced rsync mailx bind-utils vim-enhanced \
  net-tools
RedHat 7/8
yum install chrony tmux vim-enhanced rsync mailx bind-utils net-snmp net-snmp-utils \
  yum-utils sysstat nfs-utils redhat-lsb-core lsof net-tools

# for VMware guest OS
yum install open-vm-tools

桌面環境安裝

RHEL 8 & 9
yum group install GNOME base-x Fonts

#or 

yum groupinstall "Server with GUI"
RHEL 7
yum groupinstall gnome-desktop x11 fonts

# Or

yum groupinstall "Server with GUI"
RHEL 6
RHEL 5

CVE 相關指令

查詢目前系統是否有 CVE 的危害 (需要官網訂閱連線)

# 沒有內容輸出,表示沒有這個 CVE 的危害
yum updateinfo info --cve CVE-2023-48795

# With RHSA
yum updateinfo info --advisory RHSA-2023:7549

查詢目前系統的特定套件更新紀錄有無包含 CVE 編號

# rpm -q --changelog [package-name] | grep [CVE-NUMBER]
rpm -q --changelog openssl | grep CVE-2021-3450

查詢所有可用的安全性更新 (RHSA 通報資訊)

# 未安裝的
yum updateinfo list updates security

# 已安裝的
yum updateinfo list security --installed

# 顯示特定 RHSA 號碼的詳細資訊
yum updateinfo info <RHSA ID>

FAQ

About EPEL Repository

Important Notice

(https://access.redhat.com/solutions/3358 )

What is the difference between yum update vs yum update-minimal

https://access.redhat.com/solutions/3620411

How to Upgrade RHEL 8 to RHEL 9
RHEL 4 沒有 yum 指令

RHEL 4 沒有官方的 yum 套件,需要安裝社群版的。

解開下方 zip 檔,安裝所有 *.rpm。

Yum_rhel4.zip

Sign up and Register

Tutorials

Unregistered Subscription Manager

# yum repolist
Updating Subscription Management repositories.

This system is registered to Red Hat Subscription Management, but is not receiving updates. You can use subscription-manager to assign subscriptions.

NOTE: 在 /etc/yum.repos.d/ 目錄裡,如果曾經有手動設定其它的 repository,請先移除,或者將它們 Disable。

Sign up an account

RedHat 訂閱帳號有分付費版與免費版兩種。

付費版)

免費版 for developer)

申請 Developer 帳號後,在訂閱頁面會有兩個產品,主要是第二項 Red Hat Developer Subscription for Individuals,有了這個,RedHat 主機就可以像付費版那樣作線上更新。

rhn-developer.png

Configure HTTP Proxy (optional)

One-liner Command

subscription-manager config --server.proxy_hostname=proxy.example.com --server.proxy_port=8080 --server.proxy_user=admin --server.proxy_password=secret

Alternatively, proxy information can be added into configuration

/etc/rhsm/rhsm.conf:

# an http proxy server to use
proxy_hostname =

# port for http proxy server
proxy_port =

# user name for authenticating to an http proxy, if needed
proxy_user =

# password for basic http proxy auth, if needed
proxy_password =

Testing the connectivity to RHN

Without Proxy

curl -v https://subscription.rhn.redhat.com/subscription/ --cacert /etc/rhsm/ca/redhat-uep.pem

With Proxy

curl -v --proxy-user user:password --proxy proxy.example.com:8080 https://subscription.rhn.redhat.com/subscription/ --cacert /etc/rhsm/ca/redhat-uep.pem

curl -v --proxy-user user:password --proxy proxy.example.com:8080 https://subscription.rhsm.redhat.com/ --cacert /etc/rhsm/ca/redhat-uep.pem

curl -v --proxy-user user:password --proxy proxy.example.com:8080 https://cdn.redhat.com/ --cacert /etc/rhsm/ca/redhat-uep.pem
*   Trying 10.14.25.128...
* TCP_NODELAY set
* Connected to tpemispr01.winfoundry.com (10.14.25.128) port 8080 (#0)
* allocate connect buffer!
* Establish HTTP proxy tunnel to subscription.rhn.redhat.com:443
> CONNECT subscription.rhn.redhat.com:443 HTTP/1.1
> Host: subscription.rhn.redhat.com:443
> User-Agent: curl/7.61.1
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 Connection established
<
* Proxy replied 200 to CONNECT request
* CONNECT phase completed!
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/rhsm/ca/redhat-uep.pem
  CApath: none
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* CONNECT phase completed!
* CONNECT phase completed!
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Request CERT (13):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Certificate (11):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: C=US; ST=North Carolina; O=Red Hat, Inc.; OU=Red Hat Subscription Management; CN=subscription.rhsm.redhat.com; emailAddress=ca-support@redhat.com
*  start date: May  7 00:43:39 2020 GMT
*  expire date: May  7 00:43:39 2023 GMT
*  issuer: C=US; ST=North Carolina; O=Red Hat, Inc.; OU=Red Hat Network; CN=Red Hat Entitlement Operations Authority; emailAddress=ca-support@redhat.com
*  SSL certificate verify ok.
> GET /subscription/ HTTP/1.1
> Host: subscription.rhn.redhat.com
> User-Agent: curl/7.61.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: openresty/1.19.9.1
< Date: Wed, 16 Feb 2022 06:26:59 GMT
< Content-Type: application/json
< Transfer-Encoding: chunked
< Connection: keep-alive
< x-candlepin-request-uuid: 616ae5b2-53a2-4e9d-816e-b359545c4805
< X-Version: 3.2.22-1
<
[{"rel":"consumertypes","href":"/consumertypes"},{"rel":"distributor_versions","href":"/distributor_versions"},{"rel":"","href":"/"},{"rel":"admin","href":"/admin"},{"rel":"content","href":"/content"},{"rel":"cdn","href":"/cdn"},{"rel":"jobs","href":"/jobs"},{"rel":"crl","href":"/crl"},{"rel":"deleted_consumers","href":"/deleted_consumers"},{"rel":"rules","href":"/rules"},{"rel":"products","href":"/products"},{"rel":"roles","href":"/roles"},{"rel":"subscriptions","href":"/subscriptions"},{"rel":"activation_keys","href":"/activation_keys"},{"rel":"status","href":"/status"},{"rel":"consumers","href":"/consumers"},{"rel":"content_overrides","href":"/consumers/{consumer_uuid}/content_overrides"},{"rel":"users","href":"/users"},{"rel":"hypervisors","href":"/hypervisors"},{"rel":"guestids","href":"/consumers/{consumer_uuid}/guestids"},{"rel":"entitlements","href":"/entitlements"},{"rel":"owners","href":"/owners"},{"rel":"pools","href":"/pools"},{"rel":"serials","href":"/serials"},{"rel":"packages", "href":"/consume* Connection #0 to host tpemispr01.winfoundry.com left intact

Register to RHN

subscription-manager remove --all
subscription-manager unregister
subscription-manager clean
yum clean all
rm -rf /var/cache/yum/*

# Option#1:  With the credentials
subscription-manager register --username myname --password 'ThisPassword'
# Option#2: With an Activation Key
# Create a key from the url https://access.redhat.com/management/activation_keys
subscription-manager register --org=<ORG-ID> --activationkey=<NAME>
[~]# yum clean all
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use subscription-manager to register.

17 files removed
[~]# subscription-manager register --username myuser --password 'mypassword'
Registering to: subscription.rhsm.redhat.com:443/subscription
The system has been registered with ID: 36e3da57-5896-488e-ab8e-9f95a48c9f8c
The registered system name is: haproxy.winfoundry.com

[~]# yum repolist
Updating Subscription Management repositories.

This system is registered with an entitlement server, but is not receiving updates. You can use subscription-manager to assign subscriptions.

[~]# subscription-manager attach --auto
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux for x86_64
Status:       Subscribed


[~]# subscription-manager status
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Current

System Purpose Status: Matched


[~]# yum repolist
Updating Subscription Management repositories.
repo id                              repo name
rhel-8-for-x86_64-appstream-rpms     Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)
rhel-8-for-x86_64-baseos-rpms        Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)

Registered Subscription Manager

[~]# yum repolist
Updating Subscription Management repositories.
repo id                                                   repo name
rhel-8-for-x86_64-appstream-rpms                          Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)
rhel-8-for-x86_64-baseos-rpms                             Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)

登入 https://access.redhat.com/,在系統清單會顯示主機名稱。

subscription-registered.png

Registering an offline system (optional)

如果主機端沒有網際網路,也可以使用離線註冊方式。

  1. Create a system profile. From the systems page in Red Hat Subscription Management, click the New button. Provide the required information to finish creating the new system profile.
  2. Attach subscriptions. In your newly created system profile, click the Subscriptions tab, and attach any subscriptions you want to use with the system.
  3. Download and import the entitlement certificate(s). From the Subscriptions tab on your system profile, click Download Certificates to download the entitlement certificate(s) for attached subscriptions. The downloaded file will be in zip format. Extract the content and in /export/entitlement_certificates/ folder you will find the certificate xyz.pem. Move it to the client system’s /tmp directory.
# subscription-manager import --certificate=/tmp/Name_Of_Downloaded_Entitlement_Cert.pem
Restoring a registration

主機端曾經成功註冊過,因為某些原因,系統裡的註冊紀錄遺失、或者系統重新安裝後,可以回復原先的註冊紀錄。

以 System UUID 方式重新註冊原有的主機

# subscription-manager register --consumerid=SYSTEM-UUID --username=MYUSER --password=MYPASS

Verifying Subscription

[root@haproxy ~]# subscription-manager list
+-------------------------------------------+
    Installed Product Status
+-------------------------------------------+
Product Name:   Red Hat Enterprise Linux for x86_64
Product ID:     479
Version:        8.3
Arch:           x86_64
Status:         Subscribed
Status Details:
Starts:         03/02/2022
Ends:           03/02/2023


[root@haproxy ~]# yum repolist enabled
Updating Subscription Management repositories.
repo id                                                   repo name
rhel-8-for-x86_64-appstream-rpms                          Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)
rhel-8-for-x86_64-baseos-rpms                             Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)

Removing from RHN

Commands Overview

subscription-manager unsubscribe --all
subscription-manager remove --all
subscription-manager unregister
subscription-manager clean

Remove all subscriptions,run:

# subscription-manager remove --all

1 local certificate has been deleted.
1 subscription removed at the server.

To unregister the system from the Red Hat, run:

# subscription-manager unregister

Unregistering from: subscription.rhsm.redhat.com:443/subscription
System has been unregistered.

To remove all local data from the system, run:

# subscription-manager clean
All local data removed

登入 https://access.redhat.com/ 在訂閱頁面的系統欄,原先註冊的主機名稱會自動移除。

Update System

yum list updates
yum update


FAQ

Registering to: subscription.rhsm.redhat.com:443/subscription
Network error, unable to connect to server. Please see /var/log/rhsm/rhsm.log for more information.

Solution: Check the firewall by following the instructions below.

It is not recommended to specify the IP addresses because the packages are distributed through the Akamai network and the IP addresses are subject to change. However, if your firewall is unable to use host name filtering, Red Hat provides a pool of IP addresses that should provide CDN delivery.

Q: subscription-manager attach --auto

Installed Product Current Status:
Product Name: Red Hat Enterprise Linux for x86_64
Status: Not Subscribed

Solution:

  1. 登入 https://access.redhat.com/,確定帳戶裡有可用的訂閱服務。
  2. 如果是免費版 RedHat Developer 帳號,在訂閱清單裡如果沒有看到 Red Hat Developer Subscription for Individuals 這一項,請先登入 https://developers.redhat.com/ 然後再確認一次。  注意: 免費版個人授權需要每年手動更新一次有效期。
  3. 執行 subscription-manager refresh

This system is registered to Red Hat Subscription Management, but is not receiving updates. You can use subscription-manager to assign subscriptions.

Solution:

subscription-manager attach --auto



Subscription Usage

Viewing subscription

NOTE: 這裡的版本號是指已訂閱的線上產品的版本,並非安裝在系統的版本。

# subscription-manager list --installed
+-------------------------------------------+
    Installed Product Status
+-------------------------------------------+
Product Name:   Red Hat Enterprise Linux for x86_64
Product ID:     479
Version:        8.5
Arch:           x86_64
Status:         Subscribed
Status Details:
Starts:         03/27/2022
Ends:           03/27/2023
# subscription-manager list --consumed
+-------------------------------------------+
   Consumed Subscriptions
+-------------------------------------------+
Subscription Name:   Red Hat Developer Subscription for Individuals
Provides:            Red Hat Enterprise Linux High Availability - Update Services for SAP
                     Solutions
                     Red Hat CodeReady Linux Builder for IBM z Systems - Extended Update Support
                     Red Hat Enterprise Linux Atomic Host
                     JBoss Enterprise Application Platform from RHUI
                     Red Hat Enterprise Linux Atomic Host Beta
                     JBoss Enterprise Web Server from RHUI
                     Red Hat Developer Tools (for RHEL Server)
                     Red Hat Container Images
                     Red Hat 3scale API Management Platform
                     Red Hat Developer Tools Beta (for RHEL Server)
                     Red Hat Container Images Beta
                     Red Hat OpenShift Enterprise JBoss EAP add-on
                     Red Hat Software Collections (for RHEL Server for ARM)
                     Red Hat Software Collections Beta (for RHEL Server for ARM)
                     Red Hat Migration Toolkit
                     Red Hat OpenShift Enterprise JBoss FUSE add-on
                     Red Hat OpenShift Enterprise JBoss A-MQ add-on
                     Red Hat JBoss Core Services from RHUI
                     Red Hat Enterprise Linux for x86_64
                     Red Hat Enterprise Linux Resilient Storage for x86_64
                     Red Hat Enterprise Linux Resilient Storage for x86_64 - Extended Update
                     Support
                     Red Hat Enterprise Linux Scalable File System (for RHEL Server)
                     dotNET on RHEL (for RHEL Server)
                     dotNET on RHEL Beta (for RHEL Server)
                     Red Hat Enterprise Linux Scalable File System (for RHEL Server) - Extended
                     Update Support
                     Red Hat Ansible Automation Platform
                     Oracle Java (for RHEL Server)
                     Red Hat Enterprise Linux for SAP HANA for x86_64
                     OpenJDK Java (for Middleware)
                     Red Hat Enterprise Linux for Real Time
                     Red Hat Software Collections (for RHEL Server)
                     Red Hat AMQ Interconnect
                     Oracle Java (for RHEL Server) - Extended Update Support
                     Red Hat Openshift Application Runtimes for IBM Power LE
                     Red Hat Developer Tools (for RHEL Server for ARM)
                     RHEL for SAP - Extended Update Support
                     Red Hat Developer Tools Beta (for RHEL Server for ARM)
                     Red Hat S-JIS Support (for RHEL Server) - Extended Update Support
                     RHEL for SAP HANA - Extended Update Support
                     Red Hat Software Collections Beta (for RHEL Server)
                     Red Hat Ansible Engine
                     Red Hat Enterprise Linux Server
                     Red Hat OpenShift Container Platform
                     Red Hat Container Development Kit
                     Red Hat CodeReady Linux Builder for x86_64
                     MRG Realtime
                     Red Hat CodeReady Linux Builder for ARM 64
                     Red Hat Enterprise Linux High Performance Networking (for RHEL Server)
                     Red Hat Developer Toolset (for RHEL Server)
                     Red Hat Enterprise Linux High Performance Networking (for RHEL Server) -
                     Extended Update Support
                     Red Hat Enterprise Linux High Performance Networking (for RHEL Compute Node)
                     Red Hat Build of Quarkus
                     Red Hat OpenShift Application Runtimes Beta
                     Red Hat Enterprise Linux EUS Compute Node
                     Red Hat Enterprise Linux for x86_64 - Extended Update Support
                     Red Hat Openshift Application Runtimes
                     Red Hat Enterprise Linux for ARM 64
                     Red Hat Enterprise Linux for IBM z Systems - Extended Update Support
                     Red Hat Beta
                     Red Hat EUCJP Support (for RHEL Server) - Extended Update Support
                     JBoss Enterprise Application Platform
                     JBoss Enterprise Web Platform
                     RHEL for SAP (for IBM Power LE) - Update Services for SAP Solutions
                     Red Hat Developer Suite v.3
                     Red Hat Enterprise Linux Server - Update Services for SAP Solutions
                     Red Hat Enterprise Linux High Availability (for IBM z Systems) - Extended
                     Update Support
                     Red Hat Enterprise Linux for SAP Applications for x86_64
                     RHEL for SAP - Update Services for SAP Solutions
                     Red Hat JBoss AMQ Clients
                     RHEL for SAP HANA - Update Services for SAP Solutions
                     Red Hat Enterprise Linux Resilient Storage for IBM z Systems - Extended
                     Update Support
                     Red Hat OpenShift Enterprise JBoss EAP add-on Beta
                     Red Hat CodeReady Linux Builder for x86_64 - Extended Update Support
                     Red Hat CodeReady Workspaces for OpenShift
                     Red Hat JBoss Middleware
                     Red Hat JBoss Data Grid
                     Red Hat JBoss Core Services
                     Red Hat Enterprise Linux High Availability for x86_64
                     Red Hat Enterprise Linux High Availability for x86_64 - Extended Update
                     Support
                     Red Hat Enterprise Linux Load Balancer (for RHEL Server)
                     Red Hat Enterprise Linux Load Balancer (for RHEL Server) - Extended Update
                     Support
SKU:                 RH00798
Contract:
Account:
Serial:              4923702908878597137
Pool ID:             8a82c6557fc28ee7017fce53f95610a9
Provides Management: No
Active:              True
Quantity Used:       1
Service Type:
Roles:               Red Hat Enterprise Linux Server
                     Red Hat Enterprise Linux Workstation
                     Red Hat Enterprise Linux Compute Node
Service Level:       Self-Support
Usage:               Development/Test
Add-ons:
Status Details:      Subscription is current
Subscription Type:   Standard
Starts:              03/27/2022
Ends:                03/27/2023
Entitlement Type:    Physical
# subscription-manager list --available
+-------------------------------------------+
    Available Subscriptions
+-------------------------------------------+
Subscription Name:   Red Hat Beta Access
Provides:            Red Hat CodeReady Linux Builder for x86_64 Beta
                     Red Hat Enterprise Linux for IBM z Systems Beta
                     Red Hat Enterprise Linux Fast Datapath Beta for Power, little endian
                     Red Hat Enterprise Linux Resilient Storage Beta
                     Red Hat Enterprise Linux for x86_64 Beta
                     Red Hat Enterprise Linux for Real Time for NFV Beta
                     Red Hat Enterprise Linux for Real Time Beta
                     Red Hat Enterprise Linux for SAP HANA for x86_64 Beta
                     Red Hat Directory Server Beta
                     Red Hat Enterprise Linux Advanced Virtualization Beta (for RHEL Server for IBM System Z)
                     Red Hat Enterprise Linux for SAP Applications for x86_64 Beta
                     Red Hat Enterprise Linux for SAP Applications for IBM z Systems Beta
                     Red Hat CodeReady Linux Builder for ARM 64 Beta
                     Red Hat Enterprise Linux for SAP Applications for Power, little endian Beta
                     Red Hat Enterprise Linux Fast Datapath Beta for x86_64
                     Red Hat CodeReady Linux Builder for Power, little endian Beta
                     Red Hat CodeReady Linux Builder for IBM z Systems Beta
                     Red Hat Enterprise Linux High Availability Beta
                     Red Hat Enterprise Linux for Power, little endian Beta
                     Red Hat Enterprise Linux for ARM 64 Beta
                     Red Hat Certificate System Beta
                     Red Hat Enterprise Linux for SAP HANA for Power, little endian Beta
SKU:                 RH00069
Contract:
Pool ID:             8a82c6557fc28ee7017fce53f78f10a7
Provides Management: No
Available:           Unlimited
Suggested:           1
Service Type:        L1-L3
Roles:
Service Level:       Self-Support
Usage:
Add-ons:
Subscription Type:   Standard
Starts:              03/27/2022
Ends:                03/27/2023
Entitlement Type:    Physical
設定合適的系統屬性

System Purpose 是系統訂閱服務的其中一個設定,每個訂閱的系統依據用途不同以及系統安裝類型,設定適合系統的各種屬性,這些屬性在自動掛載訂閱時,系統會選擇最合適的訂閱項目。

屬性類型有分 Role、Usage、Service-Level、Addons。

要檢視各屬性包含的值,可以執行

# subscription-manager role --list
+-------------------------------------------+
               Available role
+-------------------------------------------+
 - Red Hat Enterprise Linux Workstation
 - Red Hat Enterprise Linux Server
 - Red Hat Enterprise Linux Compute Node

設定 role

# subscription-manager role --show
Role not set.

# subscription-manager role --set="Red Hat Enterprise Linux Server"
role set to "Red Hat Enterprise Linux Server".

# subscription-manager role --show
Current Role: Red Hat Enterprise Linux Server
Errata 資訊未更新

如果在官網訂閱網站顯示有最新的 Errata 套件修補資訊,但 yum 指令卻不會顯示。

強制系統檢查 errata 可以執行

rm -f /var/lib/rhsm/packages/packages.json
service rhsmcertd stop
rhsmcertd --now
yum update
Subscribe to the Extras channel/repo
subscription-manager repos --list
subscription-manager repos --enable rhel-7-server-extras-rpms
subscription-manager repos --disable amq-clients-2-for-rhel-8-x86_64-rpms

# With yum
yum repolist --all
yum-config-manager --enable <repo-id>
Expired Subscription

Error: You no longer have access to the repositories that provide these products.  It is important that you apply an active subscription in order to resume access to security and other critical updates. If you don't have other active subscriptions, you can renew the expired subscription.

檢查已 attach 的訂閱

# subscription-manager list --consumed
+-------------------------------------------+
   Consumed Subscriptions
+-------------------------------------------+
Subscription Name:   Red Hat Developer Subscription for Individuals
Provides:            Red Hat Enterprise Linux High Availability for x86_64 - Update Services for
                     SAP Solutions
                     Red Hat Enterprise Linux Atomic Host
                     Red Hat CodeReady Linux Builder for IBM z Systems - Extended Update Support
                     JBoss Enterprise Application Platform from RHUI
                     Red Hat Enterprise Linux Atomic Host Beta
                     JBoss Enterprise Web Server from RHUI
                     Red Hat Developer Tools (for RHEL Server)
                     Red Hat Container Images
                     Red Hat Developer Tools Beta (for RHEL Server)
                     Red Hat Container Images Beta
                     Red Hat 3scale API Management Platform
                     Red Hat OpenShift Enterprise JBoss EAP add-on
                     Red Hat Software Collections (for RHEL Server for ARM)
                     Red Hat Software Collections Beta (for RHEL Server for ARM)
                     Red Hat OpenShift Enterprise JBoss FUSE add-on
                     Red Hat Migration Toolkit
                     Red Hat OpenShift Enterprise JBoss A-MQ add-on
                     Red Hat JBoss Core Services from RHUI
                     Red Hat Enterprise Linux for x86_64
                     Red Hat Enterprise Linux Resilient Storage for x86_64
                     Red Hat Enterprise Linux Resilient Storage for x86_64 - Extended Update
                     Support
                     dotNET on RHEL (for RHEL Server)
                     Red Hat Enterprise Linux Scalable File System (for RHEL Server)
                     dotNET on RHEL Beta (for RHEL Server)
                     Red Hat Enterprise Linux Scalable File System (for RHEL Server) - Extended
                     Update Support
                     Red Hat Ansible Automation Platform
                     Red Hat OpenShift Container Platform for ARM 64
                     Oracle Java (for RHEL Server)
                     Red Hat Enterprise Linux for SAP Solutions for x86_64
                     OpenJDK Java (for Middleware)
                     Red Hat Enterprise Linux for Real Time
                     Red Hat AMQ Interconnect
                     Red Hat Software Collections (for RHEL Server)
                     Red Hat Enterprise Linux for SAP Applications for x86_64 - Extended Update
                     Support
                     Red Hat Openshift Application Runtimes for IBM Power LE
                     Oracle Java (for RHEL Server) - Extended Update Support
                     Red Hat Developer Tools (for RHEL Server for ARM)
                     Red Hat Developer Tools Beta (for RHEL Server for ARM)
                     Red Hat Enterprise Linux for SAP Solutions for x86_64 - Extended Update
                     Support
                     Red Hat S-JIS Support (for RHEL Server) - Extended Update Support
                     Red Hat Software Collections Beta (for RHEL Server)
                     Red Hat Enterprise Linux Fast Datapath Beta for x86_64
                     Red Hat Enterprise Linux Fast Datapath
                     Red Hat Ansible Engine
                     Red Hat Enterprise Linux Server
                     Red Hat OpenShift Container Platform
                     Red Hat Container Development Kit
                     MRG Realtime
                     Red Hat CodeReady Linux Builder for x86_64
                     Red Hat CodeReady Linux Builder for ARM 64
                     Red Hat Developer Toolset (for RHEL Server)
                     Red Hat Enterprise Linux High Performance Networking (for RHEL Server)
                     Red Hat Enterprise Linux High Performance Networking (for RHEL Server) -
                     Extended Update Support
                     Red Hat Enterprise Linux High Performance Networking (for RHEL Compute Node)
                     Red Hat Build of Quarkus
                     Red Hat OpenShift Application Runtimes Beta
                     Red Hat Enterprise Linux EUS Compute Node
                     Red Hat Enterprise Linux for x86_64 - Extended Update Support
                     Red Hat Enterprise Linux Fast Datapath (for RHEL for ARM 64)
                     Red Hat Openshift Application Runtimes
                     Red Hat Enterprise Linux for IBM z Systems - Extended Update Support
                     Red Hat Enterprise Linux for ARM 64
                     Red Hat Beta
                     Red Hat EUCJP Support (for RHEL Server) - Extended Update Support
                     JBoss Enterprise Application Platform
                     JBoss Enterprise Web Platform
                     Red Hat Developer Suite v.3
                     Red Hat Enterprise Linux for SAP Applications for Power LE - Update Services
                     for SAP Solutions
                     Red Hat Enterprise Linux High Availability (for IBM z Systems) - Extended
                     Update Support
                     Red Hat Enterprise Linux for x86_64 - Update Services for SAP Solutions
                     Red Hat Enterprise Linux for SAP Applications for x86_64 - Update Services
                     for SAP Solutions
                     Red Hat Enterprise Linux for SAP Applications for x86_64
                     Red Hat Enterprise Linux Resilient Storage for IBM z Systems - Extended
                     Update Support
                     Red Hat JBoss AMQ Clients
                     Red Hat Enterprise Linux for SAP Solutions for x86_64 - Update Services for
                     SAP Solutions
                     Red Hat OpenShift Enterprise JBoss EAP add-on Beta
                     Red Hat CodeReady Linux Builder for x86_64 - Extended Update Support
                     Red Hat JBoss Middleware
                     Red Hat CodeReady Workspaces for OpenShift
                     Red Hat JBoss Data Grid
                     Red Hat JBoss Core Services
                     Red Hat Enterprise Linux High Availability for x86_64
                     Red Hat Enterprise Linux High Availability for x86_64 - Extended Update
                     Support
                     Red Hat Enterprise Linux Load Balancer (for RHEL Server)
                     Red Hat Enterprise Linux Load Balancer (for RHEL Server) - Extended Update
                     Support
SKU:                 RH00798
Contract:
Account:
Serial:              1872264450564878453
Pool ID:             2c9486b7848d39d60184a84a43e874fb
Provides Management: No
Active:              False
Quantity Used:       1
Service Type:
Roles:
Service Level:       Self-Support
Usage:               Development/Test
Add-ons:
Status Details:      Subscription is expired      <======== NOTE: To remove this one
Subscription Type:
Starts:              11/24/2022
Ends:                11/24/2023
Entitlement Type:    Physical

Subscription Name:   Red Hat Developer Subscription for Individuals
Provides:            Red Hat Enterprise Linux High Availability for x86_64 - Update Services for
                     SAP Solutions
                     Red Hat Enterprise Linux Atomic Host
                     Red Hat CodeReady Linux Builder for IBM z Systems - Extended Update Support
                     JBoss Enterprise Application Platform from RHUI
                     Red Hat Enterprise Linux Atomic Host Beta
                     JBoss Enterprise Web Server from RHUI
                     Red Hat Developer Tools (for RHEL Server)
                     Red Hat Container Images
                     Red Hat Developer Tools Beta (for RHEL Server)
                     Red Hat Container Images Beta
                     Red Hat 3scale API Management Platform
                     Red Hat OpenShift Enterprise JBoss EAP add-on
                     Red Hat Software Collections (for RHEL Server for ARM)
                     Red Hat Software Collections Beta (for RHEL Server for ARM)
                     Red Hat OpenShift Enterprise JBoss FUSE add-on
                     Red Hat Migration Toolkit
                     Red Hat OpenShift Enterprise JBoss A-MQ add-on
                     Red Hat JBoss Core Services from RHUI
                     Red Hat Enterprise Linux for x86_64
                     Red Hat Enterprise Linux Resilient Storage for x86_64
                     Red Hat Enterprise Linux Resilient Storage for x86_64 - Extended Update
                     Support
                     dotNET on RHEL (for RHEL Server)
                     Red Hat Enterprise Linux Scalable File System (for RHEL Server)
                     dotNET on RHEL Beta (for RHEL Server)
                     Red Hat Enterprise Linux Scalable File System (for RHEL Server) - Extended
                     Update Support
                     Red Hat Ansible Automation Platform
                     Red Hat OpenShift Container Platform for ARM 64
                     Oracle Java (for RHEL Server)
                     Red Hat Enterprise Linux for SAP Solutions for x86_64
                     OpenJDK Java (for Middleware)
                     Red Hat Enterprise Linux for Real Time
                     Red Hat AMQ Interconnect
                     Red Hat Software Collections (for RHEL Server)
                     Red Hat Enterprise Linux for SAP Applications for x86_64 - Extended Update
                     Support
                     Red Hat Openshift Application Runtimes for IBM Power LE
                     Oracle Java (for RHEL Server) - Extended Update Support
                     Red Hat Developer Tools (for RHEL Server for ARM)
                     Red Hat Developer Tools Beta (for RHEL Server for ARM)
                     Red Hat Enterprise Linux for SAP Solutions for x86_64 - Extended Update
                     Support
                     Red Hat S-JIS Support (for RHEL Server) - Extended Update Support
                     Red Hat Software Collections Beta (for RHEL Server)
                     Red Hat Enterprise Linux Fast Datapath Beta for x86_64
                     Red Hat Enterprise Linux Fast Datapath
                     Red Hat Ansible Engine
                     Red Hat Enterprise Linux Server
                     Red Hat OpenShift Container Platform
                     Red Hat Container Development Kit
                     MRG Realtime
                     Red Hat CodeReady Linux Builder for x86_64
                     Red Hat CodeReady Linux Builder for ARM 64
                     Red Hat Developer Toolset (for RHEL Server)
                     Red Hat Enterprise Linux High Performance Networking (for RHEL Server)
                     Red Hat Enterprise Linux High Performance Networking (for RHEL Server) -
                     Extended Update Support
                     Red Hat Enterprise Linux High Performance Networking (for RHEL Compute Node)
                     Red Hat Build of Quarkus
                     Red Hat OpenShift Application Runtimes Beta
                     Red Hat Enterprise Linux EUS Compute Node
                     Red Hat Enterprise Linux for x86_64 - Extended Update Support
                     Red Hat Enterprise Linux Fast Datapath (for RHEL for ARM 64)
                     Red Hat Openshift Application Runtimes
                     Red Hat Enterprise Linux for IBM z Systems - Extended Update Support
                     Red Hat Enterprise Linux for ARM 64
                     Red Hat Beta
                     Red Hat EUCJP Support (for RHEL Server) - Extended Update Support
                     JBoss Enterprise Application Platform
                     JBoss Enterprise Web Platform
                     Red Hat Developer Suite v.3
                     Red Hat Enterprise Linux for SAP Applications for Power LE - Update Services
                     for SAP Solutions
                     Red Hat Enterprise Linux High Availability (for IBM z Systems) - Extended
                     Update Support
                     Red Hat Enterprise Linux for x86_64 - Update Services for SAP Solutions
                     Red Hat Enterprise Linux for SAP Applications for x86_64 - Update Services
                     for SAP Solutions
                     Red Hat Enterprise Linux for SAP Applications for x86_64
                     Red Hat Enterprise Linux Resilient Storage for IBM z Systems - Extended
                     Update Support
                     Red Hat JBoss AMQ Clients
                     Red Hat Enterprise Linux for SAP Solutions for x86_64 - Update Services for
                     SAP Solutions
                     Red Hat OpenShift Enterprise JBoss EAP add-on Beta
                     Red Hat CodeReady Linux Builder for x86_64 - Extended Update Support
                     Red Hat JBoss Middleware
                     Red Hat CodeReady Workspaces for OpenShift
                     Red Hat JBoss Data Grid
                     Red Hat JBoss Core Services
                     Red Hat Enterprise Linux High Availability for x86_64
                     Red Hat Enterprise Linux High Availability for x86_64 - Extended Update
                     Support
                     Red Hat Enterprise Linux Load Balancer (for RHEL Server)
                     Red Hat Enterprise Linux Load Balancer (for RHEL Server) - Extended Update
                     Support
SKU:                 RH00798
Contract:
Account:
Serial:              8577712511130208842
Pool ID:             2c94cfad870f5a69018726de7fc90097
Provides Management: No
Active:              True
Quantity Used:       1
Service Type:
Roles:
Service Level:       Self-Support
Usage:               Development/Test
Add-ons:
Status Details:      Subscription is current
Subscription Type:   Standard
Starts:              03/28/2023
Ends:                03/27/2024
Entitlement Type:    Physical

檢查官網的系統 > 訂閱:過期訂閱已消失或移除 (unattach) 

更新系統的訂閱資訊

subscription-manager refresh
Cheat Sheet

rh_sm_command_cheatsheet_1214_jcs_web.png