JBoss入门

摘要:
//网址:.jianshu.com/p/4baaf549436b1。安装目录安装Jboss后,目录结构目录函数appclient/包含应用程序客户端容器的配置详细信息。JBossEAP6作为托管域运行时使用的域/配置文件、部署内容和可写区域。欢迎内容/包含默认安装中端口8080上欢迎应用程序使用的内容。Jboss-modules.jar是加载模块的引导机制。

 很多内容摘自

https://www.jianshu.com/p/4baaf549436b

1.安装目录

安装完Jboss后得目录结构

目录功能
appclient/包含应用程序客户容器的配置细节。
bin/包含 Red Hat 企业版 Linux 和微软 Windows 上 JBoss EAP 的启动脚本。
docs/许可证文件、schema 和示例。
domain/配置文件、部署内容和 JBoss EAP 6 以受管域运行时使用的可写入区域。
modules/当有服务请求时 JBoss EAP 6 动态加载的模块。
standalone/配置文件、部署内容和 JBoss EAP 6 以独立服务器运行时使用的可写入区域。
welcome-content/包含默认安装里 8080 端口上的 Welcome 应用程序使用的内容。
jboss-modules.jar加载模块的引导机制。

Domains中的结构

 

名称目的
configuration/用于受管域的配置文件。这些文件是通过管理控制台和 CLI 进行修改的,不能直接进行编辑。
data/关于已部署服务的信息。服务是用管理控制台或管理 CLI,而不是通过部署扫描器来部署的。因此,请不要手动在这个目录里放入文件。
log/包含运行在本地实例上的主机和进程控制器的运行时日志文件。
servers/包含某个域里的每个服务器实例的 data/、log/ 和 tmp/ 目录,其中包含的数据和顶层的 domain/
tmp/包含临时数据,如针对受管域检验本地用户的管理 CLI 使用的共享密钥机制相关的文件。

standalone/ 里的目录

名称目的
configuration/用于独立服务器的配置文件。这些文件是通过管理控制台和 CLI 进行修改的,不能直接进行编辑。
deployments/关于已部署服务的信息。独立服务器包含一个部署扫描器,您可以在这个目录里放入要部署的归档文件。然而,我们推荐的方法是用管理控制台或管理 CLI 来管理部署。
lib/附属于独立服务器模式的外部库。默认为空。
tmp/包含临时数据,如针对服务器检验本地用户的管理 CLI 使用的共享密钥机制相关的文件。

2.基本概念

  • jboss-eap-7.1有两种运行模式,standalone单机模式 和 domain集群模式。
  • jboss启动服务器时,默认读取的配置文件是${JBOSS_HOME}/standalone/configuration/standalone.xml。也可以指定读取其他配置文件,命令是./standalone.sh --server-config=standalone-custom.xml
  • jboss-cli(command line interface),是jboss的命令行管理工具。执行${JBOSS_HOME}/bin/jboss-cli.sh即可进入。通过命令行实现部署卸载应用、配置系统设置和执行管理任务的功能。使用该工具修改系统配置时,最终也会作用到standalone.xml中。
  • Management Console,管理控制台。是jboss提供的web管理系统,地址在http://localhost:9990/console/App.html, 所有的操作均可通过jboss-cli实现。

3.standalone.xml配置

修改监听地址

<interfaces>
        <interface name="management">
            <inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
        </interface>
        <interface name="public">
            <inet-address value="${jboss.bind.address:127.0.0.1}"/>
        </interface>
    </interfaces>

缺省绑定本机,可以修改成具体的ip,如果修改成0.0.0.0则绑定所有的ip

  • 端口配置
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
        <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
        <socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
        <socket-binding name="http" port="${jboss.http.port:8080}"/>
        <socket-binding name="https" port="${jboss.https.port:8443}"/>
        <socket-binding name="txn-recovery-environment" port="4712"/>
        <socket-binding name="txn-status-manager" port="4713"/>
        <outbound-socket-binding name="mail-smtp">
            <remote-destination host="localhost" port="25"/>
        </outbound-socket-binding>
    </socket-binding-group>

基于协议修改不同的端口

  • 数据源配置
 <subsystem xmlns="urn:jboss:domain:datasources:5.0">
            <datasources>
                <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
                    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
                    <driver>h2</driver>
                    <security>
                        <user-name>sa</user-name>
                        <password>sa</password>
                    </security>
                </datasource>
                <drivers>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                </drivers>
            </datasources>
        </subsystem>

其中driver的libray目录主要需要看module模块,上面例子放在

E:eap7modulessystemlayersasecomh2databaseh2main 路径下。同时此目录下需要放置module.xml文件,格式如下:

<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2010, Red Hat, Inc., and individual contributors
  ~ as indicated by the @author tags. See the copyright.txt file in the
  ~ distribution for a full listing of individual contributors.
  ~
  ~ This is free software; you can redistribute it and/or modify it
  ~ under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation; either version 2.1 of
  ~ the License, or (at your option) any later version.
  ~
  ~ This software is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  ~ Lesser General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Lesser General Public
  ~ License along with this software; if not, write to the Free
  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  -->

<module xmlns="urn:jboss:module:1.5" name="com.h2database.h2">
    <properties>
        <property name="jboss.api" value="unsupported"/>
    </properties>


    <resources>
        <resource-root path="h2-1.4.193.redhat-2.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
        <module name="javax.servlet.api" optional="true"/>
    </dependencies>
</module>
  • undertow配置
<subsystem xmlns="urn:jboss:domain:undertow:4.0">
    <buffer-cache name="default"/>
    <server name="default-server">
        <http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
        <https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
        <host name="default-host" alias="localhost">
            <location name="/" handler="welcome-content"/>
            <filter-ref name="server-header"/>
            <filter-ref name="x-powered-by-header"/>
            <http-invoker security-realm="ApplicationRealm"/>
        </host>
            </server>
    <servlet-container name="default">
        ………… ………… …………
    </servlet-container>
    <handlers>
        <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
    </handlers>
    <filters>
        ………… ………… …………
    </filters>
</subsystem>

修改后配置为

<subsystem xmlns="urn:jboss:domain:undertow:4.0">
    <buffer-cache name="default"/>
    <server name="default-server">
        <http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true" url-charset="GBK" decode-url="false"/>
        <https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
        <host name="default-host" alias="localhost">
            <!-- <location name="/" handler="welcome-content"/> -->
            <filter-ref name="server-header"/>
            <filter-ref name="x-powered-by-header"/>
            <http-invoker security-realm="ApplicationRealm"/>
            <filter-ref name="request-dumper"/>
            <access-log pattern="combined" directory="${jboss.home.dir}/standalone/log"/>
        </host>
            </server>
    <servlet-container name="default" default-encoding="GBK" use-listener-encoding="true">
        ………… ………… …………
    </servlet-container>
    <!-- <handlers>
        <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
    </handlers> -->
    <filters>
        ………… ………… …………
        <filter name="request-dumper" class-name="io.undertow.server.handlers.RequestDumpingHandler" module="io.undertow.core"/>
    </filters>
</subsystem>
  • 修改http请求设置:在http-listener标签中,增加了url-charset和decode-url。其中url-charset默认使用的UTF-8,可以根据需要修改。decode-url指是否使用字符集解码url和参数,默认为true。设为false则交由后续代码进行解码处理。http-listener的详细配置属性点击这里
  • 修改容器默认字符集:在servlet-container标签中,default-encoding设置所有应用的字符集(默认为utf-8),use-listener-encoding指是否使用listener定义的编码。servlet-container的详细配置属性点击这里
  • 移除Jboss默认欢迎页面:配置文件中注释的部分,就是jboss默认欢迎页面的配置。直接注释就是将其移除,也可以将默认地址映射到某个应用上。
  • 开启http访问日志:在host标签下增加access-log这一标签,即可将http请求的信息记在日志中,便于调试。directory是日志存放的目录,默认文件名为access_log.log。pattern是要日志中记录的信息,预定义了common和combined两种模式,combined的信息丰富一些。自定义的输出模式详见此处
  • 输出http请求和响应的信息:在filters标签下增加名为request-dumper的filter,在host标签下增加命名一致的filter-ref,就能在jboss日志中输出每一个http请求的request和response信息,便于调试。
  • 应用部署
 <subsystem xmlns="urn:jboss:domain:deployment-scanner:2.0">
            <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" runtime-failure-causes-rollback="${jboss.deployment.scanner.rollback.on.failure:false}"/>
        </subsystem>

