Tuesday, November 17, 2009

Ldap Browser

Today I had issue where I need to check if a particular user existed in the realm or not. Many times during Weblogic Administration we face these kind of tasks where we need to see whats is in the "Embedded LDAP" server. Below are the steps to install "LDAP Browser" and connect it to "Embedded LDAP" server which ships by default with weblogic server.

1) There are many free ldap browsers available but I had used "Softerra" ldap browser. You can download this browser from the link Softerra LDAP Browser

2) You will be downloading "msi(Microsoft Installer)" file. Just click on this "ldapbrowser26.msi" and follow the steps of installation which are very simple. Once the installation is complete, go to "Start --> Programs --> Softerra Ldap Browser" and click on "LDAP Browser 2.6" which should open the browser.

3) Before creating profile, we need to need to set password for our "Embedded LDAP server" in the weblogic domain. For this Login to the console, go to "Domain --> Security --> Embedded LDAP" and enter new password in the fields "Credential" and "Confirm Credential".

4) Once you had reset we need to create profile for this "Weblogic Domain" in Ldap Browser. Follow below steps
a) Click on "File --> New Profile". Enter a profile name in GUI and click "Next" . Below is the screen shot.



b) Enter below details for "Host Information" screen and click next.
Host :- hostname on which your weblogic server is installed.
Port :- Port on which weblogic Admin server is running.
Base DN :- dc=YourDomainName. For example dc=VASTestDomain
Anonymous bind :- false(don't check this check box)



c) Enter below details for "Credentials" screen and click Finish.
User DN :- cn=Admin
Password :- enter password( you had set this password in step 3)



5) Once you had finished about step you can see your "profile" under left hand side column. Expand the profile you can see all details of the "Embedded LDAP Server".




Note :- There are lot more features where you can export or import your LDAP data. Please explore the tool.

Acknowledgments :- http://download.oracle.com/docs/cd/E12840_01/wls/docs103/secmanage/ldap.html

Tuesday, November 10, 2009

Silent Mode Installation

Today I had a task where I need to install Weblogic on multiple servers. I am guy who doesn't like to use GUI for any installation, I want to execute script and work on other tasks, and just check logs later :-). Luckily BEA had provided method for this, which is called 'SILENT MODE INSTALLATION'. Below are the steps to perform this.

1) Download binary file, it my case its portal installation so I had used 'portal103_linux32.bin'.
2) Go to the directory where the above file is located. Save the XML file. In my case I had selected 'VASSilent.xml'. Download XML file below or check the image. I can't paste XML code because blog interprets that code.

DOWNLOAD SILENT XML FILE HERE



3) Execute the below command from location where bin file is located.

./portal103_linux32.bin -mode=silent -silent_xml=/usr/VASVijay/VASSoftware/VASsilent.xml -log=/usr/VASVijay/VASSoftware/VASSilent.log

4) Tail the log 'VASSilent.log' for errors, if there are no errors then above code must return '0'.

Thanks.

Vijay Bheemineni.

Saturday, November 7, 2009

WLST script to post source path of an application

Yesterday Neeraj posted question in Oracle forums, how to get absolute source path of an application using WLST, below is the script for this.

NOTE :- Replacec "#TAB#" with "tab" keystroke. Blogspot removes "tabs", so please replace the "#TAB#" else code will not work.


# START OF SCRIPT

connect('vasadmin','vaspassword','t3://localhost:7001')
domainConfig()
vasApps = cmo.getAppDeployments()

for app in vasApps:
#TAB#vasAppPath = '/AppDeployments/' + app.getName()
#TAB#cd(vasAppPath)
#TAB#print app.getName() + ' : source path is : ' + cmo.getAbsoluteSourcePath()

# END OF SCRIPT

Thanks.

Vijay Bheemineni.

Friday, November 6, 2009

Incorrect version of application

Today we had an issue where we deployed new version of the application but still the version page was showing old version number. We had checked the directory location and archive file name from the console, every thing looked fine. We had also extracted archive file on Admin Server and checked "version" page info which displayed the correct version but the same page was displaying in-correct version from the browser.

Finally we checked "version" page in the "DOMAIN_HOME/servers/ManagedServer/data/stage/ApplicatioName/ApplicationName.ear" on the Managed Server, and this page had old version number. This is when we figured it out that we forgot to select "stage" option during deployment, where Admin Server copies the archive file to Managed Server "stage" directory when we select "stage" option.

So we had deleted current application and made sure we had selected "stage" option and deployed the application again. Once this was done we were getting correct version number from the "version" jsp page.

Vijay Bheemineni.

Script to reset weblogic Admin password

Few times I had faced issue where our team has forgot weblogic admin password, we reset the password using steps below but I had put every thing into korn shell script so that it would be easy to reset the password. Below is the korn shell script which helps to reset your 'admin' password. I had tested the script works for me, please back up original domain before executing the script.

Execution steps :-
1) Shutdown Admin Server
2) ksh VASResetWeblogicAdminUserNamePassword.ksh vasNewUsername vasNewPassword
3) Restart Admin Server. New 'DefaultAuthenticatormyrealmInit.initialized' should have been created under 'DOMAIN_HOME/servers/YourAdminServerName/data/ldap'

Change following parameters in the scripts "vasWLHOME", "vasDomainHome","vasAdminServerName" as per your environment.

### START OF SCRIPT ###

#!/bin/ksh

# Written by Vijay Bheemineni on 11/06/2009

vasNewUserName="$1"
vasNewPassword="$2"
vasWLHOME="/usr/bea10mp1/wlserver_10.0/server/bin"
vasDomainHome="/usr/VASVijay/VASDomains/VASNewDomain"
vasAdminServerName="VASAdminServer"

# Take back up of orginal domain, just as safe side
cp -r ${vasDomainHome} ${vasDomainHome}.org

# set weblogic class path
. ${vasWLHOME}/setWLSEnv.sh

# Create new 'DefaultAuthenticatorInit.ldift' file.
java weblogic.security.utils.AdminAccount ${vasNewUserName} ${vasNewPassword} .

# Back old 'DefaultAuthenticatorInit.ldift' file
cp ${vasDomainHome}/security/DefaultAuthenticatorInit.ldift ${vasDomainHome}/security/DefaultAuthenticatorInit.ldift.org

# Move newly created 'DefaultAuthenticatorInit.ldift' to ${vasDomainHome}/security directory
mv DefaultAuthenticatorInit.ldift ${vasDomainHome}/security/DefaultAuthenticatorInit.ldift

# Move original DefaultAuthenticatormyrealmInit.initialized, new one will be created when we restart the server.
mv ${vasDomainHome}/servers/${vasAdminServerName}/data/ldap/DefaultAuthenticatormyrealmInit.initialized ${vasDomainHome}/servers/${vasAdminServerName}/data/ldap/DefaultAuthenticatormyrealmInit.initialized.org

### END OF SCRIPT ###

Tuesday, November 3, 2009

Simple WLST interpreter java code

One of fellow admin "Kuppuswamy" posted query in Oracle forums, where he wants to write java program to shutdown server and the same time he doesn't want to pass plain text code.

Here is the simple "WLST interpreter script", I didn't have time so tried to keep java code as simple as possible(didn't follow good coding practices :-( ). Before executing this java program you need to generate keys. Below is the procedure for that.

Assumption :-

BEA_HOME :- /usr/VASVijay/bea10mp1
WL_HOME :- BEA_HOME/wlserver_10.0

1) Go to WL_HOME/server/bin and set the environment by executing "setWLSEnv.sh".
2) Then execute below command which generate "userconfig" and "userkey" files in the directory you had execute this command

java weblogic.Admin -adminurl t3://adminserverl:port -username -password -userconfigfile userconfig -userkeyfile userkey -STOREUSERCONFIG

This command prompts for "Y" or "N", select "Y", then creates two files "userconfig" and "userkey"

3) Validate above keys are correct, execute below command

java weblogic.Admin -adminurl t3://adminserverl:port -userconfigfile userconfig -userkeyfile userkey -GETSTATE

Above command should display "RUNNING".

4) Compile below java code and execute. Change the server name(VASMS1) in "shutdown('VASMS1','Server') according to your server name.

import java.util.*;
import weblogic.management.scripting.utils.WLSTInterpreter;
import org.python.util.InteractiveInterpreter;

public class VASServerShutdown
{
static InteractiveInterpreter interpreter = null;

VASServerShutdown()
{
interpreter = new WLSTInterpreter();
}

private static void connect()
{
StringBuffer buffer = new StringBuffer();
buffer.append("connect(userConfigFile='/usr/VASVijay/VASDomains/VASNewDomain/userconfig',userKeyFile='/usr/VASVijay/VASDomains/VAS
NewDomain/userkey',url='t3://localhost:8001') \n");
buffer.append("print(cmo)");
interpreter.exec(buffer.toString());
}

public static void serverShutdown()
{
StringBuffer buffer = new StringBuffer();
buffer.append("shutdown('VASMS1','Server')");
interpreter.exec(buffer.toString());
}
public static void main(String args[])
{
new VASServerShutdown();
connect();
serverShutdown();

}
}

WLST Get number of current sessions from all applications on all servers

Yesterday some one posted query regarding "How to get open current sessions of an application, similar to what we see in console using WLST" on Oracle forums. Below is the script to the query. I need to thank my friend who had posted this question, because this query allowed me to do research little bit deeper and help me to understand the MBean concept in a better way. I had finished this script yesterday itself but there was some small logical flaw due to which I was not getting expected results. Finally script worked today.


Note :- Google blogspot is removing tabs etc from python script, so I am attaching an Image(connnect() function had been removed from image) and also attaching python file which can be downloaded.

Download Script Here