使用订阅管理器(带或者不带代理)将RHEL 7主机注册到RHN
在本文中,将介绍在配置有或者没有代理服务器的系统上向Red Hat Network(RNH)注册RHEL 7的步骤。
订阅服务提供了一种处理Red Hat软件列表的机制,并允许我们使用yum软件包管理器安装其他软件或者将已安装的程序更新为较新的版本。
在Red Hat Enterprise Linux 7中,建议的注册系统和添加订阅的方法是使用Red Hat Subscription Manager。
使用Subscription Manager注册RHEL 7
完成以下步骤,向RHN Satellite注册RHEL 7系统,并使用Red Hat Subscription Manager添加一个或者多个订阅。
请注意,所有订阅管理器命令都应以root用户身份运行。
我们正在使用Red Hat 7.4来演示本文中的步骤。
rhel-7:~ # cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.4 (Maipo)
使用代理设置RHSM
如果我们需要使用诸如鱿鱼之类的HTTP代理来连接到Red Hat Subscription Manager或者Red Hat Satellite,请执行以下步骤。
在这种情况下,默认情况下,订阅管理器将无法连接到Red Hat Satellite Network来注册系统。
因此,我们将配置订阅管理器配置文件(/etc/rhsm/rhsm.conf
)
另请阅读:
如何在Linux中使用http_proxy和https_proxy环境变量设置代理?
如何在Linux中为yum存储库设置代理?
使用代理服务器详细信息修改以下突出显示的值
[server] # an http proxy server to use proxy_hostname = <ip or fqdn> # port for http proxy server proxy_port = <network port in use (often 3128 or 8080)> # user name for authenticating to an http proxy, if needed proxy_user = <http proxy username (if required)> # password for basic http proxy auth, if needed proxy_password = <http proxy password (if required)>
使用无代理设置RHSM
如果系统默认情况下配置有代理,而我们又不想使用代理服务器注册系统,那么有两种可能的选择
在
/etc/rhsm/rhsm.conf
中设置no_proxy = *或者或者,我们也可以使用添加参数
--server.no_proxy = *
向RHEL 7系统注册订阅管理。
通过CLI注册RHEL 7系统
运行以下命令以注册系统。
系统将提示我们输入用户名和密码。
请注意,用户名和密码与我们用于Red Hat Customer Portal的登录凭据相同。
rhel-7:~ # subscription-manager register Registering to: subscription.rhsm.redhat.com:443/subscription Username: hynman Password: The system has been registered with ID: 5288cdcf-6d0f-419a-b531-037a3821d4325
之后,使用以下命令刷新计算机上的信息。
在我们从客户门户添加或者更改附件订阅时,请确保运行此命令:
rhel-7:~ # subscription-manager refresh All local data refreshed
列出系统已注册到的可用订阅。
由于当前我们尚未对RHEL 7系统应用任何订阅,因此其显示未订阅
rhel-7:~ # subscription-manager list +-------------------------------------------+ Installed Product Status +-------------------------------------------+ Product Name: Red Hat Enterprise Linux Server Product ID: 69 Version: 7.6 Arch: x86_64 Status: Not Subscribed Status Details: 不支持 by a valid subscription. Starts: Ends:
接下来列出Red Hat Satellite上所有可用的订阅
rhel-7:~ # subscription-manager list --available --all +-------------------------------------------+ Available Subscriptions +-------------------------------------------+ Subscription Name: Red Hat Enterprise Linux Server (1-2 sockets) (Unlimited guests) - Embedded Partner Support Provides: dotNET on RHEL Beta (for RHEL Server) Red Hat Beta Oracle Java (for RHEL Server) Red Hat Enterprise Linux Server Red Hat Software Collections Beta (for RHEL Server) Red Hat CodeReady Linux Builder for x86_64 Red Hat Enterprise Linux for x86_64 Red Hat Ansible Engine dotNET on RHEL (for RHEL Server) SKU: RH0175705 Contract: 11597330 Pool ID: 8a85f98d67c1bf370167acd80186288c Provides Management: No Available: 29 Suggested: 1 Service Level: Premium Service Type: PSF Subscription Type: Stackable Ends: 12/10/2019 System Type: Physical
添加特定的订阅
注册后,使用以下命令来添加来自特定池的订阅。
我们可以从subscription-manager list --available --all命令的输出中获取POOL ID。
rhel-7:~ # subscription-manager attach --pool=8a85f98d67c1bf370167acd80186288c Successfully attached a subscription for: Red Hat Enterprise Linux Server (1-2 sockets) (Unlimited guests) - Embedded Partner Support
通过GUI注册RHEL 7系统
或者,我们也可以使用订阅管理器的GUI版本注册RHEL 7.
# subscription-manager-gui
验证订阅注册
现在,由于我们的RHEL 7系统已注册,我们可以使用以下命令进行验证:
rhel-7:~ # subscription-manager list +-------------------------------------------+ Installed Product Status +-------------------------------------------+ Product Name: Red Hat Enterprise Linux Server Product ID: 69 Version: 7.6 Arch: x86_64 Status: Subscribed Status Details: Starts: 12/10/2016 Ends: 12/10/2019
带订阅管理器的identity命令可处理系统的UUID,该系统的UUID在注册后向订阅管理服务标识该系统。
rhel-7:~ # subscription-manager identity system identity: 5288cdcf-6d0f-419a-b531-0a363821dfa2 name: rhel-7 org name: 7028599 org ID: 7028599
列出红帽订阅的存储库
现在,由于我们已经有了Red Hat订阅,因此让我们验证可用存储库的列表。
可以使用yum软件包管理器执行此操作。
在开始执行所有可用缓存存储库的清理之前
rhel-7:~ # yum clean all Loaded plugins: product-id, search-disabled-repos, subscription-manager Cleaning repos: rhel-7-dvd rhel-7-server-rpms Cleaning up everything Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos rhel-7:~ # rm -rf /var/cache/yum
接下来,列出订阅中包含的可用存储库。
rhel-7:~ # yum repolist Loaded plugins: product-id, search-disabled-repos, subscription-manager rhel-7-dvd | 4.1 kB 00:00:00 rhel-7-server-rpms | 3.5 kB 00:00:00 (1/5): rhel-7-dvd/group_gz | 137 kB 00:00:00 (2/5): rhel-7-dvd/primary_db | 4.0 MB 00:00:00 (3/5): rhel-7-server-rpms/7Server/x86_64/updateinfo | 3.2 MB 00:00:01 (4/5): rhel-7-server-rpms/7Server/x86_64/group | 774 kB 00:00:01 (5/5): rhel-7-server-rpms/7Server/x86_64/primary_db | 57 MB 00:00:07 repo id repo name status rhel-7-dvd RHEL 7 ISO DVD 4,986 rhel-7-server-rpms/7Server/x86_64 Red Hat Enterprise Linux 7 Server (RPMs) 24,397 repolist: 29,383
现在,以上命令仅列出了已启用的存储库。
但是要获取所有可用存储库的列表,请使用以下命令:
rhel-7:~ # subscription-manager repos --list +----------------------------------------------------------+ Available Repositories in /etc/yum.repos.d/redhat.repo +----------------------------------------------------------+ Repo ID: rhel-7-server-dotnet-debug-rpms Repo Name: dotNET on RHEL Debug RPMs for Red Hat Enterprise Linux 7 Server Repo URL: https://cdn.redhat.com/content/dist/rhel/server/7/$releasever/$basearch/dotnet/1/debug Enabled: 0 Repo ID: rhel-7-server-insights-3-debug-rpms Repo Name: Red Hat Insights 3 (for RHEL 7 Server) (Debug RPMs) Repo URL: https://cdn.redhat.com/content/dist/rhel/server/7/7Server/$basearch/insights/3/debug Enabled: 0 <output trimmed> Repo ID: rhel-7-server-openstack-7.0-tools-source-rpms Repo Name: Red Hat OpenStack Tools 7.0 for Red Hat Enterprise Linux 7 Server (Source RPMs) Repo URL: https://cdn.redhat.com/content/dist/rhel/server/7/$releasever/$basearch/openstack-tools/7.0/source/SRPMS Enabled: 0 Repo ID: rhel-7-server-optional-beta-rpms Repo Name: Red Hat Enterprise Linux 7 Server - Optional Beta (RPMs) Repo URL: https://cdn.redhat.com/content/beta/rhel/server/7/$basearch/optional/os Enabled: 0
启用存储库
要启用存储库,请输入以下命令:
# subscription-manager repos --enable <repository>
将存储库替换为要启用的存储库的名称。
禁用存储库
同样,要禁用存储库,请使用以下命令:
# subscription-manager repos --disable <repository>