2017-04-02 49 views
0

我是一个新手,带着阿卡。 拥有一个种子节点和一个非种子节点的非常简单的配置。Akka不会选择现有的工作节点作为种子节点,一旦种子节点被杀死

请在下面找到,操作的顺序: -

  1. 种子节点开始: -
val pConfig = ConfigFactory.load("application.conf").getConfig("PrimaryNode") 

val demoSystem = ActorSystem("DemoSystem", pConfig) 

[INFO] [04/01/2017 23:42:48.438] [run-main-0] [akka.remote.Remoting] Starting remoting                                       
[INFO] [04/01/2017 23:42:48.673] [run-main-0] [akka.remote.Remoting] Remoting started; listening on addresses :[akka.tcp://[email protected]:2551]                       
[INFO] [04/01/2017 23:42:48.688] [run-main-0] [akka.cluster.Cluster(akka://DemoSystem)] Cluster Node [akka.tcp://[email protected]:2551] - Starting up...                      
[INFO] [04/01/2017 23:42:48.759] [run-main-0] [akka.cluster.Cluster(akka://DemoSystem)] Cluster Node [akka.tcp://[email protected]:2551] - Registered cluster JMX MBean [akka:type=Cluster]             
[INFO] [04/01/2017 23:42:48.759] [run-main-0] [akka.cluster.Cluster(akka://DemoSystem)] Cluster Node [akka.tcp://[email protected]:2551] - Started up successfully                   
[INFO] [04/01/2017 23:42:48.776] [DemoSystem-akka.actor.default-dispatcher-3] [akka.cluster.Cluster(akka://DemoSystem)] Cluster Node [akka.tcp://[email protected]:2551] - Metrics will be retreived from MBeans, and may be incorrect on som 
e platforms. To increase metric accuracy add the 'sigar.jar' to the classpath and the appropriate platform-specific native libary to 'java.library.path'. Reason: java.lang.ClassNotFoundException: org.hyperic.sigar.Sigar      
[INFO] [04/01/2017 23:42:48.779] [DemoSystem-akka.actor.default-dispatcher-3] [akka.cluster.Cluster(akka://DemoSystem)] Cluster Node [akka.tcp://[email protected]:2551] - Metrics collection has started successfully      
p: akka.actor.ActorSystem = akka://DemoSystem                                                 

[INFO] [04/01/2017 23:42:48.795] [DemoSystem-akka.actor.default-dispatcher-2] [akka.cluster.Cluster(akka://DemoSystem)] Cluster Node [akka.tcp://[email protected]:2551] - Node [akka.tcp://[email protected]:2551] is JOINING, rol 
es []                                                           
[INFO] [04/01/2017 23:42:48.805] [DemoSystem-akka.actor.default-dispatcher-2] [akka.cluster.Cluster(akka://DemoSystem)] Cluster Node [akka.tcp://[email protected]:2551] - Leader is moving node [akka.tcp://[email protected]:2551] to [U 
p]                                                                                                                       

  • 非种子节点开始: -
  • val sConfig = ConfigFactory.load("application.conf").getConfig("SecondaryNode") 
    val secSystem = ActorSystem("DemoSystem", sConfig) 
    

    [INFO] [04/01/2017 23:44:15.530] [run-main-0] [akka.remote.Remoting] Starting remoting 
    [INFO] [04/01/2017 23:44:15.845] [run-main-0] [akka.remote.Remoting] Remoting started; listening on addresses :[akka.tcp://[email protected]:49169] 
    [INFO] [04/01/2017 23:44:15.847] [run-main-0] [akka.remote.Remoting] Remoting now listens on addresses: [akka.tcp://[email protected]:49169] 
    [INFO] [04/01/2017 23:44:15.854] [run-main-0] [akka.cluster.Cluster(akka://DemoSystem)] Cluster Node [akka.tcp://[email protected]:49169] - Starting up... 
    [INFO] [04/01/2017 23:44:15.929] [run-main-0] [akka.cluster.Cluster(akka://DemoSystem)] Cluster Node [akka.tcp://[email protected]:49169] - Registered cluster JMX MBean [akka:type=Cluster] 
    [INFO] [04/01/2017 23:44:15.929] [run-main-0] [akka.cluster.Cluster(akka://DemoSystem)] Cluster Node [akka.tcp://[email protected]:49169] - Started up successfully 
    [INFO] [04/01/2017 23:44:15.945] [DemoSystem-akka.actor.default-dispatcher-3] [akka.cluster.Cluster(akka://DemoSystem)] Cluster Node [akka.tcp://[email protected]:49169] - Metrics will be retreived from MBeans, and may be incorrect on some platforms. To increase metric accuracy add the 'sigar.jar' to the classpath and the appropriate platform-specific native libary to 'java.library.path'. Reason: java.lang.ClassNotFoundException: org.hyperic.sigar.Sigar 
    [INFO] [04/01/2017 23:44:15.951] [DemoSystem-akka.actor.default-dispatcher-3] [akka.cluster.Cluster(akka://DemoSystem)] Cluster Node [akka.tcp://[email protected]:49169] - Metrics collection has started successfully 
    s: akka.actor.ActorSystem = akka://DemoSystem 
    
    [INFO] [04/01/2017 23:44:16.265] [DemoSystem-akka.actor.default-dispatcher-14] [akka.cluster.Cluster(akka://DemoSystem)] Cluster Node [akka.tcp://[email protected]:49169] - Welcome from [akka.tcp://[email protected]:2551] 
    

    和种子节点移动非种子节点最多(种子节点日志启动后 非种子节点): -

    [INFO] [04/01/2017 23:44:16.190] [DemoSystem-akka.actor.default-dispatcher-14] [akka.cluster.Cluster(akka://DemoSystem)] Cluster Node [akka.tcp://[email protected]:2551] - Node [akka.tcp://[email protected]:49169] is JOINING, roles [] 
    
    [INFO] [04/01/2017 23:44:16.782] [DemoSystem-akka.actor.default-dispatcher-25] [akka.cluster.Cluster(akka://DemoSystem)] Cluster Node [akka.tcp://[email protected]:2551] - Leader is moving node [akka.tcp://[email protected]:49169] to [Up] 
    

  • 查阅种子节点被杀死(非种子节点上的日志称,该种子节点quaretined): -
  • ............ 
    ............ 
    
    [WARN] [04/01/2017 23:46:14.301] [DemoSystem-akka.remote.default-remote-dispatcher-6] [akka.tcp://[email protected]:49169/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FDemoSystem%40127.0.0.1%3A2551-2] Association with remote system [akka.tcp://[email protected]:2551] has failed, address is now gated for [5000] ms. Reason: [Association failed with [akka.tcp://[email protected]:2551]] Caused by: [Connection refused: no further information: /127.0.0.1:2551] 
    [INFO] [04/01/2017 23:46:14.959] [DemoSystem-akka.actor.default-dispatcher-21] [akka.cluster.Cluster(akka://DemoSystem)] Cluster Node [akka.tcp://[email protected]:49169] - Leader is auto-downing unreachable node [akka.tcp://[email protected]:2551] 
    [INFO] [04/01/2017 23:46:14.960] [DemoSystem-akka.actor.default-dispatcher-20] [akka.cluster.Cluster(akka://DemoSystem)] Cluster Node [akka.tcp://[email protected]:49169] - Marking unreachable node [akka.tcp://[email protected]:2551] as [Down] 
    [INFO] [04/01/2017 23:46:15.953] [DemoSystem-akka.actor.default-dispatcher-21] [akka.cluster.Cluster(akka://DemoSystem)] Cluster Node [akka.tcp://[email protected]:49169] - Leader is removing unreachable node [akka.tcp://[email protected]:2551] 
    [WARN] [04/01/2017 23:46:15.953] [DemoSystem-akka.remote.default-remote-dispatcher-5] [akka.remote.Remoting] Association to [akka.tcp://[email protected]:2551] having UID [-273153546] is irrecoverably failed. UID is now quarantined and all messages to this UID will be delivered to dead letters. Remote actorsystem must be restarted to recover from this situation. 
    

    现在,当我在非种子节点控制台上检查以下内容时: -

    1. 哪个节点是领导者

    组长船舶成功地转移到非种子节点

    scala> val cluster = Cluster(secSystem) 
    
    scala> cluster.state 
    res1: akka.cluster.ClusterEvent.CurrentClusterState = CurrentClusterState(TreeSet(Member(address = akka.tcp://[email protected]:49169, status = Up)),Set(),Set(akka.tcp://[email protected]:49169),Some(akka.tcp://[email protected]:49169),Map()) 
    
    scala> cluster.state.leader 
    res2: Option[akka.actor.Address] = Some(akka.tcp://[email protected]:49169) 
    
  • 哪个节点是种子节点: -
  • 种子节点仍然指向死节点

    scala> cluster.settings.SeedNodes 
    res0: scala.collection.immutable.IndexedSeq[akka.actor.Address] = Vector(akka.tcp://[email protected]:2551) 
    

    我在想,那非种子节点将被选举为新的种子节点,但事实并非如此。

    另外,请在下面找到两个节点的配置: -

    PrimaryNode { 
        akka { 
        actor { 
         provider = "akka.cluster.ClusterActorRefProvider" 
        } 
        remote { 
         log-remote-lifecycle-events = off 
         enabled-transports = ["akka.remote.netty.tcp"] 
         netty.tcp { 
         hostname = "127.0.0.1" 
         port = 2551 
         } 
        } 
        cluster { 
         seed-nodes = ["akka.tcp://[email protected]:2551"] 
         auto-down-unreachable-after = 10s 
        } 
        } 
    } 
    
    SecondaryNode { 
        akka { 
        actor { 
         provider = "akka.cluster.ClusterActorRefProvider" 
        } 
        remote { 
         enabled-transports = ["akka.remote.netty.tcp"] 
         netty.tcp { 
         hostname = "127.0.0.1" 
         port = 49169 
         } 
        } 
        cluster { 
         seed-nodes = ["akka.tcp://[email protected]:2551"] 
         auto-down-unreachable-after = 10s 
        } 
        } 
    } 
    

    请赐教。为什么一旦前一个种子节点被杀死,非种子节点就不会被选为新的种子节点。

    +0

    哪里了'cluster.state'和'cluster.state.leader'从何而来?你能否提供更多的背景以确保结果不会过时... –

    +0

    @FredericA。 :更新了问题以包含cluster和cluster.state.leader – mogli

    回答

    1

    对不起,我现在很少有时间,我会尽我所能在几个字。

    没有种子节点选举这样的事情。

    一旦akka集群启动,每个集群成员都可以充当加入节点的种子节点,即可以被任何加入节点用作初始接触点。而这种情况在没有配置的情况下发生,因为所有群集节点都在监听传入连接。

    在群集启动之前,(第一个)种子节点非常重要,因为它是启动群集时可用的初始节点的一部分。没有该节点,群集将无法启动。但是一旦启动(如上所述),该种子节点可以消失,一切都会好起来。

    这很可能是为什么cluster.settings.SeedNodes的值未更改或未更新。它在初始群集设置后没有影响。

    引用: