Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Troubleshooting JBOSS configuration

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Jboss provides two operation modes: standalone (independent operation mode) and domain (domain mode). In daily development, standalone mode is sufficient. However, in production and deployment, an app is often deployed in a jboss cluster environment. If all jboss server adopts standalone mode, it will bring a huge workload to operation and maintenance, which requires deployment / update on each jboss server one by one, which is obviously not suitable.

The purpose of domain mode is to solve this problem. In this mode, all jbossserver can be divided into different group (Note: the jbossserver here does not necessarily correspond to a physical machine or virtual machine. On an os, multiple jbossserver instances can be run at the same time, so the jbossserver in this article all refers to a running jbossserver instance). Each group can contain multiple jbossserver, and one of these jbossserver can be designated as a domain controller (domaincontroller). Commonly known as master server, other jbossserver are Home Controller (commonly known as slaveserver).

All jboss server can be controlled on master and their operation can be monitored. When deploying an application, a war package only needs to be deployed on group, and all jboss server in that group will be automatically deployed synchronously.

Operating system: CentOS 7

JDK version: 1.8

JBoss version: JBoss EAP 6.2

Download each version of jboss from: https://teddysun.com/260.html

Download jboss-eap-6.2.0.zip

Download the jdk package: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Download jdk-8u131-linux-x64.rpm

Centos7 can not log in using ssh and its solution

Yum instatll net-tools-y-install the netstat tool

Systemctl start sshd-start the sshd service

Netstat-nalt

JBoss needs to rely on JDK to run

Install JDK

Check whether the system comes with jdk. If the system comes with jdk, you need to uninstall it first. Then install the jdk we need.

Check to see if the jdk command is installed:

Rpm-qa | grep jdk

Delete the command that comes with jdk:

Rpm-e-- nodeps java-1.6.0-openjdk-1.6.0.0-1.41.1.10.4.el6.x86_64

Or delete it with the yum-y remove command:

Yum-y remove java-1.6.0-openjdk-1.6.0.0-1.41.1.10.4.el6.x86_64

After execution, check to see if the deletion is successful:

[root@localhost vmware-tools-distrib] # rpm-qa | grep jdk

[root@localhost vmware-tools-distrib] # java-version

-bash: java: command not found

Upload the installation package jdk-8u131-linux-x64 to the server / home/oldboy/tools directory

Chmod-R 777/home/oldboy/tools/jdk-8u131-linux-x64.rpm

Rpm-ivh/home/oldboy/tools/jdk-8u131-linux-x64.rpm

This command installs jdk to the / usr/Java directory by default

Mv / usr/java/jdk1.8.0_131 / usr/local/jdk1.8

Configure environment variables

Vi / etc/profile

Configure the following variables at the end of the file

JAVA_HOME=/usr/local/jdk1.8

PATH=$JAVA_HOME/bin:$PATH

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

Export JAVA_HOME

Export PATH

Export CLASSPATH

Then enter the source / etc/profile command to make the configuration file effective.

If the following version information appears, it means that all installation and configuration is successful.

[root@localhost vmware-tools-distrib] # java-version

Java version "1.8.0,131"

Java (TM) SE Runtime Environment (build1.8.0_131-b11)

Java HotSpot (TM) 64-Bit Server VM (build25.131-b11, mixed mode)

JBoss installation

Upload the JBoss installation file (unzipped into a directory) to the server, directory: / usr/local/software

Mkdir-pv / usr/local/software

You don't need to install it and extract it to use it. Just like Tomcat, move the JBoss directory to usr/local, which is the directory where all software is installed.

Mv / usr/local/software/jboss-eap-6.2/usr/local/jboss6.2

Vi / etc/profile

Increase

JBOSS_HOME=/usr/local/jboss6.2

Start the JBoss service

It is best to obtain the permissions of the jboss file before starting:

Chmod-R 777 / usr/local/jboss6.2

Cd / usr/local/jboss6.2/bin

Enter the command. / standalone.sh to start Jboss in a single server instance mode

You can see something like 22:37:31306INFO [org.jboss.as] (Controller BootThread) JBAS015874: JBoss EAP 6.2.0.GA (AS 7.3.0.Final-redhat-14) started in10490ms-Started 129 of 186 services (56 services are passive or on-demand), indicating that the startup was successful.

There is * *. Xml in the / usr/local/jboss6.2/standalone/configuration directory, which is used for the jboss startup type. For example:. / standalone.sh--server-config=standalone-full.xml

And. / standalone.sh is equivalent to. / standalone.sh-- server-config=standalone.xml

Cd / usr/local/jboss6.2/bin

Enter the command. / domain.sh to start JBoss in domain mode of allowing control andmanagement of multiple instances

Test:

Master: 192.168.1.58

Slave: 192.168.1.181

Configure master (master: 192.168.1.58):

Add a user on 192.168.1.58:

Cd / usr/local/jboss6.2/bin

. / add-user.sh

The user name created is slave so that slave can log in to master. Password: @ we4%7Jt, encrypted by Base64: QHdlNCU3SnQ=

Modify the management interface address:

Vi / usr/local/jboss6.2/domain/configuration/host.xml

Configure slave (slave: 192.168.1.181)

Vi / usr/local/jboss6.2/domain/configuration/host.xml

Set the name:

Set the password:

The value configured in secret value is the base64 of the password of the slave user configured on master.

Configure the master address:

Configure the local interface address:

Replace 127.0.0.1 with 0.0.0.0 or the actual IP address:

Configure the port:

Port 9999 here is changed to other ports that are not used (for example: 9099), otherwise port 9999 on slave server conflicts with the management port on master server, and an error will be reported when it finally starts.

Configure servers:

The group must be the group configured in host.xml on the master host (master: 192.168.1.58).

Start

Master (master: 192.168.1.58):

Cd / usr/local/jboss6.2/bin

. / domain.sh

Slave (slave: 192.168.1.181):

Cd / usr/local/jboss6.2/bin

. / domain.sh

Lan access management interface: (user name: slave password: @ we4%7Jt)

Http://192.168.1.58:9990

Deploying an Application in Standalone Mode

Put the application test.war (a random test file) into / usr/local/jboss6.2/standalone/deployments

The standalone/deployments directory in the JBoss Application Server

Distribution is the location end users can place their deploymentcontent

(e.g. War, ear, jar, sar files) to have it automatically deployed intothe server

Runtime.

Cd / usr/local/jboss6.2/bin

. / standalone.sh

You can see that JBAS018559: Deployed "test.war" (runtime-name: "test.war") means that it has been used. Delete test.war under / usr/local/jboss6.2/standalone/deployments and you can see JBAS018558: Undeployed "test.war" (runtime-name: "test.war").

Deploying an Application in Domain Mode

Log in to http://192.168.1.58:9990

Manage Deployments

Add

Assign

Gathering Java Virtual Machine Diagnostics (GC log analysis for troubleshooting)

Standalone mode

Vi / usr/local/jboss6.2/bin/standalone.conf

# Enable garbage collection logging

JAVA_OPTS= "$JAVA_OPTS-verbose:gc-XX:+PrintGCTimeStamps-XX:+PrintGCDetails-Xloggc:gc.log"

# Create a java heap dump on outofmerryerror

JAVA_OPTS= "$JAVA_OPTS-XX:-HeapDumpOnOutOfMemoryError"

/ usr/local/jboss6.2/bin/standalone.sh

Generate the file / root/gc.log, which can be used to view.

Domain mode

Vi / usr/local/jboss6.2/domain/configuration/host.xml

/ usr/local/jboss6.2/bin/domain.sh

Generate the file / root/gc.log, which can be used to view.

Ps-ef | grep java

You can see that the modification has been enabled

How to read and understand GC logs

The [GC "and" [Full GC "at the beginning of the GC log indicate the type of standstill in this garbage collection, rather than being used to distinguish between a new generation of GC and an old GC. If there is a "Full", it means that Stop-The-World has occurred in this GC. For example, the following log of the new generation collector ParNew will also appear "[FullGC" (this is usually due to problems such as failure to allocate guarantee, which leads to STW). If the collection is triggered by a call to the System.gc () method, "[Full GC (System)" is displayed here.

[Full GC 283.736: [ParNew:261599K- > 261599K (261952K), 0.0000288 secs]

The next "[DefNew", "[Tenured", "[Perm" indicate the region where the GC occurs, and the region name shown here is closely related to the GC collector used. For example, the new generation in the Serial collector used in the above example is called "Default New Generation", so it shows "[DefNew". If it is a ParNew collector, the name of the new generation will become "[ParNew", meaning "ParallelNew Generation". If the Parallel Scavenge collector is used, the new generation that comes with it is called "PSYoungGen". The old age is the same as the permanent generation, and the name is also determined by the collector.

The "3324K-> 152K (3712K)" inside the square brackets means "the memory area has been used before GC-> the memory area has been used since GC (the total capacity of this memory area)". The "3324K-> 152K (11904K)" outside the square brackets indicates "Java heap used capacity before GC-> Java heap used capacity after GC (total Java heap capacity)".

After that, "0.0025925 secs" represents the time, in seconds, taken by the GC in this area of memory. Some collectors will give more specific time data, such as "[Times: user=0.01 sys=0.00, real=0.02 secs]", where the user, sys and real are the same as the output time of Linux's time command, representing the CPU time consumed in user mode, the CPU event consumed in kernel state and the wall clock time (Wall Clock Time) of operation from start to finish, respectively. The difference between CPU time and wall clock time is that wall clock time includes all kinds of non-operational waiting time, such as waiting for disk ICPU O and waiting thread blocking, while CPU time does not include these times, but when the system has multiple CPU or multiple cores, multithreaded operations will stack these CPU times, so it is perfectly normal for readers to see that user or sys time exceeds real time.

GCViewer (graphical tool)

How and When to Capture a Java Thread Dump

Vi / .bashrc

# user specific aliases and functions

Export PATH=$PATH:/usr/local/jdk1.8/bin

Run. / standalone.sh before you get jboss-modules.jar

Cd / usr/local/jboss6.2/bin

. / standalone.sh

[root@localhost ~] # jps

3013 Jps

2919 jboss-modules.jar

[root@localhost ~] # jstack-l 2919 > jstack.out

[root@localhost ~] # less jstack.out (view thread status)

Samurai.jar can realize real-time monitoring TheadDump and GC chart display. (but a graphical interface is required)

Official website and documentation: http://yusuke.homeip.net/samurai/en/index.html

Download: http://yusuke.homeip.net/samurai/en/samurai.jar

Run: java-jar. / samurai.jar

Http://www.eclipse.org/mat/

The Eclipse MemoryAnalyzer is a fast and feature-rich Java heap analyzer that helps you findmemory leaks and reduce memory consumption.

Find the Java thread that consumes the most CPU in a Java process and locate the stack information

Vi / .bashrc

# user specific aliases and functions

Export PATH=$PATH:/usr/local/jdk1.8/bin

Jstack can navigate to the thread stack, and we can navigate to specific code based on stack information, so it is used a lot in JVM performance tuning. Let's take an example to find the Java thread that consumes the most CPU in a Java process and locate the stack information. The commands used are ps, top, printf, jstack, and grep.

The first step is to find out the Java process ID. The name of the Java application on the server is mrf-center:

Root@ubuntu:/# ps-ef | grep mrf-center | grep-v grep

Root 21711 11 14:47 pts/3 00:02:10 java-jar mrf-center.jar

The ID of the process is 21711. The second step is to find out which thread consumes the most CPU in the process. You can use the

1) ps-Lfp pid

2) ps-mp pid-oTHREAD, tid, time

3) top-Hp pid

With the third, the output is as follows:

The TIME column is the CPU time consumed by each Java thread. The longest CPU time is the thread with an ID of 21742.

Printf "% x\ n" 21742

The hexadecimal value of 21742 is 54ee, which will be used below.

OK, the next step is finally jstack, which is used to output stack information of process 21711, and then according to the hexadecimal value grep of thread ID, as follows:

Root@ubuntu:/# jstack 21711 | grep 54ee

"PollIntervalRetrySchedulerThread" prio=10 tid=0x00007f950043e000 nid=0x54ee in Object.wait ()

You can see that CPU consumes Object.wait () in the class PollIntervalRetrySchedulerThread. I look for my code and navigate to the following code:

/ / Idle wait

GetLog () .info ("Thread [" + getName () + "] is idle waiting...")

SchedulerThreadState = PollTaskSchedulerThreadState.IdleWaiting

Long now = System.currentTimeMillis ()

Long waitTime = now + getIdleWaitTime ()

Long timeUntilContinue = waitTime-now

Synchronized (sigLock) {

Try {

If (! halted.get ()) {

SigLock.wait (timeUntilContinue)

}

}

Catch (InterruptedException ignore) {

}

}

It is the idle wait code for the polling task, and the sigLock.wait (timeUntilContinue) above corresponds to the previous Object.wait ().

Local area network access

Entering http://xxx.xx.xx.xxx:8080 directly cannot be accessed. If you want other machines in the LAN to access it, you need to make the following configuration:

Turn off the server's firewall

Systemctl stop firewall

Failed to stop firewall.service: Unitfirewall.service not loaded.

Centos defaults to firewall from 7, which is based on iptables. Although there is a core of iptables, iptables's service is not installed. So you just have to stop the firewalld service: sudo systemctl stopfirewalld.service & & sudo systemctl disable firewalld.service

You must modify the JBoss configuration file as follows:

Vi/usr/local/jboss6.2/standalone/configuration/standalone.xml

find

Change 127.0.0.1 to the IP address of the machine where JBoss resides, or change it to 0.0.0.0, and save and exit.

Access Test:

Enter: http://192.168.1.58:8080 in the browser address bar, and the welcome screen appears, which proves that the startup is successful!

Start by running in the background

Opening JBoss directly in. / standalone.sh mode has a drawback. When the command window is closed, the JBoss service will also down. This method is very painful when the remote server operates JBoss. Close the remote terminal window and JBoss will down.

So we need to have JBoss open and run in the background: go to the bin directory and type the nohup. / standalone.sh command. In this way, the service runs in the background, and even if the command window is closed, the service still runs.

Check the Jboss startup log information and enter: tail-f nohup.out.

Out of Service

Start JBoss directly. When you shut down, you can press CTRL + C to start the terminal window to stop the JBoss service completely.

If you run in the background, it will be troublesome to shut down the server. It took a long time to find a way to shut down Jboss EAP6.2:

Go to the bin directory of JBoss and enter:

[root@adminkp bin] #. / jboss-cli.sh-c: shutdown

{"outcome" = > "success"}

Or violence: kill-9 PID

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report