Red Hat Training
A Red Hat training course is available for Red Hat Satellite
B.3. Red Hat Network Configuration Manager
與 Red Hat Network Configuration Client 不同,Red Hat Network Configuration Manager(
rhncfg-manager
)是用來維護 RHN 所儲存的配置檔案與頻道,而非儲存在本機上的檔案。此工具提供了 RHN 網站以外的指令列選擇;同時它也具有使用 script 來進行部份或所有相關維護工作。
它是用來給配置管理員使用,它需要一組 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 的預設 timeout 值為卅分鐘。如果您要修改這個值,請在執行此管理程式的伺服器上,修改
/etc/rhn/rhn.conf
檔案,加入 server.session_lifetime
選項與新的值,例如:
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
請將 mode 用打算用來使用的模式名稱所取代:
rhncfg-manager diff-revisions --help
您可在 表格 B.4, “
rhncfg-manager add
選項” 中,看到新增模式的選項清單。
B.3.1. 建立配置頻道
要為您的組織建立一組配置頻道,請使用以下指令:
rhncfg-manager create-channel channel-label
如果系統提示您輸入 RHN 使用者名稱與密碼,請依循指示。您應該會看到以下的結果:
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
除了所需的頻道標籤與檔案路徑外,您可以用可用選項,在加入檔案時一併修改。例如您可以在使用指令時加入
--dest-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
以下表格列出
rhncfg-manager add
的可用選項:
表格 B.4. 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/default/rhn_web.conf
這個檔案中,尋找或建立下列行列:
web.maximum_config_file_size=128
此外,請在
/etc/rhn/default/rhn_server.conf
檔案中尋找或建立以下一行:
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
您會看到以下資訊:
/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
的可用選項:
表格 B.5. 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
輸出畫面包括以下資訊:
--- /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
的可用選項:
表格 B.6. rhncfg-manager diff-revisions
選項
選項 | 描述 |
---|---|
-cCHANNEL, --channel=CHANNEL | 使用這個配置頻道 |
-rREVISION, --revision=REVISION | 使用此版本 |
-h, --help | 顯示求助訊息後離開 |
B.3.5. 下載頻道內的所有檔案
要將頻道內的所有檔案下載到磁碟中,請建立一個目錄,輸入以下指令:
rhncfg-manager download-channel channel-label --topdir .
輸出畫面包括以下資訊:
Copying /tmp/dest_path/example-config.txt -> \ blah2/tmp/dest_path/example-config.txt
以下表格列出
rhncfg-manager download-channel
的可用選項:
表格 B.7. rhncfg-manager download-channel
選項
選項 | 描述 |
---|---|
-tTOPDIR, --topdir=TOPDIR | 與檔案路徑相對的目錄。您必須設定此選項。 |
-h, --help | 顯示求助訊息後離開 |
B.3.6. 取得檔案內容
要將某個特定的檔案內容導向到標準輸出上,請使用以下指令:
rhncfg-manager get --channel=channel-label
\ /tmp/dest_path/example-config.txt
您應該可以看到此檔案的內容。
B.3.7. 列出頻道內的所有檔案
要列出頻道內的所有檔案,請使用以下指令:
rhncfg-manager list channel-label
您會看到以下資訊:
Files in config channel `example-channel3': /tmp/dest_path/example-config.txt
以下表格列出
rhncfg-manager get
的可用選項:
表格 B.8. rhncfg-manager get
選項
選項 | 描述 |
---|---|
-cCHANNEL, --channel=CHANNEL | 從這個配置頻道取得檔案 |
-tTOPDIR, --topdir=TOPDIR | 讓所有檔案與此字串相關 |
-rREVISION, --revision=REVISION | 取得這個版本的檔案 |
-h, --help | 顯示求助訊息後離開 |
B.3.8. 列出所有的配置頻道
要列出您公司所有的配置頻道,請使用以下指令:
rhncfg-manager list-channels
輸出畫面包括以下資訊:
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
如果系統提示您,請輸入 RHN 使用者名稱與密碼。您應該會看到以下的結果:
Red Hat Network username: rhn-user Password: Removing from config channel example-channel3 /tmp/dest_path/example-config.txt removed
以下表格列出
rhncfg-manager remove
的可用選項:
表格 B.9. rhncfg-manager remove
選項
選項 | 描述 |
---|---|
-cCHANNEL, --channel=CHANNEL | 從這個配置頻道中移除檔案 |
-tTOPDIR, --topdir=TOPDIR | 讓所有檔案與此字串相關 |
-h, --help | 顯示求助訊息後離開 |
B.3.10. 刪除配置頻道
要刪除您公司的配置頻道,請使用以下指令:
rhncfg-manager remove-channel channel-label
輸出畫面包括以下資訊:
Removing config channel example-channel Config channel example-channel removed
B.3.11. 決定檔案修訂版本的數目
要找出頻道內某個檔案/路徑的修改版本數(從 1 到 N,N 是大於零的整數),請使用以下指令:
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
B.3.12. 升級頻道內的檔案
要在頻道內建立某個檔案的新版本(或如果在指定的目錄下並沒有檔案,而您想新增該檔案的第一個版本的話),請使用以下指令:
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
以下表格列出
rhncfg-manager update
的可用選項:
表格 B.10. 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
輸出畫面包括以下資訊:
Using config channel example-channel4 Uploading /tmp/ola_world.txt from blah4/tmp/ola_world.txt
以下表格列出
rhncfg-manager upload-channel
的可用選項:
表格 B.11. rhncfg-manager upload-channel
選項
選項 | 描述 |
---|---|
-tTOPDIR, --topdir=TOPDIR | 所有檔案路徑相對的目錄 |
-cCHANNEL, --channel=CHANNEL | 列出配置資訊要上傳至的頻道。頻道以「,」隔開,例如:--channel=foo,bar,baz |
-h, --help | 顯示求助訊息後離開 |