第 11 章 将客户端注册到负载均衡器
要平衡来自客户端的网络流量负载,您必须将客户端注册到负载均衡器。
要注册客户端,请执行以下流程之一:
11.1. 使用主机注册注册客户端
您可以使用 Satellite Web UI、Hammer CLI 或 Satellite API 中的主机注册功能将主机注册到 Satellite。如需更多信息,请参阅 管理主机 中的 注册主机和设置主机集成。
先决条件
- 您已为主机注册设置了负载均衡器。如需更多信息,请参阅 第 8 章 为主机注册设置负载均衡器。
流程
- 在 Satellite Web UI 中,进入到 Hosts > Register Host。
- 从 Capsule 下拉列表中,选择配置了负载平衡的 Capsule 服务器。
- 选择 Force 注册之前注册到胶囊服务器的主机。
- 从 Activation Keys 列表中,选择要分配给主机的激活码。
- 点 Generate 来创建注册命令。
- 点 files 图标将命令复制到您的剪贴板。
- 使用 SSH 连接到您的主机并运行注册命令。
-
检查
/etc/yum.repos.d/redhat.repo
文件,并确保启用了适当的软件仓库。
CLI 过程
生成使用 Hammer CLI 的主机注册命令:
hammer host-registration generate-command \ --activation-keys "My_Activation_Key"
$ hammer host-registration generate-command \ --activation-keys "My_Activation_Key"
Copy to Clipboard Copied! 如果您的主机不信任 Satellite 服务器的 SSL 证书,您可以通过在注册命令中添加-
insecure
标志来禁用 SSL 验证。hammer host-registration generate-command \ --activation-keys "My_Activation_Key" \ --insecure true
$ hammer host-registration generate-command \ --activation-keys "My_Activation_Key" \ --insecure true
Copy to Clipboard Copied! 包含
--smart-proxy-id My_Capsule_ID
选项。您可以使用您为主机注册负载均衡配置的任何胶囊服务器的 ID。Satellite 会自动将负载均衡器应用到注册命令。包含
-强制
选项,以注册之前注册到胶囊服务器的主机。- 使用 SSH 连接到您的主机并运行注册命令。
-
检查
/etc/yum.repos.d/redhat.repo
文件,并确保启用了适当的软件仓库。
API 流程
生成使用 Satellite API 的主机注册命令:
curl -X POST https://satellite.example.com/api/registration_commands \ --user "My_User_Name" \ -H 'Content-Type: application/json' \ -d '{ "registration_command": { "activation_keys": ["My_Activation_Key_1, My_Activation_Key_2"] }}'
# curl -X POST https://satellite.example.com/api/registration_commands \ --user "My_User_Name" \ -H 'Content-Type: application/json' \ -d '{ "registration_command": { "activation_keys": ["My_Activation_Key_1, My_Activation_Key_2"] }}'
Copy to Clipboard Copied! 如果您的主机不信任 Satellite 服务器的 SSL 证书,您可以通过在注册命令中添加-
insecure
标志来禁用 SSL 验证。curl -X POST https://satellite.example.com/api/registration_commands \ --user "My_User_Name" \ -H 'Content-Type: application/json' \ -d '{ "registration_command": { "activation_keys": ["My_Activation_Key_1, My_Activation_Key_2"], "insecure": true }}'
# curl -X POST https://satellite.example.com/api/registration_commands \ --user "My_User_Name" \ -H 'Content-Type: application/json' \ -d '{ "registration_command": { "activation_keys": ["My_Activation_Key_1, My_Activation_Key_2"], "insecure": true }}'
Copy to Clipboard Copied! 使用激活码来简化指定环境的过程。如需更多信息,请参阅管理内容中的管理激活码。
Include
{ "smart_proxy_id": My_Capsule_ID }
.您可以使用您为主机注册负载均衡配置的任何胶囊服务器的 ID。Satellite 会自动将负载均衡器应用到注册命令。包含
{ "force": true }
以注册之前注册到胶囊服务器的主机。如果需要输入密码作为命令行参数,请使用
username:password
语法。请注意,这会将密码保存到 shell 的历史记录中。或者,您可以使用临时个人访问令牌而不是密码。要在 Satellite Web UI 中生成令牌,请进入到 My Account > Personal Access Tokens。- 使用 SSH 连接到您的主机并运行注册命令。
-
检查
/etc/yum.repos.d/redhat.repo
文件,并确保启用了适当的软件仓库。