一些j2ee知识
 
 WAS是典型的j2ee服务器,在开始WAS之前,了解一些j2ee的知识.
 
 J2EE全称为Java2 Platform  Enterprise Edition
 
 J2EE平台本质上是一个分布式的服务器应用程序设计环境——一个Java环境,它提供了:
 
 宿主应用的一个运行基础框架环境。一套用来创建应用的Java扩展API。
 
 大体上J2EE可以分成3个主要应用:Servlet/JSP,EJB,XML/Web Service 和一些支撑技术例如JDBC和JNDI.
 
 Servlet是运行在Web服务器上的程序,主要是处理Http(s)请求并作出响应,包括返回一个HTML页面或转交给其他URL处理。在来自Web浏览器或其他HTTP客户机的请求与HTTP服务器上的数据库或应用程序之间起一个中间层的作用。
 
 JSP(JavaServer Pages)是一种基于Java的脚本技术。在JSP 的众多优点之中,其中之一是它能将 HTML 编码从 Web 页面的业务逻辑中有效地分离出来。用 JSP 访问可重用的组件,如 Servlet、JavaBean 和基于 Java 的 Web 应用程序。JSP 还支持在 Web 页面中直接嵌入 Java 代码。最终会编译成class。
 
 EJB,全称Enterprise Java Bean。EJB 从技术上而言不是一种"产品" ,而是一个技术规范。
 
 一个ejb是由java开发的,可以部署的,服务器端的组件.其包括
 
 若干.java程序,
 
 一个xml格式的部署文件,
 
 一个j2ee容器的专门部署文件。
 
 EJB程序经过部署,在weblogic等容器上运行,自动实现中间件的特性
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 3.WAS相关概念
 
 概要文件profile、应用服务器server、节点node、单元cell
 
 
 
 
 Profile是WAS 6.0版本之后才有的。其目的是将WAS本身的文件与用户的数据文件从物理上分离,加强管理,减少出错的可能性。安装好WAS之后不能直接来部署应用,首先要根据情况新建不同类型的Profile 。
 
 Profile类型:default、dmgr、managed
 
 default为默认的profile类型,单server模式中使用。
 
 Dmgr、managed 类型在集群模式中使用,不同的是dmgr是Deployment Manager 为分布式单元的所有元素的管理中心,而managed受dmgr管控,其本质上是节点node。
 
 
 
 
 Server是最小的处理单元
 
 Node是一个或者多个Server的分组,Node只能在一台物理机器上存在,不能跨机器
 
 Node基本上等同于Profile,Node是管理概念,而Profile是实际的概要文件
 
 Cell是一个或者多个Node的分组,是最大作用域。
 
 Cell保留它所管辖的所有Node的配置,Node的配置以Cell的配置为准。
 
 NodeAgent:在集群环境下,DM(Deployment Manager Server )可以透过NodeAgent对Node中的Server进行管理
 
 如果不是集群环境,则一个Node下面只能有一个Server,可以创建多个profile来做到单机多server。
 
 如图
 
 ![微博桌面截图_20140417161658.jpg wKiom1NPjs2BSwulAADSaLFu9Ag209.jpg]()
 
 4、was应用服务器搭建
 
 4.1 创建集群环境profile
 
 新建一个WAS(AIX)
 
 以建立TDCS的控制台为例
 
 在/usr/WebSphere/AppServer/bin下,有wasprofile.sh 脚本。
 
 如果是window,则为wasprofile.bat。
 
 4.1.1编辑好端口文件
 
 如ports.dmgr 内容如下:
 
 WC_defaulthost=39083
 
 WC_adminhost=39063
 
 WC_defaulthost_secure=39446
 
 WC_adminhost_secure=39046
 
 BOOTSTRAP_ADDRESS=39812
 
 SOAP_CONNECTOR_ADDRESS=38882
 
 SAS_SSL_SERVERAUTH_LISTENER_ADDRESS=39407
 
 CSIV2_SSL_SERVERAUTH_LISTENER_ADDRESS=39417
 
 CSIV2_SSL_MUTUALAUTH_LISTENER_ADDRESS=39427
 
 ORB_LISTENER_ADDRESS=39122
 
 CELL_DISCOVERY_ADDRESS=37280
 
 DCS_UNICAST_ADDRESS=39355
 
 其中,adminhost\SOAP端口后续的dmgr、managed中会使用到。
 
 4.1.2创建dmgr
 
 语法:
 
wasprofile.sh -create 
 
              -profileName profile_name
 
              -profilePath fully_qualified_profile_path
 
              -templatePath template_path
 
              -nodeName node_name
 
              -cellName cell_name
 
              -hostName host_name
 
              -server  iSeries_server_name
 
             [-startingPort starting_port | -portsFile filepath]
 
              -winserviceCheck true | false
 
              -winserviceAccountType specifieduser | localsystem
 
              -winserviceUserName yourusername
 
              -winservicePassword yourpassword
 
              -winserviceStartupType manual | automatic | disabled
 
             [-debug] 
 
 
 
 
 如:
 
    ./wasprofile.sh \
 
 -create \
 
 -profileNameDmgr_TDCS \
 
 -profilePath/usr/WebSphere/AppServer/profiles/Dmgr_TDCS \
 
 -templatePath/usr/WebSphere/AppServer/profileTemplates/dmgr \
 
 -nodeName Dmgr_TDCS \
 
 -cellName Cell_TDCS \
 
 -hostName S1_C_CS_GC \
 
 -portsFile/usr/WebSphere/AppServer/bin/TDCS.ports
 
 
 
 
 其中nodeName, cellName 要不一致
 
 
 
 
 创建成功后,会提示
 
 ./wasprofile.sh \
 
 -create \
 
 -profileName Dmgr_TDCS \
 
 -profilePath/usr/WebSphere/AppServer/profiles/Dmgr_TDCS \
 
 -templatePath/usr/WebSphere/AppServer/profileTemplates/dmgr \
 
 -nodeName Dmgr_TDCS \
 
 -cellName Cell_TDCS \
 
 -hostName S1_C_CS_GC \
 
 -portsFile/usr/WebSphere/AppServer/bin/TDCS.ports
 
 INSTCONFSUCCESS:Success: The profile now exists.
 
 
 
 
 4.1.2创建manged
 
语法
 
wasprofile.sh -create 
 
              -profileName profile_name
 
              -profilePath fully_qualified_profile_path
 
              -templatePath template_path
 
              -nodeName node_name
 
              -cellName cell_name
 
              -hostName host_name
 
              -server  iSeries_server_name
 
             [-startingPort starting_port | -portsFile filepath]
 
              -winserviceCheck true | false
 
              -winserviceAccountType specifieduser | localsystem
 
              -winserviceUserName yourusername
 
              -winservicePassword yourpassword
 
              -winserviceStartupType manual | automatic | disabled
 
            [-debug]
 
如: 
 创建Cluster_2_TDCS
 
 ./wasprofile.sh\
 
 -create \
 
 -profileName Cluster_2_TDCS \
 
 -profilePath  /usr/WebSphere/AppServer/profiles/Cluster_2_TDCS\
 
 -templatePath  /usr/WebSphere/AppServer/profileTemplates/managed\
 
 -nodeNameNode2_TDCS \
 
 -cellNameCell_TDCS2 \
 
 -hostName S1_C_CS_GC
 
 
 
 
 执行完毕之后,提示successful
 
 ./wasprofile.sh \
 
 -create \
 
 -profileName Cluster_2_TDCS \
 
 -profilePath/usr/WebSphere/AppServer/profiles/Cluster_2_TDCS \
 
 -templatePath/usr/WebSphere/AppServer/profileTemplates/managed \
 
 -nodeName Node2_TDCS \
 
 -cellName Cell_TDCS \
 
 -hostName S1_C_CS_GC
 
 INSTCONFSUCCESS: Success: The profile nowexists.
 
 
 
 
 注意,nodename,cellname要不一致。
 
 
 
 
 完成之后,在/usr/WebSphere/AppServer/profiles
 
 可以看到Dmgr_TDCS、Cluster_2_TDCS文件夹。
 
 
 
 
 4.1.2启动Dmgr
 
 在/usr/WebSphere/AppServer/profiles/bin目录下,
 
启动脚本
./StartManger.sh
脚本,提示成功。 
 4.1.2将managed加入Dmgr管理
 
 在/usr/WebSphere/AppServer/profiles/ Cluster_1_TDCS/bin
 
 目录下,提示成功
 
 执行addNode.sh  dmgr主机 soap端口,
 
 ./addNode.sh  10.244.147.19938882
 
 ADMU0116I: Tool information is being logged in file
 
          /usr/WebSphere/AppServer/profiles/Cluster_1_TDCJ/logs/addNode.log
 
 ADMU0128I: Starting tool with the Cluster_1_TDCJ profile
 
 ADMU0001I: Begin federation of node Node1_TDCJ with Deployment Managerat
 
          10.244.147.199:38882.
 
 ADMU0001I: Begin federation of node Node1_TDCJ with DeploymentManager at
 
          10.244.147.199:38882.
 
 ADMU0009I: Successfully connected to Deployment Manager Server:
 
          10.244.147.199:38882
 
 ADMU0507I: No servers found in configuration under:
 
          /usr/WebSphere/AppServer/profiles/Cluster_1_TDCJ/config/cells/Cell_TDCJ1/nodes/Node1_TDCJ/servers
 
 ADMU2010I: Stopping all server processes for node Node1_TDCJ
 
 ADMU0024I: Deleting the old backup directory.
 
 ADMU0015I: Backing up the original cell repository.
 
 ADMU0012I: Creating Node Agent configuration for node: Node1_TDCJ
 
 ADMU0014I: Adding node Node1_TDCJ configuration to cell: Cell_TDCJ
 
 ADMU0016I: Synchronizing configuration between node and cell.
 
 ADMU0018I: Launching Node Agent process for node: Node1_TDCJ
 
 ADMU0020I: Reading configuration for Node Agent process: nodeagent
 
 ADMU0022I: Node Agent launched. Waiting for initialization status.
 
 ADMU0030I: Node Agent initialization completed successfully. Processid is:
 
           2850914
 
 ADMU9990I:
 
 ADMU0300I: Congratulations! Your node Node1_TDCJ has beensuccessfully
 
           incorporated intothe Cell_TDCJ cell.
 
 ADMU9990I:
 
 ADMU0306I: Be aware:
 
 ADMU0302I: Any cell-level documents from the standalone Cell_TDCJ1
 
           configuration havenot been migrated to the new cell.
 
 ADMU0307I: You might want to:
 
 ADMU0303I: Update the configuration on the Cell_TDCJ DeploymentManager with
 
           values from the oldcell-level documents.
 
 ADMU9990I:
 
 ADMU0306I: Be aware:
 
 ADMU0304I: Because -includeapps was not specified, applicationsinstalled on
 
           the standalone nodewere not installed on the new cell.
 
 ADMU0307I: You might want to:
 
 ADMU0305I: Install applications onto the Cell_TDCJ cell usingwsadmin $AdminApp
 
           or theAdministrative Console.
 
 ADMU9990I:
 
 ADMU0003I: Node Node1_TDCJ has been successfully federated.
 
 至此,创建部分完成。
 
 
 
 
 4.1创建单机环境profile
 
 4.2.1创建profile的命令:
 
              wasprofile.sh  -create
 
                        -profileNameprofile_name
 
                        -profilePathfully_qualified_profile_path
 
                        -templatePathtemplate_path
 
                        -nodeName node_name
 
                        -cellName cell_name
 
                        -hostName host_name
 
                        -server  iSeries_server_name
 
                       [-startingPortstarting_port | -portsFile filepath]
 
                        -winserviceCheck true |false
 
                        -winserviceAccountTypespecifieduser | localsystem
 
                        -winserviceUserNameyourusername
 
                        -winservicePasswordyourpassword
 
                        -winserviceStartupTypemanual | automatic | disabled
 
                       [-debug]
 
 单机环境的-templatePath参数,为default。
 
 如:
 
              ./wasprofile.sh\
 
                     -create-profileName test4sop \
 
                     -profilePath/websphere/AppServer/profiles/test4sop \
 
                     -templatePath/websphere/AppServer/profileTemplates/default \
 
                     -nodeNametest4sopnode \
 
                     -cellNametest4sopcell \
 
                     -hostNameS2_E_YZ_JKCS
 
 4.2.2启动server
 
 cd /websphere/AppServer/profiles/test4sop
 
 cd bin
 
 ./startServer.sh server1
 
 
 
 
 
 
 
 4.3删除概要文件
 
 当一个概要文件损毁,或者发生迁移时,需要删除原有的概要文件。
 
 要删除一个概要,必须按下列方法操作:
 
 4.3.1 移除一个已经与某个单元联合的自定义概要或应用程序服务器概要
 
 1.停止节点上的应用程序服务器。
 
 2.使用管理控制台或 removeNode 命令,将节点从单元中移除。移除一个节点并不会删除它,只是使它恢复到联合前的配置,该配置以前是作为联合过程的一部分予以保存的。
 
 3.使用 wasprofile -delete 删除概要。
 
 4.使用 wasprofile -validateAndUpdateRegistry 命令清除概要注册中心。
 
 5.删除 <profile_home> 目录。
 
 4.3.2 移除一个未与某个单元联合的应用程序服务器概要
 
 1.停止应用程序服务器。
 
 2.使用 wasprofile -delete 删除概要。
 
 3.使用 wasprofile  -validateAndUpdateRegistry 命令清除概要注册中心。
 
 4.删除 <profile_home> 目录。
 
 4.3.3 移除某个部署管理器概要
 
 使用管理控制台或 removeNode 命令,移除与单元联合的所有节点。移除一个节点并不会删除它,只是使它恢复到联合前的配置,该配置以前是作为联合过程的一部分予以保存的。
 
 1.停止部署管理器。
 
 2.使用 wasprofile -delete 删除概要。
 
 3.使用 wasprofile -validateAndUpdateRegistry 命令清除概要注册中心。
 
 4.删除 <profile_home> 目录。
 
 用 wasprofile删除一个概要
 
 要删除一个概要,请使用 wasprofile -delete 命令。其格式是:
 
 wasprofile -delete -profileName <profile>
 
 当该命令完成后,概要将从概要注册中心中移除,除了日志文件之外的运行时组件也将从 <profile_home> 目录中移除。
 
 如果在删除概要时出现了错误,请检查下列日志: <was_home>/logs/manageprofile/<profile_name>_delete.log
 
 注意:如果在删除过程中出现问题,可以手动删除概要。
 
 
 
 
 
 
 
 5、 was资源配置
 
 以营帐中使用到的资源为例。
 
 打开控制台页面,
 
 http://localhost:39063/admin
 
 完成数据源配置,应用发布等工作。
 
 
 
 
 5.1 新建server
 
 检查节点,节点已经存在