使用 az networkcloud baremetalmachine run-read-command
針對 BMM 問題進行疑難解答
在某些情況下,使用者可能需要調查並解決內部部署裸機 (BMM) 的問題。 運算子連接點提供 az networkcloud baremetalmachine run-read-command
,讓使用者可以執行只讀命令的策劃清單,以從 BMM 取得資訊。
此命令會產生包含執行讀取命令執行結果的輸出檔案。 根據預設,數據會傳送至叢集管理員記憶體帳戶。 另外還有預覽方法,使用者可以使用記憶體帳戶和身分識別來設定叢集資源,而該記憶體帳戶可以存取記憶體帳戶以接收輸出。
必要條件
- 安裝最新版本的適當 CLI 延伸模組
- 確定目標 BMM 必須將其
poweredState
設定為On
,並將其readyState
設定為True
- 取得您為
Cluster
資源建立的受控資源群組名稱 (cluster_MRG)
將命令輸出傳送至使用者指定的記憶體帳戶
如需受控識別和使用者提供的資源,請參閱 Azure作員 Nexus 叢集支援
清除叢集的 CommandOutputSettings
若要將叢集從使用者指派的身分識別變更為系統指派的身分識別,必須先使用下一節中的 命令清除 CommandOutputSettings,然後使用此命令進行設定。
您可以清除 CommandOutputSettings,將 run-data-extract 輸出導向至叢集管理員的記憶體。 不過,不建議使用此選項,因為它較不安全,且選項將在未來的版本中移除。
不過,從使用者指派的身分識別切換到系統指派的身分識別時,必須清除 CommandOutputSettings。
使用此命令清除 CommandOutputSettings:
az rest --method patch \
--url "https://management.azure.com/subscriptions/<subscription>/resourceGroups/<cluster-resource-group>/providers/Microsoft.NetworkCloud/clusters/<cluster-name>?api-version=2024-08-01-preview" \
--body '{"properties": {"commandOutputSettings":null}}'
已淘汰的方法:驗證叢集管理員記憶體帳戶的存取權
重要
叢集管理員記憶體帳戶的目標是在 2025 年 4 月最新移除。 如果您目前針對命令輸出使用這個方法,請考慮使用使用者提供的記憶體帳戶轉換成 。
如果使用叢集管理員記憶體方法,請確認您具有叢集管理員記憶體帳戶的存取權:
- 從 Azure 入口網站,瀏覽至叢集管理員的儲存體帳戶。
- 在 [儲存體帳戶詳細資料] 中,從左側導覽功能表中選取 [儲存體瀏覽器]。
- 在儲存體瀏覽器詳細資料中,選取 [Blob 容器]。
- 如果您在存取儲存體帳戶時遇到
403 This request is not authorized to perform this operation.
,則必須更新儲存體帳戶的防火牆設定,以包含公用 IP 位址。 - 透過叢集管理員資源上的入口網站,建立支援票證來要求存取權。 提供需要存取權的公用 IP 位址。
執行執行讀取命令
run-read 命令可讓您在 BMM 上執行不會造成任何變更的命令。 某些命令有多個單字,或需要引數才能運作。 這些命令會像這樣,是為了將其與可能造成變更的命令區隔開來。 例如,run-read-command 可以使用 kubectl get
,但不能使用 kubectl apply
。 當您使用這些命令時,您必須將所有字放在 「command」 欄位中。 例如,{command:'kubectl get',arguments:[nodes]}
是對的;{command:kubectl,arguments:[get,nodes]}
是錯的。
另請注意,某些命令的開頭是 nc-toolbox nc-toolbox-runread
,必須如下所示輸入這些命令。
nc-toolbox-runread
是特殊的容器映像,其中包含更多未安裝在裸機主機上的工具,例如 ipmitool
和 racadm
。
某些 run-read 命令需要提供特定的引數,以強制執行命令的唯讀功能。
需要特定引數的 run-read 命令範例是允許的 Mellanox 命令 mstconfig
,因此需要提供 query
引數以強制執行唯讀。
警告
Microsoft不提供或支援任何作員 Nexus API 呼叫,其預期會提供純文本用戶名稱和/或密碼。 請注意,傳送的任何值都會記錄,並被視為公開的秘密,這應該輪替和撤銷。 Microsoft記錄使用秘密的方法,是將它們儲存在 Azure 金鑰保存庫 中。 如果您有特定問題或疑慮,請透過 Azure 入口網站 提交要求。
此清單會顯示您可以使用的命令。 中的 *italics*
命令不能有 arguments
;其餘命令可以。
arp
brctl show
dmidecode
fdisk -l
host
hostname
ifconfig -a
ifconfig -s
ip address show
ip link show
ip maddress show
ip route show
journalctl
kubectl api-resources
kubectl api-versions
kubectl describe
kubectl get
kubectl logs
mount
ping
ss
tcpdump
traceroute
uname
ulimit -a
uptime
timedatectl status
hostnamectl status
nc-toolbox nc-toolbox-runread ipmitool channel authcap
nc-toolbox nc-toolbox-runread ipmitool channel info
nc-toolbox nc-toolbox-runread ipmitool chassis status
nc-toolbox nc-toolbox-runread ipmitool chassis power status
nc-toolbox nc-toolbox-runread ipmitool chassis restart cause
nc-toolbox nc-toolbox-runread ipmitool chassis poh
nc-toolbox nc-toolbox-runread ipmitool dcmi power get_limit
nc-toolbox nc-toolbox-runread ipmitool dcmi sensors
nc-toolbox nc-toolbox-runread ipmitool dcmi asset_tag
nc-toolbox nc-toolbox-runread ipmitool dcmi get_mc_id_string
nc-toolbox nc-toolbox-runread ipmitool dcmi thermalpolicy get
nc-toolbox nc-toolbox-runread ipmitool dcmi get_temp_reading
nc-toolbox nc-toolbox-runread ipmitool dcmi get_conf_param
nc-toolbox nc-toolbox-runread ipmitool delloem lcd info
nc-toolbox nc-toolbox-runread ipmitool delloem lcd status
nc-toolbox nc-toolbox-runread ipmitool delloem mac list
nc-toolbox nc-toolbox-runread ipmitool delloem mac get
nc-toolbox nc-toolbox-runread ipmitool delloem lan get
nc-toolbox nc-toolbox-runread ipmitool delloem powermonitor powerconsumption
nc-toolbox nc-toolbox-runread ipmitool delloem powermonitor powerconsumptionhistory
nc-toolbox nc-toolbox-runread ipmitool delloem powermonitor getpowerbudget
nc-toolbox nc-toolbox-runread ipmitool delloem vflash info card
nc-toolbox nc-toolbox-runread ipmitool echo
nc-toolbox nc-toolbox-runread ipmitool ekanalyzer print
nc-toolbox nc-toolbox-runread ipmitool ekanalyzer summary
nc-toolbox nc-toolbox-runread ipmitool fru print
nc-toolbox nc-toolbox-runread ipmitool fwum info
nc-toolbox nc-toolbox-runread ipmitool fwum status
nc-toolbox nc-toolbox-runread ipmitool fwum tracelog
nc-toolbox nc-toolbox-runread ipmitool gendev list
nc-toolbox nc-toolbox-runread ipmitool hpm rollbackstatus
nc-toolbox nc-toolbox-runread ipmitool hpm selftestresult
nc-toolbox nc-toolbox-runread ipmitool ime help
nc-toolbox nc-toolbox-runread ipmitool ime info
nc-toolbox nc-toolbox-runread ipmitool isol info
nc-toolbox nc-toolbox-runread ipmitool lan print
nc-toolbox nc-toolbox-runread ipmitool lan alert print
nc-toolbox nc-toolbox-runread ipmitool lan stats get
nc-toolbox nc-toolbox-runread ipmitool mc bootparam get
nc-toolbox nc-toolbox-runread ipmitool mc chassis poh
nc-toolbox nc-toolbox-runread ipmitool mc chassis policy list
nc-toolbox nc-toolbox-runread ipmitool mc chassis power status
nc-toolbox nc-toolbox-runread ipmitool mc chassis status
nc-toolbox nc-toolbox-runread ipmitool mc getenables
nc-toolbox nc-toolbox-runread ipmitool mc getsysinfo
nc-toolbox nc-toolbox-runread ipmitool mc guid
nc-toolbox nc-toolbox-runread ipmitool mc info
nc-toolbox nc-toolbox-runread ipmitool mc restart cause
nc-toolbox nc-toolbox-runread ipmitool mc watchdog get
nc-toolbox nc-toolbox-runread ipmitool bmc bootparam get
nc-toolbox nc-toolbox-runread ipmitool bmc chassis poh
nc-toolbox nc-toolbox-runread ipmitool bmc chassis policy list
nc-toolbox nc-toolbox-runread ipmitool bmc chassis power status
nc-toolbox nc-toolbox-runread ipmitool bmc chassis status
nc-toolbox nc-toolbox-runread ipmitool bmc getenables
nc-toolbox nc-toolbox-runread ipmitool bmc getsysinfo
nc-toolbox nc-toolbox-runread ipmitool bmc guid
nc-toolbox nc-toolbox-runread ipmitool bmc info
nc-toolbox nc-toolbox-runread ipmitool bmc restart cause
nc-toolbox nc-toolbox-runread ipmitool bmc watchdog get
nc-toolbox nc-toolbox-runread ipmitool nm alert get
nc-toolbox nc-toolbox-runread ipmitool nm capability
nc-toolbox nc-toolbox-runread ipmitool nm discover
nc-toolbox nc-toolbox-runread ipmitool nm policy get policy_id
nc-toolbox nc-toolbox-runread ipmitool nm policy limiting
nc-toolbox nc-toolbox-runread ipmitool nm statistics
nc-toolbox nc-toolbox-runread ipmitool nm suspend get
nc-toolbox nc-toolbox-runread ipmitool nm threshold get
nc-toolbox nc-toolbox-runread ipmitool pef
nc-toolbox nc-toolbox-runread ipmitool picmg addrinfo
nc-toolbox nc-toolbox-runread ipmitool picmg policy get
nc-toolbox nc-toolbox-runread ipmitool power status
nc-toolbox nc-toolbox-runread ipmitool sdr elist
nc-toolbox nc-toolbox-runread ipmitool sdr get
nc-toolbox nc-toolbox-runread ipmitool sdr info
nc-toolbox nc-toolbox-runread ipmitool sdr list
nc-toolbox nc-toolbox-runread ipmitool sdr type
nc-toolbox nc-toolbox-runread ipmitool sel elist
nc-toolbox nc-toolbox-runread ipmitool sel get
nc-toolbox nc-toolbox-runread ipmitool sel info
nc-toolbox nc-toolbox-runread ipmitool sel list
nc-toolbox nc-toolbox-runread ipmitool sel time get
nc-toolbox nc-toolbox-runread ipmitool sensor get
nc-toolbox nc-toolbox-runread ipmitool sensor list
nc-toolbox nc-toolbox-runread ipmitool session info
nc-toolbox nc-toolbox-runread ipmitool sol info
nc-toolbox nc-toolbox-runread ipmitool sol payload status
nc-toolbox nc-toolbox-runread ipmitool user list
nc-toolbox nc-toolbox-runread ipmitool user summary
nc-toolbox nc-toolbox-runread racadm arp
nc-toolbox nc-toolbox-runread racadm coredump
nc-toolbox nc-toolbox-runread racadm diagnostics
nc-toolbox nc-toolbox-runread racadm eventfilters get
nc-toolbox nc-toolbox-runread racadm fcstatistics
nc-toolbox nc-toolbox-runread racadm get
nc-toolbox nc-toolbox-runread racadm getconfig
nc-toolbox nc-toolbox-runread racadm gethostnetworkinterfaces
nc-toolbox nc-toolbox-runread racadm getled
nc-toolbox nc-toolbox-runread racadm getniccfg
nc-toolbox nc-toolbox-runread racadm getraclog
nc-toolbox nc-toolbox-runread racadm getractime
nc-toolbox nc-toolbox-runread racadm getsel
nc-toolbox nc-toolbox-runread racadm getsensorinfo
nc-toolbox nc-toolbox-runread racadm getssninfo
nc-toolbox nc-toolbox-runread racadm getsvctag
nc-toolbox nc-toolbox-runread racadm getsysinfo
nc-toolbox nc-toolbox-runread racadm gettracelog
nc-toolbox nc-toolbox-runread racadm getversion
nc-toolbox nc-toolbox-runread racadm hwinventory
nc-toolbox nc-toolbox-runread racadm ifconfig
nc-toolbox nc-toolbox-runread racadm inlettemphistory get
nc-toolbox nc-toolbox-runread racadm jobqueue view
nc-toolbox nc-toolbox-runread racadm lclog view
nc-toolbox nc-toolbox-runread racadm lclog viewconfigresult
nc-toolbox nc-toolbox-runread racadm license view
nc-toolbox nc-toolbox-runread racadm netstat
nc-toolbox nc-toolbox-runread racadm nicstatistics
nc-toolbox nc-toolbox-runread racadm ping
nc-toolbox nc-toolbox-runread racadm ping6
nc-toolbox nc-toolbox-runread racadm racdump
nc-toolbox nc-toolbox-runread racadm sslcertview
nc-toolbox nc-toolbox-runread racadm swinventory
nc-toolbox nc-toolbox-runread racadm systemconfig getbackupscheduler
-
nc-toolbox nc-toolbox-runread racadm systemperfstatistics
(不允許 PeakReset 引數) nc-toolbox nc-toolbox-runread racadm techsupreport getupdatetime
nc-toolbox nc-toolbox-runread racadm traceroute
nc-toolbox nc-toolbox-runread racadm traceroute6
nc-toolbox nc-toolbox-runread racadm usercertview
nc-toolbox nc-toolbox-runread racadm vflashsd status
nc-toolbox nc-toolbox-runread racadm vflashpartition list
nc-toolbox nc-toolbox-runread racadm vflashpartition status -a
nc-toolbox nc-toolbox-runread mstregdump
-
nc-toolbox nc-toolbox-runread mstconfig
(需要query
自變數) -
nc-toolbox nc-toolbox-runread mstflint
(需要query
自變數) -
nc-toolbox nc-toolbox-runread mstlink
(需要query
自變數) -
nc-toolbox nc-toolbox-runread mstfwmanager
(需要query
自變數) nc-toolbox nc-toolbox-runread mlx_temp
沒有自變數的單一命令的命令語法如下,使用 hostname
作為範例:
az networkcloud baremetalmachine run-read-command --name "<machine-name>"
--limit-time-seconds "<timeout>" \
--commands "[{command:hostname}]" \
--resource-group "<cluster_MRG>" \
--subscription "<subscription>"
- 參數
--commands
一律會採用命令清單,即使只有一個命令也一樣。 - 您可以使用 Azure CLI 速記表示法,以 json 格式提供多個命令。
- 任何空格符都必須以單引弧括住。
- 每個命令的任何自變數也必須以清單的形式提供,如下列範例所示。
--commands "[{command:hostname},{command:'nc-toolbox nc-toolbox-runread racadm ifconfig'}]"
--commands "[{command:hostname},{command:'nc-toolbox nc-toolbox-runread racadm getsysinfo',arguments:[-c]}]"
--commands "[{command:ping,arguments:[198.51.102.1,-c,3]}]"
這些命令可以長時間執行,因此建議將 --limit-time-seconds
設定為至少 600 秒 (10 分鐘)。 執行多個命令可能需要超過10分鐘的時間。
此命令會同步執行。 如果您想要略過等候命令完成,請指定 --no-wait --debug
選項。 如需詳細資訊,請參閱如何追蹤非同步作業。
提供選擇性引述 --output-directory
時,輸出結果會下載並解壓縮至本機目錄。
警告
使用 自 --output-directory
變數會覆寫本機目錄中與所建立新檔案同名的任何檔案。
此範例會執行 'kubectl get pods'
az networkcloud baremetalmachine run-read-command --name "<bareMetalMachineName>" \
--limit-time-seconds 60 \
--commands "[{command:'kubectl get',arguments:[pods,-n,nc-system]}]" \
--resource-group "<cluster_MRG>" \
--subscription "<subscription>"
此範例會執行 hostname
命令和 ping
命令
az networkcloud baremetalmachine run-read-command --name "<bareMetalMachineName>" \
--limit-time-seconds 60 \
--commands "[{command:hostname},{command:ping,arguments:[198.51.102.1,-c,3]}]" \
--resource-group "<cluster_MRG>" \
--subscription "<subscription>"
此範例會執行 racadm getsysinfo -c
命令
az networkcloud baremetalmachine run-read-command --name "<bareMetalMachineName>" \
--limit-time-seconds 60 \
--commands "[{command:'nc-toolbox nc-toolbox-runread racadm getsysinfo',arguments:[-c]}]" \
--resource-group "<cluster_MRG>" \
--subscription "<subscription>"
檢查命令狀態,並在使用者指定的記憶體帳戶中檢視輸出
即會顯示範例輸出。 為方便起見,這會將結果的前 4,000 個字元列印到畫面,並提供包含命令執行結果的儲存體 Blob 短期連結。 您可以使用連結來下載壓縮的輸出檔案 (tar.gz)。 若要存取輸出,使用者需要適當的記憶體 Blob 存取權。 如需將角色指派給記憶體帳戶的資訊,請參閱 指派 Azure 角色以存取 Blob 數據。
====Action Command Output====
+ hostname
rack1compute01
+ ping 198.51.102.1 -c 3
PING 198.51.102.1 (198.51.102.1) 56(84) bytes of data.
--- 198.51.102.1 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2049ms
================================
Script execution result can be found in storage account:
https://<storage_account_name>.blob.core.windows.net/bmm-run-command-output/a8e0a5fe-3279-46a8-b995-51f2f98a18dd-action-bmmrunreadcmd.tar.gz?se=2023-04-14T06%3A37%3A00Z&sig=XXX&sp=r&spr=https&sr=b&st=2023-04-14T02%3A37%3A00Z&sv=2019-12-12
已淘汰:如何在叢集管理員記憶體帳戶中檢視的 az networkcloud baremetalmachine run-read-command
輸出
本指南會逐步引導您存取在伺服器上執行 az networkcloud baremetalmachine run-read-command
時,於叢集管理員儲存體帳戶中建立的輸出檔案。 在狀態輸出中,會識別檔案的名稱 az rest
。
開啟伺服器所在叢集的 [叢集管理員受控資源群組],然後選取 [儲存器帳戶]。
在 [儲存體帳戶詳細資料] 中,從左側導覽功能表中選取 [儲存體瀏覽器]。
在儲存體瀏覽器詳細資料中,選取 [Blob 容器]。
選取 baremetal-run-command-output Blob 容器。
儲存體帳戶可能會遭到鎖定,因為網路或防火牆限制而造成
403 This request is not authorized to perform this operation.
。 如需驗證存取的程式, 請參閱叢集管理員記憶體 或 客戶管理的記憶體 區段。從 run-read 命令中選取輸出檔案。 您可以從
az rest --method get
命令識別檔案名稱。 此外,執行命令時,上次修改時間戳會一致。您可以從快顯概觀下載輸出檔案。