Azure Managed Instance for Apache Cassandra 是純開放原始碼 Apache Cassandra 叢集的完全受控服務。 服務也允許根據每個工作負載的特定需求來覆寫設定。 此功能可在需要時提供最大的彈性和控制。 本文說明如何在必要時手動執行資料庫管理員 (DBA) 命令。
重要事項
nodetool和 sstable 命令處於公開預覽狀態。
此功能在沒有服務等級協定 (SLA) 的情況下提供。 不建議此功能用於生產工作負載。 如需詳細資訊,請參閱 Microsoft Azure 預覽版增補使用條款。
DBA 命令支援
使用適用於 Apache Cassandra 的 Azure 受控實例,您可以使用 Azure CLI 執行 nodetool 和 sstable 命令,以進行例行的 DBA 管理。 並非所有命令都受到支援,而且有一些限制。 如需支援的命令,請參閱下列各節。
警告
其中一些命令可能會破壞 Cassandra 叢集的不穩定。 只有在非生產環境中測試之後,才小心地使用這些命令。 可能的話,請先部署 --dry-run 選項。 Microsoft不會針對因執行改變預設資料庫組態或數據表的命令而發生的問題提供任何 SLA 或支援。
執行 nodetool 命令
Azure Managed Instance for Apache Cassandra 提供下列 Azure CLI 命令來執行 DBA 命令:
az managed-cassandra cluster invoke-command --resource-group <rg> \
--cluster-name <cluster> --host <ip of data node> --command-name nodetool \
--arguments "<nodetool-subcommand>"="" "paramerter1"=""
子命令必須位於 --arguments 具有空值的 區段中。 nodetool沒有值的旗標以格式<flag>"="呈現。 如果旗標有值,則其格式 <flag>"="value為 。
此範例示範如何執行 nodetool 不含旗標的命令。 在此案例中,命令是nodetool status。
az managed-cassandra cluster invoke-command --resource-group <rg> --cluster-name <cluster> \
--host <ip of data node> --command-name nodetool --arguments "status"=""
此範例示範如何使用 旗標執行 nodetool 命令。 此案例中的命令是nodetool compact:
az managed-cassandra cluster invoke-command --resource-group <rg> --cluster-name <cluster> \
--host <ip of data node> --command-name nodetool --arguments "compact"="" "-st"="65678794"
這兩者都會以下列形式傳回 JSON:
{
"commandErrorOutput": "",
"commandOutput": "<result>",
"exitCode": 0
}
在大部分情況下,您只需要 commandOutput 或 exitCode。 此範例展示如何僅取得 commandOutput。
az managed-cassandra cluster invoke-command --query "commandOutput" --resource-group $resourceGroupName \
--cluster-name $clusterName --host $host --command-name nodetool --arguments getstreamthroughput=""
執行 sstable 命令
sstable 命令需要 Cassandra 資料目錄和要停止的 Cassandra 資料庫的讀取/寫入存取權。 若要配合這項需求,請指定這兩個參數: --cassandra-stop-start true 和 --readwrite true。
az managed-cassandra cluster invoke-command --resource-group <test-rg> \
--cluster-name <test-cluster> --host <ip> --cassandra-stop-start true --readwrite true \
--command-name sstableutil --arguments "system"="peers"
{
"commandErrorOutput": "",
"commandOutput": "Listing files...\n/var/lib/cassandra/data/system/peers-37f71aca7dc2383ba70672528af04d4f/me-1-big-CompressionInfo.db\n/var/lib/cassandra/data/system/peers-37f71aca7dc2383ba70672528af04d4f/me-1-big-Data.db\n/var/lib/cassandra/data/system/peers-37f71aca7dc2383ba70672528af04d4f/me-1-big-Digest.crc32\n/var/lib/cassandra/data/system/peers-37f71aca7dc2383ba70672528af04d4f/me-1-big-Filter.db\n/var/lib/cassandra/data/system/peers-37f71aca7dc2383ba70672528af04d4f/me-1-big-Index.db\n/var/lib/cassandra/data/system/peers-37f71aca7dc2383ba70672528af04d4f/me-1-big-Statistics.db\n/var/lib/cassandra/data/system/peers-37f71aca7dc2383ba70672528af04d4f/me-1-big-Summary.db\n/var/lib/cassandra/data/system/peers-37f71aca7dc2383ba70672528af04d4f/me-1-big-TOC.txt\n",
"exitCode": 0
}
執行其他命令
cassandra-reset-password命令可讓用戶變更 Cassandra 的密碼。
az managed-cassandra cluster invoke-command --resource-group <rg> --cluster-name <cluster> \
--host <ip of data node> --command-name cassandra-reset-password --arguments password="<password>"
密碼是此命令中的 URL 編碼 (UTF-8),這表示適用下列規則:
- 英文字母和數字
a到z、A到Z以及0到9保持不變。 - 特殊字元
.、-、*和_維持不變。 - 空白字元會轉換成加號(
+)。 - 所有其他字元都是不安全的,而且會先使用某些編碼配置轉換成一或多個字節。 三個字元字串
%xy代表每個位元組,其中xy是位元組的兩位數十六進位表示法。
cassandra-reset-auth-replication 命令可讓使用者變更 Cassandra 使用者的結構描述。 以空格分隔資料中心名稱。
az managed-cassandra cluster invoke-command --resource-group <rg> --cluster-name <cluster> \
--host <ip of data node> --command-name cassandra-reset-auth-replication \
--arguments password="<datacenters>"
數據中心在傳遞至此命令時會以URL編碼(UTF-8),這表示適用下列規則:
a到z、A到Z、以及0到9的英數字元維持不變。- 特殊字元
.、-、*和_維持不變。 - 空白字元被轉換為加號(
+)。 - 所有其他字元都是不安全的,而且會先使用某些編碼配置轉換成一或多個字節。 三個字元字串
%xy代表每個位元組,其中xy是位元組的兩位數十六進位表示法。
sstable-tree命令可讓使用者查看其SSTable。
az managed-cassandra cluster invoke-command --resource-group <rg> --cluster-name <cluster> \
--host <ip of data node> --command-name sstable-tree
sstable-delete命令可讓使用者刪除在特定時間之前建立的SSTable。
az managed-cassandra cluster invoke-command --resource-group <rg> --cluster-name <cluster> \
--host <ip of data node> --command-name sstable-delete --arguments datetime="<YYYY-MM-DD hh:mm:ss>"
自 datetime 變數的格式必須如範例所示。 您也可以將 新增 --dry-run="" 為自變數,以查看命令會刪除哪些檔案。
支援的 sstable 命令清單
如需每個命令的詳細資訊,請參閱 SSTable 工具。
sstableverifysstablescrubsstablemetadatasstablelevelresetsstableutilsstablesplitsstablerepairedsetsstableofflinerelevelsstableexpiredblockers
支援的 nodetool 命令清單
如需每個命令的詳細資訊,請參閱 使用 nodetool。
statuscleanupclearsnapshotcompactcompactionhistorycompactionstatsdescribeclusterdescriberingdisableautocompactiondisablehandoffdisablehintsfordcdrainenableautocompactionenablehandoffenablehintsfordcfailuredetectorflushgarbagecollectgcstatsgetcompactionthresholdgetcompactionthroughputgetconcurrentcompactorsgetendpointsgetinterdcstreamthroughputgetlogginglevelsgetsstablesgetstreamthroughputgettimeoutgettraceprobabilitygossipinfoinfoinvalidatecountercacheinvalidatekeycacheinvalidaterowcachelistsnapshotsnetstatspausehandoffproxyhistogramsrangekeysamplerebuildrebuild_index:針對自變數,請使用"keyspace"="table indexname..."。refreshrefreshsizeestimatesreloadlocalschemareplaybatchlogresetlocalschemaresumehandoffringscrubsetcachecapacity:針對自變數,請使用"key-cache-capacity" = "<row-cache-capacity> <counter-cache-capacity>"。setcachekeystosave:針對自變數,請使用"key-cache-keys-to-save":"<row-cache-keys-to-save> <counter-cache-keys-to-save>"。setcompactionthreshold:針對自變數,請使用"<keyspace>"="<table> <minthreshold> <maxthreshold>。setcompactionthroughputsetconcurrentcompactorssethintedhandoffthrottlekbsetinterdcstreamthroughputsetstreamthroughputsettimeoutsettraceprobabilitystatusbackupstatusbinarystatusgossipstatushandoffstoptablehistogramstablestatstoppartitionstpstatstruncatehintsverifyversionviewbuildstatus