网站搜索

WildFly 8 - 适用于 Linux 的全新改进的 JBoss 应用服务器


众所周知,JBoss AS已更名为WildFly。添加了许多新功能,并且升级了许多功能。最后,WildFly 8.0.0 Final 已于2014 年 2 月 11 日发布。 WildFly 项目负责人 Jason Greene 也宣布了同样的事情。

WildFly 8Red HatJava EE 7 兼容开源应用服务器。主要特点如下:

Java EE 7 兼容性

其中最大的变化是,现在 WildFly 8 已获得官方 Java EE7 认证。

高性能网络服务器

Undertow 是用 Java 编写的新型高性能 Web 服务器。现在,这已在 WildFly 8 中实现。这确实是为高吞吐量和可扩展性而设计的,可以处理数百万个连接。 Undertow 的生命周期完全由嵌入应用程序控制。这是非常轻量级的,核心 jar 大小为 1MB,嵌入式服务器使用不到 4MB 的堆空间。这真是太棒了。

3端口减少

由于它使用的是支持升级 HTTP 的 Undertow,这将允许多个协议在单个 HTTP 端口上复用。 WildFly 8 已将其几乎所有协议移至两个 HTTP 端口上进行多路复用:一个是管理端口,另一个是应用程序端口。对于在单个服务器上运行数百到数千个实例的云提供商(例如 OpenShift)来说,这确实是一个巨大的变化和好处。总共,它有两个默认配置端口,分别是 9990(Web 管理控制台)和 8080(应用程序控制台)。

基于管理角色的访问控制和审核

这是 WildFly 8 中实现的新的、有趣的事情。通过使用它,我们可以创建不同的用户,并可以根据要求将这些用户分配给不同的角色。稍后我将通过屏幕截图向您展示。

记录

管理 API 现在支持列出和查看服务器上可用日志文件的功能。现在,我们有一个名为“add-logging-api-dependency”的属性,可用于我们想要跳过容器日志记录的任何类型的部署。这将禁用添加隐式服务器日志记录依赖项。我们还有另一个选择,即我们可以使用 jboss-deployment-struct.xml 来排除日志记录子系统。使用此功能,将有助于阻止日志子系统进行任何部署。

我们还可以使用另一个参数,即 use-deployment-logging-config 来启用/禁用部署中日志配置文件的处理。

注意:我们用于禁用每次日志记录的系统属性已从此版本中弃用。

聚类

同样,大的变化是一个集群。 WildFly 8 中与集群支持相关的所有功能均已更改,其中包括如下:

  1. 分布式 Web 会话已通过新的基于 Java 的 Web 服务器(即 Undertow)进行了优化。
  2. mod_cluster 对 Undertow 的支持。
  3. 优化分布式SSO(单点登录)功能并支持Undertow。
  4. 新的/优化的分布式 @Stateful EJB 缓存实现。
  5. WildFly 8 添加了一些新的公共集群 API。
  6. 为了创建单例服务,它提供了新的公共 API。
CLI 改进

CLI 配置也得到了改进。您知道所有管理员都喜欢在 CLI 上工作;)。因此,现在我们可以为特定服务器创建别名,然后每当想要使用 connect 命令连接到该服务器时都可以使用该别名。

WildFly 8 中仍然有许多增强功能和更新。您可以在以下位置查看所有这些内容:

  1. http://wildfly.org/news/2014/02/11/WildFly8-Final-Released/

在 Linux 中安装 WildFly 8

在继续安装之前,请确保您的系统上已安装Java EE 7。 WildFly 8 不适用于以前的版本。请按照以下指南在 Linux 系统中安装 Java EE 7。

  1. 在 Linux 中安装 JDK/JRE 7u25

第 1 步:下载 WildFly 8

使用以下链接下载最新的 WildFly zip 文件。

  1. http://download.jboss.org/wildfly/8.0.0.Final/wildfly-8.0.0.Final.zip

您也可以在命令行中使用“wget”命令直接下载。

[root@tecmint]# wget http://download.jboss.org/wildfly/8.0.0.Final/wildfly-8.0.0.Final.zip

将 zip 文件复制到任何首选位置(例如,在我的情况下为“/data/”)并使用“unzip”命令解压缩。

[root@tecmint]# cp wildfly-8.0.0.Final.zip /data/
[root@tecmint]# cd /data/
[root@tecmint data]# unzip wildfly-8.0.0.Final.zip

步骤2:设置环境变量

现在设置一些环境变量。您可以在系统上或在配置文件中设置这些。在这里,我在“bin”文件夹中的配置文件standalone.shstandalone.conf中进行设置。

[root@tecmint data]# cd wildfly-8.0.0.Final
[root@tecmint data]# cd bin/

