This Blog is discontinued, its only read-only

Tuesday, October 24, 2017

Manually rotate WebLogic Server Logfiles

From time to time you have the requirement to rotate the WebLogic Server Logfiles manually on the fly without stopping the WebLogic Managed Servers or AdminServer, for example while you perform some load tests in order to have fresh WebLogic Server Logfiles.

Here is a small Python Script, which rotates the WebLogic Server Logfiles for a list of given Managed Servers and AdminServer.

You will need:
  • rotatelogs.py = Python Script which rotates the Logfiles
  • domain.properties = Property File for the required connect data to the Admin Server of your WebLogic Domain
The rotatelogs.py Python Script will read the Property File (parameter -props) in order to get the necessary data for the connect to the Admin Server of your WebLogic Server Domain and will loop through your provided list of Servers (parameter -servers) and force a rotating of the logfiles. The list of Servers (parameter -servers) can accept multiple Servers delimited by ":".

domain.properties

# Align the values for your settings
admin.url=localhost:7001
admin.userName=weblogic
admin.password=welcome01

rotatelogs.py

# ============================================================
#
# Script: rotatelogs.py
#
# Author: Dirk Nachbar, https/dirknachbar.blogspot.ch
#
# Purpose: Rotates the WebLogic Server Logfiles for a list
#          of given Servers, either AdminServer or Managed Servers
#
# ============================================================

# Imports 
import sys
from java.io import File
from java.io import FileOutputStream
from java.io import FileInputStream

servers_list=''
configfile=''

def helpUsage():
    print 'Usage: rotatelogs.py -help'
    print '          [-servers] list of Servers, delimited by :'
    print '          [-props] properties file for connect to AdminServer'
    print 'E.g.:  wlst.sh rotatelogs.py -servers DEMOMS1:DEMOMS2 -props /home/oracle/domain.properties'
    exit()

def connectAdmin():
    connect(adminUserName,adminPassword,adminURL)

for i in range(len(sys.argv)):
    if sys.argv[i] == "-help":
        helpUsage()
    elif sys.argv[i] == "-servers":
        if i+1 < len(sys.argv):
            servers_list = sys.argv[i+1]
    elif sys.argv[i] == "-props":
        if i+1 < len(sys.argv):
            configfile = sys.argv[i+1]

if len(servers_list)==0 or len(configfile)==0:
    print 'Missing required arguments (-servers, -props)'
    print ''
    helpUsage()

propInputStream = FileInputStream(configfile)
configProps = Properties()
configProps.load(propInputStream)
adminURL=configProps.get("admin.url")
adminUserName=configProps.get("admin.userName")
adminPassword=configProps.get("admin.password")

connectAdmin()

domainRuntime()

servers=servers_list.split(":")

for server in servers:
    print '================================================'
    print 'Current Server: ' +server
    cd('/ServerRuntimes/'+server+'/ServerLogRuntime/'+server)
    print 'Rotating Logfile for Server: ' +server
    cmo.forceLogRotation()
    print '================================================'

Create the 2 above given files on your Server hosting the Oracle WebLogic Domain, align the domain.properties file with your settings, connect to your Server with the Oracle Software User and execute the script as following:

oracle@server> $ORACLE_HOME/oracle_common/common/bin/wlst.sh rotatelogs.py -props domain.properties -servers DEMOMS1:DEMOMS2
Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Connecting to t3://localhost:7001 with userid weblogic ...
Successfully connected to Admin Server "DemoAdminServer" that belongs to domain "demo_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 domainRuntime tree. This is a read-only tree 
with DomainMBean as the root MBean. 
For more help, use help('domainRuntime')

================================================
Current Server: DEMOMS1
Rotating Logfile for Server: DEMOMS1
================================================
================================================
Current Server: DEMOMS2
Rotating Logfile for Server: DEMOMS2
================================================

Happy rotating of WebLogic Server Logfiles . . .

