IBM WebSphere 9.0.5 笔记大全

9 篇文章 0 订阅
7 篇文章 0 订阅

IBM WebSphere note

author: joey_lee

Docker安裝WebSphere

拉取websphere镜像:

docker pull  ibmcom/websphere-traditional:9.0.5.9

使用镜像生成容器并且启动容器:

docker run --name websphere9.0.5.9 -h websphere -e UPDATE_HOSTNAME=true -p 9043:9043 -p 9443:9443 -p 9080:9080 --restart=always -d ibmcom/websphere-traditional:9.0.5.9

 docker run   #启动容器的命令,后面跟各种参数 + 容器镜像信息
 --name websphere   #指定启动的容器名为 websphere
 -e UPDATE_HOSTNAME=true    #访问websphere的ip不是localhost时需要此参数
 -p 9043:9043     #指定访问端口号
 -d ibmcom/websphere-traditional:8.5.5.12-profile   #后台运行该镜像生成的容器

查看生成登录的密码:

 docker exec websphere9.0.5.9 cat /tmp/PASSWORD

通过浏览器访问websphere:

 https://127.0.0.1:9043/ibm/console/login.do?action=secure
 127.0.0.1    #当前虚拟机的ip地址(每个人的都不一样)
 9043   #设定访问websphere的端口号

登录的账号密码

 账号 :    wsadmin
 密码 :    T52Rp3Mm  (就是前面使用 docker exec websphere cat /tmp/PASSWORD 命令输出的内容,每个人的都不一样)

提示

 如果忘记了websphere的密码,可以使用docker exec websphere cat /tmp/PASSWORD 命令来查看登录该容器的密码,账号都统一为 wsadmin。 (websphere为容器名)

 如果容器启动不正常,可以使用 docker logs -f websphere 命令来查看容器启动的日志信息,确定错误原因。(websphere为容器名)
docker exec websphere9.0.5.9 cat /tmp/PASSWORD

Docker-Compose安裝WebSphere

文件示例

version: '3'
services:
  was:
    # 镜像
    image: "ibmcom/websphere-traditional:latest"
    #端口映射
    ports:
      - "9043:9043"
      - "9443:9443"
      - "9080:9080"
      - "9060:9060"
      - "8880:8880"
      - "9403:9403"
      # 绑定与宿主机的目录
    volumes:
      - /data/was:/data/was

启动

cd /data/was
docker-compose up

后台启动

docker-compose up -d

查看密码

管理控制台用户 ID 默认为wsadmin,初始 wsadmin 用户密码为/tmp/PASSWORD

docker-compose exec was cat /tmp/PASSWORD

进入终端

docker exec -it was_was_1 /bin/bash

windows命令(管理员运行)

储存库密码

admin
123@163.com

进入bin目录

cd C:\Program Files\IBM\WebSphere\AppServer\bin

WAS操作

进入bin目录

C:
cd  /d  C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\bin

启动Was

startServer server1 -profileName AppSrv01

如下所示,表示启动成功:

C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\bin>startServer server1 -profileName AppSrv01
ADMU0116I: 正在文件 C:\Program
           Files\IBM\WebSphere\AppServer\profiles\AppSrv01\logs\server1\startServer.log
           中记录工具信息
ADMU0128I: 正在启动具有 AppSrv01 概要文件的工具
ADMU3100I: 正在从服务器读取配置:server1
ADMU3200I: 服务器已启动。正在等待初始化状态。
ADMU3000I: 为电子商务开放服务器 server1;进程标识为 7068

停止Was

stopServer server1 -profileName AppSrv01 -user admin -password admin

注:

-user <名称>
如果在服务器中启用了安全性,则指定用于身份验证的用户名。作用与 -username 选项相同。
-password <密码>
如果在服务器中启用了安全性,则指定用于身份验证的密码。

重启Was

stopServer server1
startServer server1

查看状态

serverStatus server1 -user admin -password admin

查看版本

C:
cd C:\Program Files\IBM\WebSphere\AppServer\bin
versionInfo.bat

示例结果

C:\Program Files\IBM\WebSphere\AppServer\bin>serverStatus server1 -user admin -password admin
ADMU0116I: 正在文件 C:\Program
           Files\IBM\WebSphere\AppServer\profiles\AppSrv01\logs\server1\serverStatus.log
           中记录工具信息
ADMU0128I: 正在启动具有 AppSrv01 概要文件的工具
ADMU0500I: 正在检索 server1 的服务器状态
ADMU0508I: Application Server“server1”处于 STARTED 状态

使用wasdeploy

C:\Program Files\IBM\WebSphere\AppServer\bin\wsadmin.bat -user admin -password admin -f E:\Work\forward-server-jndi.jacl

maven打包

E:
cd E:\Work\code\gitlab\pbhk\mbk-server\common
mvn install -U --settings E:\Work\code\gitlab\pbhk\mbk-server\document\maven\settings.xml -Dmaven.test.skip=true
cd E:\Work\code\gitlab\pbhk\mbk-server\common\common-call
mvn install -U --settings E:\Work\code\gitlab\pbhk\mbk-server\document\maven\settings.xml -Dmaven.test.skip=true
cd E:\Work\code\gitlab\pbhk\mbk-server\common\common-call-test
mvn install -U --settings E:\Work\code\gitlab\pbhk\mbk-server\document\maven\settings.xml -Dmaven.test.skip=true
cd E:\Work\code\gitlab\pbhk\mbk-server\common\common-call-test-jndi
mvn package -U --settings E:\Work\code\gitlab\pbhk\mbk-server\document\maven\settings.xml -Dmaven.test.skip=true

根据jacl命名脚本文件启动

安装应用

C:
cd C:\Program Files\IBM\WebSphere\AppServer\bin
wsadmin.bat -user admin -password admin -f "E:\Work\websphere application server\common-call-test-jndi\common-call-test-jndi_install.jacl"

注:

user 用户名
password 密码
f 指定jacl文件

更新应用

C:
cd C:\Program Files\IBM\WebSphere\AppServer\bin
wsadmin.bat -user admin -password admin -f "E:\Work\websphere application server\common-call-test-jndi\common-call-test-jndi_update.jacl"

注:

user 用户名
password 密码
f 指定jacl文件

WebSphere 控制台页面

https://localhost:9043/ibm/console/logon.jsp

用户名/密码

admin/admin

查看日志

#查看应用日志

cd C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\logs\server1
cat TextLog_22.06.23_00.44.18_server1.log 

测试接口路径

http://localhost:8081/http/v1/testJNDI

was路径

http://localhost:9080/common-call-test-jndi/http/v1/testJNDI

Linux命令

进入docker

docker exec -it websphere9.0.5.9 /bin/bash

查找安装目录

-type d:查找目录。

find / -type d -name WebSphere

WAS操作

进入bin目录

cd /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin

启动Was

startServer.sh server1 -profileName AppSrv01

如下所示,表示启动成功:

ADMU0116I: 正在文件 C:\Program
           Files\IBM\WebSphere\AppServer\profiles\AppSrv01\logs\server1\startServer.log
           中记录工具信息
ADMU0128I: 正在启动具有 AppSrv01 概要文件的工具
ADMU3100I: 正在从服务器读取配置:server1
ADMU3200I: 服务器已启动。正在等待初始化状态。
ADMU3000I: 为电子商务开放服务器 server1;进程标识为 7068

停止Was

stopServer.sh server1 -profileName AppSrv01 -user admin -password admin

注:

-user <名称>
如果在服务器中启用了安全性,则指定用于身份验证的用户名。作用与 -username 选项相同。
-password <密码>
如果在服务器中启用了安全性,则指定用于身份验证的密码。

重启Was

stopServer.sh server1
startServer.sh server1

查看状态

serverStatus.sh server1 -user wsadmin -password pwd

输出

[was@websphere bin]$ serverStatus.sh server1 -user wsadmin -password pwd
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/server1/serverStatus.log
ADMU0128I: Starting tool with the AppSrv01 profile
ADMU0500I: Retrieving server status for server1
ADMU0508I: The Application Server "server1" is STARTED

查看版本

versionInfo.sh

示例结果

[was@websphere bin]$ versionInfo.sh 
WVER0010I: Copyright (c) IBM Corporation 2002, 2012; All rights reserved.
WVER0012I: VersionInfo reporter version 1.15.1.48, dated 2/8/12

--------------------------------------------------------------------------------
IBM WebSphere Product Installation Status Report
--------------------------------------------------------------------------------

Report at date and time September 1, 2022 8:54:16 AM UTC

Installation
--------------------------------------------------------------------------------
Product Directory        /opt/IBM/WebSphere/AppServer
Version Directory        /opt/IBM/WebSphere/AppServer/properties/version
DTD Directory            /opt/IBM/WebSphere/AppServer/properties/version/dtd
Log Directory            /opt/IBM/WebSphere/AppServerIMData/logs

Product List
--------------------------------------------------------------------------------
JAVA8                    installed
BASE                     installed

Installed Product
--------------------------------------------------------------------------------
Name            IBM SDK, Java Technology Edition, Version 8
Version         8.0.7.6
ID              JAVA8
Build Level     pxa6480sr7fp6-20220330_01
Build Date      03/30/22
Architecture    x86-64 (64 bit)

Installed Product
--------------------------------------------------------------------------------
Name                  IBM WebSphere Application Server
Version               9.0.5.9
ID                    BASE
Build Level           f5092134.01
Build Date            8/23/21
Package               com.ibm.websphere.ILAN.v90_9.0.5009.20210823_0038
Architecture          x86-64 (64 bit)
Installed Features    WebSphere Application Server traditional
                      EJBDeploy tool for pre-EJB 3.0 modules
                      Embeddable EJB container
                      Stand-alone thin clients and resource adapters

--------------------------------------------------------------------------------
End Installation Status Report
--------------------------------------------------------------------------------

使用wasdeploy

wsadmin.sh -user admin -password admin -f E:\Work\forward-server-jndi.jacl

查看日志

#查看应用日志

cd /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/server1
cat SystemOut.log

控制台查看日志

https://www.ibm.com/support/pages/how-view-logging-information-inside-websphere-application-server

Jython

wsadmin 工具支持两种脚本语言:Jacl 和 Jython。使用脚本时有五个对象可用:

  • AdminControl:用于运行操作命令。
  • AdminConfig:用于运行配置命令以创建或修改 WebSphere Application Server 配置元素。
  • AdminApp:用于管理应用程序。
  • AdminTask:用于运行管理命令。
  • 帮助:用于获得一般帮助。

进入控制台

cd /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin
wsadmin.sh -user wsadmin -password pwd
cd /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin
wsadmin.sh -user admin1 -password admin1

使用 wsadmin 脚本的 AdminConfig 对象的命令

https://www.ibm.com/docs/en/was-nd/9.0.5?topic=scripting-commands-adminconfig-object-using-wsadmin

使用 wsadmin 脚本的 AdminApp 对象的命令

https://www.ibm.com/docs/en/was-nd/9.0.5?topic=scripting-commands-adminapp-object-using-wsadmin

使用 wsadmin 脚本的 AdminTask 对象的命令

https://www.ibm.com/docs/en/was-nd/9.0.5?topic=scripting-commands-admintask-object-using-wsadmin

AdminConfig 命令参考

wsadmin>print AdminConfig.help()
WASX7053I: The AdminConfig object communicates with the Config Service in a
        WebSphere server to manipulate configuration data for a WebSphere
        installation.  AdminConfig has commands to list, create, remove,
        display, and modify configuration data, as well as commands to display
        information about configuration data types.

        Most of the commands supported by AdminConfig operate in two modes:
        the default mode is one in which AdminConfig communicates with the
        WebSphere server to accomplish its tasks.  A local mode is also
        possible, in which no server communication takes place.  The local
        mode of operation is invoked by bringing up the scripting client with
        no server connected using the command line "-conntype NONE" option
        or setting the "com.ibm.ws.scripting.connectionType=NONE" property in
        the wsadmin.properties.

        The following commands are supported by AdminConfig; more detailed
        information about each of these commands is available by using the
        "help" command of AdminConfig and supplying the name of the command
        as an argument.

attributes      Shows the attributes for a given type
checkin         Checks a file into the configuration repository
convertToCluster
                Converts a server to be the first member of a new ServerCluster
create          Creates a configuration object, given a type, a parent, and
                a list of attributes, and optionally an attribute name for the
                new object
createClusterMember
                Creates a new server that is a member of an existing cluster
createDocument  Creates a new document in the configuration repository
createUsingTemplate
                Creates an object using a particular template type
defaults        Displays the default values for attributes of a given type
deleteDocument  Deletes a document from the configuration repository
existsDocument  Tests for the existence of a document in the configuration
                repository
extract         Extracts a file from the configuration repository
getCrossDocumentValidationEnabled
                Returns true if cross-document validation is enabled
getid           Shows the configuration ID of an object, given a string version
                of its containment
getObjectName   Given a configuration ID, returns a string version of the
                ObjectName for the corresponding running MBean, if any
getObjectType   Given a configuration ID, returns a string version of the
                object type
getSaveMode     Returns the mode used when "save" is invoked
getValidationLevel
                Returns the validation used when files are extracted from the
                repository.
getValidationSeverityResult
                Returns the number of messages of a given severity from the
                most recent validation
hasChanges      Returns true if unsaved configuration changes exist
help            Shows help information
installResourceAdapter
                Installs a J2C resource adapter with the given rar file name
                and an option string in the node
list            Lists all configuration objects of a given type
listTemplates   Lists all available configuration templates of a given type
modify          Changes specified attributes of a given configuration object
parents         Shows the objects which contain a given type
queryChanges    Returns a list of unsaved files
remove          Removes the specified configuration object
required        Displays the required attributes of a given type.
reset           Discards unsaved configuration changes
resetAttributes Resets value of the specified attributes.
save            Commits unsaved changes to the configuration repository
setCrossDocumentValidationEnabled
                Sets the cross-document validation enabled mode.
setSaveMode     Changes the mode used when "save" is invoked
setValidationLevel
                Sets the validation used when files are extracted from the
                repository.
show            Shows the attributes of a given configuration object
showall         Recursively shows the attributes of a given configuration
                object, and all the objects contained within each attribute.
showAttribute   Displays only the value for the single attribute specified.
types           Shows the possible types for configuration
uninstallResourceAdapter
                Uninstalls a J2C resource adapter with the given resource
                adapter configuration ID.
unsetAttributes Unsets value of the specified attributes.
validate        Invokes validation

AdminApp 命令参考

wsadmin>AdminApp.help()
u'WASX7095I: The AdminApp object allows application objects to be manipulated\n\t-- this includes installing, uninstalling, editing, and listing. Most\n\tof the commands supported by AdminApp operate in two modes: the default\n\tmode is one in which AdminApp communicates with the WebSphere server to\n\taccomplish its tasks.  A local mode is also possible, in which no\n\tserver communication takes place.  The local mode operation is invoked\n\tby bringing up the scripting client with no server connected using the\n\tcommand line "-conntype NONE" option tor setting the\n\t"com.ibm.ws.scripting.connectionType=NONE" property in the\n\twsadmin.properties.\n\n\tThe following commands are supported by AdminApp; more detailed\n\tinformation about each of these commands is available by using the\n\t"help" command of AdminApp and supplying the name of the command\n\tas an argument.\n\ndeleteUserAndGroupEntries \n\t\tDeletes all the user/group information for all the roles and\n\t\tall the user name/password information for RunAs roles for a\n\t\tgiven application\nedit\t\tEdits the properties of an application\neditInteractive\tEdits the properties of an application interactively\nexport\t\tExports application to a file\nexportDDL\tExports DDL from application to a directory\nexportFile\tExports content of a single file from an application to a file\ngetDeployStatus\tReturns the combined Deployment status of the application\nhelp\t\tShows help information\ninstall\t\tInstalls an application, given a file name and an option string\ninstallInteractive\n\t\tInstalls an application in interactive mode, given a file name\n\t\tand an option string\nisAppReady\tChecks whether the application is ready to be run\nlist\t\tLists all installed applications\nlistModules\tLists the modules in a specified application\noptions\t\tShows the options available, for a given file, application,\n\t\tor in general\nrenameApplication\tRename a given application\npublishWSDL\tPublishs WSDL files for a given application\nsearchJNDIReferences\n\t\tLists application that refers to the given JNDIName on a given\n\t\tnode\ntaskInfo\tShows detailed information pertaining to a given install task\n\t\tfor a given file\nuninstall\tUninstalls an application, given an application name and\n\t\tan option string\nupdate\t\tUpdates an installed application\nupdateAccessIDs\tUpdates the user/group binding information with accessID\n\t\tfrom user registry for a given application\nupdateInteractive\tUpdates an installed application interactively\nview\t\tViews an application or module, given an application or\n\t\tmodule name'
wsadmin>print AdminApp.help()
WASX7095I: The AdminApp object allows application objects to be manipulated
        -- this includes installing, uninstalling, editing, and listing. Most
        of the commands supported by AdminApp operate in two modes: the default
        mode is one in which AdminApp communicates with the WebSphere server to
        accomplish its tasks.  A local mode is also possible, in which no
        server communication takes place.  The local mode operation is invoked
        by bringing up the scripting client with no server connected using the
        command line "-conntype NONE" option tor setting the
        "com.ibm.ws.scripting.connectionType=NONE" property in the
        wsadmin.properties.

        The following commands are supported by AdminApp; more detailed
        information about each of these commands is available by using the
        "help" command of AdminApp and supplying the name of the command
        as an argument.

