Saturday, March 1, 2014

How to Change the Weblogic Password in Oracle fusion Middleware domains

1. Login as "oracle" and then set your environment variables by running setDomainEnv.sh as follows:

# su - oracle
# cd /u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/bin
# . ./setDomainEnv.sh

2. Navigate to Weblogic security directory:

# cd /u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/security
3. Enter the below command to change WSLT :

# java weblogic.security.utils.AdminAccount weblogic new_password .


Don’t forget the period “.” at the end of the above command, it is required.

4. After running the command, the file “DefaultAuthenticatorInit.ldift” will get updated.

# ls -lah
total 44K
drwxr-xr-x  2 oracle dba 4.0K Jul 25 18:51 .
drwxr-xr-x 12 oracle dba 4.0K Aug 26 15:02 ..
-rw-r--r--  1 oracle dba 3.3K Aug 26 17:25 DefaultAuthenticatorInit.ldift
-rw-r--r--  1 oracle dba 2.4K Jul 25 18:51 DefaultRoleMapperInit.ldift
-rw-r--r--  1 oracle dba   64 Jul 25 18:51 SerializedSystemIni.dat
-rw-r--r--  1 oracle dba  23K Jul 25 18:51 XACMLRoleMapperInit.ldift

5. Delete or move the file “ldap” from "data" directory:

# cd /u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/servers/AdminServer/data
# ls -lah
total 16K
drwxr----- 4 oracle dba 4.0K Aug 26 17:26 .
drwxr-xr-x 9 oracle dba 4.0K Aug 14 16:25 ..
drwxr----- 2 oracle dba 4.0K Jul 25 19:02 console
drwxr----- 7 oracle dba 4.0K Aug 26 15:03 ldap
drwxr----- 4 oracle dba 4.0K Jul 25 18:51 store

# mv ldap ldap_old
# ls -lah
total 16K
drwxr----- 4 oracle dba 4.0K Aug 26 17:26 .
drwxr-xr-x 9 oracle dba 4.0K Aug 14 16:25 ..
drwxr----- 2 oracle dba 4.0K Jul 25 19:02 console
drwxr----- 7 oracle dba 4.0K Aug 26 17:27 ldap_old
drwxr----- 4 oracle dba 4.0K Jul 25 18:51 store


6 . Go to the directory /u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/servers/AdminServer/security

# cd /u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/servers/AdminServer/security
# ls -lah
total 12K
drwxr-xr-x 2 oracle dba 4.0K Aug 26 17:29 .
drwxr-xr-x 9 oracle dba 4.0K Aug 14 16:25 ..
-rw-r--r-- 1 oracle dba  150 Aug 26 15:01 boot.properties

# mv boot.properties boot.properties.bak
# ls -lah
total 12K
drwxr-xr-x 2 oracle dba 4.0K Aug 26 17:29 .
drwxr-xr-x 9 oracle dba 4.0K Aug 14 16:25 ..
-rw-r--r-- 1 oracle dba  150 Aug 26 17:29 boot.properties.bak


7. Create "boot.properties" file and change the password to the value already used on step 5.

- for example :
# vi boot.properties
#Wed Aug 14 16:34:41 KST 2013
password=test1234
username=weblogic


** Do write to "plain text". Weblogic will be encoded.


8. Start Weblogic Server (Weblogic Server will encrypt the password for you).

