Cassandra 数据库未通过 Rcassandra 与 R 连接 [英] Cassandra Database is not connecting with R via Rcassandra
问题描述
当我使用 RCassandra 包连接到 Cassandra 数据库时,正在建立连接.但是当尝试使用任何键空间时,R 没有响应.我使用了以下语句.
When I'm connecting to Cassandra database using RCassandra package, connection is establishing. But When trying to use any keyspace, R is not responding.I used the following statements.
图书馆(RCassandra)
library(RCassandra)
rc <- RC.connect(host =localhost", port = 9042)
rc <- RC.connect(host ="localhost", port = 9042)
RC.use(rc, db1", cache.def = TRUE)
RC.use(rc, "db1", cache.def = TRUE)
任何建议请
推荐答案
你的问题是你直接指定了端口,而且你使用的是原生协议的端口,而 RCassandra 使用的是 thrift 协议(即使用端口9160),所以当它与端口 9042 交谈时,它根本不明白它在说什么.因此,您需要完全删除 port
参数,或将其指定为 9160
,并确保将 start_rpc
参数设置为 在
.cassandra.yaml
中为真
Your problem is that you're specifying the port directly, and you're using the port of the native protocol, while RCassandra uses thrift protocol (that uses port 9160), so when it's talking to port 9042, it simply don't understand what it says. So you need to either remove port
argument completely, or specify it as 9160
, and make sure that you have start_rpc
parameter set to true
in the cassandra.yaml
.
我查看了 RCassandra 的源代码,发现它已经超过 5 年没有更新了.由于它使用 Thrift 而不是本机协议,因此与使用本机协议相比,您有许多限制.并且在 Cassandra 的下一个主要版本 - 4.0 中将删除对 Thrift 的支持.更好的选择是围绕 DataStax C/C++ 驱动程序编写一个包装器,并将底层功能公开给 R.
I've looked into source code of the RCassandra, and see that it wasn't updated for more than 5 years. And as it uses Thrift instead of native protocol, then you have many limitations comparing to use of native protocol. And support for Thrift will be removed in the next major version of Cassandra - 4.0. The better alternative will be to write a wrapper around DataStax C/C++ driver, and expose underlying functionality to R.
这篇关于Cassandra 数据库未通过 Rcassandra 与 R 连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!