nodetool repair 顧名思義就是修複,這是nodetool中一個非常重要的操作。當我們對資料有修改或刪除動作時,或定期執行repair操作,以保持各個節點的一致性。 基本格式
nodetool [(-h <host> | --host <host>)] [(-p <port> | --port <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