03-13_WLST導航和定位MBean

本文重點:WLST導航和定位MBean

   

  1. MBean切換圖

    如上:紅色的字體表示切換的命令。lscd是在當前樹下切換,其他命令是在不同樹之間切換。

    其中:

  • DomainMBeanServer有三種狀態:
    • 運行domainConfig() 進入到DomainMBean中。
    • 運行domainRuntime() 進入到Domain-RuntimeMBean中。
    • 運行domainCustom() 進入到Domain-CustomMBean中。(自定義MBean,需要先掛載)
  • EditMBeanServer只有一種狀態:
    • 運行edit() 進入到DomainMBean中。
  • RuntimeMBeanServer也有三種狀態:
    • 運行serverConfig() 進入到DomainMBean中。
    • 運行serverRuntime() 進入到Server-RuntimeMBean中。
    • 運行Custom() 進入到custom() 中。(自定義MBean,需要先掛載)
  • 如果在管理服務器上,那麼RuntimeMBeanServer和DomainMBeanServer的數據是相同的。
  1. 各模式下切換。
    1. 首先要啓動管理服務器,然後啓動wlst.sh腳本。

[root@wls1 ~]# /opt/weblogic/wlserver_10.3/common/bin/wlst.sh

   

CLASSPATH=/opt/weblogic/patch_wls1036/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/opt/weblogic/patch_ocp371/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/opt/jdk1.8.0_144/lib/tools.jar:/opt/weblogic/wlserver_10.3/server/lib/weblogic_sp.jar:/opt/weblogic/wlserver_10.3/server/lib/weblogic.jar:/opt/weblogic/modules/features/weblogic.server.modules_10.3.6.0.jar:/opt/weblogic/wlserver_10.3/server/lib/webservices.jar:/opt/weblogic/modules/org.apache.ant_1.7.1/lib/ant-all.jar:/opt/weblogic/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar::/opt/weblogic/utils/config/10.3/config-launch.jar::/opt/weblogic/wlserver_10.3/common/derby/lib/derbynet.jar:/opt/weblogic/wlserver_10.3/common/derby/lib/derbyclient.jar:/opt/weblogic/wlserver_10.3/common/derby/lib/derbytools.jar::

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0

   

Initializing WebLogic Scripting Tool (WLST) ...

   

Welcome to WebLogic Server Administration Scripting Shell

   

Type help() for help on available commands

   

wls:/offline> connect() # 連接

Please enter your username :weblogic # 帳號

Please enter your password : # 密碼