deleteUserAndGroupEntries 
                Deletes all the user/group information for all the roles and
                all the user name/password information for RunAs roles for a
                given application
edit            Edits the properties of an application
editInteractive Edits the properties of an application interactively
export          Exports application to a file
exportDDL       Exports DDL from application to a directory
exportFile      Exports content of a single file from an application to a file
getDeployStatus Returns the combined Deployment status of the application
help            Shows help information
install         Installs an application, given a file name and an option string
installInteractive
                Installs an application in interactive mode, given a file name
                and an option string
isAppReady      Checks whether the application is ready to be run
list            Lists all installed applications
listModules     Lists the modules in a specified application
options         Shows the options available, for a given file, application,
                or in general
renameApplication       Rename a given application
publishWSDL     Publishs WSDL files for a given application
searchJNDIReferences
                Lists application that refers to the given JNDIName on a given
                node
taskInfo        Shows detailed information pertaining to a given install task
                for a given file
uninstall       Uninstalls an application, given an application name and
                an option string
update          Updates an installed application
updateAccessIDs Updates the user/group binding information with accessID
                from user registry for a given application
updateInteractive       Updates an installed application interactively
view            Views an application or module, given an application or
                module name

AdminControl 命令参考

WASX7027I: The AdminControl object enables the manipulation of MBeans running
  in a WebSphere server process.  The number and type of MBeans available
  to the scripting client depends on the server to which the client is
  connected.  If the client is connected to a Deployment Manager, then
  all the MBeans running in the Deployment Manager are visible as are all
  the MBeans running in the Node Agents connected to this Deployment
  Manager, and all the MBeans running in the application servers on those
  nodes.

  The following commands are supported by AdminControl; more detailed
  information about each of these commands is available by using the
  "help" command of AdminControl and supplying the name of the command
  as an argument.

  Note that many of these commands support two different sets of
  signatures: one that accepts and returns strings, and one low-level
  set that works with JMX objects like ObjectName and AttributeList.
  In most situations, the string signatures are likely to be more useful,
  but JMX-object signature versions are supplied as well.  Each of these
  JMX-object signature commands has "_jmx" appended to the command name.
  Hence there is an "invoke" command, as well as a "invoke_jmx" command.

completeObjectName
       Returns a String version of an object name given a template
       name
getAttribute_jmx
       Given ObjectName and name of attribute, returns value of
       attribute
getAttribute Given String version of ObjectName and name of attribute,
       returns value of attribute
getAttributes_jmx
       Given ObjectName and array of attribute names, returns 
       AttributeList.
getAttributes   Given String version of ObjectName and attribute names,
       returns String of name value pairs. Given String version
       of ObjectName, returns String of all name value pairs.
getCell  Returns the cell name of the connected server 
getConfigId  Given String version of ObjectName, return a configuration
       ID for the corresponding configuration object, if any
getDefaultDomain
       Returns "WebSphere"
getDomainName   Returns "WebSphere"
getHost  Returns String representation of connected host
getMBeanCount   Returns number of registered beans
getMBeanInfo_jmx
       Given ObjectName, returns MBeanInfo structure for MBean
getNode  Returns the node name of the connected server 
getObjectInstance
       Given String version of ObjectName, returns ObjectInstance
       object that match.
getPort  Returns String representation of port in use
getType  Returns String representation of connection type in use
help    Shows help information
invoke_jmx   Given ObjectName, name of method, array of parameters and
       signature, invokes method on MBean specified
invoke  Invokes a method on the specified MBean
isRegistered_jmx
       Returns true if supplied ObjectName is registered
isRegistered Returns true if supplied String version of ObjectName is
       registered
makeObjectName  Returns an ObjectName built with the given string
queryNames_jmx  Given ObjectName and QueryExp, retrieves set of ObjectNames
       that match.
queryNames   Given String version of ObjectName, retrieves String of
       ObjectNames that match
queryMBeans  Given String version of ObjectName, returns a set of
       ObjectInstances object that match
reconnect    Reconnects with server
setAttribute_jmx
       Given ObjectName and Attribute object, sets attribute for MBean
       specified
setAttribute Given String version of ObjectName, attribute name and
       attribute value, sets attribute for MBean specified
setAttributes_jmx
       Given ObjectName and AttributeList object, sets attributes for
       the MBean specified
setAttributes   Given String version of ObjectName, attribute name
       and value pairs, sets attributes for the MBean specified
startServer  Given the name of a server, starts that server
stopServer   Given the name of a server, stops that server
testConnection  Tests the connection to a DataSource object
trace   Sets the wsadmin trace specification

用户操作

控制台操作

左侧 Users and Groups

搜索用户

样本

要搜索具有主体名称的所有用户,请发出以下命令:

AdminTask.searchUsers(['-principalName', '*'])

输出

wsadmin>AdminTask.searchUsers(['-principalName', '*'])
u'uid=admin1,o=defaultWIMFileBasedRealm\nuid=wsadmin,o=defaultWIMFileBasedRealm'

要搜索具有以字母“d”开头的 uid 的所有用户,请发出以下命令:

AdminTask.searchUsers(['-uid', 'd*'])

输出

wsadmin>AdminTask.searchUsers(['-uid', '*'])
u'uid=wsadmin,o=defaultWIMFileBasedRealm'

创建用户

要求不得出现共用特权管理账号,管理账号必须按角色分配用户角色为 monitor(监控员)、Configurator(配置员)、Operator(操作员)Administrator(管理员) 之一

参数

  • -uid uid

    指定要创建的用户的唯一 ID。Virtual member manager 然后为用户创建一个 uniqueId 值和一个 uniqueName 值。此参数映射到虚拟成员管理器中的 uid 属性。

  • -password密码

    指定用户的密码。此参数映射到 virtual member manager 中的密码属性。

  • -confirmPassword密码

    再次指定密码以验证它是如何在密码参数中输入的。此参数映射到 virtual member manager 中的密码属性。

  • -cn通用名

    指定用户的名字或名字。此参数映射到虚拟成员管理器中的 cn 属性。

  • -sn姓氏

    指定用户的姓氏或姓氏。此参数映射到 virtual member manager 中的 sn 属性。

  • **-**mail邮件

    指定用户的电子邮件地址。此参数映射到 virtual member manager 中的 ibm-PrimaryEmail 属性。

  • -parent*父母*

    指定要在其中创建用户的存储库。此参数映射到 virtual member manager 中的 parent 属性。

  • -securityDomainName域名

    指定唯一标识安全域的名称。如果不指定此参数,则该命令使用全局联合存储库。

样本

要创建一个名为 Dan Meyers 的用户,其唯一 ID 为 dmeyers,电子邮件地址为 dmeyers@acme.com,密码为 tempPass,请发出以下命令:

$AdminTask createUser {-uid dmeyers -password admin1 -confirmPassword admin1
                         -cn admin1 -sn admin1 -mail dmeyers@acme.com}

示例:

AdminTask.createUser(['-uid', 'admin1', '-password', 'admin1', '-confirmPassword', 'admin1', '-cn', 'administrator', '-sn', 'administrator'])

输出

u'uid=administrator,o=defaultWIMFileBasedRealm'

删除用户

参数

  • -uniqueName 唯一名称

    指定要删除的用户的唯一名称值。此参数映射到 virtual member manager 中的 uniqueName 属性。

  • -securityDomainName域名

    指定唯一标识安全域的名称。如果不指定此参数,则该命令使用全局联合存储库。

样本

要删除唯一名称为 uid=dmeyers,cn=users,dc=yourco,dc=com 的用户 Dan Meyers,请发出以下命令:

$AdminTask deleteUser {-uniqueName uid=dmeyers,cn=users,dc=yourco,dc=com}

示例:

AdminTask.deleteUser ('[-uniqueName uid=admin1,cn=administrator1,dc=yourco,dc=com]')
AdminTask.deleteUser ('[-uniqueName uid=admin1,o=defaultWIMFileBasedRealm]')

输出

u'uid=administrator,o=defaultWIMFileBasedRealm'

将用户设置为管理员

AdminTask.mapUsersToAdminRole('[-roleName administrator -userids uid=admin1,o=defaultWIMFileBasedRealm]')

配置JMS、MQ

配置队列连接工厂

获取节点和单元标识符
AdminConfig.getid("/Node:DefaultNode01")

输出

wsadmin>AdminConfig.getid("/Node:DefaultNode01")
u'DefaultNode01(cells/DefaultCell01/nodes/DefaultNode01|node.xml#Node_1)'
wsadmin>
创建工厂
创建请求连接工厂,指定节点、JNDI名称
AdminTask.createWMQConnectionFactory("DefaultNode01(cells/DefaultCell01/nodes/DefaultNode01|node.xml#Node_1)", ["-name esb_req_factory -jndiName 'jms/cf/esb_req_factory' -type CF -description 'lee`s req_factory' -qmgrName ESB_REQ -qmgrHostname 127.0.0.1 -qmgrPortNumber 11517 -qmgrSvrconnChannel CHL_CONN"])
AdminConfig.save()

输出:

u'esb_req_factory(cells/DefaultCell01/nodes/DefaultNode01|resources.xml#MQConnectionFactory_1662098926715)'
创建响应连接工厂,指定节点、JNDI名称
AdminTask.createWMQConnectionFactory("DefaultNode01(cells/DefaultCell01/nodes/DefaultNode01|node.xml#Node_1)", ["-name esb_res_factory -jndiName 'jms/cf/esb_res_factory' -type CF -description 'lee`s res_factory' -qmgrName ESB_RES -qmgrHostname 127.0.0.1 -qmgrPortNumber 11518 -qmgrSvrconnChannel CHL_CONN"])  
AdminConfig.save()

输出:

u'esb_res_factory(cells/DefaultCell01/nodes/DefaultNode01|resources.xml#MQConnectionFactory_1662099030776)'

新建完成后,可在控制台 Resources-JMS-Connection factories 查看

创建队列
创建请求队列,指定节点、JNDI名称
AdminTask.createWMQQueue("DefaultNode01(cells/DefaultCell01/nodes/DefaultNode01|node.xml#Node_1)", ["-name esb_req -jndiName jms/queues/esb_req -queueName Q_ESB_LJ"]) 
AdminConfig.save()

输出:

u'esb_req(cells/DefaultCell01/nodes/DefaultNode01|resources.xml#MQQueue_1662099054288)'
创建响应队列,指定节点、JNDI名称
AdminTask.createWMQQueue("DefaultNode01(cells/DefaultCell01/nodes/DefaultNode01|node.xml#Node_1)", ["-name esb_res -jndiName jms/queues/esb_res -queueName Q_RCVR_LJ"]) 
AdminConfig.save()

输出:

u'esb_res(cells/DefaultCell01/nodes/DefaultNode01|resources.xml#MQQueue_1662099080480)'

更新

更新工厂
AdminTask.modifyWMQConnectionFactory("esb_req_factory(cells/DefaultCell01/nodes/DefaultNode01|resources.xml#MQConnectionFactory_1662108208851)", [" -description 'lee`s req_factory' -qmgrName QM_HBK_CLIENT -qmgrHostname 127.0.0.1 -qmgrPortNumber 11520 -qmgrSvrconnChannel CHL_CONN"]) 

AdminTask.modifyWMQConnectionFactory("esb_res_factory(cells/DefaultCell01/nodes/DefaultNode01|resources.xml#MQConnectionFactory_1662108208851)", [" -description 'lee`s res_factory' -qmgrName QM_HBK_SERVER -qmgrHostname 127.0.0.1 -qmgrPortNumber 11521 -qmgrSvrconnChannel CHL_CONN"]) 
更新队列
AdminTask.modifyWMQQueue("esb_req(cells/DefaultCell01/nodes/DefaultNode01|resources.xml#MQQueue_1662605238946)", ["-queueName Q_ESB_LJ"]) 

AdminTask.modifyWMQQueue("esb_res(cells/DefaultCell01/nodes/DefaultNode01|resources.xml#MQQueue_1662605238946)", ["-queueName Q_RCVR_LJ"]) 

查看

查看队列工厂
AdminTask.listWMQConnectionFactories("DefaultNode01(cells/DefaultCell01/nodes/DefaultNode01|node.xml#Node_1)") 

输出

u'esb_req_factory(cells/DefaultCell01/nodes/DefaultNode01|resources.xml#MQConnectionFactory_1662108208851)\nesb_res_factory(cells/DefaultCell01/nodes/DefaultNode01|resources.xml#MQConnectionFactory_1662605238475)'
查看队列
AdminTask.listWMQQueues("DefaultNode01(cells/DefaultCell01/nodes/DefaultNode01|node.xml#Node_1)") 

输出

u'esb_req(cells/DefaultCell01/nodes/DefaultNode01|resources.xml#MQQueue_1662605238946)\nesb_res(cells/DefaultCell01/nodes/DefaultNode01|resources.xml#MQQueue_1662605239088)'

删除

删除工厂
AdminTask.deleteWMQConnectionFactory("esb_req_factory(cells/DefaultCell01/nodes/DefaultNode01|resources.xml#MQConnectionFactory_1662108208851)") 
AdminTask.deleteWMQConnectionFactory("esb_res_factory(cells/DefaultCell01/nodes/DefaultNode01|resources.xml#MQConnectionFactory_1662605238475)") 
删除队列
AdminTask.deleteWMQQueue("esb_req_req(cells/DESKTOP-BOMMDG2Node01Cell/nodes/DESKTOP-BOMMDG2Node01|resources.xml#MQQueue_1661475789072)") 

输出

u''

保存配置

AdminConfig.save()

新建完成后,可在控制台 Resources-JMS-Queues 查看

部署War

将war包拷贝到服务器

Linux
scp user@10.31.27.29:E:/Work/code/gitlab/pbhk/mbk-server/common/common-call-test-jndi/target/common-call-test-jndi.war /data/was

user为Windows用户名,10.150.69.247为Windows的ip,/home/zhao/data/test.txt(/home/zhao/data)为想要将文件复制到linux的哪个文件(文件夹)

Windows
scp "D:\work\code\gitlab\pbhk\mbk-server\common\common-call-test-jndi\target\common-call-test-jndi.war" user@127.0.0.1:/home/user
输入密码
Aa@123456
scp "D:\work\code\gitlab\pbhk\mbk-server\common\common-call-test-jndi\target\common-call-test-jndi.war" user@127.0.0.1:/home/user
输入密码
Formssi@dz

切换root用户

sudo su -
Aa@123456

移动文件到docker挂载目录

mv /home/user/common-call-test-jndi.war /data/was/common-call-test-jndi.war
如果没有挂载则需要拷贝进docker容器内部
docker cp /home/forms/common-call-test-jndi.war websphere9.0.5.9:/common-call-test-jndi.war

进入容器并进入wasadmin控制台

docker exec -it was_was_1 /bin/bash
cd /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin
wsadmin.sh -user wsadmin -password pwd

安装应用

AdminApp.install('/data/was/common-call-test-jndi.war','[-appname common-call-test-jndi-lee  -contextroot /common-call-test-jndi-lee -node DefaultNode01 -cell DefaultCell01 -server server1 -MapWebModToVH [[.* .* default_host]]]')

输出

wsadmin>AdminApp.install('/data/was/common-call-test-jndi.war','[-appname common-call-test-jndi-lee  -contextroot /common-call-test-jndi-lee -node DefaultNode01 -cell DefaultCell01 -server server1 -MapWebModToVH [[.* .* default_host]]]')
AdminConfig.save()
WASX7327I: Contents of was.policy file:
 //
