📜 ⬆️ ⬇️

How to create a cluster in JBoss AS 7.1 in standalone mode?

The article is translated and published here in order to supplement it with a recipe from myself, obtained on the basis of personal experience. There is a hope that someone will save half a day-day of googling and a lot of trial and error that I had to face. This is followed by a free translation and addition from me personally. The main problem to be solved: replication of user sessions to all nodes of the cluster. Due to the replication of sessions, in case of loss of one of the cluster nodes, the balancer can transparently switch the user to another node. The work of the balancer is beyond the scope of this translation and will be described in the next article.

JBoss AS 7 is completely different from previous versions of JBoss, therefore, if you want to create a cluster in JBoss AS 7, you need to know a few things so as not to run into problems.

There are two modes in JBoss AS 7: domain mode ( domain ) and standalone ( standalone ) mode, in this article we will talk about offline mode. In offline mode, there are various XML files in the configuration folder, but clustering support is only included in standalone-ha.xml and standalone-full-ha.xml , so make sure you use one of them when starting (see the start command below) .

Steps for creating a cluster in JBoss AS 7.1

')
After you unpacked JBoss-like-7.1.1.Final.zip (from translator: tested in version 7.2.2), make two copies of the standalone folder and rename them, for example, standalone-node1 and standalone-node2 , as shown below:
1 Home / user / jboss-as-7.1.1.Final / standalone-node1
2 Home / user / jboss-as-7.1.1.Final / standalone-node2
Note : Make sure you keep the original copy of the standalone folder for possible future use.

Now you have to start JBoss with the following command so that it works as a node in the cluster
Node1
./standalone.sh -c standalone-ha.xml -b 10.10.10.10 -u 230.0.0.4 -Djboss.server.base.dir = .. / standalone-node1 -Djboss.node.name = node1 -Djboss.socket. binding.port-offset = 100

Node2
./standalone.sh -c standalone-ha.xml -b 10.10.10.10 -u 230.0.0.4 -Djboss.server.base.dir = .. / standalone-node2 -Djboss.node.name = node2 -Djboss.socket. binding.port-offset = 200

Where:
-c = server configuration file to be used
-b = is used to specify the address that JBoss listens on
-u = multicast address. (from translator: it is assumed that it will be used when merging nodes into a cluster, but there may be problems with this, see below)
-Djboss.server.base.dir = path to the folder in which the node is expanded
-Djboss.node.name = node name
-Djboss.socket.binding.port-offset = port offset

Note : Pay attention to the following things:
- Both nodes must have the same broadcast address.
- Both nodes must have different node names.
- In the case of running on the same computer, both nodes must have different different displacement by ports, in order to avoid conflicts. For one of the nodes, the -Djboss.socket.binding.port-offset parameter can be omitted, it will run on the default ports. Also, this parameter can not be used in the case of running on different computers.

After starting the nodes in the cluster configuration, you will not see any changes. To make sure that both nodes are clustered, you will need to deploy a web application that has a <distributable /> tag in web.xml. You can download one of our examples of the cluster application here .

