Top Weblogic Tasks You can Automate Now Session ID#: 10506 Prepared by: Mrityunjay Kant Practice Manager, SOA & Integration Services AST Corporation @MrityunjayKant REMINDER Check in on the COLLABORATE mobile app
Specialized. Recognized. Preferred. OUR SERVICES ORACLE PARTNERSHIP ORACLE SPECIALIZED Enterprise Resource Planning Business Intelligence EPM-Hyperion Middleware CRM Managed Services Education / Oracle University Project Advisory Services Oracle Platinum Partner Pillar Partner SOA Business Intelligence Hyperion Oracle University Approved Education Center Oracle University Reseller Oracle Accelerator Implementer Oracle Managed Cloud Services Implementer Oracle Cloud Marketplace Small Business Strategy Council Advanced Partner Support EBS Financial Management EBS Human Capital Management EBS Supply Chain Management BI Applications BI Foundation Service Oriented Architecture Public Sector Utilities Travel & Transportation Education & Research Application Development Framework 11g WebCenter Content 11g Access Management Suite Plus 11g Hyperion Planning 11 Essbase 11 Database 11g Hyperion Financial Management 11 3 Time Oracle Excellence Award Winner 2014 Chicago Tribune Top 100 Workplaces 2014, 2013, 2012 Inc. 5000 Fastest Growing Companies 2014, 2012 Best & Brightest Companies to Work For 2011 Inc. Top Small Company Workplaces
Agenda About Weblogic Server Weblogic tasks you can Automate Now Weblogic Cluster Administration Q&A * All code/scripts in this presentation are available as part of white paper
Weblogic Server Introduction #1 in worldwide Application Server Software The Foundation for Oracle Applications and Middleware Technologies Platform The Foundation for Cloud Applications and Application Infrastructure Consolidation Supported features such as Java EE Standards Scalability/Clustering Monitoring & Management Enterprise Security Enterprise Messaging Linear Scalability Coherence etc Latest Version 12.1.3
What is Weblogic Scripting (WLST)? Scripting Interface to Weblogic server Based on Java Scripting Interpreter - Jython Provides repeatable process for propagating configuration changes across environments Quickly allow environments to be replicated and migrated Can be in either online or offline operation
Interaction Modes Interactive Script Enter a command and view response at a command-line prompt In online mode shell maintains a persistent connection to a WLS instance Text file with a.py extension Executed using Jython commands for running scripts Invoke a series of WLST commands without requiring your input Embedded Instantiate WLST interpreter in your Java code Execute WLST command from a Java program
Connection Modes Offline Analogous to the Configuration Wizard Read and write access to the configuration data that is persisted in the domains configuration directory or domain template JAR Intended to create domain or modify a non-running domain Used during WLS install to create samples domain Online Analogous to the Administration Console JMX client Interacts with server s MBeans Intended as runtime management tool: configuration, management, deployment and monitoring
WLST Offline Can/Can t Do Can Do Create/modify templates Create domains Extend domains Access and modify configurations for offline domain Can t Do View runtime performance data Modify security data Do not use Offline mode to manage configuration of an active domain. Offline edits are ignored by running servers and can be overwritten by other JMX client such as WLST Online and Administration Console
WLST Online Can/Can t Do Can Do Change Configuration View runtime data Deploy applications Start/stop servers Can t Do Create a domain (must be offline mode)
Invoking WLST (Online) Ensure you have the Weblogic server installed! Remember all commands are case sensitive Set the run env with following script: WL_HOME\server\bin\setWLSEnv Enter following command to run WLST: java weblogic.wlst Starts in offline mode Connect to domain wls:/(offline)> connect('username','password','t3s://localhost:7002')
Traversing Mbean Trees Simpler than JMX no need to know JMX object name Mbeans are hierarchical, similar to a file system, with DomainMBean at top of tree Use commands similar to Unix to traverse cd(), ls() Syntax is same as WLST offline Domain MBean (root) - - - MBean Type (ServerMBean) - - - MBean Instance (ManagedServer1) - - - MBean attributes & Operations (AutoRestart) - - - MBean Instance (ManagedServer2)
Available Mbean Trees domainconfig Configuration hierarchy of the entire domain; represents configuration MBeans in RuntimeMBeanServer domainruntime Hierarchy of runtime Mbeans for entire domain; read only serverconfig Configuration hierarchy (configuration Mbeans) of the server you are connected to; read only serverruntime hierarchy of runtime Mbeans of the server you are connected to; read only
Available Mbean Trees edit jndi custom Writable domain configuration with pending changes; represents configuration MBeans in EditMBeanServer Read-only JNDI tree for the server you are connected to List of custom MBeans Can be hierarchical/grouped if MBeans use namespaces correctly
Switching Between Trees Use appropriate command to move to a different tree domainconfig() serverconfig() domainruntime() serverruntime() edit() jndi() custom() When returning to a tree, you return to the same place where you left, except custom and jndi (return to root)
Changing Configuration (Online) Step Change to the edit tree Get an edit lock Syntax wls:/wl_server/domainconfig> edit() wls:/wl_server/edit> startedit() Make Changes wls:/wl_server/edit!> cmo.createserver(managedserver1 ) wls:/wl_server/edit!> cd('/servers/managedserver1') wls:/wl_server/edit!> cmo.setlistenport(8001) wls:/wl_server/edit!> cmo.setlistenaddress( my-address ) Save and implicitly validate your changes Activate/distribute, release lock wls:/wl_server/edit!>save() wls:/wl_server/edit!> activate()
Current Management Object CMO variable current management object Java bean that serves as proxy for direct access to the WLS MBean Makes it easy to interact with Mbean get and set attributes, other commands Always set to the current WLST path Only available for WLS MBeans, not custom MBeans Example: wls:/mydomain/edit> cmo.setadministrationport(9091) (This example changes the Administration port in Domain MBean)
Start/Stop Server Invoke WLST java weblogic.wlst Connect to Node Manager nmconnect('weblogic', 'welcome1', 'localhost', '5556', 'mydomain', /usr/oracle/wls/user_projects/domai ns/mydomain', plain') Start Server (can be admin or managed server) nmstart( servername ) Stop Server nmkill( servername ) Server Status nmserverstatus( servername )
Server Lifecycle commands using WLST You can also manage server lifecycle through WLST without using node manager commands startserver start the Administration server start Start a managed server instance or cluster using Node Manager suspend Suspend a running server resume - Resume a suspended server shutdown Gracefully shutdown a running server instance or cluster migrate Migrate services to a target server within a cluster
Product Demo
Scripting Basics Each Script has 4 basic parts Import Section Global Variables Definitions class/functions Main program Data Types Base Datatypes integer, float, long, char, str, bool Collection Types list, dictionary, tuple, sequences, maps etc Object types Python objects and Java package objects The help() command gives info on any built-in functions
Automated start Admin Server Create a domain.properties file Create a Start_Admin.py script file Execute the script from command line or shell/batch script * All code/scripts in this presentation are available as part of white paper
Send Email on Server state Ready to use script, just change Admin email Does not need cron job for scheduling! Admin server need not be running for this script to run More reliable than just checking serer logs Bonus Script send email on application status! * All code/scripts in this presentation are available as part of white paper
Create a Data Source Can create multiple data sources with one script Properties file contains all details for data sources Can be used for creation of a new environment Execute using following command: java weblogic.wlst createmultipledatasource.py
Start/Stop Data Source To shutdown a data source: connect( weblogic,welcome1,'t3://localhost:7001') domainruntime() cd( ServerRuntimes/AdminServer/JDBCServiceRuntime/AdminServer/ JDBCDataSourceRuntimeMBeans/TestDS ) objectarray = jarray.array([], java.lang.object) stringarray = jarray.array([], java.lang.string) invoke( shutdown, objectarray, stringarray) exit() Replace shutdown with start to start the data soruce.
Forcibly Rotate Server Logs Comes handy if the log file is too big Can be run anytime as needed Ability to adjust max log file size Recommend setting correct log configuration to allow auto rotate
Deploy Apps Allow deployment of apps using script Can recursively pick apps form a dir and deploy List of applications specified in property file Easy setup of a new env! Can also be used to un-deploy applications. Change the deploy command to undeploy
Creating Users and Groups Can create multiple users and groups with one script Properties file contains all details for users and groups Can be used for creation of a new environment Execute using following command: java weblogic.wlst createusersngroups.py
Disable/Enable Admin Console Provides additional security Prevents unauthorized access May be required by policy or for audit compliance Disable Admin console connect("weblogic","welcome1","t3://localhost:7001") edit() startedit() cmo.setconsoleenabled(false) save() activate() disconnect() exit() To enable console, replace false with true in above step
Advanced Weblogic Concepts - Clusters
What is a Cluster? Multiple Servers running together as one unit Can be on same or different machines Appears to clients as a single unit Is part of Domain
Why Cluster? Scalability High-Availability Application Fail over Load Balancing Whole server migration!
What can be clustered? Servlets JSPs EJBs Remote Method Invocation (RMI) objects Java Messaging Service (JMS) destinations Web Services (if cluster aware) These cannot be clustered: File services including file shares Time services
Dynamic Clusters Server instances that can be scaled at runtime Meets peak application needs Can be destroyed when not needed Uses a template to create and spawn new servers automatically
Clustering Best Practices Plan for clusters from Day 1 High Availability Scalability Zero downtime upgrades! Use scripts to monitor managed server states Keep log rotation in check Configure In-Memory Replication HTTP Session state management Ask developers to design idempotent services for clusters Use Weblogic Clustering API Don t put cluster nodes in DMZ Web and Application Nodes Use logical DNS names instead of IP addresses Load test cluster capacity before Production
Resources WLST Basics https://docs.oracle.com/middleware/1213/wls/wlstg/toc.htm WLST Command Reference https://docs.oracle.com/middleware/1213/wls/wlstc/reference. htm#wlstc119 Weblogic Administration https://docs.oracle.com/middleware/1213/wls/wlach/core/inde x.html WLST Sample Scripts https://docs.oracle.com/middleware/1213/wls/wlstg/intro.ht m#wlstg112 WL_HOME\wlserver\common\templates\scripts\wlst
Thank You! Mrityunjay Kant mkant@astcorporation.com
Please complete the session evaluation We appreciate your feedback and insight You may complete the session evaluation either on paper or online via the mobile app