将以下两行添加到 standlone.sh/standlone.conf 文件中。请指定您的 WildFly 安装位置和 Java 主目录位置。

JBOSS_HOME=”/data/wildfly-8.0.0.Final”
JAVA_HOME=”/data/java/jre7/bin/java”

注意:对于整个系统范围,您可以在“/etc/profile”文件下进行设置。

第 3 步:启动 WildFly 8

现在启动服务器,即对于独立模式使用“standalone.sh”,对于域模式使用“domain.sh”。

[root@tecmint bin]# ./standalone.sh
[root@tecmint bin]# ./domain.sh

但是,我在这里以独立模式开始。默认情况下,它将由“standalone.xml”文件启动,但您也可以使用“-server-config”选项启动一些其他配置。

如下所示,我使用“standalone-full-ha.xml”启动服务器,该文件位于“$JBOSS_HOME/standalone(profile)/configuration/”中。

[root@tecmint bin]# ./standalone.sh --server-config standalone-full-ha.xml
样本输出
Calling "/data/wildfly-8.0.0.Final/standalone/configuration/standalone.conf"
Setting JAVA property to "/data/java/jre7/bin/java"
===============================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: "/data/wildfly-8.0.0.Final"

  JAVA: "/data/java/jre7/bin/java"

  JAVA_OPTS: "-client -Dprogram.name=standalone.sh -Xms64M -Xmx512M -XX:MaxPerm
Size=256M -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman"

===============================================================================

13:55:26,403 INFO  [org.jboss.modules] (main) JBoss Modules version 1.3.0.Final
13:55:33,812 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.0.Final
13:55:35,481 INFO  [org.jboss.as] (MSC service thread 1-1) JBAS015899: WildFly 8.0.0.Final "WildFly" starting
13:55:58,646 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)
...........
13:56:22,778 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
13:56:22,794 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
13:56:22,794 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.0.0.Final "WildFly" started in 64534ms - Started 229 of 356 services (172 services are lazy, passive or on-demand)

第 4 步:访问 WildFly 8

现在,您可以将浏览器指向“http://localhost:8080”(如果使用默认配置的 http 端口),这将带您进入欢迎屏幕。

从这里,您可以访问 WildFly 社区文档指南和增强的基于 Web 的管理控制台访问。

第 5 步:管理 WildFly 8

WildFly 8 提供了两个管理控制台来管理正在运行的实例:

    1. 基于网络的管理控制台
    2. 命令行界面

在连接到管理控制台或使用命令行远程连接之前,您需要使用 bin 文件夹中的“add-user.sh”脚本创建一个新用户。

接下来,进入'bin'目录,在add-user.sh中设置'JBOSS_HOME'(如果系统上未设置变量)并创建用户如下。

[root@tecmint bin]# ./add-user.sh

启动脚本后,您将被引导完成添加新用户的过程:

样本输出
What type of user do you wish to add?
 a) Management User (mgmt-users.properties)
 b) Application User (application-users.properties)
(a):
Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
Username : admin
The username 'admin' is easy to guess
Are you sure you want to add user 'admin' yes/no? yes
Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.
 - The password should not be one of the following restricted values {root, admin, administrator}
 - The password should contain at least 8 characters, 1 alphanumeric character(s), 1 digit(s), 1 non-alphanumeric symbol(s)
 - The password should be different from the username
Password :
Re-enter Password :
What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]:
About to add user 'admin' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'admin' to file '/data/wildfly-8.0.0.Final/standalone/configuration/mgmt-users.properties'
Added user 'admin' to file /data/wildfly-8.0.0.Final/domain/configuration/mgmt-users.properties'
Added user 'admin' with groups  to file /data/wildfly-8.0.0.Final/standalone/configuration/mgmt-groups.properties'
Added user 'admin' with groups  to file /data/wildfly-8.0.0.Final/domain/configuration/mgmt-groups.properties'
Is this new user going to be used for one AS process to connect to another AS process?
e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.
yes/no? yes
To represent the user add the following to the server-identities definition 
Press any key to continue . . .

现在,通过“http://localhost:9990/console”访问基于 Web 的管理控制台,并输入新创建的用户名和密码以直接访问管理控制台。

登录后的第一个屏幕。

如果您希望通过 CLI 处理服务器,请从提供以下命令的“bin”目录运行“jboss-cli.sh”脚本:通过基于 Web 的 UI 可以使用相同的功能。

[root@tecmint bin]# cd bin
[root@tecmint bin]# ./jboss-cli.sh --connect
Connected to standalone controller at localhost:9999

有关更多信息,请参阅 https://docs.jboss.org/author/display/WFLY8/Documentation 上的官方 WildFly 8 文档。

另请阅读:WildFly (JBoss AS) – 如何使用 GUI 访问和管理 CLI