The snitch in Cassandra is used to tell the Cassandra network topology, such as the relative distance between the nodes, how the nodes are grouped, and the rack where the nodes are located, so that the user requests can be efficiently routed.
Note: All nodes in a cluster must adopt the same snitch policy.
Classification of Snitch:
Simplesnitch:
This snitch is the default snitch and is most appropriate when there is no rack (rack) or data center. Because it doesn't recognize any rack or data center information.
Rackinferringsnitch:
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/database/extra/
This snitch the node location by analyzing the IP information of the node, assuming that the 2nd decimal point of the IP address 4 is the data center name, and the 3rd is the rack name. So if there are two nodes and the first 3 are the same, then the two nodes are on the same rack, and if the first 2 bits are the same, then the two nodes are in the same data center.
Propertyfilesnitch:
In this snitch, the location of the node is given through the user-configured Cassandra-topology.properties file. This method is the most flexible.
A template for this file is given in Cassandra and we need to configure this template if we want to enable this snitch:
Actual combat:
Let's look at the Snitch method in our environment, using the default Simplesnitch: