了解从Cassandra中的单个分区读取 [英] Understanding read from a single partition in Cassandra

查看:83
本文介绍了了解从Cassandra中的单个分区读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个三节点设置,Node1(172.30.56.60),Node2(172.30.56.61)和Node3(172.30.56.62),
它具有单个分区数据100K,该分区由nodeip构成

请找到节点IP的令牌/分区值-172.30.56.60

I have a 3 node setup, Node1 (172.30.56.60), Node2 (172.30.56.61) and Node3 (172.30.56.62), It has the single partition data of 100K, the partition is framed by nodeip.
Please find the token / partition value for the nodeip - 172.30.56.60

cqlsh:qnapstat> SELECT token(nodeip) FROM nodedata WHERE nodeip = '172.30.56.60' LIMIT 5; 

 system.token(nodeip)
----------------------
   222567180698744628
   222567180698744628
   222567180698744628
   222567180698744628
   222567180698744628

根据./nodetool在下面提供的环值中, 172.30.56.60只会将数据返回给协调器,因为从173960939250606057到239923324758894350的值是通过节点172.30.56.60处理的。 注意:这是我的理解

As per the ./nodetool ring value provided below, '172.30.56.60' only will return the data to the coordinator since the value from 173960939250606057 to 239923324758894350 is handled bu the node 172.30.56.60. Note : This is my understanding

172.30.56.60  rack1       Up     Normal  32.72 MiB       100.00%             173960939250606057                          
172.30.56.62  rack1       Up     Normal  32.88 MiB       100.00%             239923324758894351                          
172.30.56.61  rack1       Up     Normal  32.84 MiB       100.00%             253117576269706963                          
172.30.56.60  rack1       Up     Normal  32.72 MiB       100.00%             273249439554531014                          
172.30.56.61  rack1       Up     Normal  32.84 MiB       100.00%             295635292275517104                          
172.30.56.62  rack1       Up     Normal  32.88 MiB       100.00%             301162927966816823                          

我在这里有两个问题,

1)当我尝试执行以下查询时,是否表示协调器(例如172.30。 56.61)从172.30.56.60中读取所有数据?

1) When I try to execute the following query, Does it mean that Coordinator (say 172.30.56.61) reads all the data from the 172.30.56.60?

2)是在接收到协调器中的所有100K条目之后,协调器将执行100K的聚合,如果这样,它将所有100K条目保留在172.30中的内存中.56.61?

2) Is that after receiving all the 100 K entries in the coordinator, Coordinator will perform the aggregation for 100K, If so does it keeps all 100K entries in memory in 172.30.56.61?

SELECT Max(readiops) FROM nodedata WHERE nodeip = '172.30.56.60';


推荐答案

有一个不错的工具,叫做 CQL TRACING ,可以帮助您了解并查看执行SELECT查询后的事件流。

There is nice tool called CQL TRACING that can help you understand and see the flow of events once a SELECT query is executed.

cqlsh> INSERT INTO test.nodedata (nodeip, readiops) VALUES (1, 10);
cqlsh> INSERT INTO test.nodedata (nodeip, readiops) VALUES (1, 20);
cqlsh> INSERT INTO test.nodedata (nodeip, readiops) VALUES (1, 30);
cqlsh> select * from test.nodedata ;

 nodeip | readiops   
--------+-----------
      1 |        10 
      1 |        20 
      1 |        30 

(3 rows)
cqlsh> SELECT MAX(readiops) FROM test.nodedata WHERE nodeip = 1;

 system.max(readiops)
-----------------------
                   30

(1 rows)

现在让我们设置 cqlsh>跟踪并再次运行相同的查询。

Now let's set cqlsh> TRACING ON and run the same query again.

cqlsh> TRACING ON
Now Tracing is enabled
cqlsh> SELECT MAX(readiops) FROM test.nodedata WHERE nodeip = 1;

 system.max(readiops)
----------------------
                   30

(1 rows)

Tracing session: 4d7bf970-eada-11e7-a79d-000000000003


 activity                                                                                                                                                        | timestamp                  | source       | source_elapsed
-----------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------+--------------+----------------
                                                                                                                                              Execute CQL3 query | 2017-12-27 07:48:44.404000 | 172.16.0.128 |              0
                                                                                                        read_data: message received from /172.16.0.128 [shard 4] | 2017-12-27 07:48:44.385109 |  172.16.0.48 |              9
                                                                                       read_data handling is done, sending a response to /172.16.0.128 [shard 4] | 2017-12-27 07:48:44.385322 |  172.16.0.48 |            222
                                                                                                                                   Parsing a statement [shard 1] | 2017-12-27 07:48:44.404821 | 172.16.0.128 |             --
                                                                                                                                Processing a statement [shard 1] | 2017-12-27 07:48:44.404913 | 172.16.0.128 |             93
 Creating read executor for token 6292367497774912474 with all: {172.16.0.128, 172.16.0.48, 172.16.0.115} targets: {172.16.0.48} repair decision: NONE [shard 1] | 2017-12-27 07:48:44.404966 | 172.16.0.128 |            146
                                                                                                          read_data: sending a message to /172.16.0.48 [shard 1] | 2017-12-27 07:48:44.404972 | 172.16.0.128 |            152
                                                                                                             read_data: got response from /172.16.0.48 [shard 1] | 2017-12-27 07:48:44.405497 | 172.16.0.128 |            676
                                                                                                                  Done processing - preparing a result [shard 1] | 2017-12-27 07:48:44.405535 | 172.16.0.128 |            715
                                                                                                                                                Request complete | 2017-12-27 07:48:44.404722 | 172.16.0.128 |            722

对于您的问题:


  1. 如果 RF = 1 或( RF> 1 CL = ONE ),则它将收到来自1个副本的答复,但如果( RF> 1 CL> 1 ),则它需要从多个副本中接收答复并比较答案,因此协调器方面也需要进行协调。
    实际完成的方式是向最快的副本发送数据请求(使用snitch),向满足CL的其他副本请求摘要请求。
    然后协调器需要对数据的响应进行哈希处理,然后摘要请求并进行比较。
    如果将分区散列到特定节点中,则它将驻留在该节点中(假设RF = 1),并且信息将仅从该节点读取。

  1. The Coordinator passes the query to the replica, if RF = 1 or (RF > 1 and CL=ONE), than it will receive the reply from 1 replica, but if (RF > 1 and CL > 1), than it needs to receive replies from multiple replicas and compare the answers, so there's also orchestration done on the Coordinator side. The way it is actually done is a data request to the fastest replica (using the snitch) and a digest request to the other replicas needed to satisfy the CL. And then the coordinator need to hash the responses from the data and digest requests and compare them. If the partition is hashed into a specific node, it will reside in that node (assuming RF=1) and information will be read only from that node.

客户端随查询一起发送页面大小,因此答复本身将成批返回(默认值= 5000),可以从客户端进行设置。

The Client sends with the query the page size, so the reply itself is returned in bulks (default=5000), which can be set from the client side.

我建议观看此 Cassandra上的youtube 片段阅读路径以获取更多详细信息。

I recommend watching this youtube clip on Cassandra read path for more details.

这篇关于了解从Cassandra中的单个分区读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