【问题标题】:Lagom external Cassandra authenticationLagom 外部 Cassandra 身份验证
【发布时间】:2017-03-07 20:42:08
【问题描述】:

我一直在尝试为我的 Lagom 设置设置一个外部 Cassandra。

我在 root 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 提供凭据来使其工作?

【问题讨论】:

    标签: cassandra akka lagom


    【解决方案1】:

    在 Lagom 中,您可能已经为您的journalsnapshot-store 使用了akka-persistence-cassandra 设置(请参阅source code 中的reference.conf,并向下滚动查看cassandra-snapshot-store.authentication.*)。无需配置它,因为 Lagom 对 Cassandra 持久性的支持已经将 akka-persistence-cassandra 声明为 Akka Persistence 实现:

    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 连接到 Cassandra 时要配置的倒数第三位是 Lagom 的读取端。如果您覆盖the defaults,这也可以通过application.conf 实现。

    请注意每个存储可能如何使用不同的 Cassandra Ring/Keyspace/credentials/...,以便您可以单独调整它们。

    Lagom docs 中查看更多信息。

    【讨论】:

    • 感谢您的回复。我将我的 cassandra 版本更改为 3.0 并开始工作。但是我有几个疑问,首先我的项目是在 Maven 中。我无法从任何调试日志中了解它是否实际连接到 Cassandra。我正在运行的 Cassandra 服务器中也不存在我的密钥空间。当我运行一个 sbt 项目时,我看到创建了密钥空间以及一些调试日志。其次,cluster-id 是否总是必须是“cas_native”?
    猜你喜欢
    • 2015-10-09
    • 2010-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多