Share via


Azure Managed Instance for Apache Cassandra 的 DBA 命令

Azure Managed Instance for Apache Cassandra 是純開放原始碼 Apache Cassandra 叢集的完全受控服務。 此服務也允許根據每個工作負載的特定需求來覆寫組態,而能視需要提供最大彈性和控制。 本文將說明如何在需要時手動執行 DBA 命令。

重要

Nodetool 和 sstable 命令目前處於公開預覽狀態。 此功能是在沒有服務等級協定的情況下提供,不建議用於生產工作負載。 如需詳細資訊,請參閱 Microsoft Azure 預覽版增補使用條款

DBA 命令支援

Azure Managed Instance for Apache Cassandra 可讓您透過 Azure CLI 執行 nodetoolsstable 命令,以進行例行 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),這表示適用下列規則:

  • The alphanumeric characters "a" through "z", "A" through "Z" and "0" through "9" remain the same.
  • The special characters ".", "-", "*", and "_" remain the same.
  • The space character " " is converted into a plus sign "+".
  • All other characters are unsafe and are first converted into one or more bytes using some encoding scheme. Then each byte is represented by the 3-character string "%xy", where xy is the two-digit hexadecimal representation of the byte.

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),這表示適用下列規則:

  • The alphanumeric characters "a" through "z", "A" through "Z" and "0" through "9" remain the same.
  • The special characters ".", "-", "*", and "_" remain the same.
  • The space character " " is converted into a plus sign "+".
  • All other characters are unsafe and are first converted into one or more bytes using some encoding scheme. Then each byte is represented by the 3-character string "%xy", where xy is the two-digit hexadecimal representation of the byte.

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 命令清單

如需每個命令的詳細資訊,請參閱 https://cassandra.apache.org/doc/latest/cassandra/tools/sstable/index.html

  • sstableverify
  • sstablescrub
  • sstablemetadata
  • sstablelevelreset
  • sstableutil
  • sstablesplit
  • sstablerepairedset
  • sstableofflinerelevel
  • sstableexpiredblockers

支援的 nodetool 命令清單

如需每個命令的詳細資訊,請參閱 https://cassandra.apache.org/doc/latest/cassandra/tools/nodetool/nodetool.html

  • status
  • cleanup
  • clearsnapshot
  • compact
  • compactionhistory
  • compactionstats
  • describecluster
  • describering
  • disableautocompaction
  • disablehandoff
  • disablehintsfordc
  • drain
  • enableautocompaction
  • enablehandoff
  • enablehintsfordc
  • failuredetector
  • flush
  • garbagecollect
  • gcstats
  • getcompactionthreshold
  • getcompactionthroughput
  • getconcurrentcompactors
  • getendpoints
  • getinterdcstreamthroughput
  • getlogginglevels
  • getsstables
  • getstreamthroughput
  • gettimeout
  • gettraceprobability
  • gossipinfo
  • info
  • invalidatecountercache
  • invalidatekeycache
  • invalidaterowcache
  • listsnapshots
  • netstats
  • pausehandoff
  • proxyhistograms
  • rangekeysample
  • rebuild
  • rebuild_index - 針對引數使用 "keyspace"="table indexname..."
  • refresh
  • refreshsizeestimates
  • reloadlocalschema
  • replaybatchlog
  • resetlocalschema
  • resumehandoff
  • ring
  • scrub
  • setcachecapacity - 針對引數使用 "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>
  • setcompactionthroughput
  • setconcurrentcompactors
  • sethintedhandoffthrottlekb
  • setinterdcstreamthroughput
  • setstreamthroughput
  • settimeout
  • settraceprobability
  • statusbackup
  • statusbinary
  • statusgossip
  • statushandoff
  • stop
  • tablehistograms
  • tablestats
  • toppartitions
  • tpstats
  • truncatehints
  • verify
  • version
  • viewbuildstatus

下一步