// Template policy file for enterprise application.
// Extra permissions can be added if required by the enterprise application.
//
// NOTE: Syntax errors in the policy files will cause the enterprise application FAIL to start.
//       Extreme care should be taken when editing these policy files. It is advised to use
//       the policytool provided by the JDK for editing the policy files
//       (WAS_HOME/java/jre/bin/policytool). 
//

grant codeBase "file:${application}" {
};

grant codeBase "file:${jars}" {
};

grant codeBase "file:${connectorComponent}" {
};

grant codeBase "file:${webComponent}" {
};

grant codeBase "file:${ejbComponent}" {
};


ADMA5016I: Installation of common-call-test-jndi-lee started.
ADMA5058I: Application and module versions are validated with versions of deployment targets.
ADMA5005I: The application common-call-test-jndi-lee is configured in the WebSphere Application Server repository.
ADMA5005I: The application common-call-test-jndi-lee is configured in the WebSphere Application Server repository.
ADMA5081I: The bootstrap address for client module is configured in the WebSphere Application Server repository.
ADMA5053I: The library references for the installed optional package are created.
ADMA5005I: The application common-call-test-jndi-lee is configured in the WebSphere Application Server repository.
ADMA5001I: The application binaries are saved in /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/wstemp/Script18315ed39f9/workspace/cells/DefaultCell01/applications/common-call-test-jndi-lee.ear/common-call-test-jndi-lee.ear
ADMA5005I: The application common-call-test-jndi-lee is configured in the WebSphere Application Server repository.
SECJ0400I: Successfully updated the application common-call-test-jndi-lee with the appContextIDForSecurity information.
ADMA5005I: The application common-call-test-jndi-lee is configured in the WebSphere Application Server repository.
ADMA5005I: The application common-call-test-jndi-lee is configured in the WebSphere Application Server repository.
ADMA5113I: Activation plan created successfully.
ADMA5011I: The cleanup of the temp directory for application common-call-test-jndi-lee is complete.
ADMA5013I: Application common-call-test-jndi-lee installed successfully.
u''

安装完保存

AdminConfig.save()

安装完成后,可在控制台 Applications-Application Types-WebSphere nterprise Applications 查看

更新应用

print AdminApp.update('common-call-test-jndi-lee', 'file', '[-operation update -contents /data/was/common-call-test-jndi.war -contenturi common-call-test-jndi.war]')
AdminConfig.save()

输出

wsadmin>print AdminApp.update('common-call-test-jndi-lee', 'file', '[-operation update -contents /data/was/common-call-test-jndi.war -contenturi common-call-test-jndi.war]')
am=AdminControl.queryNames('cell=DefaultCell01,node=DefaultNode01,type=ApplicationManager,process=server1,*')
ADMA5078I: Update of common-call-test-jndi-lee has started.
ADMA5058I: Application and module versions are validated with versions of deployment targets.
ADMA5009I: Extracting application archive to /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/wstemp/appmgmt/mbean/AppManagement_18311c60ee2_1/app_183161b6147/ext.
ADMA5064I: FileMergeTask completed successfully for common-call-test-jndi-lee.
ADMA5005I: The application common-call-test-jndi-lee is configured in the WebSphere Application Server repository.
ADMA5005I: The application common-call-test-jndi-lee is configured in the WebSphere Application Server repository.
ADMA5005I: The application common-call-test-jndi-lee is configured in the WebSphere Application Server repository.
ADMA5113I: Activation plan created successfully.
ADMA5005I: The application common-call-test-jndi-lee is configured in the WebSphere Application Server repository.
ADMA5011I: The cleanup of the temp directory for application common-call-test-jndi-lee is complete.
ADMA5079I: Update of common-call-test-jndi-lee has ended. The application or its web modules may require a restart when a save is performed.

更新完保存

AdminConfig.save()

更新完成后,可在控制台 Applications-Application Types-WebSphere nterprise Applications 查看

卸载应用

print AdminApp.uninstall('common-call-test-jndi-lee')

输出

wsadmin>print AdminApp.uninstall('common-call-test-jndi-lee')
ADMA5017I: Uninstallation of common-call-test-jndi-lee started.
ADMA5104I: The server index entry for WebSphere:cell=DefaultCell01,node=DefaultNode01 is updated successfully.
ADMA5102I: The configuration data for common-call-test-jndi-lee from the configuration repository is deleted successfully.
ADMA5011I: The cleanup of the temp directory for application common-call-test-jndi-lee is complete.
ADMA5106I: Application common-call-test-jndi-lee uninstalled successfully.

卸载完保存

AdminConfig.save()

卸载完成后,可在控制台 Applications-Application Types-WebSphere nterprise Applications 查看验证

启动单个应用

am=AdminControl.queryNames('cell=DefaultCell01,node=DefaultNode01,type=ApplicationManager,process=server1,*')
AdminControl.invoke(am, 'startApplication', '[common-call-test-jndi-lee]')

测试接口

http://127.0.0.1:9080/common-call-test-jndi-lee/esb/testJNDI
http://127.0.0.1:9080/common-call-test-jndi-lee/esb/call

停止单个应用

am=AdminControl.queryNames('cell=DefaultCell01,node=DefaultNode01,type=ApplicationManager,process=server1,*')
AdminControl.invoke(am, 'stopApplication', '[common-call-test-jndi-lee]')

Jacl

  • 【英文全称】 Java Application Control Language
  • 【中文意思】 Java应用程序控制语言

