简体   繁体   English

Lagom外部Cassandra身份验证

[英]Lagom external Cassandra authentication

I have been trying to set up an external Cassandra for my Lagom setup. 我一直在尝试为我的Lagom设置设置外部Cassandra。

In root pom I have written 在root pom中,我写了

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

In my impl application.conf 在我的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
      }
    }

}

But I get the error 但是我得到了错误

[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
)

I also tried providing this config 我也尝试提供此配置

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

How to make it work by providing credentials for Cassandra? 如何通过为Cassandra提供凭据来使其工作?

In Lagom, you may already use akka-persistence-cassandra settings for your journal and snapshot-store (see reference.conf in the source code , and scroll down for cassandra-snapshot-store.authentication.* ). 在Lagom中,您可能已经将akka-persistence-cassandra设置用于journalsnapshot-store (请参阅源代码中的 reference.conf,并向下滚动至cassandra-snapshot-store.authentication.* )。 There's no need to configure it because Lagom's support for Cassandra persistence already declares akka-persistence-cassandra as the Akka Persistence implementation: 无需进行配置,因为Lagom对Cassandra持久性的支持已经将akka-persistence-cassandra声明为Akka Persistence实现:

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

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

The third last bit to configure when connecting Lagom to Cassandra is Lagom's Read-Side. 将Lagom连接到Cassandra时要配置的倒数第三位是Lagom的Read-Side。 That is also doable via application.conf if you override the defaults . 如果您覆盖默认值,那么也可以通过application.conf

Note how each storage may use a different Cassandra Ring/Keyspace/credentials/... so you can tune them separately. 请注意,每个存储如何使用不同的Cassandra Ring / Keyspace / credentials / ...,以便分别进行调整。

See extra info in the Lagom docs . Lagom文档中查看更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM