第 1 章 Red Hat Satellite 信息


本小节论述了 Red Hat Satellite 高级配置的内容。

1.1. 命令行配置管理工具

除了 Red Hat Satellite 网站提供的选项以外,还有管理系统配置文件的两个命令行工具:Red Hat Network Configuration ClientRed Hat Network Configuration Manager。有一个全面的 Red Hat Network Actions Control 可用来启用和禁用客户端系统中的配置管理。如果您尚未安装这些工具,您可以在操作系统的「红帽网络工具」子频道中找到它们。

注意

无论何时通过网站部署配置文件时,都会在受影响系统的 /var/lib/rhncfg/backups/ 目录中生成之前的文件及其完整路径的备份。这个备份会和原来的文件有相同的文件名,只是增加了一个 .rhn-cfg-backup 扩展名。

1.1.1. Red Hat Network Actions Control

Red Hat Network Actions Controlrhn-actions-control)被用来启动和禁用系统的配置管理。在默认的情况下无法使用此模式管理用户端系统。这个工具允许系统管理员启用或者禁用允许某些动作的具体模式,比如:在系统中部署配置文件;从该系统中上传文件;使用 diff 找到目前系统中管理的文件以及哪些文件可用,或者允许运行随机远程命令。可通过在 /etc/sysconfig/rhn/allowed-actions/ 目录中放置(/删除)文件和目录启用(/禁用)这些模式。根据 /etc/sysconfig/rhn/ 目录的默认访问权限,通常需要有 root 访问的人方可执行 Red Hat Network Actions Control。

1.1.1.1. 常规命令行选项

可参考 man 说明书页,因为该手册包含大多数命令行工具,只要为系统管理员确定要启用哪些红帽网络调度的动作即可。这些选项可启用各种调度的动作模式:
Expand
表 1.1. rhn-actions-control 选项
选项 描述
--enable-deploy 允许 rhncfg-client 部署文件。
--enable-diff 允许 rhncfg-client 使用 diff 命令比较文件。
--enable-upload 允许 rhncfg-client 上传文件。
--enable-mtime-upload 允许 rhncfg-client 上传 mtime。
--enable-all 允许 rhncfg-client 执行一切。
--enable-run 启用 script.run
--disable-deploy 禁用部署。
--disable-diff 禁用比较
--disable-upload 禁用上传
--disable-mtime-upload 禁用 mtime 上传
--disable-all 禁用所有选项
--disable-run 禁用 script.run
--report 报告是否启用或者禁用这些模式
-f, --force 不询问而强行执行
-h, --help 显示帮助信息后退出
设定某个模式后,您的系统现在就可以使用 Red Hat Satellite 进行配置管理。rhn-actions-control --enable-all 是一个通用选项。

1.1.2. Red Hat Network Configuration Client

正如其名所示,Red Hat Network Configuration Clientrhncfg-client)是在单独的用户端系统中安装并运行的。在此您可以了解红帽网络如何在用户端中部署配置文件。
Red Hat Network Configuration Client 提供了以下几个主要模式:list、get、channels、diff 和 verify。

1.1.2.1. 列出配置文件

要列出这台机器的配置文件和包括这些配置文件的配置频道标签,请执行命令:
rhncfg-client list
Copy to Clipboard Toggle word wrap
输出包括以下列表:
Config Channel      File
config-channel-17   /etc/example-config.txt
config-channel-17   /var/spool/aalib.rpm
config-channel-14   /etc/rhn/rhn.conf
Copy to Clipboard Toggle word wrap
这些是在您系统中应用的配置文件。不过,其他频道中可能会有重复的文件。例如,执行以下命令:
rhncfg-manager list config-channel-14rhncfg-manager list config-channel-14
Copy to Clipboard Toggle word wrap
并观察以下输出:
配置频道 'config-channel-14' /etc/example-config.txt /etc/rhn/rhn.conf 中的文件
Copy to Clipboard Toggle word wrap
您可能想知道第二个 /etc/example-config.txt 文件被保存到哪里了。config-channel-17 中的 /etc/example-config.txt 文件比 config-channel-14 中的同一文件级别要高。因此,尽管 config-channel-14 中的配置文件仍旧存在,但是它不会被部署。rhncfg-client 命令没有列出该文件,因为不会在该系统中部署这个文件。