部署War

启动应用

# 停止应用
# 识别应用程序所在的服务器的应用程序管理器 MBean,并将其指定给 appManager 变量
set appManager [$AdminControl queryNames cell=DESKTOP-BOMMDG2Node01Cell,node=DESKTOP-BOMMDG2Node01,type=ApplicationManager,process=server1,*]

# 使用程序内部数据源
#appname 应用名称
#target 将模块映射至服务器
#MapWebModToVH 使用指定host
#contextroot 为 Web 模块映射上下文根
# 安装
$AdminApp install "E:/Work/code/gitlab/pbhk/mbk-server/common/common-call-test-jndi/target/common-call-test-jndi.war" {-appname common-call-test-jndi -target WebSphere:cell=DESKTOP-BOMMDG2Node01Cell,node=DESKTOP-BOMMDG2Node01,server=server1 -MapWebModToVH{{.* .* default_host}} -contextroot /common-call-test-jndi}

# 安装后需要保存配置
$AdminConfig save

# STEP 4 启动应用
# 识别应用程序所在的服务器的应用程序管理器 MBean,并将其指定给 appManager 变量
set appManager [$AdminControl queryNames cell=DESKTOP-BOMMDG2Node01Cell,node=DESKTOP-BOMMDG2Node01,type=ApplicationManager,process=server1,*] 

# 启动单个应用
# myapp:被启动的服务名
$AdminControl invoke $appManager startApplication common-call-test-jndi

更新应用

# STEP 1 停止应用
# 识别应用程序所在的服务器的应用程序管理器 MBean,并将其指定给 appManager 变量
set appManager [$AdminControl queryNames cell=DESKTOP-BOMMDG2Node01Cell,node=DESKTOP-BOMMDG2Node01,type=ApplicationManager,process=server1,*]

# 更新
$AdminApp update common-call-test-jndi file {-operation update -contents "E:/Work/code/gitlab/pbhk/mbk-server/common/common-call-test-jndi/target/common-call-test-jndi.war" -contenturi common-call-test-jndi.war}

# 安装后需要保存配置
$AdminConfig save

# STEP 4 启动应用
# 识别应用程序所在的服务器的应用程序管理器 MBean,并将其指定给 appManager 变量
set appManager [$AdminControl queryNames cell=DESKTOP-BOMMDG2Node01Cell,node=DESKTOP-BOMMDG2Node01,type=ApplicationManager,process=server1,*] 

# 启动单个应用
# myapp:被启动的服务名
$AdminControl invoke $appManager startApplication common-call-test-jndi

停止单个应用

# 停止单个应用 
# $AdminControl invoke $appManager stopApplication forward-server-jndi

启动单个应用

# 启动单个应用
# myapp:被启动的服务名
$AdminControl invoke $appManager startApplication common-call-test-jndi

卸载应用

$AdminApp uninstall forward-server-jndi
# 需要保存配置
$AdminConfig save

部署脚本集合

配置MQ脚本

AdminTask.createWMQConnectionFactory("DefaultNode01(cells/DefaultCell01/nodes/DefaultNode01|node.xml#Node_1)", ["-name esb_req_factory -jndiName 'jms/cf/esb_req_factory' -type CF -description 'Must remember to keep each of these connection factories in sync with the IBM MQ queue manager to which they refer' -qmgrName ESB_REQ -qmgrHostname 127.0.0.1 -qmgrPortNumber 11517 -qmgrSvrconnChannel CHL_CONN"])

AdminTask.createWMQConnectionFactory("DefaultNode01(cells/DefaultCell01/nodes/DefaultNode01|node.xml#Node_1)", ["-name esb_res_factory -jndiName 'jms/cf/esb_res_factory' -type CF -description 'Must remember to keep each of these connection factories in sync with the IBM MQ queue manager to which they refer' -qmgrName ESB_RES -qmgrHostname 127.0.0.1 -qmgrPortNumber 11518 -qmgrSvrconnChannel CHL_CONN"])  

AdminTask.createWMQQueue("DefaultNode01(cells/DefaultCell01/nodes/DefaultNode01|node.xml#Node_1)", ["-name esb_req -jndiName jms/queues/esb_req -queueName Q_ESB_LJ"]) 

AdminTask.createWMQQueue("DefaultNode01(cells/DefaultCell01/nodes/DefaultNode01|node.xml#Node_1)", ["-name esb_res -jndiName jms/queues/esb_res -queueName Q_RCVR_LJ"]) 
AdminConfig.save()

安装启动war包

AdminApp.install('/data/was/common-call-test-jndi.war','[-appname common-call-test-jndi-lee  -contextroot /common-call-test-jndi-lee -node DefaultNode01 -cell DefaultCell01 -server server1 -MapWebModToVH [[.* .* default_host]]]')
AdminConfig.save()
am=AdminControl.queryNames('cell=DefaultCell01,node=DefaultNode01,type=ApplicationManager,process=server1,*')
AdminControl.invoke(am, 'startApplication', '[common-call-test-jndi-lee]')

更新启动war包

print AdminApp.update('common-call-test-jndi-lee', 'file', '[-operation update -contents /data/was/common-call-test-jndi.war -contenturi common-call-test-jndi.war]')
am=AdminControl.queryNames('cell=DefaultCell01,node=DefaultNode01,type=ApplicationManager,process=server1,*')
AdminConfig.save()
am=AdminControl.queryNames('cell=DefaultCell01,node=DefaultNode01,type=ApplicationManager,process=server1,*')
AdminControl.invoke(am, 'startApplication', '[common-call-test-jndi-lee]')
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值