簡體   English   中英

/127.0.0.1連接上的錯誤(com.datastax.driver.core.TransportException:[/127.0.0.1]觸發了意外的異常),沒有其他主機可以嘗試

[英]error on /127.0.0.1 connection (com.datastax.driver.core.TransportException: [/127.0.0.1] Unexpected exception triggered), no more host to try

我正在Windows環境下嘗試將Cassandra與Java連接。 以下是application / OS / lib版本。

-Windows 7
-Java 7
-Cassandra 2.1.12

碼:

Cluster clst;
Session ses;
clst= Cluster.builder().addContactPoint("127.0.0.1").withPort(9042).build();

Cassandra和nodetool正在運行。 以下是nodetool的狀態。

C:\Program Files\DataStax Community\apache-cassandra\bin>nodetool -h localhost status
Starting NodeTool
Datacenter: datacenter1
========================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens  Owns    Host ID                               Rack
UN  127.0.0.1  245.99 KB  256     ?       61c6b0e5-2f83-4bc9-9b86-6507e2f06dfc  rack1

Note: Non-system keyspaces don't have the same replication settings, effective ownership information is meaningless
C:\Program Files\DataStax Community\apache-cassandra\bin>

當我嘗試將cassandra與localhost / 127.0.01連接時,出現堆棧跟蹤錯誤。

19:19:05.996 [main] DEBUG c.d.driver.core.ControlConnection - [Control connection] Refreshing node list and token map
19:19:06.465 [main] DEBUG c.d.driver.core.ControlConnection - [Control connection] error on /127.0.0.1 connection (com.datastax.driver.core.TransportException: [/127.0.0.1] Unexpected exception triggered), no more host to try
19:19:06.469 [main] DEBUG com.datastax.driver.core.Cluster - Shutting down
Exception in thread "main" com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: [/127.0.0.1])
    at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:162)
    at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:83)
    at com.datastax.driver.core.Cluster$Manager.<init>(Cluster.java:516)
    at com.datastax.driver.core.Cluster$Manager.<init>(Cluster.java:473)
    at com.datastax.driver.core.Cluster.<init>(Cluster.java:65)
    at com.datastax.driver.core.Cluster.buildFrom(Cluster.java:93)
    at com.datastax.driver.core.Cluster$Builder.build(Cluster.java:458)
    at cass.Cass.main(Cass.java:16)
Java Result: 1

我也嘗試在其他站點上的stackoverflow上找到解決方案,但未能解決我的問題。

有人對此查詢有解決方案嗎?

請檢查您的rpc_address。 我建議放置rpc_address = 0.0.0.0和broadcast_rpc_address =監聽地址可以為空或機器IP

從您的堆棧跟蹤中,我懷疑您使用的Java驅動程序的版本非常舊,可能是1.x系列(1.0.1?)的某個版本。 嘗試使用最新的3.0.0版本,然后查看錯誤是否仍然存在。

我發現了問題,我正在使用大量第三方庫從一個項目中運行代碼,而其中一個正在引起錯誤(我尚不知道哪個)。 我替換了整個jar文件,問題解決了。 轉到以下URL,並根據使用的cassandra版本下載Java驅動程序jar文件。 http://docs.datastax.com/en/developer/driver-matrix/doc/javaDrivers.html#java-drivers

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM