WebLogic静默建域建server

weblogic自带一个非常强大 的脚本工具可以对weblogic进行自动化建域建实例等,还可以进行各种个性化配置,管理页面上可以实现的功能大多都可以用自动化脚本的方式来完成,工具名:wlst.sh,脚本位于wls_home/common/bin/wlst.sh,12c中位于wls_home/oracle_common/common/bin/wlst.sh
将我们要配置的内容写入一个py文件中,执行wlst脚本读取py文件自动完成配置
注:本次使用环境为12c
命令格式:

sh wlst.sh createDomain.py

本次配置py文件内容如下:

readTemplate('/app/dufgtest/wls12/wls.jar')
(这里是复制12c环境下的wls_home/wlserver/common/templates/wls/wls.jar文件,对文件解压,修改config目录下的config.xml中的AdminServer为自己想设置的adminserver名,重新打包即可。11g下文件位置可能是wls_home/common/templates/domains/wls.jar,修改方式相同)
cd('Servers/adminserver')
set('ListenAddress','')
set('ListenPort', 20000)

cd('/')
cd('Security/base_domain/User/weblogic')
set('Name','weblogic')
set('Password','weblogic1234')
setOption('ServerStartMode', 'prod')
setOption('JavaHome','/app/mw/jdk1.8')
setOption('OverwriteDomain', 'true')
writeDomain('/app/base-domain')
closeTemplate()

startServer('adminserver','base-domain','t3://localhost:20000','weblogic','weblogic1234','/app/base-domain','true', 120000,jvmArgs='-Xms512m, -Xmx512m,-XX:MaxPermSize=256m')
connect('weblogic','weblogic1234','t3://localhost:20000')

edit()
startEdit()

cd('/Servers/adminserver/Log/adminserver')
set('RotationType','bySize')
set('FileMinSize','20480')
set('NumberOfFilesLimited','true')
set('FileCount','20')
save()

cd('/Servers/adminserver/SSL/adminserver')
set('Enabled','true')
set('ListenPort','7002')
save()

cd('/Servers/adminserver')
set('StuckThreadMaxTime','60')
save()
cd('/Servers/adminserver/OverloadProtection/adminserver/ServerFailureTrigger/')
create('adminserver')
cd('/Servers/adminserver/OverloadProtection/adminserver/ServerFailureTrigger/adminserver')
set('MaxStuckThreadTime','60')
save()
activate(block="true")
shutdown('adminserver','Server','true',0,block='false')
disconnect()
exit()

如果正常执行完成,12c环境下输出结果大致如下:

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Starting weblogic server ...
WLST-WLS-1532510273741: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
WLST-WLS-1532510273741: <2018-7-25 下午05时17分54秒 CST> <Info> <Security> <BEA-090905> <Disabling the CryptoJ JCE Provider self-integrity check for better startup performance. To enable this check, specify -Dweblogic.security.allowCryptoJDefaultJCEVerification=true.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时17分54秒 CST> <Info> <Security> <BEA-090906> <Changing the default Random Number Generator in RSA CryptoJ from ECDRBG128 to HMACDRBG. To disable this change, specify -Dweblogic.security.allowCryptoJDefaultPRNG=true.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时17分54秒 CST> <Info> <WebLogicServer> <BEA-000377> <Starting WebLogic Server with Java HotSpot(TM) 64-Bit Server VM Version 25.131-b11 from Oracle Corporation.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时17分55秒 CST> <Info> <RCM> <BEA-2165021> <"ResourceManagement" is not enabled in this JVM. Enable "ResourceManagement" to use the WebLogic Server "Resource Consumption Management" feature. To enable "ResourceManagement", you must specify the following JVM options in the WebLogic Server instance in which the JVM runs: -XX:+UnlockCommercialFeatures -XX:+ResourceManagement.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时17分55秒 CST> <Info> <Management> <BEA-141107> <Version: WebLogic Server 12.2.1.3.0 Thu Aug 17 13:39:49 PDT 2017 1882952> 
WLST-WLS-1532510273741: <2018-7-25 下午05时17分56秒 CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时17分57秒 CST> <Info> <WorkManager> <BEA-002900> <Initializing self-tuning thread pool.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时17分57秒 CST> <Info> <WorkManager> <BEA-002942> <CMM memory level becomes 0. Setting standby thread pool size to 256.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时17分57,823秒 CST> <Notice> <Log Management> <BEA-170019> <The server log file weblogic.logging.FileStreamHandler instance=1028749585
WLST-WLS-1532510273741: Current log file=/app/dufgtest/dufgtest-web-domain/servers/adminserver/logs/adminserver.log
WLST-WLS-1532510273741: Rotation dir=/app/dufgtest/dufgtest-web-domain/servers/adminserver/logs
WLST-WLS-1532510273741:  is opened. All server side log events will be written to this file.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时17分57,960秒 CST> <Notice> <Security> <BEA-090946> <Security pre-initializing using security realm: myrealm> 
WLST-WLS-1532510273741: <2018-7-25 下午05时17分58,816秒 CST> <Notice> <Security> <BEA-090947> <Security post-initializing using security realm: myrealm> 
.WLST-WLS-1532510273741: <2018-7-25 下午05时17分59,965秒 CST> <Notice> <Security> <BEA-090082> <Security initialized using administrative security realm: myrealm> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分00,547秒 CST> <Notice> <JMX> <BEA-149512> <JMX Connector Server started at service:jmx:iiop://20.26.28.125:20000/jndi/weblogic.management.mbeanservers.runtime.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分00,569秒 CST> <Notice> <JMX> <BEA-149512> <JMX Connector Server started at service:jmx:iiop://20.26.28.125:20000/jndi/weblogic.management.mbeanservers.domainruntime.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分00,587秒 CST> <Notice> <JMX> <BEA-149512> <JMX Connector Server started at service:jmx:iiop://20.26.28.125:20000/jndi/weblogic.management.mbeanservers.edit.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分02,112秒 CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STANDBY.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分02,112秒 CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分02,171秒 CST> <Notice> <Log Management> <BEA-170036> <The Logging monitoring service timer has started to check for logged message counts every 30 seconds.> 
.WLST-WLS-1532510273741: <2018-7-25 下午05时18分05,209秒 CST> <Notice> <Log Management> <BEA-170027> <The server has successfully established a connection with the Domain level Diagnostic Service.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分06,480秒 CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to ADMIN.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分06,688秒 CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RESUMING.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分06,743秒 CST> <Notice> <Server> <BEA-002613> <Channel "Default[1]" is now listening on 192.168.122.1:20000 for protocols iiop, t3, ldap, snmp, http.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分06,743秒 CST> <Warning> <Server> <BEA-002611> <The hostname "localhost", maps to multiple IP addresses: 127.0.0.1, 0:0:0:0:0:0:0:1.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分06,744秒 CST> <Notice> <Server> <BEA-002613> <Channel "Default" is now listening on 20.26.28.125:20000 for protocols iiop, t3, ldap, snmp, http.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分06,744秒 CST> <Notice> <Server> <BEA-002613> <Channel "Default[2]" is now listening on 0:0:0:0:0:0:0:1%lo:20000 for protocols iiop, t3, ldap, snmp, http.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分06,744秒 CST> <Notice> <Server> <BEA-002613> <Channel "Default[3]" is now listening on 127.0.0.1:20000 for protocols iiop, t3, ldap, snmp, http.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分06,745秒 CST> <Notice> <Server> <BEA-002613> <Channel "Default[1]" is now listening on 192.168.122.1:20000 for protocols iiop, t3, ldap, snmp, http.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分06,745秒 CST> <Notice> <WebLogicServer> <BEA-000329> <Started the WebLogic Server Administration Server "adminserver" for domain "dufgtest-web-domain" running in production mode.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分06,745秒 CST> <Notice> <Server> <BEA-002613> <Channel "Default" is now listening on 20.26.28.125:20000 for protocols iiop, t3, ldap, snmp, http.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分06,745秒 CST> <Notice> <Server> <BEA-002613> <Channel "Default[2]" is now listening on 0:0:0:0:0:0:0:1%lo:20000 for protocols iiop, t3, ldap, snmp, http.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分06,746秒 CST> <Notice> <Server> <BEA-002613> <Channel "Default[3]" is now listening on 127.0.0.1:20000 for protocols iiop, t3, ldap, snmp, http.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分06,766秒 CST> <Notice> <WebLogicServer> <BEA-000360> <The server started in RUNNING mode.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分06,775秒 CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING.> 
Server started successfully.
Connecting to t3://localhost:20000 with userid weblogic ...
WLST-WLS-1532510273741: <2018-7-25 下午05时18分08,753秒 CST> <Notice> <JMX> <BEA-149535> <JMX Resiliency Activity Server=adminserver : Initializing callbacks> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分08,755秒 CST> <Notice> <JMX> <BEA-149535> <JMX Resiliency Activity Server=adminserver : Added MBeanServerConnection in DomainRuntimeServiceMBean > 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分08,756秒 CST> <Notice> <JMX> <BEA-149535> <JMX Resiliency Activity Server=adminserver : Callback is done> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分08,759秒 CST> <Notice> <JMX> <BEA-149535> <JMX Resiliency Activity Server=adminserver : Connection already exists for the server. Did not attempt to connect to the server> 
Successfully connected to Admin Server "adminserver" that belongs to domain "dufgtest-web-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.

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').

Starting an edit session ...
Started edit session, be sure to save and activate your changes once you are done.
Saving all your changes ...
Saved all your changes successfully.
Saving all your changes ...
Saved all your changes successfully.
Saving all your changes ...
Saved all your changes successfully.
ServerFailureTrigger has been created successfully with its parents name since this mbean is an optional singleton MBean.
Saving all your changes ...
Saved all your changes successfully.
Activating all your changes, this may take a while ... 
The edit lock associated with this edit session is released once the activation is completed.
WLST-WLS-1532510273741: <2018-7-25 下午05时18分23,308秒 CST> <Warning> <Management> <BEA-141239> <The non-dynamic attribute StuckThreadMaxTime on weblogic.management.configuration.ServerMBeanImpl@1678f865([dufgtest-web-domain]/Servers[adminserver]) has been changed. This may require redeploying or rebooting configured entities.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分23,308秒 CST> <Warning> <Management> <BEA-141238> <A non-dynamic change has been made which affects the server adminserver. This server must be rebooted in order to consume this change.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分23,309秒 CST> <Warning> <Management> <BEA-141239> <The non-dynamic attribute StuckThreadMaxTime on weblogic.management.configuration.ServerMBeanImpl@1678f865([dufgtest-web-domain]/Servers[adminserver]) has been changed. This may require redeploying or rebooting configured entities.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分23,309秒 CST> <Warning> <Management> <BEA-141239> <The non-dynamic attribute ServerFailureTrigger on weblogic.management.configuration.OverloadProtectionMBeanImpl@3de1d71f([dufgtest-web-domain]/Servers[adminserver]/OverloadProtection[adminserver]) has been changed. This may require redeploying or rebooting configured entities.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分23,309秒 CST> <Warning> <Management> <BEA-141238> <A non-dynamic change has been made which affects the server adminserver. This server must be rebooted in order to consume this change.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分23,310秒 CST> <Warning> <Management> <BEA-141239> <The non-dynamic attribute ServerFailureTrigger on weblogic.management.configuration.OverloadProtectionMBeanImpl@3de1d71f([dufgtest-web-domain]/Servers[adminserver]/OverloadProtection[adminserver]) has been changed. This may require redeploying or rebooting configured entities.> 

The following non-dynamic attribute(s) have been changed on MBeans 
that require server re-start:
MBean Changed : com.bea:Name=adminserver,Type=OverloadProtection,Server=adminserver
Attributes changed : ServerFailureTrigger

MBean Changed : com.bea:Name=adminserver,OverloadProtection=adminserver,Type=ServerFailureTrigger,Server=adminserver
Attributes changed : MaxStuckThreadTime

MBean Changed : com.bea:Name=adminserver,Type=Server
Attributes changed : StuckThreadMaxTime

Activation completed
Shutting down the server adminserver with force=false while connected to adminserver ...
WLST-WLS-1532510273741: <2018-7-25 下午05时18分23,484秒 CST> <Notice> <Server> <BEA-002638> <Graceful shutdown of adminserver was issued remotely from 20.26.28.125.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分23,494秒 CST> <Notice> <WebLogicServer> <BEA-000396> <Server shutdown has been requested by weblogic.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分23,495秒 CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to SUSPENDING.> 

