JBoss Server – How to Start and Stop? – JBoss服务器 – 如何启动和停止?

最后修改: 2018年 8月 30日

中文/混合/英文(键盘快捷键:t)

1. Introduction

1.介绍

In this tutorial, we’ll have a look at how to start and stop a JBoss application server.

在本教程中,我们将看看如何启动和停止一个JBoss应用服务器。

First, we’ll explore the operating modes of this server. Further, we’ll discuss how to start and stop the server in each of these operating modes.

首先,我们将探讨这个服务器的操作模式。此外,我们将讨论如何在这些操作模式中启动和停止服务器。

JBoss is an open source application server developed by RedHat and is now known as WildFly. We can download it from the official WildFly website.

JBoss是由RedHat开发的开源应用服务器,现在被称为WildFly。我们可以从WildFly官方网站下载它。

We can operate this server in two different modes. However, the key difference between these modes lies in the management of the server.

我们可以在两种不同的模式下操作这个服务器。然而,这些模式的关键区别在于对服务器的管理。

2. JBoss Standalone Server

2.JBoss独立服务器

In this mode, each standalone server instance is an independent process. Consequently, we have to manage each of these servers individually.

在这种模式下,每个独立的服务器实例是一个独立的进程。因此,我们必须单独管理这些服务器中的每一个。

In other words, we can launch multiple instances of the standalone servers in case multi-server configuration is desired.

换句话说,如果需要多服务器配置,我们可以启动独立服务器的多个实例。

However, we’ll need to deploy the application on each server individually.

然而,我们需要在每个服务器上单独部署应用程序。

2.1. Preferences and Configurations

2.1.首选项和配置

The standalone startup script i.e. standalone.sh for OSX/Linux and standalone.bat for Windows, utilizes:

独立的启动脚本,即OSX/Linux的standalone.sh和Windows的standalone.bat,利用。

  • standalone.conf/standalone.conf.bat: defines the JVM preferences for the standalone server instance
  • standalone.xml: defines the default configurations for the server; we can find it under $JBOSS_HOME/standalone/configuration.

JBoss also provides some alternate configurations in the same directory:

JBoss还在同一目录下提供了一些备用的配置。

  • standalone-ee8.xml: same as standalone.xml, but with EE8 technologies enabled
  • standalone-ha.xml: Java Enterprise Edition 7 web profile certified configuration with high availability
  • standalone-full.xml: Java Enterprise Edition 7 full profile certified configuration including all the required EE 7 technologies
  • standalone-full-ha.xml: Java Enterprise Edition 7 full profile certified configuration with high availability

2.2. Starting the Server

2.2.启动服务器

Let’s open a terminal in OSX/Linux or a command prompt in Windows and navigate to the $JBOSS_HOME/bin directory.

让我们在OSX/Linux中打开一个终端,或在Windows中打开一个命令提示符,并导航到$JBOSS_HOME/bin目录。

Further, we’ll start the standalone server with default configuration by running:

此外,我们将通过运行来启动独立服务器的默认配置。

standalone.sh

in OSX/Linux or in Windows:

在OSX/Linux或Windows中。

standalone.bat

Similarly, we can start the standalone server with an alternate configuration, say with EE8 capabilities, by executing:

同样,我们可以用另一种配置启动独立服务器,比如说用EE8的功能,通过执行。

standalone.sh --server-config=standalone-ee8.xml

in OSX/Linux or in Windows:

在OSX/Linux或Windows中。

standalone.bat --server-config=standalone-ee8.xml

Furthermore, to check if the startup is successful, we can open up a browser and navigate to http://localhost:8080/. It’ll show the default WildFly welcome page.

此外,为了检查启动是否成功,我们可以打开浏览器,导航到http://localhost:8080/。它将显示默认的WildFly欢迎页面。

2.3. Stopping the Server

2.3.停止服务器

To stop the server we can simply press “CTRL+C”.

