你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
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 命令列表
有关每个命令的详细信息,请参阅 Use 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