After downloading ClusterWebApp.war, you just have to copy it to (/home/user/jboss-as-7.1.1.Final/standalone-nodeX/deployments) on both nodes, and immediately after that you will see the following messages:
JBoss log
18:32:46,863 INFO [stdout] (pool-13-thread-1) ------------------------------------------------------------------- 18:32:46,863 INFO [stdout] (pool-13-thread-1) GMS: address=node1/web, cluster=web, physical address=10.10.10.10:55300 18:32:46,863 INFO [stdout] (pool-13-thread-1) ------------------------------------------------------------------- 18:32:47,572 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (MSC service thread 1-8) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be pasivated. 18:32:47,581 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (MSC service thread 1-1) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be pasivated. 18:32:47,771 INFO [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (pool-15-thread-1) ISPN000078: Starting JGroups Channel 18:32:47,791 INFO [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (pool-15-thread-1) ISPN000094: Received new cluster view: [node1/web|1] [node1/web, node2/web] 


From translator

If you duplicate the entire JBoss folder, and not just standalone, then you can omit the -Djboss.server.base.dir parameter.

Multiple IP Addresses

In this article, and in most of the resources on the Web, one problem is not solved. Many (including me) at startup specify the -b 0.0.0.0 parameter, which tells JBoss that you should listen on all available network interfaces. This is required if your server, for example, has external and internal IP addresses, or it is required that it be available also by default addresses (for example, localhost). So, the problem is that the jgroups used by JBoss to merge the cluster refuses to work if the -b parameter is 0.0.0.0. When the nodes start, a message is displayed:
 GMS: address=node1/web, cluster=web, physical address=0.0.0.0:55200 

and when trying to merge them, an error appears:
 [org.jgroups.protocols.UDP] (OOB-14,shared=udp) failed sending message to node2/web (117 bytes): java.lang.Exception: dest=/0.0.0.0:55500 (120 bytes), cause: java.net.BindException: Cannot assign requested address: Datagram send failed 

As I understand it, jgroups requires a specific IP address, and refuses to work with abstract 0.0.0.0, and the launch option -u 230.0.0.4 is simply ignored in this case.

Judging by the messages on the forums, there are no other possibilities to force JBoss to listen to several addresses, except for how to specify the start option -b 0.0.0.0. You can specify the <any-address/> tag in the standalone-ha.xml / standalone-full-ha.xml configuration file for <inet-address value="${jboss.bind.address:127.0.0.1}"/> , , -b 0.0.0.0, .. .

: -Djgroups.bind_addr=IP- , jgroups . , -b 0.0.0.0, jgroups, . Windows :
GMS: address=node1/web, cluster=web, physical address=127.0.0.1:55200
, -b 0.0.0.0 -Djgroups.bind_addr=127.0.0.1.


: JBoss / JBoss 7, distributable-, "" . . 7- , , UDP ( -u). , , UDP- , , . UPD , , JBoss .

UPD jgroups 230.0.0.4, -u. ? , " IP Multicast 224.0.0.0 239.255.255.255 ". , , , , 230.0.0. 5 , , Windows, . - 230.0.0. 3 23 1 .0.0.4 - . , , , , , , " ".

.
<inet-address value="${jboss.bind.address:127.0.0.1}"/> , , -b 0.0.0.0, .. .

: -Djgroups.bind_addr=IP- , jgroups . , -b 0.0.0.0, jgroups, . Windows :
GMS: address=node1/web, cluster=web, physical address=127.0.0.1:55200
, -b 0.0.0.0 -Djgroups.bind_addr=127.0.0.1.


: JBoss / JBoss 7, distributable-, "" . . 7- , , UDP ( -u). , , UDP- , , . UPD , , JBoss .

UPD jgroups 230.0.0.4, -u. ? , " IP Multicast 224.0.0.0 239.255.255.255 ". , , , , 230.0.0. 5 , , Windows, . - 230.0.0. 3 23 1 .0.0.4 - . , , , , , , " ".

.
  <inet-address value="${jboss.bind.address:127.0.0.1}"/> , ,       -b 0.0.0.0, ..   . 

: -Djgroups.bind_addr=IP- , jgroups . , -b 0.0.0.0, jgroups, . Windows :
GMS: address=node1/web, cluster=web, physical address=127.0.0.1:55200
, -b 0.0.0.0 -Djgroups.bind_addr=127.0.0.1.


: JBoss / JBoss 7, distributable-, "" . . 7- , , UDP ( -u). , , UDP- , , . UPD , , JBoss .

UPD jgroups 230.0.0.4, -u. ? , " IP Multicast 224.0.0.0 239.255.255.255 ". , , , , 230.0.0. 5 , , Windows, . - 230.0.0. 3 23 1 .0.0.4 - . , , , , , , " ".

.
<inet-address value="${jboss.bind.address:127.0.0.1}"/> , , -b 0.0.0.0, .. .

: -Djgroups.bind_addr=IP- , jgroups . , -b 0.0.0.0, jgroups, . Windows :
GMS: address=node1/web, cluster=web, physical address=127.0.0.1:55200
, -b 0.0.0.0 -Djgroups.bind_addr=127.0.0.1.


: JBoss / JBoss 7, distributable-, "" . . 7- , , UDP ( -u). , , UDP- , , . UPD , , JBoss .

UPD jgroups 230.0.0.4, -u. ? , " IP Multicast 224.0.0.0 239.255.255.255 ". , , , , 230.0.0. 5 , , Windows, . - 230.0.0. 3 23 1 .0.0.4 - . , , , , , , " ".

.
<inet-address value="${jboss.bind.address:127.0.0.1}"/> , , -b 0.0.0.0, .. .

: -Djgroups.bind_addr=IP- , jgroups . , -b 0.0.0.0, jgroups, . Windows :
GMS: address=node1/web, cluster=web, physical address=127.0.0.1:55200
, -b 0.0.0.0 -Djgroups.bind_addr=127.0.0.1.


: JBoss / JBoss 7, distributable-, "" . . 7- , , UDP ( -u). , , UDP- , , . UPD , , JBoss .

UPD jgroups 230.0.0.4, -u. ? , " IP Multicast 224.0.0.0 239.255.255.255 ". , , , , 230.0.0. 5 , , Windows, . - 230.0.0. 3 23 1 .0.0.4 - . , , , , , , " ".

.
<inet-address value="${jboss.bind.address:127.0.0.1}"/> , , -b 0.0.0.0, .. .

: -Djgroups.bind_addr=IP- , jgroups . , -b 0.0.0.0, jgroups, . Windows :
GMS: address=node1/web, cluster=web, physical address=127.0.0.1:55200
, -b 0.0.0.0 -Djgroups.bind_addr=127.0.0.1.


: JBoss / JBoss 7, distributable-, "" . . 7- , , UDP ( -u). , , UDP- , , . UPD , , JBoss .

UPD jgroups 230.0.0.4, -u. ? , " IP Multicast 224.0.0.0 239.255.255.255 ". , , , , 230.0.0. 5 , , Windows, . - 230.0.0. 3 23 1 .0.0.4 - . , , , , , , " ".

.

Source: https://habr.com/ru/post/189588/


All Articles