# cd /u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/bin
# ./startWeblogic.sh &
#
<Aug 26, 2013 5:32:00 PM KST> <Notice> <WebLogicServer> <BEA-000395> <Following extensions directory contents added to the end of the classpath:
/u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/lib/log4j.jar:/u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/lib/wllog4j.jar>
<Aug 26, 2013 5:32:01 PM KST> <Info> <WebLogicServer> <BEA-000377> <Starting WebLogic Server with Java HotSpot(TM) 64-Bit Server VM Version 20.12-b01 from Sun Microsystems Inc.>
<Aug 26, 2013 5:32:02 PM KST> <Info> <Management> <BEA-141107> <Version: WebLogic Server 10.3.5.0  Fri Apr 1 20:20:06 PDT 2011 1398638 >
<Aug 26, 2013 5:32:03 PM KST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING>
<Aug 26, 2013 5:32:03 PM KST> <Info> <WorkManager> <BEA-002900> <Initializing self-tuning thread pool>
<Aug 26, 2013 5:32:03 PM KST> <Notice> <LoggingService> <BEA-320400> <The log file /u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/servers/AdminServer/logs/AdminServer.log will be rotated. Reopen the log file if tailing has stopped. This can happen on some platforms like Windows.>
<Aug 26, 2013 5:32:03 PM KST> <Notice> <LoggingService> <BEA-320401> <The log file has been rotated to /u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/servers/AdminServer/logs/AdminServer.log00057. Log messages will continue to be logged in /u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/servers/AdminServer/logs/AdminServer.log.>
<Aug 26, 2013 5:32:03 PM KST> <Notice> <Log Management> <WL-170019> <The server log file /u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/servers/AdminServer/logs/AdminServer.log is opened. All server side log events will be written to this file.>
<Aug 26, 2013 5:32:32 PM KST> <Notice> <Security> <BEA-090082> <Security initializing using security realm myrealm.>
<Aug 26, 2013 5:32:32 PM KST> <Notice> <Security> <BEA-090083> <Storing boot identity in the file: /u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/servers/AdminServer/security/boot.properties>
<Aug 26, 2013 5:35:56 PM KST> <Notice> <LoggingService> <BEA-320400> <The log file /u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/servers/AdminServer/logs/access.log will be rotated. Reopen the log file if tailing has stopped. This can happen on some platforms like Windows.>
<Aug 26, 2013 5:35:56 PM KST> <Notice> <LoggingService> <BEA-320401> <The log file has been rotated to /u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/servers/AdminServer/logs/access.log00021. Log messages will continue to be logged in /u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/servers/AdminServer/logs/access.log.>

(Snip..)
<Aug 26, 2013 5:37:08 PM KST> <Notice> <WebLogicServer> <WL-000331> <Started WebLogic Admin Server "AdminServer" for domain "base_adf_domain" running in Development Mode>
<Aug 26, 2013 5:37:08 PM KST> <Notice> <WebLogicServer> <WL-000365> <Server state changed to RUNNING>
<Aug 26, 2013 5:37:08 PM KST> <Notice> <WebLogicServer> <WL-000360> <Server started in RUNNING mode>

#


9. Check to security files

# ls -lah /u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/servers/AdminServer/security
total 12K
drwxr-xr-x 2 oracle dba 4.0K Aug 26 17:30 .
drwxr-xr-x 9 oracle dba 4.0K Aug 14 16:25 ..
-rw-r--r-- 1 oracle dba  150 Aug 26 17:35 boot.properties

# cat /u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/servers/AdminServer/security/boot.properties
#Mon Aug 26 17:35:55 KST 2013
password={AES}5W2bd+ehLSu62QXC441qKqztanqtnTEKdsmJaHmx/gk\=
username={AES}+QkSK4ZRvLkI1hMCMqLM//ASgXHXwM3HCEcgfIc8aKI\=

How to Enable Monitoring on Proxy Services in OSB through WLST

We often get request to enable disable the monitoring on the Proxy Services which are deployed on the OSB, if we need to do it through console it might take a significant amount of time it;s fine when we have few projects deployed in the OSB when we have a lot and need to do it across the regions (dev, ist, perf, prod) it will take a significant time. 

We can use the WLST scripting to make the change on all the proxy services deployed in the OSB. 

Sample code for Time Saving and to get rid of boring of doing through obs consoles :)

---------------------------------------------------------------------------------------------------
# Scope    : To Enable the monitoring options on the proxy services deployed on the OSB.
# Process  :
#               1. Set the classpath
#                       CLASSPATH=/u01/app/oracle/product/fmw/Oracle_OSB1/lib/sb-kernel-api.jar:/u01/app/oracle/product/fmw/Oracle_OSB1/lib/sb-kernel-impl.jar:/u01/app/oracle/product/fmw/Oracle_OSB1/lib/modules/com.bea.alsb.configfwk-wls.jar:$CLASSPATH
#               2. export CLASSPATH
#               3. set the domain  eg : . ./bin/setDomain.sh
#               4. Update the sction below on the Enviroment specificaitons ( host,port,credentials)
#               5. execute the following command  java weblogic.WLST ProxyServiceMonotringOptions.py


import javax.management
import java.util
import javax.management.remote
import javax.naming
import weblogic.management.mbeanservers.domainruntime
import com.bea.wli.sb.management.configuration
import weblogic.management.jmx.MBeanServerInvocationHandler
from java.util import Hashtable
from java.util import HashSet
from java.util import ArrayList
from javax.management.remote import JMXServiceURL
from weblogic.management.mbeanservers.domainruntime import DomainRuntimeServiceMBean
from javax.naming import Context
from javax.management.remote import JMXConnectorFactory
from javax.management import ObjectName
from com.bea.wli.sb.management.configuration import SessionManagementMBean
from com.bea.wli.sb.management.configuration import ALSBConfigurationMBean
from com.bea.wli.sb.management.configuration import CommonServiceConfigurationMBean
from com.bea.wli.config import Ref
from com.bea.wli.config.env import EnvValueQuery
from com.bea.wli.config.env import QualifiedEnvValue
from com.bea.wli.config.resource import DependencyQuery
from com.bea.wli.sb.management.query import ProxyServiceQuery
from com.bea.wli.sb.management.query import BusinessServiceQuery
from com.bea.wli.sb.util import EnvValueTypes
from java.util import Collection
from java.util import Collections


def setMonitoringAllProjectsAndServices(isEnabled):
    refs = configMBean.getRefs(Ref.DOMAIN)
    refsList = ArrayList()
    refsList.addAll(refs)

    for ref in refsList :
        if ref.getTypeId() == "ProxyService" :
            if ref.getTypeId() == "ProxyService" :
                isPS = "1"
            else:
                isPS =  "0"
            if isEnabled:
                print "enabling monitoring for ", ref.getFullName()
                proxyServiceConfigurationMBean.enableMonitoring(ref)
            else:
                print "disabling monitoring for ", ref.getFullName()
                proxyServiceConfigurationMBean.disableMonitoring(ref)

        else:
                print " This is Not a Proxy", ref.getFullName()

# Update the environment specific values belwo

sessionName = "MonitorUpdate"
hostname='localhost'
port=7001
username='xxxxxx'
password='xxxxxx'
serviceURL=JMXServiceURL("t3", hostname, port, "/jndi/" + DomainRuntimeServiceMBean.MBEANSERVER_JNDI_NAME)
h=Hashtable()
h.put(Context.SECURITY_PRINCIPAL, username)
h.put(Context.SECURITY_CREDENTIALS, password)
h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote")

conn = JMXConnectorFactory.connect(serviceURL, h)

mbconn = conn.getMBeanServerConnection()

sm = JMX.newMBeanProxy(mbconn, ObjectName.getInstance(SessionManagementMBean.OBJECT_NAME), SessionManagementMBean)

sm.createSession(sessionName)
configMBean = JMX.newMBeanProxy(mbconn, ObjectName.getInstance("com.bea:Name=" + ALSBConfigurationMBean.NAME + "." + sessionName + ",Type=" + ALSBConfigurationMBean.TYPE), ALSBConfigurationMBean)

domainService = weblogic.management.jmx.MBeanServerInvocationHandler.newProxyInstance(mbconn, ObjectName(DomainRuntimeServiceMBean.OBJECT_NAME), DomainRuntimeServiceMBean, false)

proxyServiceConfigurationMBean = domainService.findService(String("ProxyServiceConfiguration.").concat(sessionName),'com.bea.wli.sb.management.configuration.ProxyServiceConfigurationMBean', None)

setMonitoringAllProjectsAndServices(true)

sm.activateSession(sessionName, "Complete enable/disable service monitoring")
conn.close()

-------------------------------------------------------------------------------------------------------