WEBLOGIC ADMINISTRATION UNDDEPLOYMENT MIT WLST            „Infrastructure as Code“Oracle WebLogic Scripting Tool          ...
Andreas KoopÜBER MICH                                                          Consultant                                 ...
ENTERPRISE.PRAGMATIC.IT   Consulting                  Training                Development Oracle Fusion         Oracle    ...
AGENDAMotivation „Infrastructure as Code“Überblick WebLogic Scripting ToolBest Practices Administration und DeploymentAndr...
INFRASTRUCTURE AS CODE‣       Vision - Bereitstellung einer        lauffähigen Umgebung aus    ‣          Source Code Repo...
RESTORE ENV FROM CODE                      app source                                     App                             ...
WAS BRAUCHT EINEORACLE FMW UMGEBUNG?‣      WebLogic Installation, Domain       ‣       WebLogic Konfiguration‣      Applica...
MANUELLE KONFIGURATIONIST KEINE LÖSUNGAndreas Koop   8
WEBLOGIC SCRIPTING TOOL‣       Jython basierte Scriptsprache zur Automatisierung jeglicher WebLogic        Administrations...
DOMAIN ERSTELLENreadTemplate(os.environ[WL_HOME] + /common/templates/domains/wls.jar)cd(/)                    Currentcmo.s...
DOMAIN ERWEITERN# Z.B. um die ADF Runtime in Form der JRFreadDomain(DOMAIN_DIR)addTemplate(MW_HOME + /oracle_common/common...
WLST EXECUTIONBEST PRACTICE (OFFLINE)#!/bin/shexport DOMAIN_HOME=/oracle/fmw /11.1.1.6/user_projects/domains /my_domainexp...
WLST EXECUTIONBEST PRACTICE (OFFLINE)Andreas Koop   13
WLST ONLINE  connect(weblogic, welcome1, t3://adminhost:7001)  edit()  startEdit()  # do something  save()  activate()  di...
DOMAIN ERWEITERN connect(weblogic, welcome1, t3://adminhost:7001) edit() startEdit() cmo.createServer(os.environ[MS_NAME])...
MODULARIZE WLST SCRIPTS                                       connect(weblogic, welco..)   execfile(connect.py)    execfil...
MODULARIZE WLST SCRIPTSEVEN MORE  # Custom Functions  import os  def getDomainName():    return os.environ[DOMAIN_NAME]   ...
WLST DOMAIN INTERACTION                    Quelle: Oracle FMW Doc LibAndreas Koop   18
DOMAIN STARTUPnmConnect(Dh4bZwJNNP, welcome1, DOMAIN_NAME, NM_PORT)nmStart(AdminServer)nmStart(WLS_FORMS)nmStart(WLS_REPOR...
WLST NODE MANAGERENCRYPTED PASSWORD  nmConnect(Dh4bZwJNNP, welcome1, DOMAIN_NAME, NM_PORT)  storeUserConfig(userConfigFile...
DOMAIN SHUTDOWNNM_HOME = WL_HOME + /common/nodemanagernmConnect(userConfigFile = NM_HOME + /userconfigNM.secure,          ...
LOGGING LOGGING LOGGING‣       Never-Ending-Story‣       Was tun? Was berücksichtigen?    ‣          Log Rotating    ‣    ...
LOGGING KONFIGURATION  execfile(connect.py)  execfile(start.edit.session.py)  cd(/Servers/AdminServer/Log/AdminServer)  cm...
DEPLOYMENT‣       Data Source vorbereiten                                       Java EE App‣       Targets                ...
DATA SOURCE ANLEGEN‣ JNDI Lookup#connect(..), edit() startEdit()cd(/)create(myDataSource, JDBCSystemResource)cd(JDBCSystem...
DATA SOURCEENCRYPTED PASSWORDShell  akmac2:doag1_domain ak$ . ./bin/setDomainEnv.sh  akmac2:doag1_domain ak$ java weblogic...
APPLICATION DEPLOYMENT‣       2 Phasen                                             Java EE App    ‣          Vorbereiten  ...
HOW TO DEPLOY  connect(weblogic, welcome1, ADMIN_URL)  deploy(myApp, /path/to/myApp.ear, targets=Cluster1)  # targets=Serv...
HOW TO UNDEPLOY  connect(weblogic, welcome1, ADMIN_URL)  stopApplication(myApp)  undeploy(myApp)  # default: from all targ...
DEPLOYMENT COMMANDSCommanddeploy(appName, path, [targets], [stageMode], [planPath], [options])startApplication(appName, [o...
HOW TO RELAX(CUSTOM SOLUTION)                                        Keep last 10 EARs‣      ...falls das Deployment mal  ...
SIDE-BY-SIDY DEPLOYMENT  deploy(myApp, /path/to/myApp.ear, ..,appVersion = 1.0)               Bestehende Client-          ...
SERVER MONITORING  ..  state(<ServerName>)  ..  domainConfig()  serverNames = cmo.getServers()  domainRuntime()  for name ...
SERVER THREAD DUMP  ..  threadDump(writeToFile=true,fileName=/tmp/threaddump.txt,  serverName=AdminServer)  ..Andreas Koop...
DOMAIN CONFIG AS CODEDomain Configurationwls:offline>configToScript(configPath=$DH,pyPath=config.mydomain.py)MDS per Applic...
WLST RECORDING FEATURE‣      WebLogic Console Record (Aufzeichnen)-Button klicken‣      Gewünschte Konfiguration vornehmen‣...
CONCLUSION‣       WLST RULEZ!‣       MUST for every Oracle FMW Admin!‣       Vollständige Automatisierung von    ‣        ...
VIELEN DANK FÜR IHRE   AUFMERKSAMKEITHABEN SIE NOCH FRAGEN?
WebLogic Administration und Deployment mit WLST
Nächste SlideShare
Wird geladen in …5
×

WebLogic Administration und Deployment mit WLST

7.048 Aufrufe

Veröffentlicht am

PDF-Version http://www.enpit.de/wp-content/uploads/2012/08/20120829-doag-sig-fmw-wls-wlst.pdf

Veröffentlicht in: Technologie, News & Politik
  • Als Erste(r) kommentieren

WebLogic Administration und Deployment mit WLST

  1. 1. WEBLOGIC ADMINISTRATION UNDDEPLOYMENT MIT WLST „Infrastructure as Code“Oracle WebLogic Scripting Tool Best Practices Andreas Koop Consultant Oracle TechnologiesDOAG SIG Middleware, Köln, 29. Aug. 2012
  2. 2. Andreas KoopÜBER MICH Consultant Oracle TechnologiesBeratung, Training Oracle TechnologieADF Certified Implementation SpecialistCommunityDOAG, ADF EMG, ADF German Community, Twitter @multikoopBlogTechnical http://multikoop.blogspot.comSonstiges http://www.enpit.de/blog 2
  3. 3. ENTERPRISE.PRAGMATIC.IT Consulting Training Development Oracle Fusion Oracle Oracle Oracle Middleware WebCenter ADF WebLogicEnable productive IT by Oracle Technologies
  4. 4. AGENDAMotivation „Infrastructure as Code“Überblick WebLogic Scripting ToolBest Practices Administration und DeploymentAndreas Koop 4
  5. 5. INFRASTRUCTURE AS CODE‣ Vision - Bereitstellung einer lauffähigen Umgebung aus ‣ Source Code Repository ‣ Anwendungsdaten (Backup) ‣ Ressourcen (Physikalisch / Virtuell)‣ In Zeiten von Cloud und steigendem Bedarf nach horizontal skalierbaren System ist IaC unabdingbarAndreas Koop 5
  6. 6. RESTORE ENV FROM CODE app source App App SCM App Artefacts Artefacts Artefacts infra sourceDB / Service Endpoints configuration / Sh, Chef, WLST, ... data / backupAndreas Koop 6
  7. 7. WAS BRAUCHT EINEORACLE FMW UMGEBUNG?‣ WebLogic Installation, Domain ‣ WebLogic Konfiguration‣ Application Deployment ‣ Data Sources‣ System and Performance ‣ Message Queues Monitoring ‣ Logging ‣ Diagnostics (WLDF) App1 App2 ‣ Security Provider ‣ ...Andreas Koop 7
  8. 8. MANUELLE KONFIGURATIONIST KEINE LÖSUNGAndreas Koop 8
  9. 9. WEBLOGIC SCRIPTING TOOL‣ Jython basierte Scriptsprache zur Automatisierung jeglicher WebLogic Administrationsaufgabe‣ Read / Write MBeans‣ Offline ‣ ~ Configuration Wizard‣ Online ‣ ~ Administration ConsoleAndreas Koop 9
  10. 10. DOMAIN ERSTELLENreadTemplate(os.environ[WL_HOME] + /common/templates/domains/wls.jar)cd(/) Currentcmo.setName(my_domain) Managementcd(Servers/AdminServer) Objectcmo.setListenAddress( All Local Addresses )cmo.setListenPort( int(ADMIN_PORT) )cd( / )cd( Security/+DOMAIN_NAME+/User/ + ADMIN_USER )cmo.setPassword( ADMIN_PWD )cd(/)setOption( JavaHome, os.environ[JAVA_HOME] )setOption( "ServerStartMode", "prod")setOption( "OverwriteDomain", "true" )writeDomain( DOMAIN_DIR )closeTemplate()Andreas Koop 10
  11. 11. DOMAIN ERWEITERN# Z.B. um die ADF Runtime in Form der JRFreadDomain(DOMAIN_DIR)addTemplate(MW_HOME + /oracle_common/common/templates/applications/jrf_template_11.1.1.jar)updateDomain()closeDomain()exit()Andreas Koop 11
  12. 12. WLST EXECUTIONBEST PRACTICE (OFFLINE)#!/bin/shexport DOMAIN_HOME=/oracle/fmw /11.1.1.6/user_projects/domains /my_domainexport DOMAIN_NAME=my_domain... readTemplate(os.environ[WL_HOME] + / env/env.sh common/templates/domains/wls.jar) cd(/) cmo.setName(os.environ[DOMAIN_NAME])#!/bin/sh cd(Servers/AdminServer) cmo.setListenAddress( All Local. $PRJ_HOME/env/env.sh Addresses ). $DOMAIN_HOME/bin/setDomainEnv.sh cmo.setListenPort( int( WL_ADMIN_PORT) )cd $PRJ_HOME/bin/wlst ...java weblogic.WLST create.domain.py writeDomain( DOMAIN_DIR )cd - closeTemplate() bin/create.domain.sh bin/wlst/create.domain.pyAndreas Koop 12
  13. 13. WLST EXECUTIONBEST PRACTICE (OFFLINE)Andreas Koop 13
  14. 14. WLST ONLINE connect(weblogic, welcome1, t3://adminhost:7001) edit() startEdit() # do something save() activate() disconnect() exit()Andreas Koop 14
  15. 15. DOMAIN ERWEITERN connect(weblogic, welcome1, t3://adminhost:7001) edit() startEdit() cmo.createServer(os.environ[MS_NAME]) cd(/Servers/+ os.environ[MS_NAME]) cmo.setListenAddress() cmo.setListenPort(os.environ[MS_PORT]) cmo.setListenPortEnabled(true) cmo.setJavaCompiler(javac) cmo.setMachine(getMBean(/Machines/Machine1)) cmo.setCluster(Cluster1) cd(/Servers/+os.environ[MS_NAME]+/SSL/+os.environ[MS_NAME]) cmo.setEnabled(false) cd(/Servers/+os.environ[MS_NAME]+/ServerStart/+os.environ[MS_NAME]) cmo.setArguments(-Xms512M -Xmx1024M) save() activate() disconnect() bin/wlst/create.server.pyAndreas Koop 15
  16. 16. MODULARIZE WLST SCRIPTS connect(weblogic, welco..) execfile(connect.py) execfile(connect.py) edit() execfile(connect.py) execfile(start.edit.session.py) startEdit() execfile(start.edit.session.py) execfile(start.edit.session.py) ## do something # do something do something try: execfile(end.edit.session.py) execfile(end.edit.session.py) save() execfile(end.edit.session.py) execfile(disconnect.py) execfile(disconnect.py) execfile(disconnect.py) activate() exit() exit() except ... exit() .. bin/wlst/myscriptX.py disconnect()Andreas Koop 16
  17. 17. MODULARIZE WLST SCRIPTSEVEN MORE # Custom Functions import os def getDomainName(): return os.environ[DOMAIN_NAME] $WL_HOME/ def startEditSession(): common/wlst logInfo(start edit session) edit() startEdit() ... Custom Functions bin/wlst/modules/enpit.utils.py stehen dann alle Skripten .. zur startEditSession() Verfügung # do something saveAndActivate() ..Andreas Koop 17
  18. 18. WLST DOMAIN INTERACTION Quelle: Oracle FMW Doc LibAndreas Koop 18
  19. 19. DOMAIN STARTUPnmConnect(Dh4bZwJNNP, welcome1, DOMAIN_NAME, NM_PORT)nmStart(AdminServer)nmStart(WLS_FORMS)nmStart(WLS_REPORTS)nmStart(WLS_DISCO)nmStart(WLS_MY_APPS)..nmDisconnect()exit() bin/wlst/start.domain.pyAndreas Koop 19
  20. 20. WLST NODE MANAGERENCRYPTED PASSWORD nmConnect(Dh4bZwJNNP, welcome1, DOMAIN_NAME, NM_PORT) storeUserConfig(userConfigFile = .., userKeyFile = .., true) disconnect() # Ab jetzt: Anmeldung ohne Passwort im Klartext nmConnect(userConfigFile = NM_HOME + /userconfigNM.secure, userKeyFile = NM_HOME + /userkeyNM.secure, domainName = DOMAIN_NAME, port=5556) exit()Andreas Koop 20
  21. 21. DOMAIN SHUTDOWNNM_HOME = WL_HOME + /common/nodemanagernmConnect(userConfigFile = NM_HOME + /userconfigNM.secure, userKeyFile = NM_HOME + /userkeyNM.secure, domainName = DOMAIN_NAME, port=5556)nmKill(WLS_FORMS)nmKill(WLS_REPORTS)nmKill(WLS_DISCO)nmKill(WLS_MY_APPS)..nmKill(AdminServer)nmDisconnect()exit() bin/wlst/shutdown.domain.pyAndreas Koop 21
  22. 22. LOGGING LOGGING LOGGING‣ Never-Ending-Story‣ Was tun? Was berücksichtigen? ‣ Log Rotating ‣ Domain Log ‣ Server Logs‣ „Wo sind die Log-Files???“Andreas Koop 22
  23. 23. LOGGING KONFIGURATION execfile(connect.py) execfile(start.edit.session.py) cd(/Servers/AdminServer/Log/AdminServer) cmo.setStacktraceDepth(5) cmo.setRotationType(bySize) cmo.setDomainLogBroadcasterBufferSize(10) cmo.setLog4jLoggingEnabled(false) cmo.setNumberOfFilesLimited(false) cmo.setDateFormatPattern(dd.MM.yyyy HH:mm Uhr z) cmo.setBufferSizeKB(8) cmo.setFileMinSize(5000) cmo.setLoggerSeverity(Info) cmo.setRotateLogOnStartup(false) .. cmo.setRedirectStdoutToServerLogEnabled(true) cmo.setFileName(logs/AdminServer.log) execfile(end.edit.session.py) execfile(disconnect.py) exit()Andreas Koop 23
  24. 24. DEPLOYMENT‣ Data Source vorbereiten Java EE App‣ Targets deploy‣ Deploy ‣ Application ‣ Shared Libs App1 App2 ‣ EJBsAndreas Koop 24
  25. 25. DATA SOURCE ANLEGEN‣ JNDI Lookup#connect(..), edit() startEdit()cd(/)create(myDataSource, JDBCSystemResource)cd(JDBCSystemResource/myDataSource/JdbcResource/myDataSource)create(myJdbcDriverParams,JDBCDriverParams)cd(JDBCDriverParams/myDSName)set(DriverName,oracle.jdbc.OracleDriver)set(URL,jdbc:oracle:thin:@localhost:1521:XE)set(Password, HR)set(UseXADataSourceInterface, false)create(myProps,Properties)cd(Properties/myDSName)create(user, Property)cd(Property/user)cmo.setValue(HR)..cd(/JDBCSystemResource/myDataSource/JdbcResource/myDataSource)create(myJdbcDataSourceParams,JDBCDataSourceParams)cd(JDBCDataSourceParams/myDSName)set(JNDIName, java.lang.String("jdbc/hrDS"))Andreas Koop 25
  26. 26. DATA SOURCEENCRYPTED PASSWORDShell akmac2:doag1_domain ak$ . ./bin/setDomainEnv.sh akmac2:doag1_domain ak$ java weblogic.security.Encrypt HR {AES}s77UdlHeZXMziW4i8WoPxBSN/DovWtnpYEPTJbBQ70M=create.datasource.py .. cd(/) create(myDataSource, JDBCSystemResource) .. set(PasswordEncrypted, {AES}s77UdlHeZXMziW4i8WoPxBSN/DovWtnpYEPTJbBQ70M=) .. set(Targets,jarray.array([ObjectName(com.bea:Name=MS1,Type=Server)], ObjectName))Andreas Koop 26
  27. 27. APPLICATION DEPLOYMENT‣ 2 Phasen Java EE App ‣ Vorbereiten ‣ Deployment Durchführen deploy‣ Modi ‣ No Stage App1 App2 ‣ Stage ‣ External StageAndreas Koop 27
  28. 28. HOW TO DEPLOY connect(weblogic, welcome1, ADMIN_URL) deploy(myApp, /path/to/myApp.ear, targets=Cluster1) # targets=Server1 startApplication(myApp) disconnect() exit()Andreas Koop 28
  29. 29. HOW TO UNDEPLOY connect(weblogic, welcome1, ADMIN_URL) stopApplication(myApp) undeploy(myApp) # default: from all targets disconnect() exit()Andreas Koop 29
  30. 30. DEPLOYMENT COMMANDSCommanddeploy(appName, path, [targets], [stageMode], [planPath], [options])startApplication(appName, [options])stopApplication(appName, [options])undeploy(appName,[targets],[options]) Mittels plan.xmlupdateApplication(appName, [planPath], [options]) aktualisierenlistApplications()Andreas Koop 30
  31. 31. HOW TO RELAX(CUSTOM SOLUTION) Keep last 10 EARs‣ ...falls das Deployment mal 2012-08-02-myapp.ear 2012-08-02-myapp.ear 2012-08-02-myapp.ear nicht reibungslos läuft?‣ Deploy And Backup EAR deploy(...) shutil.copy(...)‣ Restore def restore(): #Get last EAR #deploy(lastEAR) myappAndreas Koop 31
  32. 32. SIDE-BY-SIDY DEPLOYMENT deploy(myApp, /path/to/myApp.ear, ..,appVersion = 1.0) Bestehende Client- Verbindungen app v1.0 app v2.0 Neue Client- Verbindungen deploy(myApp, /path/to/myApp.ear, ..,appVersion = 2.0)Andreas Koop 32
  33. 33. SERVER MONITORING .. state(<ServerName>) .. domainConfig() serverNames = cmo.getServers() domainRuntime() for name in serverNames: cd("/ServerRuntimes/"+name.getName()+"/JVMRuntime/"+name.getName()) heapFree = int(get(HeapFreeCurrent))/(1024*1024) heapTotal = int(get(HeapSizeCurrent))/(1024*1024) heapUsed = (heapTotal - heapFree) print %14s %4d MB %4d MB %4d MB % (name.getName(),heapTotal, heapFree, heapUsed)Andreas Koop 33
  34. 34. SERVER THREAD DUMP .. threadDump(writeToFile=true,fileName=/tmp/threaddump.txt, serverName=AdminServer) ..Andreas Koop 34
  35. 35. DOMAIN CONFIG AS CODEDomain Configurationwls:offline>configToScript(configPath=$DH,pyPath=config.mydomain.py)MDS per Applicationwls:online>exportMetadata(application=doag-demo, server=AdminServer, toLocation=/tmp/exportmdsUser / Groups Embedded LDAPwls:online> domainRuntime() cd(‘/DomainServices/DomainRuntimeService/DomainConfiguration/<domain>/SecurityConfiguration/<domain>/DefaultRealm/myre alm/AuthenticationProviders/DefaultAuthenticator’)cmo.exportData(DefaultAtn, /export.ldif, Properties())Andreas Koop 35
  36. 36. WLST RECORDING FEATURE‣ WebLogic Console Record (Aufzeichnen)-Button klicken‣ Gewünschte Konfiguration vornehmen‣ Generiertes WLST-Skript anpassen und integrierenAndreas Koop 36
  37. 37. CONCLUSION‣ WLST RULEZ!‣ MUST for every Oracle FMW Admin!‣ Vollständige Automatisierung von ‣ Domainerstellung, -konfiguration ‣ Application, Library Deployment ‣ Export / Import MDS ‣ Server - Startup / Shutdown - MonitoringAndreas Koop 37
  38. 38. VIELEN DANK FÜR IHRE AUFMERKSAMKEITHABEN SIE NOCH FRAGEN?

×