Cassandra 常用命令之 nodetool repair


nodetool repair 顾名思义就是修复,这是nodetool中一个非常重要的操作。当我们对数据有修改或删除动作时,或定期执行repair操作,以保持各个节点的一致性。

基本格式

nodetool [(-h | --host )] [(-p | --port )]
     [(-pw password | --password password)]
     [(-pwf passwordFilePath | --password-file passwordFilePath)]
     [(-u username | --username username)] repair
     [(-dc specific_dc | --in-dc specific_dc)...]
     [(-dcpar | --dc-parallel)] [(-et end_token | --end-token end_token)]
     [(-full | --full)]
     [(-hosts specific_host | --in-hosts specific_host)...]
     [(-j job_threads | --job-threads job_threads)]
     [(-local | --in-local-dc)] [(-pr | --partitioner-range)]
     [(-seq | --sequential)]
     [(-st start_token | --start-token start_token)] [(-tr | --trace)]
     [--] [keyspace tables...]

这里要注意的是这些参数是有顺序的,有些只能在repair,有些只能在repair后,哥一开始没注意这些顺序,走了很多弯路。

选项
hort Long Description
-h --host Hostname or IP address.
-p --port Port number.
-pwf --password-file Password file path.
-pw --password Password.
-u --username Remote JMX agent username.
-dc specific_dc --in-dc specific_dc Repair to nodes in the named datacenter (specific_dc).
-dcpar --dc-parallel Repair datacenters in parallel, one node per datacenter at a time.
-et end_token --end-tokenend_token Token UUID. Repair a range of nodes starting with the first token (see -st) and ending with this token (end_token). Use -hosts to specify neighbor nodes.
-full --full Do a full repair.
-h host_name --host host_name Node host name or IP address.
-hosts specific_host --in-hostsspecific_host Repair specific hosts.
-j job_threads --job-threadsjob_threads Number of threads (job_threads) to run repair jobs. Usually the number of tables to repair concurrently. Be aware that increasing this setting puts more load on repairing nodes. (Default: 1, maximum: 4)
-local --in-local-dc Use to only repair nodes in the same datacenter.
-pr --partitioner-range Run a repair on the partition ranges that are primary on a replica.
-seq start_token --sequentialstart_token Run a sequential repair.
-st start_token --start-tokenstart_token Specify the token (start_token) at which the repair range starts.
-tr --trace Trace the repair. Traces are logged tosystem_traces.events.
keyspace Name of keyspace.
tables One or more table names, separated by a space.
-- Separates an option from an argument that could be mistaken for a option.

示例:


在当前节点,顺序修复所有的keyspaces
./nodetool repair -seq


修复当前所在的数据中心(data_center),该命令只能在当前数据中心使用。
./nodetool repair -dc DC1


如果想修复某一段ring的数据(相对于全部修复,话费时间更少),就用-st(即start_token) -et(即end_token),这对token必须是同一个node,且有大小顺序。查看ring的命令用repair ring


./nodetool repair -st 7521963415957825786 -et 8097903535872843286


只修复range落在该节点的master数据
./nodetool repair -pr



原文地址:http://docs.datastax.com/en/cassandra/3.0/cassandra/tools/toolsRepair.html
参考文章:http://zhaoyanblog.com/archives/649.html



你可能感兴趣的:(Cassandra)