Please enter your server URL [t3://localhost:7001] : # 連接的地址

Connecting to t3://localhost:7001 with userid weblogic ...

Successfully connected to Admin Server 'AdminServer' that belongs to domain 'base_domains'.

   

Warning: An insecure protocol was used to connect to the

server. To ensure on-the-wire security, the SSL port or

Admin port should be used instead.

   

wls:/base_domains/serverConfig>

  1. 連接後,默認進入serverConfig狀態

wls:/base_domains/serverConfig>

wls:/base_domains/serverConfig> cmo # 打印當前對象的名字和類型。

[MBeanServerInvocationHandler]com.bea:Name=base_domains,Type=Domain

wls:/base_domains/serverConfig> ls() # 列出MBean的層級結構。

dr-- AdminConsole

dr-- AppDeployments

dr-- BridgeDestinations

dr-- Clusters

dr-- CoherenceClusterSystemResources

..

   

-r-- AdminServerName AdminServer

-r-- AdministrationMBeanAuditingEnabled false

-r-- AdministrationPort 9002

-r-- AdministrationPortEnabled false

..

   

-r-x freezeCurrentValue Void : String(attributeName)

-r-x isSet Boolean : String(propertyName)

-r-x unSet Void : String(propertyName)

   

如上所示:dr--,四個標識

第一位:"d" 代表是MBean實例或類型,可以看作是目錄,確實如目錄一樣操作。 "-" 代表是MBean的屬性

第二位:"r" 代表可讀,"-" 代表不可讀。

第三位:"w" 代表可寫,"-" 代表不可寫。

第四位:"x" 代表執行,"-" 代表不可執行。

   

wls:/base_domains/serverConfig> cd('Servers') # 進入到servers

wls:/base_domains/serverConfig/Servers> cmo

[MBeanServerInvocationHandler]com.bea:Name=base_domains,Type=Domain

wls:/base_domains/serverConfig/Servers> ls() # 列出該節點下屬性。

dr-- AdminServer

dr-- Server-0

  

  1. 進入domainConfig狀態

wls:/base_domains/serverConfig/Servers> domainConfig()

Location changed to serverRuntime tree. This is a read-only tree with DomainMBean as the root.

For more help, use help(domainConfig)

   

wls:/base_domains/domainConfig> cmo # 打印當前對象的名字和類型。

[MBeanServerInvocationHandler]com.bea:Name=base_domains,Location=base_domains,Type=Domain

wls:/base_domains/domainConfig> ls() # 該狀態下ls()列出的數據和serverConfig狀態下的數據大致一樣(初步驗證)。

dr-- AdminConsole

dr-- AppDeployments

dr-- BridgeDestinations

dr-- Clusters

dr-- CoherenceClusterSystemResources

dr-- CoherenceServers

..

  1. 進入domainRuntime狀態

wls:/base_domains/domainConfig> domainRuntime()

Location changed to domainRuntime tree. This is a read-only tree with DomainMBean as the root.

For more help, use help(domainRuntime)

   

wls:/base_domains/domainRuntime> cmo

[MBeanServerInvocationHandler]com.bea:Name=base_domains,Type=DomainRuntime

wls:/base_domains/domainRuntime> ls() # ls列出的數據

dr-- AppRuntimeStateRuntime

dr-- CoherenceServerLifeCycleRuntimes

dr-- ConsoleRuntime

dr-- DeployerRuntime

dr-- DeploymentManager

dr-- DomainServices

dr-- LogRuntime

dr-- MessageDrivenControlEJBRuntime

dr-- MigratableServiceCoordinatorRuntime

dr-- MigrationDataRuntimes

dr-- PolicySubjectManagerRuntime

dr-- SNMPAgentRuntime

dr-- ServerLifeCycleRuntimes

dr-- ServerRuntimes

dr-- ServerServices

dr-- ServiceMigrationDataRuntimes

   

-r-- ActivationTime Tue Jan 30 22:36:28 CST 2018

-r-- MigrationDataRuntimes null

-r-- Name base_domains

-rw- Parent null

-r-- ServiceMigrationDataRuntimes null

-r-- Type DomainRuntime

   

-r-x preDeregister Void :

-r-x restartSystemResource Void : WebLogicMBean(weblogic.management.configuration.SystemResourceMBean)

  1. 進入serverRuntime狀態

wls:/base_domains/domainRuntime> serverRuntime()

Location changed to serverRuntime tree. This is a read-only tree with ServerRuntimeMBean as the root.

For more help, use help(serverRuntime)

   

wls:/base_domains/serverRuntime> cmo

[MBeanServerInvocationHandler]com.bea:Name=AdminServer,Type=ServerRuntime

wls:/base_domains/serverRuntime> ls() # 注意,和domainRuntime的數據並不相同

dr-- ApplicationRuntimes

dr-- AsyncReplicationRuntime

dr-- ClusterRuntime

dr-- ConnectorServiceRuntime

dr-- DefaultExecuteQueueRuntime

dr-- EntityCacheCumulativeRuntime

dr-- EntityCacheCurrentStateRuntime

dr-- EntityCacheHistoricalRuntime

..

-r-- SocketsOpenedTotalCount 1

-r-- State RUNNING

-r-- StateVal 2

-r-- Type ServerRuntime

-r-- WANReplicationRuntime null

-r-- WLECConnectionServiceRuntime null

-r-- WeblogicHome /opt/weblogic/wlserver_10.3

-r-- WeblogicVersion WebLogic Server 10.3.6.0 Tue Nov 15 08:52:36 PST 2011 1441050

-r-- WseeClusterFrontEndRuntime null

   

-r-x addRequestClassRuntime Boolean : WebLogicMBean(weblogic.management.runtime.RequestClassRuntimeMBean)

-r-x forceShutdown Void :

-r-x forceSuspend Void :

-r-x getIPv4URL String : String(protocol)

-r-x getIPv6URL String : String(protocol)

-r-x getServerChannel java.net.InetSocketAddress : String(protocol)

-r-x getURL String : String(protocol)

-r-x preDeregister Void :

-r-x restartSSLChannels Void :

-r-x resume Void :

-r-x shutdown Void :

-r-x shutdown Void : Integer(timeout),Boolean(ignoreSessions)

-r-x start Void :

-r-x suspend Void :

-r-x suspend Void : Integer(timeout),Boolean(ignoreSessions)

  1. 進入domainCustom()狀態

wls:/base_domains/domainRuntime> domainCustom()

Location changed to domain custom tree. This is a writable tree with No root. # 這棵樹可寫,但是沒有存根

For more help, use help(domainCustom)

   

wls:/base_domains/domainCustom> cmo

'No Stub Available' # 沒有存根

wls:/base_domains/domainCustom> ls()

drw- JMImplementation

drw- com.sun.management

drw- java.lang

drw- java.nio

drw- java.util.logging

  1. 進入custom()狀態

wls:/base_domains/domainCustom> custom()

Location changed to custom tree. This is a writable tree with No root.

For more help, use help(custom)

   

wls:/base_domains/custom> cmo

'No Stub Available'

wls:/base_domains/custom> ls()

drw- JMImplementation

drw- com.sun.management

drw- java.lang

drw- java.nio

drw- java.util.logging

  1. 進入edit()狀態

wls:/base_domains/custom> edit() # 這是一個編輯樹,可寫;使用domainMBean做爲根,如果要進行更改,需要startEdit()編輯會話。

Location changed to edit tree. This is a writable tree with

DomainMBean as the root. To make changes you will need to start

an edit session via startEdit().

   

For more help, use help(edit)

You already have an edit session in progress and hence WLST will

continue with your edit session.

   

wls:/base_domains/edit !> cmo # 進入的是domainMBean中

[MBeanServerInvocationHandler]com.bea:Name=base_domains,Type=Domain

wls:/base_domains/edit !> ls()

dr-- AdminConsole

dr-- AppDeployments

dr-- BridgeDestinations

dr-- Clusters

dr-- CoherenceClusterSystemResources

  1. 高級操作
    1. 獲取屬性值

wls:/base_domains/edit !> serverConfig()

   

wls:/base_domains/serverConfig> cd('Servers')

wls:/base_domains/serverConfig/Servers> ls()

dr-- AdminServer

dr-- Server-0

   

wls:/base_domains/serverConfig/Servers> cd('Server-0')

wls:/base_domains/serverConfig/Servers/Server-0> cmo.getXMLEntityCache() # 該值因爲爲空

wls:/base_domains/serverConfig/Servers/Server-0> cmo.getVirtualMachineName()

'base_domains_Server-0'

wls:/base_domains/serverConfig/Servers/Server-0> get('VirtualMachineName') # 另一種方式獲取值

'base_domains_Server-0'

wls:/base_domains/serverConfig/Servers/Server-0/WebServer> cd('..') # 返回根目錄

wls:/base_domains/serverConfig/Servers/Server-0> cd('/') # 返回父目錄

wls:/base_domains/serverConfig> find('VirtualMachineName') # 可以使用find命令查找

Finding 'VirtualMachineName' in all registered MBean instances ...

/Servers/AdminServer VirtualMachineName base_domains_AdminServer

/Servers/Server-0 VirtualMachineName base_domains_Server-0

wls:/base_domains/serverConfig> bean1 = getMBean('/Servers/AdminServer')

wls:/base_domains/serverConfig> bean1

[MBeanServerInvocationHandler]com.bea:Name=AdminServer,Type=Server

wls:/base_domains/serverConfig> bean1.getVirtualMachineName()

'base_domains_AdminServer'

  1. 受管服務器上只有RuntimeMBeanServer

       

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章