B.3. Red Hat Network Configuration Manager
与 Red Hat Network Configuration Client 不同,Red Hat Network Configuration Manager(
rhncfg-manager)是被用来维护 RHN 的配置文件和频道中央库,而不是那些用户端系统中的配置文件和频道。这个工具提供命令行工具,与在 RHN 网站进行的管理功能相同,并可以将部分或者全部相关维护任务编写成脚本。
它旨在由配置管理员使用的,且需要有适当权限的 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
server.session_lifetime = 120
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
使用被检查的模式名来替换 mode:
rhncfg-manager diff-revisions --help
rhncfg-manager diff-revisions --help
您可以在 表 B.4 “
rhncfg-manager add 的选项” 中看到 add 模式的选项列表。
B.3.1. 创建配置频道 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
运行以下命令可以创建配置频道:
rhncfg-manager create-channel channel-label
rhncfg-manager create-channel channel-label
如果提示输入您的 RHN 用户名和密码,输入后可以看到以下输出:
Red Hat Network username: rhn-user Password: Creating config channel channel-label Config channel channel-label created
Red Hat Network username: rhn-user Password: Creating config channel channel-label Config channel channel-label created
创建配置频道后,您就可以使用以上列出的其他模式填入和维护该频道。
B.3.2. 在配置频道中添加文件 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
要在配置频道中添加文件,您需要指定频道标签和需要上传的本地文件,如:
rhncfg-manager add --channel=channel-label /path/to/file
rhncfg-manager add --channel=channel-label /path/to/file
除了需要的频道标签和这个文件的路径,您还可以使用有效的选项在添加文件的时候修改这个文件。例如,您可以在命令中包括
--dest-file 选项修改路径和文件名,如:
rhncfg-manager add --channel=channel-label--dest-file=/new/path/to/file.txt/path/to/file
rhncfg-manager add --channel=channel-label--dest-file=/new/path/to/file.txt/path/to/file
您将会看到以下的输出:
Pushing to channel example-channel Local file >/path/to/file -> remote file /new/path/to/file.txt
Pushing to channel example-channel Local file >/path/to/file -> remote file /new/path/to/file.txt
以下表格列出了
rhncfg-manager add 的可用选项:
| 选项 | 描述 |
|---|---|
| -cCHANNEL --channel=CHANNEL | 将文件上传到该配置频道 |
| -dDEST_FILE --dest-file=DEST_FILE | 使用这个路径上传该文件 |
| --delim-start=DELIM_START | 添加变量的起始定界符。 |
| --delim-end=DELIM_END | 添加变量的终止定界符。 |
| -h, --help | 显示帮助信息后退出 |
注意
在默认情况下,配置文件最大为 128KB。如果您需要修改这个数值,请在
/etc/rhn/rhn_web.conf 文件中找到或者创建下面这一行:
web.maximum_config_file_size=128
web.maximum_config_file_size=128
另外,在
/etc/rhn/default/rhn_server.conf 文件中创建以下行:
maximum_config_file_size=128
maximum_config_file_size=128
在两个位置将该数值从 128 改为您想要的任意数值,单位为字节。
B.3.3. 与最新的配置文件进行比较 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
运行以下命令来比较本地硬盘中的配置文件和频道中的最新修改的配置文件:
rhncfg-manager diff --channel=channel-label --dest-file=/path/to/file.txt \ /local/path/to/file
rhncfg-manager diff --channel=channel-label --dest-file=/path/to/file.txt \ /local/path/to/file
您将会看到类似的输出:
/tmp/dest_path/example-config.txt /home/test/blah/hello_world.txt --- /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
/tmp/dest_path/example-config.txt /home/test/blah/hello_world.txt --- /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
以下表格列出了
rhncfg-manager diff 的可用选项:
| 选项 | 描述 |
|---|---|
| -cCHANNEL, --channel=CHANNEL | 从配置频道获取文件 |
| -rREVISION, --revision=REVISION | 使用这个版本 |
| -dDEST_FILE, --dest-file=DEST_FILE | 使用这个路径上传该文件 |
| -tTOPDIR, --topdir=TOPDIR | 使所有文件都与该字符串相关 |
| -h, --help | 显示帮助信息后退出。 |
B.3.4. 不同版本间的比较 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
要比较频道和修订本间个文件的不同版本,请使用
-r 指定文件要比较的修订本,并使用 -n 指定需要被检查的两个频道。有关步骤请参考 第 B.3.11 节 “决定文件修订本号”。请注意,您只需要指定一个文件名。这是因为您只是比较这个文件的不同版本。例如:
rhncfg-manager diff-revisions -n=channel-label1-r=1-n=channel-label2-r=1/path/to/file.txt
rhncfg-manager diff-revisions -n=channel-label1-r=1-n=channel-label2-r=1/path/to/file.txt
您将会看到以下的输出:
--- /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 +blaaaaaaaaaaaaaaah +-----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-----
--- /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 +blaaaaaaaaaaaaaaah +-----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-----
以下表格列举了
rhncfg-manager diff-revisions 的可用选项:
| 选项 | 描述 |
|---|---|
| -cCHANNEL, --channel=CHANNEL | 使用该配置频道 |
| -rREVISION, --revision=REVISION | 使用这个版本 |
| -h, --help | 显示帮助信息后退出。 |
B.3.5. 下载某个频道中的所有文件 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
创建目录并运行以下命令将某个频道中的所有文件都下载到本地硬盘:
rhncfg-manager download-channel channel-label --topdir .
rhncfg-manager download-channel channel-label --topdir .
您将会看到以下的输出:
Copying /tmp/dest_path/example-config.txt -> \ blah2/tmp/dest_path/example-config.txt
Copying /tmp/dest_path/example-config.txt -> \ blah2/tmp/dest_path/example-config.txt
以下表格列举了
rhncfg-manager download-channel 的可用选项:
| 选项 | 描述 |
|---|---|
| -tTOPDIR, --topdir=TOPDIR | 所有文件路径都与这个目录相关。必须设定该选项。 |
| -h, --help | 显示帮助信息后退出。 |
B.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
您将会看到这个文件内容的输出。
B.3.7. 列出某个频道的所有文件 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
运行以下命令列出某个频道中的所有文件:
rhncfg-manager list channel-label
rhncfg-manager list channel-label
您将会看到类似的输出:
Files in config channel `example-channel3': /tmp/dest_path/example-config.txt
Files in config channel `example-channel3': /tmp/dest_path/example-config.txt
以下表格列出了
rhncfg-manager get 中的可用选项:
| 选项 | 描述 |
|---|---|
| -cCHANNEL, --channel=CHANNEL | 从配置频道获取文件 |
| -tTOPDIR, --topdir=TOPDIR | 使所有文件都与该字符串相关 |
| -rREVISION, --revision=REVISION | 获取该文件的修订本 |
| -h, --help | 显示帮助信息后退出。 |
B.3.8. 列出所有配置频道 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
运行以下命令列出您的机构的所有配置频道:
rhncfg-manager list-channels
rhncfg-manager list-channels
您将会看到以下的输出:
Available config channels: example-channel example-channel2 example-channel3 config-channel-14 config-channel-17
Available config channels: example-channel example-channel2 example-channel3 config-channel-14 config-channel-17
请注意,它不会列出
local_override 或 server_import 频道。
B.3.9. 从频道中删除文件 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
运行以下命令从频道中删除文件:
rhncfg-manager remove --channel=channel-label /tmp/dest_path/example-config.txt
rhncfg-manager remove --channel=channel-label /tmp/dest_path/example-config.txt
如果提示输入 RHN 的用户名和密码,输入它们。您可以看到与以下类似的输出:
Red Hat Network username: rhn-user Password: Removing from config channel example-channel3 /tmp/dest_path/example-config.txt removed
Red Hat Network username: rhn-user Password: Removing from config channel example-channel3 /tmp/dest_path/example-config.txt removed
以下表格列出了
rhncfg-manager remove 的可用选项:
| 选项 | 描述 |
|---|---|
| -cCHANNEL, --channel=CHANNEL | 从该配置频道中删除文件 |
| -tTOPDIR, --topdir=TOPDIR | 使所有文件都与该字符串相关 |
| -h, --help | 显示帮助信息后退出。 |
B.3.10. 删除配置频道 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
运行以下命令删除您机构中的配置频道:
rhncfg-manager remove-channel channel-label
rhncfg-manager remove-channel channel-label
您将会看到以下的输出:
Removing config channel example-channel Config channel example-channel removed
Removing config channel example-channel Config channel example-channel removed
B.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
您将会看到以下的输出:
Analyzing files in config channel example-channel \ /tmp/dest_path/example-config.txt: 1
Analyzing files in config channel example-channel \ /tmp/dest_path/example-config.txt: 1
B.3.12. 更新某个频道中的某个文件 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
运行以下命令在某个频道中为某个文件创建新的修订版本(或在某个频道中添加第一个文件修订版本):
rhncfg-manager update \ --channel=channel-label --dest-file=/path/to/file.txt /local/path/to/file
rhncfg-manager update \ --channel=channel-label --dest-file=/path/to/file.txt /local/path/to/file
您将会看到以下的输出:
Pushing to channel example-channel: Local file example-channel/tmp/dest_path/example-config.txt -> \ remote file /tmp/dest_path/example-config.txt
Pushing to channel example-channel: Local file example-channel/tmp/dest_path/example-config.txt -> \ remote file /tmp/dest_path/example-config.txt
以下表格列出了
rhncfg-manager update 的可用选项:
| 选项 | 描述 |
|---|---|
| -cCHANNEL, --channel=CHANNEL | 将文件上传到该配置频道 |
| -dDEST_FILE, --dest-file=DEST_FILE | 使用这个路径上传该文件 |
| -tTOPDIR, --topdir=TOPDIR | 使所有文件都与该字符串相关 |
| --delim-start=DELIM_START | 添加变量的起始定界符。 |
| --delim-end=DELIM_END | 添加变量的终止定界符。 |
| -h, --help | 显示帮助信息后退出。 |
B.3.13. 一次上传多个文件 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
运行以下命令可以一次将多个存在本地的文件上传到配置频道:
rhncfg-manager upload-channel --topdir=topdir channel-label
rhncfg-manager upload-channel --topdir=topdir channel-label
您将会看到以下的输出:
Using config channel example-channel4 Uploading /tmp/ola_world.txt from blah4/tmp/ola_world.txt
Using config channel example-channel4 Uploading /tmp/ola_world.txt from blah4/tmp/ola_world.txt
以下表格列出了
rhncfg-manager upload-channel 的可用选项:
| 选项 | 描述 |
|---|---|
| -tTOPDIR, --topdir=TOPDIR | 所有文件路径都与该目录相关 |
| -cCHANNEL, --channel=CHANNEL | 要上传配置信息的频道列表。频道使用“,”间隔。例如:--channel=foo,bar,baz |
| -h, --help | 显示帮助信息后退出。 |