【问题标题】:Setting up Akka cluster for Lagom application in production mode在生产模式下为 Lagom 应用程序设置 Akka 集群
【发布时间】:2019-11-04 22:58:26
【问题描述】:

我正在尝试在 Akka 集群中以生产模式运行 Lagom 服务,该集群是通过 Akka Cluster Bootstrap 配置的,如 https://www.lagomframework.com/documentation/1.5.x/scala/Cluster.html 中所述。 (我可以通过手动指定种子节点来运行该应用程序)。但是,我无法启动该服务。我有以下设置:

application.conf (only the cluster related configs)
akka.management.cluster.bootstrap {
  # example using kubernetes-api
  contact-point-discovery {
    discovery-method = akka.discovery
#    discovery-method = config
    service-name = "lagom-scala"
    required-contact-point-nr = 0
  }
}

一个应用程序加载器,在生产模式下加载AkkaDiscoveryComponents,如下所述(https://www.lagomframework.com/documentation/1.5.x/scala/AkkaDiscoveryIntegration.html):

class LagomscalaLoader extends LagomApplicationLoader {

  override def load(context: LagomApplicationContext): LagomApplication =
    new LagomscalaApplication(context) with AkkaDiscoveryComponents

  override def loadDevMode(context: LagomApplicationContext): LagomApplication =
    new LagomscalaApplication(context) with LagomDevModeComponents

  override def describeService = Some(readDescriptor[LagomscalaService])
}

required-contact-point-nr 设置为0 时,我得到以下日志:

2019-10-28T23:48:54.867Z [info] akka.management.cluster.bootstrap.internal.BootstrapCoordinator [sourceThread=application-akka.actor.default-dispatcher-26, akkaTimestamp=23:48:54.867UTC, akkaSource=akka.tcp://application@192.168.0.34:2552/system/bootstrapCoordinator, sourceActorSystem=application] - Looking up [Lookup(lagom-scala,None,Some(tcp))]
2019-10-28T23:48:54.886Z [info] akka.management.cluster.bootstrap.internal.BootstrapCoordinator [sourceThread=application-akka.actor.default-dispatcher-22, akkaTimestamp=23:48:54.886UTC, akkaSource=akka.tcp://application@192.168.0.34:2552/system/bootstrapCoordinator, sourceActorSystem=application] - Located service members based on: [Lookup(lagom-scala,None,Some(tcp))]: [], filtered to []
2019-10-28T23:48:55.957Z [info] akka.management.cluster.bootstrap.LowestAddressJoinDecider [sourceThread=application-akka.actor.default-dispatcher-16, akkaTimestamp=23:48:55.957UTC, akkaSource=LowestAddressJoinDecider(akka://application), sourceActorSystem=application] - Exceeded stable margins without locating seed-nodes, however this node 192.168.0.34:8558 is NOT the lowest address out of the discovered endpoints in this deployment, thus NOT joining self. Expecting node [] (out of []) to perform the self-join and initiate the cluster.

当我将required-contact-point-nr 设置为2(默认)时,我得到以下日志:

2019-10-29T00:15:57.846Z [info] akka.management.cluster.bootstrap.internal.BootstrapCoordinator [sourceThread=application-akka.actor.default-dispatcher-23, akkaTimestamp=00:15:57.846UTC, akkaSource=akka.tcp://application@192.168.0.34:2552/system/bootstrapCoordinator, sourceActorSystem=application] - Looking up [Lookup(lagom-scala,None,Some(tcp))]
2019-10-29T00:15:57.865Z [info] akka.management.cluster.bootstrap.internal.BootstrapCoordinator [sourceThread=application-akka.actor.default-dispatcher-4, akkaTimestamp=00:15:57.865UTC, akkaSource=akka.tcp://application@192.168.0.34:2552/system/bootstrapCoordinator, sourceActorSystem=application] - Located service members based on: [Lookup(lagom-scala,None,Some(tcp))]: [], filtered to []
2019-10-29T00:15:58.299Z [info] akka.management.cluster.bootstrap.LowestAddressJoinDecider [sourceThread=application-akka.actor.default-dispatcher-3, akkaTimestamp=00:15:58.299UTC, akkaSource=LowestAddressJoinDecider(akka://application), sourceActorSystem=application] - Discovered [0] contact points, confirmed [0], which is less than the required [2], retrying
2019-10-29T00:15:58.599Z [warn] akka.cluster.sharding.ShardRegion [sourceThread=application-akka.actor.default-dispatcher-4, akkaTimestamp=00:15:58.597UTC, akkaSource=akka.tcp://application@192.168.0.34:2552/system/sharding/kafkaProducer-greetings, sourceActorSystem=application] - kafkaProducer-greetings: No coordinator found to register. Probably, no seed-nodes configured and manual cluster join not performed? Total [1] buffered messages.

我使用Akka 2.5.25 和默认配置,除了我上面指定的配置。例如。运行服务后,我看到以下可能相关的日志:

2019-10-29T00:15:44.987Z [info] akka.remote.Remoting [sourceThread=main, akkaTimestamp=00:15:44.987UTC, akkaSource=akka.remote.Remoting, sourceActorSystem=application] - Remoting now listens on addresses: [akka.tcp://application@192.168.0.34:2552]
2019-10-29T00:15:45.276Z [info] akka.cluster.Cluster(akka://application) [sourceThread=application-akka.actor.default-dispatcher-2, akkaSource=akka.cluster.Cluster(akka://application), sourceActorSystem=application, akkaTimestamp=00:15:45.275UTC] - Cluster Node [akka.tcp://application@192.168.0.34:2552] - No seed-nodes configured, manual cluster join required, see https://doc.akka.io/docs/akka/current/cluster-usage.html#joining-to-seed-nodes
2019-10-29T00:15:46.411Z [info] akka.management.cluster.bootstrap.ClusterBootstrap [sourceThread=main, akkaTimestamp=00:15:46.411UTC, akkaSource=ClusterBootstrap(akka://application), sourceActorSystem=application] - Using self contact point address: http://192.168.0.34:8558
2019-10-29T00:15:48.164Z [info] akka.management.scaladsl.AkkaManagement [sourceThread=application-akka.actor.default-dispatcher-24, akkaSource=AkkaManagement(akka://application), sourceActorSystem=application, akkaTimestamp=00:15:48.163UTC] - Bound Akka Management (HTTP) endpoint to: 192.168.0.34:8558
2019-10-29T00:15:48.286Z [info] akka.management.cluster.bootstrap.internal.BootstrapCoordinator [sourceThread=application-akka.actor.default-dispatcher-24, akkaSource=akka.tcp://application@192.168.0.34:2552/system/bootstrapCoordinator, sourceActorSystem=application, akkaTimestamp=00:15:48.285UTC] - Locating service members. Using discovery [akka.discovery.aggregate.AggregateServiceDiscovery], join decider [akka.management.cluster.bootstrap.LowestAddressJoinDecider]
2019-10-29T00:15:48.772Z [info] play.core.server.AkkaHttpServer [] - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

所以,我认为端口之间存在不匹配,但我不知道如何修复它。感谢您的帮助。

【问题讨论】:

  • 看起来很奇怪,因为没有发现任何加入节点,但 192.168.0.34:8558 最终证明不是最低地址。因此,您的 Akka Bootstrap 会遍历节点并尝试确定它们的任何接触点是否有任何种子节点。比它应该加入 self 并开始充当种子节点但它没有发生。在第二种情况下,它根本没有发现任何接触点。您能否提供有关如何启动应用程序的更多信息?
  • 也请分享您的akka.management.http.hostname
  • 我使用sbt dist 创建包并运行生成的脚本,例如:./lagom-scala-impl-1.0-SNAPSHOT/bin/lagom-scala-impl -Dplay.http.secret.key=changemeasdf。我使用akka.management.http.hostname 的默认值。我猜默认是localhost。为方便起见,我创建了一个项目结构的 zip 包,可在以下位置获得:dropbox.com/s/ngnx2h0b9jx7sik/lagom-scala.zip?dl=0。我真的很感谢你的帮助。谢谢
  • 我也尝试将lagom.akka.discovery.service-name-mappings 定义为service-name-mappings { lagom-scala { lookup = "lagom-scala" (or "_http._tcp.lagom-scala") scheme = http } },但这些也不起作用

标签: scala akka cluster-computing production lagom


【解决方案1】:

问题似乎是本地设置中缺少 DNS 服务器,并且 Lagom 本身不提供 DNS 服务器 正如@tim-moore 在Lightbend forum 所述。

【讨论】:

  • 您是否尝试将您的服务部署到 OpenShift / K8s?
  • 不,我没有。我试图通过简单地运行生成的 jar 来在本地部署它:./lagom-scala-impl-1.0-SNAPSHOT/bin/lagom-scala-impl -Dplay.http.secret.key=changemeasdf.
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-07-08
  • 1970-01-01
  • 1970-01-01
  • 2012-01-08
  • 2022-11-23
  • 2021-07-16
  • 1970-01-01
相关资源
最近更新 更多