2017-03-07 92 views
0

我一直在試圖爲我的Lagom安裝設置外部Cassandra。Lagom外部Cassandra身份驗證

在根POM我已經寫

    <configuration> 
         <unmanagedServices> 
          <cas_native>http://ip:9042</cas_native> 
         </unmanagedServices> 
         <cassandraEnabled>false</cassandraEnabled> 
        </configuration> 

在我IMPL application.conf

akka { 
persistent { 
    journal { 
    akka.persistence.journal.plugin = "this-cassandra-journal" 

     this-cassandra-journal { 
     contact-points = ["10.15.2.179"] 
     port = 9042 
     cluster-id = "cas_native" 

     keyspace = "hello" 

     authentication.username = "cassandra" 
     authentication.password = "rodney" 
     # Parameter indicating whether the journal keyspace should be auto created 
     keyspace-autocreate = true 

     # Parameter indicating whether the journal tables should be auto created 
     tables-autocreate = true 
     } 
    } 

    snapshot-store { 
    akka.persistence.snapshot-store.plugin = "this-cassandra-snapshot-store" 

     this-cassandra-snapshot-store { 
     contact-points = ["10.15.2.179"] 
     port = 9042 
     cluster-id = "cas_native" 

     keyspace = "hello_snap" 
     authentication.username = "cassandra" 
     authentication.password = "rodney" 
     # Parameter indicating whether the journal keyspace should be auto created 
     keyspace-autocreate = true 

     # Parameter indicating whether the journal tables should be auto created 
     tables-autocreate = true 
     } 
    } 

} 

但我得到的錯誤

[warn] a.p.c.j.CassandraJournal - Failed to connect to Cassandra and initialize. 
It will be retried on demand. Caused by: Authentication error on host /10.15.2. 
179:9042: Host /10.15.2.179:9042 requires authentication, but no authenticator f 
ound in Cluster configuration 
[warn] a.p.c.s.CassandraSnapshotStore - Failed to connect to Cassandra and initi 
alize. It will be retried on demand. Caused by: Authentication error on host /10 
.15.2.179:9042: Host /10.15.2.179:9042 requires authentication, but no authentic 
ator found in Cluster configuration 
[warn] a.p.c.j.CassandraJournal - Failed to connect to Cassandra and initialize. 
It will be retried on demand. Caused by: Authentication error on host /10.15.2. 
179:9042: Host /10.15.2.179:9042 requires authentication, but no authenticator f 
ound in Cluster configuration 
[error] a.c.s.PersistentShardCoordinator - Persistence failure when replaying ev 
ents for persistenceId [/sharding/ProductCoordinator]. Last known sequence numbe 
r [0] 
com.datastax.driver.core.exceptions.AuthenticationException: Authentication erro 
r on host /10.15.2.179:9042: Host /10.15.2.179:9042 requires authentication, but 
no authenticator found in Cluster configuration 
     at com.datastax.driver.core.AuthProvider$1.newAuthenticator(AuthProvider 
.java:40) 
     at com.datastax.driver.core.Connection$5.apply(Connection.java:250) 
     at com.datastax.driver.core.Connection$5.apply(Connection.java:234) 
     at com.google.common.util.concurrent.Futures$AsyncChainingFuture.doTrans 
form(Futures.java:1442) 
     at com.google.common.util.concurrent.Futures$AsyncChainingFuture.doTrans 
form(Futures.java:1433) 
     at com.google.common.util.concurrent.Futures$AbstractChainingFuture.run(
Futures.java:1408) 
     at com.google.common.util.concurrent.Futures$2$1.run(Futures.java:1177) 
     at com.google.common.util.concurrent.MoreExecutors$DirectExecutorService 
.execute(MoreExecutors.java:310) 
     at com.google.common.util.concurrent.Futures$2.execute(Futures.java:1174 
) 

我也嘗試過提供這種配置

lagom.persistence.read-side { 
    cassandra { 
    } 
} 

如何通過提供Cassandra的憑據來使其工作?

回答

4

在Lagom,你可能已經在使用akka-persistence-cassandra設置你的journalsnapshot-store(在source code看到reference.conf,並向下滾動的cassandra-snapshot-store.authentication.*)。有沒有必要對它進行配置,因爲Lagom對Cassandra的持久性的支持已經宣佈akka-persistence-cassandra作爲阿卡持久化實現:

akka.persistence.journal.plugin = cassandra-journal akka.persistence.snapshot-store.plugin = cassandra-snapshot-store

https://github.com/lagom/lagom/blob/c63383c343b02bd0c267ff176bfb4e48c7202d7d/persistence-cassandra/core/src/main/resources/play/reference-overrides.conf#L5-L6

倒數第三位連接Lagom卡桑德拉時配置是Lagom的閱讀-側。如果您覆蓋the defaults,也可以通過application.conf進行操作。

注意如何每個存儲可分別使用不同的卡珊德拉環/ KEYSPACE /憑證/ ...所以你可以調整它們。

看到Lagom docs額外的信息。

+0

感謝您的回覆。我將我的cassandra版本更改爲3.0,並開始工作。不過,我沒有幾個疑問,首先我的項目是maven。我從任何調試日誌都不知道它是否實際連接到Cassandra。另外我的密鑰空間不在我正在運行的Cassandra服務器中。當我運行一個sbt項目時,我看到了密鑰空間被創建以及一些調試日誌。其次,cluster-id總是必須是「cas_native」? –