1.1.2.2. 得到配置文件

执行以下命令下载与这台机器最相关的配置文件:
rhncfg-client get /etc/example-config.txt
Copy to Clipboard Toggle word wrap
您将会看到类似的输出:
Deploying /etc/example-config.txt
Copy to Clipboard Toggle word wrap
使用 less 或者另一个 pager 查看该文件的内容。请注意,该文件是根据所在配置频道的最大相关性选择的。您还可以使用「系统详情」页中的「配置」标签页进行设置。

1.1.2.3. 查看配置频道

执行以下命令来查看应用到这个系统的配置频道标签和名称:
rhncfg-client channels
Copy to Clipboard Toggle word wrap
您将会看到类似的输出:
Config channels: Label Name ----- ---- config-channel-17 config chan 2 config-channel-14 config chan 1
Copy to Clipboard Toggle word wrap
以下表格列出了 rhncfg-client get 的可用选项:
Expand
表 1.2. rhncfg-client get 的选项
选项 描述
--topdir=TOPDIR 使所有操作都与该字符串相关。
--exclude=EXCLUDE 不包括使用 'get'/ 部署的文件,可多次使用。
-h, --help 显示帮助信息后退出。

1.1.2.4. 比较配置文件。

执行以下命令可将系统中部署的配置文件与红帽网络中保存的配置文件进行比较:
rhncfg-client diff
Copy to Clipboard Toggle word wrap
您将会看到以下的输出:
[root@testsatellite root]# rhncfg-client diff
--- /etc/test
+++ /etc/test	2013-08-28 00:14:49.405152824 +1000
@@ -1 +1,2 @@
 This is the first line
+This is the second line added
Copy to Clipboard Toggle word wrap
另外,您可以使用 --topdir 选项将红帽网络中的配置文件与位于模糊(未使用)位置的配置文件进行比较:
[root@ root]# rhncfg-client diff --topdir /home/test/blah/ /usr/bin/diff: /home/test/blah/etc/example-config.txt: No such file or directory /usr/bin/diff: /home/test/blah/var/spool/aalib.rpm: No such file or directory
Copy to Clipboard Toggle word wrap

1.1.2.5. 验证配置文件

执行以下命令可以快速地决定用户配置文件是否与在红帽网络中的相关文件不同:
rhncfg-client verify
Copy to Clipboard Toggle word wrap
您将会看到以下的输出:
修改的 /etc/example-config.txt /var/spool/aalib.rpm
Copy to Clipboard Toggle word wrap
example-config.txt 文件是本地修改的,而 aalib.rpm 不是。
以下表格列出了 rhncfg-client verify 命令的可用选项:
Expand
表 1.3. rhncfg-client verify 的选项
选项 描述
-v, --verbose 增加输出的详细程度。显示指定配置文件的模式、所有者、以及组权限的区别。
-o, --only 只显示有区别的文件。
-h, --help 显示帮助信息后退出。

1.1.3. Red Hat Network Configuration Manager

Red Hat Network Configuration Client 不同,Red Hat Network Configuration Managerrhncfg-manager)是用来维护红帽网络的配置文件和频道中央库,而不是那些用户端系统中的配置文件和频道。这个工具提供命令行工具,与在 RHN 网站进行的管理功能相同,并可以将部分或者全部相关维护任务编写成脚本。
它旨在由配置管理员使用的,且需要有适当权限的红帽网络用户名和密码。可在 /etc/sysconfig/rhn/rhncfg-manager.conf~/.rhncfgrc 中的 [rhncfg-manager] 项中指定该用户名。
当以 root 用户运行 Red Hat Network Configuration Manager 时,它会尝试从 Red Hat Update Agent 中提取需要的配置值。如果以 root 用户以外的身份运行时,您需要在 ~/.rhncfgrc 文件中进行配置更改。这个会话文件会临时保存在 ~/.rhncfg-manager-session 缓存中,这样就不需要在运行每个命令时都进行登录。
Red Hat Network Configuration Manager 默认的超时时间是 30 分钟。您可以通过在运行这个程序的服务器中的 /etc/rhn/rhn.conf 文件中添加 server.session_lifetime 选项和新的值到更改这个时间,如:
server.session_lifetime = 120
Copy to Clipboard Toggle word wrap
Red Hat Network Configuration Manager 提供了以下的主要模式:add、create-channel、diff、diff-revisions、download-channel、get、list、list-channels、remove、remove-channel、revisions、update 和 upload-channel。
每个模式都会提供一组选项。这些选项可以通过以下命令查看:
rhncfg-manager mode --help rhncfg-manager mode --help rhncfg-manager mode --help 
Copy to Clipboard Toggle word wrap
使用被检查的模式名来替换 mode
rhncfg-manager diff-revisions --help
Copy to Clipboard Toggle word wrap
您可以在 表 1.4 “rhncfg-manager add 的选项” 中看到 add 模式的选项列表。

1.1.3.1. 创建配置频道

运行以下命令可以创建配置频道:
rhncfg-manager create-channel channel-labelrhncfg-manager create-channel channel-label
Copy to Clipboard Toggle word wrap
如果提示输入您的 Red Hat Satellite 用户名和密码,请输入这些内容,并可在输入后看到以下输出:
Red Hat Network username: rhn-user
Password:
Creating config channel channel-label Config channel channel-label created
Copy to Clipboard Toggle word wrap
创建配置频道后,您就可以使用以上列出的其他模式填入和维护该频道。

1.1.3.2. 在配置频道中添加文件

要在配置频道中添加文件,您需要指定频道标签和需要上传的本地文件,如:
rhncfg-manager add --channel=channel-label /path/to/filerhncfg-manager add --channel=channel-label /path/to/filerhncfg-manager add --channel=channel-label /path/to/filerhncfg-manager add --channel=channel-label /path/to/file
Copy to Clipboard Toggle word wrap
除了需要的频道标签和这个文件的路径,您还可以使用有效的选项在添加文件的时候修改这个文件。例如,您可以在命令中包括 --dest-file 选项修改路径和文件名,如:
rhncfg-manager add --channel=channel-label --dest-file=/new/path/to/file.txt/path/to/filerhncfg-manager add --channel=channel-label --dest-file=/new/path/to/file.txt/path/to/filerhncfg-manager add --channel=channel-label --dest-file=/new/path/to/file.txt/path/to/filerhncfg-manager add --channel=channel-label --dest-file=/new/path/to/file.txt/path/to/filerhncfg-manager add --channel=channel-label --dest-file=/new/path/to/file.txt/path/to/file
Copy to Clipboard Toggle word wrap
您将会看到以下的输出:
Pushing to channel example-channel
Local file >/path/to/file -> remote file /new/path/to/file.txt
Copy to Clipboard Toggle word wrap
以下表格列出了 rhncfg-manager add 的可用选项:
Expand
表 1.4. rhncfg-manager add 的选项
选项 描述
-c CHANNEL --channel=CHANNEL 将文件上传到该配置频道
-d DEST_FILE --dest-file=DEST_FILE 使用这个路径上传该文件
--delim-start=DELIM_START 添加变量的起始定界符。
--delim-end=DELIM_END 添加变量的终止定界符。
-i, --ignore-missing 忽略缺少的本地文件
--selinux-context=SELINUX_CONTEXT 覆盖 SELinux 上下文
-h, --help 显示帮助信息后退出

注意

在默认情况下,配置文件最大为 128KB。如果您需要修改这个数值,请在 /etc/rhn/rhn.conf 文件中找到或者创建下面这一行:
web.maximum_config_file_size=128
Copy to Clipboard Toggle word wrap
另外,请在 /etc/rhn/rhn.conf 文件中查找或者创建以下行:
maximum_config_file_size=128
Copy to Clipboard Toggle word wrap
在两个位置将该数值从 128 改为您想要的任意数值,单位为字节。

1.1.3.3. 与最新的配置文件进行比较

运行以下命令来比较本地硬盘中的配置文件和频道中的最新修改的配置文件:
rhncfg-manager diff --channel=channel-label --dest-file=/path/to/file.txt \ /local/path/to/filerhncfg-manager diff --channel=channel-label --dest-file=/path/to/file.txt \ /local/path/to/filerhncfg-manager diff --channel=channel-label --dest-file=/path/to/file.txt \ /local/path/to/filerhncfg-manager diff --channel=channel-label --dest-file=/path/to/file.txt \ /local/path/to/filerhncfg-manager diff --channel=channel-label --dest-file=/path/to/file.txt \ /local/path/to/filerhncfg-manager diff --channel=channel-label --dest-file=/path/to/file.txt \ /local/path/to/file
Copy to Clipboard Toggle word wrap
您将会看到类似的输出:
--- /tmp/dest_path/example-config.txt config_channel: example-channel revision: 1
+++ /home/test/blah/hello_world.txt 2003-12-14 19:08:59.000000000 -0500
@@ -1 +1 @@
-foo
+hello, world
Copy to Clipboard Toggle word wrap
以下表格列出了 rhncfg-manager diff 的可用选项:
Expand
表 1.5. rhncfg-manager diff 的选项
选项 描述
-c CHANNEL, --channel=CHANNEL 从配置频道获取文件
-r REVISION, --revision=REVISION 使用这个版本
-d DEST_FILE, --dest-file=DEST_FILE 使用这个路径上传该文件
-t TOPDIR, --topdir=TOPDIR 使所有文件都与该字符串相关
-h, --help 显示帮助信息后退出。

1.1.3.4. 不同版本间的比较

要比较各频道和修订本之间的不同,请使用 -r 指定文件要比较的修订本,并使用 -n 指定需要检查的两个频道。有关步骤请参考 第 1.1.3.11 节 “决定文件修订本号”。请注意,您只需要指定一个文件名。这是因为您只是比较这个文件的不同版本。例如:
rhncfg-manager diff-revisions -n=channel-label1 -r=1 -n=channel-label2 -r=1 /path/to/file.txtrhncfg-manager diff-revisions -n=channel-label1 -r=1 -n=channel-label2 -r=1 /path/to/file.txtrhncfg-manager diff-revisions -n=channel-label1 -r=1 -n=channel-label2 -r=1 /path/to/file.txtrhncfg-manager diff-revisions -n=channel-label1 -r=1 -n=channel-label2 -r=1 /path/to/file.txtrhncfg-manager diff-revisions -n=channel-label1 -r=1 -n=channel-label2 -r=1 /path/to/file.txtrhncfg-manager diff-revisions -n=channel-label1 -r=1 -n=channel-label2 -r=1 /path/to/file.txtrhncfg-manager diff-revisions -n=channel-label1 -r=1 -n=channel-label2 -r=1 /path/to/file.txtrhncfg-manager diff-revisions -n=channel-label1 -r=1 -n=channel-label2 -r=1 /path/to/file.txtrhncfg-manager diff-revisions -n=channel-label1 -r=1 -n=channel-label2 -r=1 /path/to/file.txtrhncfg-manager diff-revisions -n=channel-label1 -r=1 -n=channel-label2 -r=1 /path/to/file.txt
Copy to Clipboard Toggle word wrap
您将会看到以下的输出:
--- /tmp/dest_path/example-config.txt 2004-01-13 14:36:41 \ config channel: example-channel2 revision: 1
--- /tmp/dest_path/example-config.txt 2004-01-13 14:42:42 \ config channel: example-channel3 revision: 1
@@ -1 +1,20 @@
-foo
+blah
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.0.6 (GNU/Linux)
+Comment: For info see http://www.gnupg.org
+
+iD8DBQA9ZY6vse4XmfJPGwgRAsHcAJ9ud9dabUcdscdcqB8AZP7e0Fua0NmKsdhQCeOWHX +VsDTfen2NWdwwPaTM+S+Cow=
+=Ltp2
+-----END PGP SIGNATURE-----
Copy to Clipboard Toggle word wrap
以下表格列举了 rhncfg-manager diff-revisions 的可用选项:
Expand
表 1.6. rhncfg-manager diff-revisions 的选项
选项 描述
-c CHANNEL, --channel=CHANNEL 使用该配置频道
-r REVISION, --revision=REVISION 使用这个版本
-h, --help 显示帮助信息后退出。

1.1.3.5. 下载某个频道中的所有文件

创建目录并运行以下命令将某个频道中的所有文件都下载到本地硬盘:
rhncfg-manager download-channel channel-label --topdir . rhncfg-manager download-channel channel-label --topdir . rhncfg-manager download-channel channel-label --topdir . 
Copy to Clipboard Toggle word wrap
您将会看到以下的输出:
正在复制 /tmp/dest_path/example-config.txt -> \ blah2/tmp/dest_path/example-config.txt
Copy to Clipboard Toggle word wrap
以下表格列举了 rhncfg-manager download-channel 的可用选项:
Expand
表 1.7. rhncfg-manager download-channel 的选项
选项 描述
-t TOPDIR, --topdir=TOPDIR 所有文件路径都与这个目录相关。必须设定该选项。
-h, --help 显示帮助信息后退出。

1.1.3.6. 获得文件的内容

运行以下命令将具体文件的内容输出到 stdout:
rhncfg-manager get --channel=channel-label \ /tmp/dest_path/example-config.txt rhncfg-manager get --channel=channel-label \ /tmp/dest_path/example-config.txt rhncfg-manager get --channel=channel-label \ /tmp/dest_path/example-config.txt 
Copy to Clipboard Toggle word wrap
您将会看到这个文件内容的输出。

1.1.3.7. 列出某个频道的所有文件

运行以下命令列出某个频道中的所有文件:
rhncfg-manager list channel-labelrhncfg-manager list channel-label
Copy to Clipboard Toggle word wrap
您将会看到类似的输出:
配置频道 `example-channel3': /tmp/dest_path/example-config.txt 中的文件
Copy to Clipboard Toggle word wrap
以下表格列出了 rhncfg-manager get 中的可用选项:
Expand
表 1.8. rhncfg-manager get 的选项
选项 描述
-c CHANNEL, --channel=CHANNEL 从配置频道获取文件
-t TOPDIR, --topdir=TOPDIR 使所有文件都与该字符串相关
-r REVISION, --revision=REVISION 获取该文件的修订本
-h, --help 显示帮助信息后退出。

1.1.3.8. 列出所有配置频道

运行以下命令列出您的机构的所有配置频道:
rhncfg-manager list-channels 
Copy to Clipboard Toggle word wrap
您将会看到以下的输出:
可用配置频道:example-channel example-channel2 example-channel3 config-channel-14 config-channel-17
Copy to Clipboard Toggle word wrap
请注意,它不会列出 local_overrideserver_import 频道。

1.1.3.9. 从频道中删除文件

运行以下命令从频道中删除文件:
rhncfg-manager remove --channel=channel-label /tmp/dest_path/example-config.txtrhncfg-manager remove --channel=channel-label /tmp/dest_path/example-config.txtrhncfg-manager remove --channel=channel-label /tmp/dest_path/example-config.txtrhncfg-manager remove --channel=channel-label /tmp/dest_path/example-config.txt
Copy to Clipboard Toggle word wrap
如果提示输入红帽网络的用户名和密码,输入它们。您可以看到与以下类似的输出:
Red Hat Network username: rhn-user Password: Removing from config channel example-channel3 /tmp/dest_path/example-config.txt removed
Copy to Clipboard Toggle word wrap
以下表格列出了 rhncfg-manager remove 的可用选项:
Expand
表 1.9. rhncfg-manager remove 的选项
选项 描述
-c CHANNEL, --channel=CHANNEL 从该配置频道中删除文件
-t TOPDIR, --topdir=TOPDIR 使所有文件都与该字符串相关
-h, --help 显示帮助信息后退出。

1.1.3.10. 删除配置频道

运行以下命令删除您机构中的配置频道:
rhncfg-manager remove-channel channel-label rhncfg-manager remove-channel channel-label rhncfg-manager remove-channel channel-label 
Copy to Clipboard Toggle word wrap
您将会看到以下的输出:
正在删除配置频道 example-channel,已删除配置频道 example-channel。
Copy to Clipboard Toggle word wrap

1.1.3.11. 决定文件修订本号

运行以下命令找出某个频道中的某个 file/path 的所有修订版本号(修订版本从 1到 N,其中 N 是一个大于 0 的整数):
rhncfg-manager revisions channel-label /tmp/dest_path/example-config.txt rhncfg-manager revisions channel-label /tmp/dest_path/example-config.txt rhncfg-manager revisions channel-label /tmp/dest_path/example-config.txt 
Copy to Clipboard Toggle word wrap
您将会看到以下的输出:
分析配置频道 example-channel \ /tmp/dest_path/example-config.txt: 1 中的文件
Copy to Clipboard Toggle word wrap

1.1.3.12. 更新某个频道中的某个文件

运行以下命令在某个频道中为某个文件创建新的修订版本(或在某个频道中添加第一个文件修订版本):
rhncfg-manager update \ --channel=channel-label --dest-file=/path/to/file.txt /local/path/to/filerhncfg-manager update \ --channel=channel-label --dest-file=/path/to/file.txt /local/path/to/filerhncfg-manager update \ --channel=channel-label --dest-file=/path/to/file.txt /local/path/to/filerhncfg-manager update \ --channel=channel-label --dest-file=/path/to/file.txt /local/path/to/filerhncfg-manager update \ --channel=channel-label --dest-file=/path/to/file.txt /local/path/to/filerhncfg-manager update \ --channel=channel-label --dest-file=/path/to/file.txt /local/path/to/file
Copy to Clipboard Toggle word wrap
您将会看到以下的输出:
Push 到频道 example-channel: 本地文件 example-channel/tmp/dest_path/example-config.txt -> \ 远程文件 /tmp/dest_path/example-config.txt
Copy to Clipboard Toggle word wrap
以下表格列出了 rhncfg-manager update 的可用选项:
Expand
表 1.10. rhncfg-manager update 的选项
选项 描述
-c CHANNEL, --channel=CHANNEL 将文件上传到该配置频道
-d DEST_FILE, --dest-file=DEST_FILE 使用这个路径上传该文件
-t TOPDIR, --topdir=TOPDIR 使所有文件都与该字符串相关
--delim-start=DELIM_START 添加变量的起始定界符。
--delim-end=DELIM_END 添加变量的终止定界符。
-h, --help 显示帮助信息后退出。

1.1.3.13. 一次上传多个文件

运行以下命令可以一次将多个存在本地的文件上传到配置频道:
rhncfg-manager upload-channel --topdir=topdir channel-labelrhncfg-manager upload-channel --topdir=topdir channel-labelrhncfg-manager upload-channel --topdir=topdir channel-labelrhncfg-manager upload-channel --topdir=topdir channel-label
Copy to Clipboard Toggle word wrap
您将会看到以下的输出:
使用配置频道 example-channel4 上传 /tmp/ola_world.txt from blah4/tmp/ola_world.txt
Copy to Clipboard Toggle word wrap
以下表格列出了 rhncfg-manager upload-channel 的可用选项:
Expand
表 1.11. rhncfg-manager upload-channel 的选项
选项 描述
-t TOPDIR, --topdir=TOPDIR 所有文件路径都与该目录相关
-c CHANNEL, --channel=CHANNEL 要上传配置信息的频道列表。频道使用“,”间隔。例如:--channel=foo,bar,baz
-h, --help 显示帮助信息后退出。
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat