了解如何在 RHEL 中使用订阅管理器来启用软件仓库。 这篇文章还包括了将系统注册到 Red Hat 的步骤、添加订阅和发生错误时的解决方案。
在本文中,我们将逐步介绍如何在刚安装的 RHEL 服务器中启用 Red Hat 软件仓库。
可以利用 subscription-manager 命令启用软件仓库,如下所示:
1 2 3
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.
这里假设您已经安装了新系统并且尚未在 Red Hat 上注册。如果您已经注册了该系统,那么您可以忽略此步骤。
您可以使用下面的命令来检查您的系统是否已在 Red Hat 注册了该订阅:
1 2 3 4 5 6 7
# subscription-manager version servertype: This systemis 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 帐户凭证。
1 2 3 4 5 6
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.logfor more information.
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并接受条款。回到终端,然后再试一次。
1 2 3 4 5 6
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 选项来验证它。
1 2 3 4 5 6 7
#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:将订阅添加到您的服务器
首先尝试列出软件仓库。您将无法列出任何内容,因为我们尚未在我们的服务器中添加任何订阅。
1 2 3
root@kerneltalks# subscription-manager repos --list This system has no repositories available through subscriptions.
root@kerneltalks # subscription-manager list --available +-------------------------------------------+ Available Subscriptions +-------------------------------------------+ SubscriptionName: 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 SubscriptionType: Stackable (Temporary) Ends: 12/01/2018 SystemType: Virtual
您将获得可用于您的服务器的此类订阅的软件仓库列表。您需要阅读它提供的内容并记下对您有用或需要的订阅的 Pool ID。
现在,使用 pool ID 将订阅添加到您的服务器。
1 2 3
# subscription-manager attach --pool=8a85f98c6011059f0160110a2ae6000f Successfully attached a subscription for: RedHatEnterpriseLinux for VirtualDatacenters, Standard
如果您不确定选择哪一个,则可以使用下面的命令自动地添加最适合您的服务器的订阅:
1 2 3 4 5
root@kerneltalks # subscription-manager attach --auto Installed Product Current Status: ProductName: Red Hat Enterprise Linux Server Status: Subscribed