如何在 RHEL 中使用訂閱管理器啟用軟件倉庫
發布時間: 2018-06-13
了解如何在 RHEL 中使用訂閱管理器來啟用軟件倉庫。 這篇文章還包括了將系統注冊到 Red Hat 的步驟、添加訂閱和發生錯誤時的解決方案。
在本文中,我們將逐步介紹如何在剛安裝的 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 來啟用軟件倉庫。
這里假設您已經安裝了新系統并且尚未在 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
首先嘗試列出軟件倉庫。您將無法列出任何內容,因為我們尚未在我們的服務器中添加任何訂閱。
- 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
接下來是最后一步啟用軟件倉庫。
現在您將能夠啟用軟件倉庫,該軟件倉庫在您的附加訂閱下可用。
- 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 命令列出軟件倉庫并確認。
上一篇: MySQL 文檔存儲介紹