使用datastax java驱动程序在cassandra中读取异常时超时

时间:2014-08-21 06:08:53

标签: cassandra-2.0 cassandra-jdbc

我正在尝试向cassandra群集插入一行大小为500MB的单行,并且我已经低于错误。

com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: [/10.138.90.207:9042, /10.138.90.208:9042, /10.138.90.191:9042, /10.138.90.240:9042, /10.138.90.232:9042, /10.138.90.205:9042, /10.138.90.236:9042, /10.138.90.246:9042] - use getErrors() for details)
at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:65)
at com.datastax.driver.core.DefaultResultSetFuture.extractCauseFromExecutionException(DefaultResultSetFuture.java:256)
at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:172)
at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:52)
at com.tcs.asml.cassandra.Crud.Insert(Crud.java:44)
at com.tcs.asml.factory.PartToolInsert.main(PartToolInsert.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: [/10.138.90.207:9042, /10.138.90.208:9042, /10.138.90.191:9042, /10.138.90.240:9042, /10.138.90.232:9042, /10.138.90.205:9042, /10.138.90.236:9042, /10.138.90.246:9042] - use getErrors() for details)
at com.datastax.driver.core.RequestHandler.sendRequest(RequestHandler.java:103)
at com.datastax.driver.core.RequestHandler$1.run(RequestHandler.java:175)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

当我在异常中打印获取错误时,它会在集群中所有节点的读取错误期间显示超时。

Get errors: 
{/10.138.90.207:9042=com.datastax.driver.core.exceptions.DriverException: Timeout during read, /10.138.90.191:9042=com.datastax.driver.core.exceptions.DriverException: Timeout during read, /10.138.90.208:9042=com.datastax.driver.core.exceptions.DriverException: Timeout during read, /10.138.90.240:9042=com.datastax.driver.core.exceptions.DriverException: Timeout during read, /10.138.90.232:9042=com.datastax.driver.core.exceptions.DriverException: Timeout during read, /10.138.90.205:9042=com.datastax.driver.core.exceptions.DriverException: Timeout during read, /10.138.90.236:9042=com.datastax.driver.core.exceptions.DriverException: Timeout during read, /10.138.90.246:9042=com.datastax.driver.core.exceptions.DriverException: Timeout during read}

群集详细信息:

  • 一个数据中心,每个数据中心有8个节点,每个节点为16GB RAM
  • 每个节点都有单个硬盘。
  • 所有节点都以10mbps带宽连接,默认延迟。

我尝试使用以下命令增加读取时间。

cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(60000);

以下是使用yaml配置。

  • 记忆总空间:4Gb
  • 提交日志段大小:512MB
  • read_request_timeout_in_ms(ms):10000
  • request_timeout_in_ms(ms):10000
  • 并发读取:32
  • 并发写道:32

当我尝试插入250mb行并将读取时间设置为30秒时,我遇到了同样的问题。

cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(30000);

但是对于500MB的行大小,它无法正常工作。

任何人都可以请给我一些想法如何调整cassandra以插入包含大量数据的单行。

感谢。

1 个答案:

答案 0 :(得分:0)

问题:为什么需要在cassandra中连续存储500MB或200MB的数据? cassandra分区大小的最佳位置是100MB,也许是几百。 Cassandra是一个快速存储和快速查询的数据存储。 500MB的数据也不会给你。那么为什么要使用cassandra?