我是Cassandra和R的新手。当我使用RCassandra
包连接到Cassandra数据库时,连接已经建立。但是,当尝试使用任何keyspace时,R没有响应。我使用了以下语句。
c <- RC.connect('192.168.1.20', 9042)
RC.use(c, 'effesensors')
请简要介绍如何使用RCassandra
来避免这个问题。
我是Cassandra和R的新手。当我使用RCassandra
包连接到Cassandra数据库时,连接已经建立。但是,当尝试使用任何keyspace时,R没有响应。我使用了以下语句。
c <- RC.connect('192.168.1.20', 9042)
RC.use(c, 'effesensors')
请简要介绍如何使用RCassandra
来避免这个问题。
使用RODBC而不是RCassandra。我们需要安装Cassandra ODBC驱动程序。
谢谢@D. Venkata Naresh,您使用RODBC驱动程序的建议解决了我的问题。
我正在使用R和datastax cassandra社区版。
这是我遵循的链接,在我的Windows机器上配置ODBC驱动程序。
https://www.datastax.com/dev/blog/using-the-datastax-odbc-driver-for-apache-cassandra
接下来,在我的R Studio中,以下是连接和从Cassandra获取数据的命令:
install.packages("RODBC")
library("RODBC")
require("RODBC")
conn <- odbcConnect(<ODBC datasource name>)
dataframe <- sqlFetch(conn, <column family / table name>)
dataframe
connect.handle <- RC.connect(host="127.0.0.1", port=9160)
连接到您的数据库。
Cassandra 默认监听端口为 9160,但您可以根据您的配置进行更改。要将群集类型显示到提示符中,请使用 RC.cluster.name(connect.handle)
。RC.describe.keyspaces(connect.handle)
。$system_traces$strategy_options
replication_factor
"2"
$system_traces$cf_defs
named list()
$system_traces$durable_writes
[1] TRUE
如果我的答案没有起作用,请告诉我你的结果,我会更新我的答案。祝你好运!
我看到了你上面的评论,你使用了错误的端口。你应该运行以下命令: c <- RC.connect('192.168.1.20', 9160) 这一定会对你有用。