The server shutdown task for server adminserver 
is assigned to variable adminserverTask 
You can call the getStatus(), getError(), getDescription() 
or isRunning() methods on this variable to determine 
the status of your server shutdown

Disconnected from weblogic server: adminserver
WLST-WLS-1532510273741: <2018-7-25 下午05时18分23,526秒 CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to ADMIN.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分23,526秒 CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to SHUTTING_DOWN.> 
WLST-WLS-1532510273741: <2018-7-25 下午05时18分23,545秒 CST> <Notice> <Log Management> <BEA-170037> <The log monitoring service timer has been stopped.> 
Disconnected from weblogic server: 


Exiting WebLogic Scripting Tool.

到这里domain和adminserver都建好了,后面就是新建实例
新建实例的方法与新建域类似,都是将配置内容写入py文件,然后调用wlst脚本读取配置文件自动完成
新建createServers.py文件,内容如下:

servername = ['srv01', 'srv02', 'srv03', 'srv04']
serverport=[20001, 20002, 20003, 20004]

startServer('adminserver','base-domain','t3://localhost:20000','weblogic','weblogic1234','/app/base-domain','true', 120000,jvmArgs='-Xms512m, -Xmx512m,-XX:MaxPermSize=256m')
connect('weblogic','weblogic1234','t3://localhost:20000')

edit()
startEdit()
for i in list(range(0,len(serverport))):
    name = servername[i]
    port = serverport[i]
    cd('/')
    managedServer=create(name,'Server')
    managedServer.setListenAddress('20.26.28.125')
    managedServer.setListenPort(int(port))

    cd('/Servers/'+name+'/Log/'+name)
    set('RotationType','bySize')
    set('FileMinSize','20480')
    set('NumberOfFilesLimited','true')
    set('FileCount','20')
    save()

    cd('/Servers/'+name+'/WebServer/'+name+'/WebServerLog/'+name)
    set('LoggingEnabled','true')
    set('RotationType','bySize')
    set('NumberOfFilesLimited','true')
    set('FileMinSize','5120')
    set('FileCount','20')

    cd('/Servers/'+name)
    set('AcceptBacklog','1000')

    cd('/Servers/'+name+'/OverloadProtection/'+name)
    set('SharedCapacityForWorkManagers','90')
    cd('/Servers/'+name+'/SSL/'+name)
    set('Enabled','false')
    cd('/Servers/'+name)
    set('MaxOpenSockCount','6553200')

    cd('/Servers/'+name)
    set('StuckThreadMaxTime','60')
    cd('/Servers/'+name+'/OverloadProtection/'+name+'/ServerFailureTrigger/')
    create(name)
    cd('/Servers/'+name+'/OverloadProtection/'+name+'/ServerFailureTrigger/'+name)
    set('MaxStuckThreadTime','60')
    cd('/Servers/'+name)
    set('Cluster','cluster_1')

save()
activate(block="true")

命令参考:

sh wlst.sh /path/createServers.py
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 206,968评论 6 482
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 88,601评论 2 382
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 153,220评论 0 344
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 55,416评论 1 279
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 64,425评论 5 374
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,144评论 1 285
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,432评论 3 401
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,088评论 0 261
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,586评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,028评论 2 325
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,137评论 1 334
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,783评论 4 324
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,343评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,333评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,559评论 1 262
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,595评论 2 355
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,901评论 2 345

推荐阅读更多精彩内容

  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 46,748评论 6 342
  • 1. Java基础部分 基础部分的顺序:基本语法,类相关的语法,内部类的语法,继承相关的语法,异常的语法,线程的语...
    子非鱼_t_阅读 31,587评论 18 399
  • 一、Python简介和环境搭建以及pip的安装 4课时实验课主要内容 【Python简介】: Python 是一个...
    _小老虎_阅读 5,723评论 0 10
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,601评论 18 139
  • feisky云计算、虚拟化与Linux技术笔记posts - 1014, comments - 298, trac...
    不排版阅读 3,815评论 0 5