要停止服务器,我们可以简单地按 “CTRL+C”。

Additionally, jboss-cli could be utilized for issuing commands to the running instance of the server. For instance, we can use it to shut down the server.

此外,jboss-cli可以用来向运行中的服务器实例发布命令。例如,我们可以用它来关闭服务器。

Let’s open a new terminal or a command prompt and run:

让我们打开一个新的终端或命令提示符并运行。

./jboss-cli.sh --connect command:shutdown

in OSX/Linux and in Windows:

在OSX/Linux和Windows中。

./jboss-cli.bat --connect command:shutdown

3. Managed Domain Servers

3.管理的域名服务器

In this mode, we can manage multiple instances of the server from a single control point. These servers are logically members of a single domain. Here, a single Domain Controller process acts as the central management control point.

在这种模式下,我们可以从一个控制点管理服务器的多个实例。这些服务器在逻辑上是一个单一域的成员。在这里,一个单一的域控制器进程充当了中央管理控制点。

By default, JBoss provides few instances of the server. We can find these instances under $JBOSS_HOME/domain/servers directory.

默认情况下,JBoss提供了一些服务器的实例。我们可以在$JBOSS_HOME/domain/servers目录下找到这些实例。

3.1. Preferences and Configurations

3.1.首选项和配置

The domain startup script i.e. domain.sh for OSX/Linux and domain.bat for Windows utilizes:

域的启动脚本,即OSX/Linux的domain.sh和Windows的domain.bat利用。

  • domain.conf/domain.conf.bat: defines the JVM preferences for the servers under the domain
  • domain.xml: defines the configurations for the domain; we can find it under $JBOSS_HOME/domain/configuration.

Additionally, we can define our custom configuration for operating these servers similar to the alternate configurations of the standalone server.

此外,我们可以定义我们的自定义配置来操作这些服务器,类似于独立服务器的备用配置。

3.2. Starting the Server

3.2.启动服务器

The process of starting the server under a managed domain remains the same as the standalone server. However, instead of standalone.sh/standalone.bat, we’ll use domain.sh/domain.bat.

在管理域下启动服务器的过程与独立服务器相同。然而,我们将使用standalone.sh/standalone.bat,而不是domain.sh/domain.bat

Consequently, this will spin up multiple servers instances under a single domain.

因此,这将在一个单一域下启动多个服务器实例。

3.3. Stopping the Server

3.3.停止服务器

To stop all the servers we can simply press “CTRL+C”. Moreover, we can stop a specific server using jboss-cli.

要停止所有的服务器,我们可以简单地按 “CTRL+C”。此外,我们可以用jboss-cli来停止一个特定的服务器。

Let’s open a new terminal or a command prompt and run:

让我们打开一个新的终端或命令提示符并运行。

jboss-cli.sh --connect

in OSX/Linux or in Windows:

在OSX/Linux或Windows中。

jboss-cli.bat --connect

Presently, we are connected to the domain controller. Here, we can issue commands to multiple instances of the server. For instance, to view all the servers under this domain:

目前,我们连接到域控制器。在这里,我们可以向服务器的多个实例发出命令。例如,要查看这个域下的所有服务器。

/host=master:read-children-names(child-type=server-config)

Similarly, to stop a specific instance of the server, we’ll execute:

同样地,为了停止一个特定的服务器实例,我们将执行。

/host=master/server-config=<server-name>:stop

Accordingly, we can check the status of this server:

据此,我们可以检查这个服务器的状态。

/host=master/server-config=<server-name>:read-resource(include-runtime=true)

4. Conclusion

4.结论

In this short guide, we explored how to start and stop the application server with different configurations.

在这个简短的指南中,我们探讨了如何用不同的配置启动和停止应用服务器。

For further reading, we have an article that describes the process of deploying a war file on the JBoss application server.

为了进一步阅读,我们有一篇文章介绍了在JBoss应用服务器上部署war文件的过程