一些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。
如圖

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
檢查節點,節點已經存在