全自动模式

在默认配置下,将war包上传至${JBOSS_HOME}/standalone/deployments,服务器会在启动时和每5000毫秒间隔,检查deployments下的文件变化,部署应用。

半自动模式

增加属性 auto-deploy-zipped="false"
上传应用myApp.war至deployments文件夹后,在deployments文件夹下新建一个文件,命名为myApp.war.dodeploy,服务器检测到这个文件后,则会开始执行部署。

手动模式

增加属性scan-enabled="false"
此模式是官方推荐的生产环境部署应用方式,无需将应用上传至deployments文件夹下。首先保证myApp.war在服务器上,假设其路径为/usr/me/myApp.war
启动服务器,并使用./jboss-cli.sh --connect命令进入命令行管理界面。执行命令deploy /usr/me/myApp.war部署应用。取消部署时,在命令行管理界面执行 undeploy myApp.war
应用的数据会在${JBOSS_HOME}/standalone/data/content下,并且standalone.xml最下方会出现deployments标签,显示已经部署的应用。



 

免责声明:文章转载自《JBoss入门》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Sublime Text 3 安装Go语言相关插件gosublimespringboot2.1.3 + redisTemplate + Lock 操作 redis 3.0.5下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

ftp命令

ftp命令是标准的文件传输协议的用户接口。ftp是在TCP/IP网络上的计算机之间传输文件的简单有效的方法。它允许用户传输ASCII文件和二进制文件。 在ftp会话过程中,用户可以通过使用ftp客户程序连接到另一台计算机上。从此,用户可以在目录中上下移动、列出目录内容、把文件从远程机拷贝到本地机上、把文件从本地机传输到远程系统中。需要注意的是,如果用户没有...

Jmeter(一)

 ------------------------------------------------------------------- 转载自:北京-宏哥 https://www.cnblogs.com/du-hong/p/12894560.html ----------------------------------------------------...

linux权限问题学习总结

寒假里看的权限问题,现在来总结一下。 文件权限除了r、w、x外还有s、t、i、a权限: 1、s:文件属主和组设置SUID和GUID,文件在被设置了s权限后将以root身份执行。在设置s权限时文件属主、属组必须先设置相应的x权限,否则s权限并不能正真生效(chmod命令不进行必要的完整性检查,即使不设置x权限就设置s权限,chmod也不会报错,当我们ls -...

seaJs学习笔记之javascript的依赖问题

之前分别为大家介绍了有关javascript中的冲突和性能问题,今天为大家介绍一下有关javascript中的依赖问题。我们将继续就之前javascript中性能问题继续介绍。 先来回顾一下性能问题的解决方法,那就是按需引入js文件。那么这样按需引入会不会存在问题呢?今天我们为大家继续揭晓答案。先看如下页面。 多文件HTML代码 <!doctype...

Linux 内核:设备驱动模型 平台设备驱动

介绍 Linux系统的驱动框架主要就是三个主要部分组成,驱动、总线、设备。 随着电子行业的发展,控制器越来越强大,SOC(片上系统)出现了:在片内的CPU外围集成很多外设电路,这些外设都挂接在SOC内部的总线上。 不同于IIC、SPI和USB等这一类实际存在外部PCB走线总线,片内外设从Chip之外是看不到的。 为了统一驱动架构抽象,所以Linux从2.6...

百度地图API初体验和偏移纠正方法

      最近的项目想做一个在可以通过手持设备获取经纬度,然后在地图上进行标注显示的功能,因为还在技术调研阶段,所以决定先使用百度地图或Google Maps的API来做Demo。通过网上的一些资料和自己对于Google和百度地图的使用,对这两个地图做了一些简单的对比,结论是很明显的——Google在技术水平和成熟度上都要比百度高很多,可以说完全不在一个...