Starting component `ctl`: /home/tidb/.tiup/components/ctl/v4.0.8/ctl tikv TiKV Control (tikv-ctl) Release Version: 4.0.8 Edition: Community Git Commit Hash: 83091173e960e5a0f5f417e921a0801d2f6635ae Git Commit Branch: heads/refs/tags/v4.0.8 UTC Build Time: 2020-10-30 08:40:33 Rust Version: rustc 1.42.0-nightly (0de96d37f 2019-12-19) Enable Features: jemalloc mem-profiling portable sse protobuf-codec Profile: dist_release A tool for interacting with TiKV deployments. USAGE: TiKV Control (tikv-ctl) [FLAGS] [OPTIONS] [SUBCOMMAND] FLAGS: -h, --help Prints help information --skip-paranoid-checks Skip paranoid checks when open rocksdb -V, --version Prints version information OPTIONS: --ca-path <ca-path> Set the CA certificate path --cert-path <cert-path> Set the certificate path --config <config> TiKV config path, by default it's <deploy-dir>/conf/tikv.toml --data-dir <data-dir> TiKV data directory path, check <deploy-dir>/scripts/run.sh to get it --decode <decode> Decode a key in escaped format --encode <encode> Encode a key in escaped format --to-hex <escaped-to-hex> Convert an escaped key to hex key --to-escaped <hex-to-escaped> Convert a hex key to escaped key --host <host> Set the remote host --key-path <key-path> Set the private key path --log-level <log-level> Set the log level [default:warn] --pd <pd> Set the address of pd SUBCOMMANDS: bad-regions Get all regions with corrupt raft cluster Print the cluster id compact Compact a column family in a specified range compact-cluster Compact the whole cluster in a specified range in one or more column families consistency-check Force a consistency-check for a specified region decrypt-file Decrypt an encrypted file diff Calculate difference of region keys from different dbs dump-snap-meta Dump snapshot meta file encryption-meta Dump encryption metadata fail Inject failures to TiKV and recovery help Prints this message or the help of the given subcommand(s) metrics Print the metrics modify-tikv-config Modify tikv config, eg. tikv-ctl --host ip:port modify-tikv-config -n rocksdb.defaultcf.disable-auto-compactions -v true mvcc Print the mvcc value print Print the raw value raft Print a raft log entry raw-scan Print all raw keys in the range recover-mvcc Recover mvcc data on one node by deleting corrupted keys recreate-region Recreate a region with given metadata, but alloc new id for it region-properties Show region properties scan Print the range db range size Print region size split-region Split the region store Print the store id tombstone Set some regions on the node to tombstone by manual unsafe-recover Unsafely recover the cluster when the majority replicas are failed
当 key 范围精准到某个 Region 的范围时,以上述 Region 1239 为例:当给定的 key 范围为 Region 1239 的范围时,由于 Region 范围为左闭右开区间,并且 Region 1009 以 Region 1239 的 end_key 作为 start_key,因此会同时输出 Region 1009 和 Region 1239 的信息。
tikv-ctl --host 127.0.0.1:20160 raft region --start 7480000000000000FF4E5F728000000000FF1443770000000000FA --end 7480000000000000FF4E5F728000000000FF21C4420000000000FA
unsafe-recover remove-fail-stores 命令可以将故障机器从指定 Region 的 peer 列表中移除。运行命令之前,需要目标 TiKV 先停掉服务以便释放文件锁。
-s 选项接受多个以逗号分隔的 store_id,并使用 -r 参数来指定包含的 Region。如果要对某一个 store 上的全部 Region 都执行这个操作,可简单指定 --all-regions。
警告
此功能使用不当可能导致集群难以恢复,存在风险。请悉知潜在的风险,尽量避免在生产环境中使用。
如果使用 --all-regions,必须在剩余所有连入集群的 store 上执行此命令。需要保证这些健康的 store 都停掉服务后再进行恢复,否则期间 Region 副本之间的 peer 列表不一致会导致执行 split-region 或者 remove-peer 时报错进而引起其他元数据的不一致,最终引发 Region 不可用。
一旦执行了 remove-fail-stores,不可再重新启动被移除的节点并将其加入集群,否则会导致元数据的不一致,最终引发 Region 不可用。
--ids 选项可以指定以逗号分隔的数据加密密钥 id 列表。如果不指定 --ids 选项,本命令打印所有的数据加密密钥,以及最新的数据加密密钥的 id。
本命令会输出一个警告,提示本命令会泄漏敏感数据。根据提示输入 "I consent" 即可。
tikv-ctl --config=./conf.toml encryption-meta dump-key This action will expose encryption key(s) as plaintext. Do not output the result in file on disk. Type "I consent" to continue, anything else to exit: I consent current key id: 9291156302549018620 9291156302549018620: key: 8B6B6B8F83D36BE2467ED55D72AE808B method: Aes128Ctr creation_time: 1592938357
tikv-ctl --config=./conf.toml encryption-meta dump-key --ids=9291156302549018620 This action will expose encryption key(s) as plaintext. Do not output the result in file on disk. Type "I consent" to continue, anything else to exit: I consent 9291156302549018620: key: 8B6B6B8F83D36BE2467ED55D72AE808B method: Aes128Ctr creation_time: 1592938357