Thursday, October 12, 2017

Changing Logfiles Permission of WebLogic and Node Manager Logfiles to 644

In some cases you will need to align the Logfile permissions of the Oracle WebLogic Server (12.2.1.1 and 12.2.1.2) and Node Manager generated Logfiles to 644 (-rw-r--r--), so that for example Monitoring Tools like Patrol can access and monitor the WebLogic Server Logfiles with another OS user as the Oracle Software Installation user.

Just take a look on the Start Script startWebLogic.sh under your $DOMAIN_HOME/bin and the startNodeManager.sh under $ORACLE_HOME/wlserver/server/bin. Within these 2 Start Scripts you will find each a line defining the umask with 027.

# Snippet from $ORACLE_HOME/wlserver/server/bin/startNodeManager.sh

. . .
# Set user-defined variables.
unset JAVA_VM MEM_ARGS

umask 027


mypwd="$(pwd)"
. . .

# Replace the line "umask 027" with "umask 022"

. . .
# Set user-defined variables.
unset JAVA_VM MEM_ARGS

umask 022


mypwd="$(pwd)"
. . .

# Snippet from $DOMAIN_HOME/bin/startWebLogic.sh

. . .
umask 027


mypwd="$(pwd)"
. . .

# Replace the line "umask 027" with "umask 022"

. . .
umask 022


mypwd="$(pwd)"
. . .

When you startup now your Node Manager and your WebLogic Server Domain, your Logfiles will still have the permissions "-rw-r-----" :-(

That's a known bug, for Oracle WebLogic Server 12.2.1.1.0 and 12.2.1.2.0 just apply the Patch 24794915.



After you applied the patch, you will get the required permissions with "-rw-r--r--".
Under Oracle WebLogic Server 12.2.1.3.0 the bug is already fixed and you don't need to apply any patch for the umask problem.


Tuesday, October 10, 2017

ODC Appreciation Day: Oracle GitHub Docker Images and Oracle Container Registry

It's time again for the ODC Appreciation Day (formerly known as OTN Appreciation Day) driven by Tim Hall.

My personal favorite this year are the Oracle GitHub Docker Images and the Oracle Container Registry.

The Oracle GitHub Docker Images (https://github.com/oracle/docker-images) are the "Community Version" provided by Oracle. So in order to use them you will need to download upfront the required Installation Software from OTN or Oracle Software Delivery Cloud.

Under the Oracle GitHub Docker Images you can find a wide range of Ready-To-Use Docker Images for nearly all the main products of Oracle:

  • Oracle WebLogic
  • Oracle Fusion Middleware Infrastructure
  • Oracle Java
  • Oracle Database
  • Oracle SOA Suite
  • and so on

The great thing about is, that you can easily start by using simple architectures, e.g. a single Oracle WebLogic Domain and learn how to build Docker Images.
In the next step you can extend the provided Dockerfiles with your own stuff/needs or use more complex architectures like Oracle WebLogic Cluster.

The Oracle GitHub Docker Images are quite frequently updated, corrected and extended by several Oracle people, e.g. Bruno Borges and Gerald Venzl. For example under the Section OracleWebLogic you can even find Dockerfiles the latest Release of Oracle WebLogic Server 12.2.1.3.0.


On top you can even find Workshop materials within the Oracle GitHub Docker Images, e.g. Workshop for Creating Docker Images for Oracle WebLogic.



On the other hand you have the Oracle Container Registry (https://container-registry.oracle.com) which is a kind of "Official Source". They are containing complete Docker Images, so you dont need to download any Installation Software from Oracle Technology Network or Oracle Software Delivery Cloud, just simply pull your required Docker images. 



If any body is interested to know more about Docker Images or got some specific questions or problems, a good starting point is the Oracle Community Forum "OTN Docker Space" https://community.oracle.com/community/server_&_storage_systems/containers.

Happy ODC Appreciation Day to everyone :-)