摘要:直接執(zhí)行該腳本即可運(yùn)行工具。有離線和在線兩種模式,通過命令可以從進(jìn)入,按照目錄形式對(duì)資源進(jìn)行管理,甚至連操作的命令都和高度相似,比如是切換到指定資源路徑下,是列出該目錄下所有資源。
說明
weblogic安裝目錄下有一個(gè)創(chuàng)建Managed Server的腳本,腳本位于/u01/app/Oracle/Middleware/oracle_common/common/bin/config.sh下,但腳本會(huì)啟動(dòng)一個(gè)GUI界面程序,在Linux下需要安裝圖形界面程序,非常不方便。wlst(WebLogic Scripting Tools,WebLogic)是一個(gè)用來管理和配置weblogic的CLI命令行工具,可以運(yùn)行Jython腳本,本文介紹如何通過該工具創(chuàng)建Managed Server。
WLST介紹wlst位于/u01/app/Oracle/Middleware/wlserver_10.3/common/bin/wlst.sh目錄下,其中/u01/app/Oracle/Middleware/wlserver_10.3目錄為$WEBLOGIC_HOME,所以嚴(yán)謹(jǐn)?shù)闹v,是安裝在$WEBLOGIC_HOME/common/bin/wlst.sh下。直接執(zhí)行該腳本即可運(yùn)行wlst工具。
$ cd /u01/app/Oracle/Middleware/wlserver_10.3/common/bin/ $ ./wlst.sh Initializing WebLogic Scripting Tool (WLST) ... Welcome to WebLogic Server Administration Scripting Shell Type help() for help on available commands wls:/offline> connect("weblogic","weblogic1","t3://localhost:7001") Connecting to t3://localhost:7001 with userid weblogic ... Successfully connected to Admin Server "AdminServer" that belongs to domain "base_domain". 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_domain/serverConfig> cd("/") wls:/base_domain/serverConfig> ls() dr-- AdminConsole dr-- AppDeployments dr-- BridgeDestinations dr-- Clusters dr-- CoherenceClusterSystemResources dr-- CoherenceServers ....
wlst有offline(離線)和online(在線)兩種模式,通過connect命令可以從offline進(jìn)入online,wlst按照Linux目錄形式對(duì)weblogic資源進(jìn)行管理,甚至連操作的命令都和Linux高度相似,比如cd是切換到指定資源路徑下,ls()是列出該目錄下所有資源。如要了解更多關(guān)于wlst的內(nèi)容,可以查看官方文檔。
wlst腳本本腳本原作者為Tim Hall,本文這里稍作修改,以下為腳本代碼
create_managed_server.py
#!/usr/bin/python # Author : Tim Hall # Modified : Jianfeng.Zheng # Save Script as : create_managed_server.py import time import getopt import sys import re # Get location of the properties file. properties = "" try: opts, args = getopt.getopt(sys.argv[1:],"p:h::",["properies="]) except getopt.GetoptError: print "create_managed_server.py -pproperties文件" sys.exit(2) for opt, arg in opts: if opt == "-h": print "create_managed_server.py -p " sys.exit() elif opt in ("-p", "--properties"): properties = arg print "properties=", properties # Load the properties from the properties file. from java.io import FileInputStream propInputStream = FileInputStream(properties) configProps = Properties() configProps.load(propInputStream) # Set all variables from values in properties file. adminUsername=configProps.get("admin.username") adminPassword=configProps.get("admin.password") adminURL=configProps.get("admin.url") msName=configProps.get("ms.name") msAddress=configProps.get("ms.address") msPort=configProps.get("ms.port") msMachine=configProps.get("ms.machine") # Display the variable values. print "adminUsername=", adminUsername print "adminPassword=", adminPassword print "adminURL=", adminURL print "msName=", msName print "msAddress=", msAddress print "msPort=", msPort print "msMachine=", msMachine # Connect to the AdminServer. connect(adminUsername, adminPassword, adminURL) edit() startEdit() # Create the managed Server. cd("/") cmo.createServer(msName) cd("/Servers/" + msName) cmo.setListenAddress(msAddress) cmo.setListenPort(int(msPort)) # Associated with a node manager. cd("/Servers/" + msName) cmo.setMachine(getMBean("/Machines/" + msMachine)) save() activate() disconnect() exit()
腳本所需參數(shù)通過properties文件傳入,以下是properties文件
api-api-managed-server.properties
# AdminServer connection details. admin.username=weblogic admin.password=weblogic1 admin.url=t3://10.1.11.71:7001 ms.name=api-server ms.address=0.0.0.0 ms.port=7002 ms.machine=api-server-machine
admin.username: weblogic管理員用戶名
admin.password: weblogic管理員密碼
admiin.url: weblogic控制臺(tái)地址需要加上t3協(xié)議字段
ms.name: managed server名稱,可以自定義
ms.address: managed server監(jiān)聽地址
ms.port: managed server監(jiān)聽端口號(hào)
ms.machine: managed server關(guān)聯(lián)的計(jì)算機(jī)名稱
ms.machine需要提前創(chuàng)建好,可以在weblogic控制臺(tái)頁面http://localhost:7001/console/console.portal?_nfpb=true&_pageLabel=CoreMachineMachineTablePage創(chuàng)建
運(yùn)行將create_managed_server.py和api-api-managed-server.properties文件上傳到服務(wù)器,這里上傳到目錄~/shell下
$ cd /u01/app/Oracle/Middleware/user_projects/domains/base_domain/bin $ . ./setDomainEnv.sh $ java weblogic.WLST ~/shell/create_managed_server.py -p ~/shell/api-managed-server.properties
ps:. ./setDomainEnv.sh第一個(gè)點(diǎn)(.)不能省略
執(zhí)行完畢后登錄console查看結(jié)果。
參考https://oracle-base.com/articles/web/wlst-create-managed-server
https://docs.oracle.com/cd/E13222_01/wls/docs90/config_scripting/using_WLST.html
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://specialneedsforspecialkids.com/yun/73327.html
閱讀 970·2021-11-24 10:42
閱讀 3480·2021-11-19 11:34
閱讀 2609·2021-09-29 09:35
閱讀 2534·2021-09-09 09:33
閱讀 646·2021-07-26 23:38
閱讀 2521·2019-08-30 10:48
閱讀 1391·2019-08-28 18:07
閱讀 425·2019-08-26 13:44