REMINDER
Check in on the COLLABORATE mobile app
Top Weblogic Tasks You can
Automate Now
Prepared by: Mrityunjay Kant
Practice Manager, SOA & Integration Services AST Corporation
Session ID#: 10506
Specialized. Recognized. Preferred.
3 Time Oracle Excellence
Award Winner 2014 Chicago TribuneTop 100 Workplaces Fastest Growing Companies2014, 2013, 2012 Inc. 5000
2014, 2012 Best & Brightest Companies
to Work For
2011 Inc. Top Small Company Workplaces
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
Agenda
■ About Weblogic Server
■ Weblogic tasks you can Automate Now
■ Weblogic Cluster Administration
■ Q&A
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…
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
Interaction Modes
■ Interactive
▪ Enter a command and view response at a command-line prompt
▪ In online mode shell maintains a persistent connection to a WLS instance
■ Script
▪ 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
Connection Modes
■ 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
■ 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
■ Create/modify templates
■ Create domains
■ Extend domains
■ Access and modify
configurations for offline domain
■ View runtime performance data
■ Modify security data
Can Do Can’t Do
WLST Online Can/Can’t Do
■ Change Configuration
■ View runtime data
■ Deploy applications
■ Start/stop servers
■ 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)>
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)
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
Available Mbean Trees
■ edit
▪ Writable domain configuration with pending changes; represents configuration MBeans in EditMBeanServer
■ jndi
▪ Read-only JNDI tree for the server you are connected to
■ custom
▪ List of custom MBeans
Switching Between Trees
■ Use appropriate command to move to a different tree
▪ domainConfig() ▪ serverConfig() ▪ domainRuntime() ▪ serverRuntime() ▪ edit() ▪ jndi() ▪ custom()
Changing Configuration (Online)
Step Syntax
Change to the edit tree wls:/wl_server/domainConfig> edit()
Get an edit lock 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 wls:/wl_server/edit !>save()
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)
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
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
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
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
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!
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:
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()
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
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.
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:
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()
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
Why Cluster?
■ Scalability
■ High-Availability
■ Application Fail over
■ Load Balancing
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
Dynamic Clusters
■ Server instances that can be scaled at runtime
■ Meets peak application needs
■ Can be destroyed when not needed
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
Thank You!
Mrityunjay Kant
Please complete the session
evaluation
We appreciate your feedback and insight