Cassandraのいくつかのメンテナンス操作
1.クラスタがvnodesを使用しているかどうかを確認する
用途:virtual nodesを使用し、ノードを削除すると自動的にデータが等化され、手動で処理しないでください.主にあなたのcassandraを見ています.ymlプロファイルでinitial_が構成されているかどうかtokenは、構成されていない場合はvnodesを使用します.
この行の注釈が見つかったのでvirtual nodesを使用しました
2.replication_の表示factor
主に疎なクラスタを運営し、特にノードを削除する際には、特にデータの損失に注意する必要がありますので、見てみましょう.2つの方法があります.
a. desc keyspace_name
b.system keyspaceで見る
adというkeyspaceのStrategyが
3.現在のクラスタステータスの表示
4.ノードの追加、ノードの削除
主にnodetoolコマンドの使用です.
削除ノードの公式ステップ:第1ステップ:まず各マシンが修復するkeyspace
5.keyがどのendpointにあるかを確認する
6.続行
7.other: nodetool help
用途:virtual nodesを使用し、ノードを削除すると自動的にデータが等化され、手動で処理しないでください.主にあなたのcassandraを見ています.ymlプロファイルでinitial_が構成されているかどうかtokenは、構成されていない場合はvnodesを使用します.
cassandra/conf$ less cassandra.yaml
# initial_token allows you to specify tokens manually. While you can use # it with
# vnodes (num_tokens > 1, above) -- in which case you should provide a
# comma-separated list -- it's primarily used when adding nodes # to legacy clusters
# that do not have vnodes enabled.
# initial_token:
この行の注釈が見つかったのでvirtual nodesを使用しました
2.replication_の表示factor
主に疎なクラスタを運営し、特にノードを削除する際には、特にデータの損失に注意する必要がありますので、見てみましょう.2つの方法があります.
a. desc keyspace_name
$desc
この命令はこのkeyspaceをnameと次のcolumn familyはすべてdescします.cqlsh> desc keyspace example;
CREATE KEYSPACE ad WITH replication = {'class': 'NetworkTopologyStrategy', 'DC1': '3'} AND durable_writes = true;
...desc other column families
b.system keyspaceで見る
cqlsh> use system;
cqlsh:system> select * from schema_keyspaces;
keyspace_name | durable_writes | strategy_class | strategy_options
---------------+----------------+------------------------------------------------------+----------------------------
OpsCenter | False | org.apache.cassandra.locator.NetworkTopologyStrategy | {"DC1":"1","DC2":"1"}
system | True | org.apache.cassandra.locator.LocalStrategy | {}
example | True | org.apache.cassandra.locator.NetworkTopologyStrategy | {"DC1":"3"}
adというkeyspaceのStrategyが
NetworkTopologyStrategy,{"DC1":"3"}
であることがわかります3.現在のクラスタステータスの表示
/cassandra/bin$ ./nodetool status
Datacenter: DC1
===================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns Host ID Rack
DN 10.6.120.11 502.91 GB 256 ? 11299fbb-627e-4453-838a-2af2e7e06b29 R07
UN 10.6.120.12 489.04 GB 256 ? 19185573-6f3e-431d-bf60-5c10691c85b6 R07
UN 10.6.120.13 482.92 GB 256 ? 524182a1-771c-4f0a-b904-ce1b7c24b48f R07
UN 10.6.120.14 500.63 GB 256 ? e288eb41-b151-4d03-9fe3-3508dfd77ed7 R07
...
4.ノードの追加、ノードの削除
主にnodetoolコマンドの使用です.
/cassandra/bin$ ./nodetool removenode host_id
/cassandra/bin$ ./nodetool removenode host_id force
# Decommission the *node I am connecting to*
/cassandra/bin$ ./nodetool decommission
# for more command, use help
/cassandra/bin$ ./nodetool help
削除ノードの公式ステップ:第1ステップ:まず各マシンが修復するkeyspace
$nodetool repair -h ip_address_of_node keyspace_name
第2ステップ:削除するマシンがUP状態のマシンである場合、削除するマシン上でnodetool decommission
を実行するダウンタイムがない.そのまま終わります.そうしないと、次の手順に進みます.ステップ3:アクティブなノードで削除操作$ nodetool removenode host_id
を実行すると、それは自分でデータを等化し、ここで直接終了します.そうしないと、続行します.ステップ4:削除に成功したかどうかを確認5.keyがどのendpointにあるかを確認する
/cassandra/bin$ ./nodetool getendpoint keyspace_name columnfamily_name key
6.続行
7.other: nodetool help
/cassandra/bin$ ./nodetool help
usage: nodetool [(-u | --username )]
[(-pw | --password )] [(-h | --host )]
[(-pwf | --password-file )]
[(-p | --port )] []
The most commonly used nodetool commands are:
cfhistograms Print statistic histograms for a given column family
cfstats Print statistics on column families
cleanup Triggers the immediate cleanup of keys no longer belonging to a node. By default, clean all keyspaces
clearsnapshot Remove the snapshot with the given name from the given keyspaces. If no snapshotName is specified we will remove all snapshots
compact Force a (major) compaction on one or more column families
compactionhistory Print history of compaction
compactionstats Print statistics on compactions
decommission Decommission the *node I am connecting to*
describecluster Print the name, snitch, partitioner and schema version of a cluster
describering Shows the token ranges info of a given keyspace
disableautocompaction Disable autocompaction for the given keyspace and column family
disablebackup Disable incremental backup
disablebinary Disable native transport (binary protocol)
disablegossip Disable gossip (effectively marking the node down)
disablehandoff Disable storing hinted handoffs
disablethrift Disable thrift server
drain Drain the node (stop accepting writes and flush all column families)
enableautocompaction Enable autocompaction for the given keyspace and column family
enablebackup Enable incremental backup
enablebinary Reenable native transport (binary protocol)
enablegossip Reenable gossip
enablehandoff Reenable the future hints storing on the current node
enablethrift Reenable thrift server
flush Flush one or more column families
gcstats Print GC Statistics
getcompactionthreshold Print min and max compaction thresholds for a given column family
getcompactionthroughput Print the MB/s throughput cap for compaction in the system
getendpoints Print the end points that owns the key
getlogginglevels Get the runtime logging levels
getsstables Print the sstable filenames that own the key
getstreamthroughput Print the Mb/s throughput cap for streaming in the system
gossipinfo Shows the gossip information for the cluster
help Display help information
info Print node information (uptime, load, ...)
invalidatecountercache Invalidate the counter cache
invalidatekeycache Invalidate the key cache
invalidaterowcache Invalidate the row cache
join Join the ring
listsnapshots Lists all the snapshots along with the size on disk and true size.
move Move node on the token ring to a new token
netstats Print network information on provided host (connecting node by default)
pausehandoff Pause hints delivery process
proxyhistograms Print statistic histograms for network operations
rangekeysample Shows the sampled keys held across all keyspaces
rebuild Rebuild data by streaming from other nodes (similarly to bootstrap)
rebuild_index A full rebuild of native secondary indexes for a given column family
refresh Load newly placed SSTables to the system without restart
reloadtriggers Reload trigger classes
removenode Show status of current node removal, force completion of pending removal or remove provided ID
repair Repair one or more column families
resetlocalschema Reset node's local schema and resync
resumehandoff Resume hints delivery process
ring Print information about the token ring
scrub Scrub (rebuild sstables for) one or more column families
setcachecapacity Set global key, row, and counter cache capacities (in MB units)
setcachekeystosave Set number of keys saved by each cache for faster post-restart warmup. 0 to disable
setcompactionthreshold Set min and max compaction thresholds for a given column family
setcompactionthroughput Set the MB/s throughput cap for compaction in the system, or 0 to disable throttling
sethintedhandoffthrottlekb Set hinted handoff throttle in kb per second, per delivery thread.
setlogginglevel Set the log level threshold for a given class. If both class and level are empty/null, it will reset to the initial configuration
setstreamthroughput Set the Mb/s throughput cap for streaming in the system, or 0 to disable throttling
settraceprobability Sets the probability for tracing any given request to value. 0 disables, 1 enables for all requests, 0 is the default
snapshot Take a snapshot of specified keyspaces or a snapshot of the specified column family
status Print cluster information (state, load, IDs, ...)
statusbackup Status of incremental backup
statusbinary Status of native transport (binary protocol)
statusgossip Status of gossip
statushandoff Status of storing future hints on the current node
statusthrift Status of thrift server
stop Stop compaction
stopdaemon Stop cassandra daemon
toppartitions Sample and print the most active partitions for a given column family
tpstats Print usage statistics of thread pools
truncatehints Truncate all hints on the local node, or truncate hints for the endpoint(s) specified.
upgradesstables Rewrite sstables (for the requested column families) that are not on the current version (thus upgrading them to said current version)
version Print cassandra version