JBoss provides two running modes: Standalone (independent running mode) and domain (domain mode). In daily development, the standalone mode is enough. However, during production and deployment, an app, usually deployed in the JBoss cluster environment. If all JBoss servers adopt the standalone mode, the O & M workload will be greatly increased, and each JBoss server needs to be deployed/updated one by one, obviously not suitable.
The domain mode is designed to solve this problem. In this mode, all JBoss servers can be divided into different groups (Note: The JBoss server here does not necessarily correspond to a physical machine or virtual machine, on one OS, you can run multiple JBoss server instances at the same time. Therefore, the JBoss server in this Article refers to a running JBoss server instance. Each group can contain multiple JBoss servers, in all these JBoss servers, you can specify one as the domain controller (Domain Controller), commonly known as the master server, and other JBoss servers as the home controller (slave server ).
The master can control all JBoss servers and monitor their running status. When deploying an application, a war package only needs to be deployed to the group, all JBoss servers in the group are automatically deployed.
The configuration steps are as follows:
Environment:
Windows, JBoss EAP 6.3
Machine resources:
172.21.129.181 (master), 172.21.129.57 (slave57), 172.21.129.128 (slave128)-that is, 181 is the host, and 57, 128 is the slave
1. Download and install JBoss EAP 6.3.
The latest version of JBoss EAP is 6.3, https://www.jboss.org/products/eap/download/
After the download is complete, decompress the package to a directory (use jboss_home to replace the JBoss root directory)
Ii. master server configuration
2.1Go to "jboss_home \ domain \ configuration" and open host. xml
1 <interfaces> 2 <interface name="management"> 3 <inet-address value="${jboss.bind.address.management:172.21.129.181}"/> 4 </interface> 5 <interface name="public"> 6 <inet-address value="${jboss.bind.address:172.21.129.181}"/> 7 </interface> 8 <interface name="unsecure"> 9 <!-- Used for IIOP sockets in the standard configuration.10 To secure JacORB you need to setup SSL -->11 <inet-address value="${jboss.bind.address.unsecure:172.21.129.181}"/>12 </interface>13 </interfaces>
View code
Replace all 127.0.0.1 addresses with the real IP address corresponding to the master server (otherwise, you cannot remotely access the JBoss console through a browser)
2.2Start master server in domain Mode
Jboss_home \ bin \ domain. bat
2.3Go to the master JBoss Console
Http: // 172.21.129.181: 9990/console/
Upon first entry, you may be prompted that you have not created an administrator account. For details, refer to the section 6.5 C in the VMware installation of cent OS 6.2 + Oracle 11g Xe + JBoss EAP 7.5 + WebLogic 12C + webshpere MQ 3.4) to create an administrator.
2.4Create group and Server
After entering the console, we can see that some groups and servers have been created by default in JBoss. First, we can completely eliminate them (normally, we will create our own group/Server)
Refer to the following interface to create two groups: My-group-1 and my-group-2.
TIPS: when creating a group, we recommend that you select full-ha for profile (we will talk about how to configure JBoss cluster in the future, and use full-ha profile for load balancing and smart fault tolerance)
Refer to the figure below to create four servers on the master server
Note: When creating a server, there is a Port Offset option (refer)
By default, the server port is 8080 and Port Offset indicates the Port Offset. If Port Offset is set to 5, it indicates that after the server is created, the corresponding port is 8080 + 5, that is, port 8085 (which can be accessed through http: // 172.21.129.181: 8085)
TIPS: If a server is already in the started status, it cannot be removed. You can stop the server on the following page and then return to the page to remove it.
Iii. slave server configuration
3.1Decompress JBoss EAP 6.3 to 172.21.129.57 Server Load balancer.
3.2Enter jboss_home \ domain \ configuration, rename the original host. xml backup, and then copy the host-slave.xml and rename it host. xml
3.3Modify host. xml
A)
1 <management-interfaces>2 <native-interface security-realm="ManagementRealm">3 <socket interface="management" port="${jboss.management.native.port:9099}"/>4 </native-interface>5 </management-interfaces>
Change the port 9999 here to another unused port (for example, 9099). Otherwise, port 9999 on the slave server conflicts with the Management port on the master server. An error will be reported when the server is started.
B)
1 <domain-controller>2 <remote host="${jboss.domain.master.address:172.21.129.181}" port="${jboss.domain.master.port:9999}" security-realm="ManagementRealm"/>3 </domain-controller>
In row 2nd, specify the IP address of the master server (172.21.129.181 in this article). This way, when slave is started, it will know which master to connect.
C)
1 <interfaces> 2 <interface name="management"> 3 <inet-address value="${jboss.bind.address.management:0.0.0.0}"/> 4 </interface> 5 <interface name="public"> 6 <inet-address value="${jboss.bind.address:0.0.0.0}"/> 7 </interface> 8 <interface name="unsecure"> 9 <!-- Used for IIOP sockets in the standard configuration.10 To secure JacORB you need to setup SSL -->11 <inet-address value="${jboss.bind.address.unsecure:0.0.0.0}"/>12 </interface>13 </interfaces>
The original 127.0.0.1 is changed to the real IP address of the slave server or 0.0.0.0. Otherwise, the application on the slave can only be accessed on the slave local machine.
D)
1 <servers>2 <server name="slave-server-8082" group="my-group-2">3 <socket-bindings port-offset="2"/>4 </server>5 <server name="slave-server-8083" group="my-group-2"> 6 <socket-bindings port-offset="3"/>7 </server>8 </servers>
Manually create two servers on the slave and add them to my-group-2 (Note: The group value must have been created on the master server; otherwise, the server on slave cannot be added to the Group related to the master)
E)
1
Add a name = "XXX" attribute to the starting host node (slave57 in this article). The name value will be displayed on the JBoss console of the master server, we recommend that you use a name that is easy to recognize.
Iv. Security Authentication Configuration
4.1Return to the master server, add an administrator account named slave57, and remember the last generated <secret value = "XXXX"/> string (XXX is the content of the password after base64 processing)
4.2Return to the server of slave57, edit host. xml again, and replace the content of <secret value = "XXXX"/>.
1 <server-identities>2 <!-- Replace this with either a base64 password of your own, or use a vault with a vault expression -->3 <!--<secret value="c2xhdmVfdXNlcl9wYXNzd29yZA=="/>-->4 <secret value="c2xhdmU1Ny4xMjM=" />5 </server-identities>
<Secret value =.../>
Explanation: When slave is started, you need to connect to the JBoss registered to the master. The connection process requires security authentication. The secret here is equivalent to the authentication key, and the authenticated user name is: host in JBoss on the connected slave machine. the name value in the
4.3Start JBoss on Master and slave57 in domain mode in sequence
If it succeeds, we can see that slave57 has been automatically registered in the JBoss console of the master.
Similarly, the name of the
1 <servers>2 <server name="slave-server-8080" group="my-group-1"/>3 <server name="slave-server-8081" group="my-group-1">4 <!-- server-two avoids port conflicts by incrementing the ports in5 the default socket-group declared in the server-group -->6 <socket-bindings port-offset="1"/>7 </server>8 </servers>
In this way, we have created eight JBoss server instances (four on the master server, and the other four on slave57 and slave128), which are divided into two groups.
5. Application Deployment
Enter the deployment interface (for example), click Add, add a war package, and then assign to a group to automatically deploy the package to all servers in the group. If you want to deploy an app to multiple groups, it's okay. Click assign again and assign it to another group.
Taking this article as an example, After deploying an application named SSO to my-group-1 and my-group-2, the corresponding eight JBoss servers should be accessible:
Http: // 172.21.129.181: 8080/SSO/
Http: // 172.21.129.181: 8081/SSO/
Http: // 172.21.129.181: 8082/SSO/
Http: // 172.21.129.181: 8083/SSO/
Http: // 172.21.129.57: 8082/SSO/
Http: // 172.21.129.57: 8083/SSO/
Http: // 172.21.129.128: 8080/SSO/
Http: // 172.21.129.128: 8081/SSO/
All eight URLs can be accessed.
JBoss EAP 6.3 domain mode configuration