如何在 RHEL 中使用訂閱管理器啟用軟體倉庫
在本文中,我們將逐步介紹如何在剛安裝的 RHEL 伺服器中啟用 Red Hat 軟體倉庫。
可以利用 subscription-manager
命令啟用軟體倉庫,如下所示:
root@kerneltalks # subscription-manager repos --enable rhel-6-server-rhv-4-agent-beta-debug-rpms
Error: 'rhel-6-server-rhv-4-agent-beta-debug-rpms' does not match a valid repository ID. Use "subscription-manager repos --list" to see valid repositories.
當您的訂閱沒有配置好時,您會看到上述錯誤。讓我們一步一步地通過 subscription-manager
來啟用軟體倉庫。
步驟 1:使用 Red Hat 註冊您的系統
這裡假設您已經安裝了新系統並且尚未在 Red Hat 上註冊。如果您已經註冊了該系統,那麼您可以忽略此步驟。
您可以使用下面的命令來檢查您的系統是否已在 Red Hat 註冊了該訂閱:
# subscription-manager version
server type: This system is currently not registered.
subscription management server: Unknown
subscription management rules: Unknown
subscription-manager: 1.18.10-1.el6
python-rhsm: 1.18.6-1.el6
在這裡輸出的第一行中,您可以看到該系統未註冊。那麼,讓我們開始註冊系統。您需要在 subscription-manager
命令中使用 register
選項。在這一步需要使用您的 Red Hat 帳戶憑證。
root@kerneltalks # subscription-manager register
Registering to: subscription.rhsm.redhat.com:443/subscription
Username: admin@kerneltalks.com
Password:
Network error, unable to connect to server. Please see /var/log/rhsm/rhsm.log for more information.
如果您遇到上述錯誤,那麼表明您的伺服器無法連接到 RedHat。檢查您的網路連接,或者您能解決網站名稱解析的問題。有時候,即使你能夠 ping 通訂閱伺服器,你也會看到這個錯誤。這可能是因為您的環境中有代理伺服器。在這種情況下,您需要將其詳細信息添加到文件 /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 =
一旦你完成了這些,通過使用下面的命令重新檢查 subscription-manager
是否獲得了新的代理信息:
root@kerneltalks # subscription-manager config
[server]
hostname = [subscription.rhsm.redhat.com]
insecure = [0]
port = [443]
prefix = [/subscription]
proxy_hostname = [kerneltalksproxy.abc.com]
proxy_password = [asdf]
proxy_port = [3456]
proxy_user = [user2]
server_timeout = [180]
ssl_verify_depth = [3]
[rhsm]
baseurl = [https://cdn.redhat.com]
ca_cert_dir = [/etc/rhsm/ca/]
consumercertdir = [/etc/pki/consumer]
entitlementcertdir = [/etc/pki/entitlement]
full_refresh_on_yum = [0]
manage_repos = [1]
pluginconfdir = [/etc/rhsm/pluginconf.d]
plugindir = [/usr/share/rhsm-plugins]
productcertdir = [/etc/pki/product]
repo_ca_cert = /etc/rhsm/ca/redhat-uep.pem
report_package_profile = [1]
[rhsmcertd]
autoattachinterval = [1440]
certcheckinterval = [240]
[logging]
default_log_level = [INFO]
[] - Default value in use
現在,請嘗試重新註冊您的系統。
root@kerneltalks # subscription-manager register
Registering to: subscription.rhsm.redhat.com:443/subscription
Username: admin@kerneltalks.com
Password:
You must first accept Red Hat's Terms and conditions. Please visit https://www.redhat.com/wapps/tnc/termsack?event[]=signIn . You may have to log out of and back into the Customer Portal in order to see the terms.
如果您是第一次將伺服器添加到 Red Hat 帳戶,您將看到上述錯誤。轉到該 URL並接受條款。回到終端,然後再試一次。
oot@kerneltalks # subscription-manager register
Registering to: subscription.rhsm.redhat.com:443/subscription
Username: admin@kerneltalks.com
Password:
The system has been registered with ID: xxxxb2-xxxx-xxxx-xxxx-xx8e199xxx
Bingo!系統現在已在 Red Hat 上註冊。你可以再次用 version
選項來驗證它。
#subscription-managerversionservertype:RedHatSubscriptionManagementsubscriptionmanagementserver:2.0.43-1subscriptionmanagementrules:5.26subscription-manager:1.18.10-1.el6python-rhsm:1.18.6-1.el6" decode="true" ]root@kerneltalks # subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 2.0.43-1
subscription management rules: 5.26
subscription-manager: 1.18.10-1.el6
python-rhsm: 1.18.6-1.el6
步驟 2:將訂閱添加到您的伺服器
首先嘗試列出軟體倉庫。您將無法列出任何內容,因為我們尚未在我們的伺服器中添加任何訂閱。
root@kerneltalks # subscription-manager repos --list
This system has no repositories available through subscriptions.
正如您所看到 subscription-manager
找不到任何軟體倉庫,您需要將訂閱添加到您的伺服器上。一旦訂閱被添加,subscription-manager
將能夠列出下列的軟體倉庫。
要添加訂閱,請先使用以下命令檢查伺服器的所有可用訂閱:
root@kerneltalks # subscription-manager list --available
+-------------------------------------------+
Available Subscriptions
+-------------------------------------------+
Subscription Name: Red Hat Enterprise Linux for Virtual Datacenters, Standard
Provides: Red Hat Beta
Red Hat Software Collections (for RHEL Server)
Red Hat Enterprise Linux Atomic Host Beta
Oracle Java (for RHEL Server)
Red Hat Enterprise Linux Server
dotNET on RHEL (for RHEL Server)
Red Hat Enterprise Linux Atomic Host
Red Hat Software Collections Beta (for RHEL Server)
Red Hat Developer Tools Beta (for RHEL Server)
Red Hat Developer Toolset (for RHEL Server)
Red Hat Developer Tools (for RHEL Server)
SKU: RH00050
Contract: xxxxxxxx
Pool ID: 8a85f98c6011059f0160110a2ae6000f
Provides Management: Yes
Available: Unlimited
Suggested: 0
Service Level: Standard
Service Type: L1-L3
Subscription Type: Stackable (Temporary)
Ends: 12/01/2018
System Type: Virtual
您將獲得可用於您的伺服器的此類訂閱的軟體倉庫列表。您需要閱讀它提供的內容並記下對您有用或需要的訂閱的 Pool ID
。
現在,使用 pool ID 將訂閱添加到您的伺服器。
# subscription-manager attach --pool=8a85f98c6011059f0160110a2ae6000f
Successfully attached a subscription for: Red Hat Enterprise Linux for Virtual Datacenters, Standard
如果您不確定選擇哪一個,則可以使用下面的命令自動地添加最適合您的伺服器的訂閱:
root@kerneltalks # subscription-manager attach --auto
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux Server
Status: Subscribed
接下來是最後一步啟用軟體倉庫。
步驟 3:啟用軟體倉庫
現在您將能夠啟用軟體倉庫,該軟體倉庫在您的附加訂閱下可用。
root@kerneltalks # subscription-manager repos --enable rhel-6-server-rhv-4-agent-beta-debug-rpms
Repository 'rhel-6-server-rhv-4-agent-beta-debug-rpms' is enabled for this system.
到這裡,您已經完成了。您可以用 yum 命令列出軟體倉庫並確認。
via: https://kerneltalks.com/howto/how-to-enable-repository-using-subscription-manager-in-rhel/
作者:kerneltalks 譯者:S9mtAt 校對:wxy
本文轉載來自 Linux 中國: https://github.com/Linux-CN/archive