2015年7月15日星期三

EAP_023:EAP 6 功能演示1:安装、启动、部署应用

环境:JBoss EAP 6.4

1. 安装与启动
(1)unzip jboss-eap-6.4.0.zip
(2)cd jboss-eap-6.4/bin
(3)./standalone.sh
(4)http://localhost:9990/,访问出错,提示创建用户
(5)./add-user.sh,做此步时不用停 EAP Server
(6)访问 http://localhost:9990/,点击Try again,输入管理员账户口令
(7)介绍 Management Console 基本功能:
         Runtime Tab -> Overview -> SERVER
                              -> Overview -> EXTENSIONS
                              -> System Status -> Platform -> JVM ...
         Configuration Tab -> Subsystems -> Core -> Logging ...
         Configuration Tab -> Subsystems -> Core -> Logging -> LOG CATEGORIES...
           新增 org.jboss.as.clustering,DEBUG log level。
                                      -> Subsystems -> Core -> Deployment Scanners ...
         Configuration Tab -> General Configuration -> Interfaces ...
         Configuration Tab -> General Configuration -> Socket Binding ...
(8)访问 http://[IP_ADDRESS]:9990/,访问出错,提示“无法显示此页”。
(9)./standalone.sh -Djboss.bind.address.management=[IP_ADDRESS] 或 ./standalone.sh -bmanagement [IP_ADDRESS]
(10)./standalone.sh -Djboss.bind.address=[IP_ADDRESS] 或 ./standalone.sh -b [IP_ADDRESS]
注意,jboss.bind.address 可以设置 0.0.0.0,表示机器上的所有 IP 地址都可以访问。
(11)停止 EAP  Server
(12)安装后目录介绍
(13)介绍配置文件:standalone.xml
           <interfaces> 定义 IP 地址。
           <socket-binding-group > 定义端口。
           <management> 决定哪些 interface 可以使用。

2. 概念理解:Extensions,Subsystems,Profiles

2.1 Extensions
(1)EAP 6 的所有功能特性(部署、Server配置、Java EE)都是在核心功能的基础上通过 Extensions 扩展实现的(以 module 的方式)。
(2)每个 extension 提供的具体功能特性在其对应的 subsystem 中配置。
(3)一个 extension 也可以定义多个 subsystem,但大多数 extension 只定义一个 subsystem。
(4)extension 是以 module 的方式发布的,extension 扩展了 EAP 6 的核心功能,比如:Java EE,clustering,transactions,security,logging 等等。
(5)可以根据需要开启或关闭这些 extension 功能,可以删除 extension 及其对应的subsystem,或者使用 CLI 将其 disable。
(6)extension 部署在 EAP 6 的 modules 目录下,并且有一个 jar 文件以及对应的 XML 配置文件:module.xml。

2.2 Subsystems
(1)subsystem 不可以具体配置 在 extension 中没有的定义。
(2)extension 只是说具有了某个功能特性,但这个功能到底如何使用还是要看该 extension 对应的subsystem中的具体配置。

2. 3 Profiles
(1)一个 profile 就是多个 subsystem 的集合。
(2)EAP 6 开箱提供4个 profile:default,ha,full,full-ha。
(3)可以定制自己的 profile。
(4)Standalone Mode 只能有一个 profile,所以无需命名,Domain Mode 可以有多个 profile。

2. 创建定制的 Standalone EAP
(1)mkdir myeap
(2)cp -r ./jboss-eap-6.4/standalone/configuration ./jboss-eap-6.4/standalone/deployments ./jboss-eap-6.4/standalone/lib myeap
(3)./standalone.sh -Djboss.server.base.dir=/Users/maping/Redhat/eap/demo/myeap -Djboss.socket.binding.port-offset=10000
注意,如果原来部署过应用,需要在standalone.xml中删除,并且在deployments目录下删除相关应用文件。
注意,只有端口不同的两个EAP 是共用一个配置文件,这样会导致互相覆盖,因此应该以 jboss.server.base.dir 来区分不同的 EAP Server。
(4)访问 http://localhost:19990/
         Runtime Tab -> System Status -> Platform -> Enviroment ...
         观察 jboss.home.dir = /Users/maping/Redhat/eap/demo/jboss-eap-6.4
                 jboss.server.base.dir = /Users/maping/Redhat/eap/demo/myeap
                 java.home = /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre
                 jboss.server.log.dir = /Users/maping/Redhat/eap/demo/myeap/log
(5)访问 http://localhost:18080/
(6)./standalone.sh -Djboss.server.base.dir=/Users/maping/Redhat/eap/demo/myeap -b [IP_ADDRESS] -Djboss.socket.binding.port-offset=10000
(7)访问 http://[IP_ADDRESS]:18080/
(8)./standalone.sh -Djboss.server.base.dir=/Users/maping/Redhat/eap/demo/myeap -b [IP_ADDRESS] -bmanagement [IP_ADDRESS] -Djboss.socket.binding.port-offset=10000

3. 部署应用

3.1 通过控制台部署 example.war 
(1)访问 http://localhost:18080/example/

3.2. 设置 example 为默认的Web应用。
(1)cp standalone.xml standalone-root-web.xml
(2)修改 standalone-root-web.xml,注意修改前,要停止 EAP Server
(3)./standalone.sh -Djboss.server.base.dir=/Users/maping/Redhat/eap/demo/myeap -c standalone-root-web.xml -Djboss.socket.binding.port-offset=10000
(4)如果没有部署 example.war,现在通过控制台部署 example.war
(5)访问 http://localhost:18080/,注意这次不是访问 http://localhost:18080/example/
注意:一旦把 example 设置为 Root Web Application 后,就不能用原来的 context path 访问 example 了。

4. 按目录方式部署应用 version.war 目录,注意这是个目录
(1)./standalone.sh -Djboss.server.base.dir=/Users/maping/Redhat/eap/demo/myeap -Djboss.socket.binding.port-offset=10000
(2)cp -r version.war ../myeap/deployments/
(3)cp version.war.dodeploy ../myeap/deployments/
(4)访问 http://localhost:18080/version/
这里可以学习,如何获取并显示JBoss EAP Server 版本信息
(5)直接修改 index.jsp 文件,1.0 改为 2.0
(6)touch version.war.dodeploy
(7)http://localhost:18080/version/
(8)卸载 version.war,只需执行 rm version.war.deployed,过一会会自动生成一个文件:version.war.undeployed
(9)访问 http://localhost:18080/version/ 会报告404错误

5. 禁止自动部署 example.war 文件,注意这是个文件
(1)如果已经部署了 example.war,请先卸载。
(2)./standalone.sh -Djboss.server.base.dir=/Users/maping/Redhat/eap/demo/myeap -Djboss.socket.binding.port-offset=10000
(3)cp example.war ../myeap/deployments/,会自动部署成功,并且生成 example.war.deployed 文件
(4)http://localhost:18080/example/
(5)rm example.war,会自动卸载掉 example 应用,过一会会自动生成一个文件:example.war.undeployed
(6)rm example.war.undeployed
(7)touch example.war.skipdeploy
(8)cp example.war ../myeap/deployments/,这次不会自动部署
(9)mv example.war.skipdeploy example.war.dodeploy,再次部署

没有评论: