Wednesday, April 17, 2013

How to do Multicast Test on the Network


When you have servers in one cluster, the servers communicate with each other using multicast messaging mode.

But most of times you see the messages in the log files of the servers like “Lost Multicast Messages”(because of network or some other reasons)

This means there is something wrong in the servers communication. At this point of time it is necessary to test the network connection between the ip addresses where the clusters are running.

We have simple syntax to test the multicast
Syntax : java utils.MulticastTest -n name -a address [-p portnumber] [-t timeout] [-s send]
-N : Name of the server so that you can identify the communication.
-A : Multicast address on which the messages are sent and received.
-P : This is the multicast port number on which the servers communicate.
-T : This is the timeout value, if no multicast message is received within this time, warning is shown on the shell prompt.
-S : The duration in seconds between sending the messages.
Below is how you do it:
Test :  Start the command prompts on machines where you have your managed servers. (can be 1 or more)
Ensure that the servers in the cluster are not running, this test is for checking the network connectivity.
Set the java environment on both the shells. Then enter the below syntax:
System 1 : java utils.MulticastTest -N Instance1 -A 237.0.0.1 -P 7004 -T 10 -S 2
System 2 : java utils.MulticastTest -N Instance2 -A 237.0.0.1 -P 7004 -T 10 -S 2

Difference between Multicast message and Unicast


When servers are in a cluster, these member servers communicate with each other by sending heartbeats and indicating that they are alive. For this communication between the servers, either unicast or multicast messaging is used. This is chosen from the admin console in Cluster -> Configuration -> Messaging -> Messaging Mode.
To use multicast messaging, hardware configuration and support for multicast packets is required. Unicast does not have this requirement, which is why using unicast in latest versions is recommended.
When multicast messaging is used, it is a one-to-many communication, every server sends the notification/heartbeat/multicast packet to each other. This causes a heavy load on the application’s multicast buffer, so if the buffer is full, new multicast messages cannot be written to the buffer and the application is not notified when messages are dropped. So there is a possibility that the server instances miss the messages. This might lead in the cluster throwing out the server instances out of the cluster.
Unicast configuration is much easier because it does not require cross network configuration that multicast requires. Additionally, it reduces potential network errors that can occur from multicast address conflicts.
Mode of Communication:
Multicast – A multicast address and multicast port is used for listening to the messages.
Unicast – A network channel is used for communication between the servers. If no channel is specified, default network channel is used.
=====================
Method of communication between servers:
Multicast – Each server communicates with every member server in the cluster. Which means heartbeats are sent to every server.
Unicast - For the member servers in the cluster, group leaders are chosen and only those group leaders communicate with the servers among the group and these leaders notify each other about the availability of all the other servers.
For example : Suppose there are 6 servers in the cluster. 2 groups are made and there are 2 group leaders. Other 2 servers of the group will notify their leader that they are alive and the group leader will send this information to the leader of other group.
The frequency of communication in unicast mode is similar to the frequency of sending messages on multicast port.
=====================
For new server versions, using unicast is recommended because it is a simplified communication mode. But for backward compatibility with the previous versions, you will need to use multicast if there is a communication requirement between clusters of versions prior to WLS 10.0.
Whenever the messaging mode of the cluster is changed, all the servers in the cluster need a restart because the changes are not dynamic.
If you have any questions regarding unicast and multicast messaging mode, please let us know about it.

How to configure Sunone Iplanet server for Weblogic server

Just follow the simple steps .... !
Step 1). Create a Web server running on port 8081 using the Admin Console of SunOne(port should be uniq).
Step 2). Copy over the plugin present in the following directory
C:\bea103\wlserver_10.3\server\plugin\win\32\proxy61.dll
To the Sun One Installation Directory
C:\Sun\WebServer6.1\plugins\lib
Step 3). Load the plugins by adding the following lines in magnus.conf present in
C:\Sun\WebServer6.1\https-testserver\configsu
magnus.conf
Init fn=”load-modules” funcs=”wl_proxy,wl_init” shlib=”C:/Sun/WebServer6.1/plugins/lib/
proxy61.dll”
To forward request to a Standalone Server add the following lines to obj.conf file present in
the following directory
C:\Sun\WebServer6.1\https-testserver\config
obj.conf

To forward request to a CLuster we need to add the following in the bj.conf file

To configure SSL Between SunOne Webserver and Weblogic Server, add the following in
the obj.conf file

where rootCA.pem is the root certificate of Weblogic Server.
Step 4). Start the test server using startsvr.bat present in
C:\Sun\WebServer6.1\https-testserver
Step 5). Acess the Weblogic Console using the following url
http://localhost:8081/console

Monday, December 17, 2012

Monitoring JDBC Datasource Runtime Attributes using WLST

In weblogic server , we can monitor the JDBC resources easly with WLST.

See how can ?
Step 1 :- Set the environment
C:\bea103\user_projects\domains\testdomain\bin>setDomainEnv.bat
Step 2:- Connect to server and browse to the JDBCDataSourceRuntime MBean
C:\bea103\user_projects\domains\testdomain>java weblogic.WLST
Initializing WebLogic Scripting Tool (WLST) …
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands
wls:/offline> connect()
Please enter your username [weblogic] :
Please enter your password [weblogic] :
Please enter your server URL [t3://localhost:7001] :t3://localhost:7003
Connecting to t3://localhost:7003 with userid weblogic …
Successfully connected to managed Server ‘MS0′ that belongs to domain ‘testdomain′.
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.
wls:/testdomain/serverConfig> serverRuntime()
Location changed to serverRuntime tree. This is a read-only tree with ServerRunt
imeMBean as the root.
For more help, use help(serverRuntime)
wls:/testdomain/serverRuntime> cd(‘JDBCServiceRuntime’)
wls:/testdomain/serverRuntime/JDBCServiceRuntime> cd(‘MS0′)
wls:/testdomain/serverRuntime/JDBCServiceRuntime/MS0> cd(‘JDBCDataSourceRuntimeMBeans’)
wls:/testdomain/serverRuntime/JDBCServiceRuntime/MS0/JDBCDataSourceRuntimeMBeans> cd(‘MyDs’)
gaRules> cmo.getActiveConnectionsCurrentCount()
1
The other JDBC Datasource Runtime attributes that can be monitored are listed below.
wls:/testdomain/serverRuntime/JDBCServiceRuntime/MS0/JDBCDataSourceRuntimeMBeans/PegaRules> ls()
dr– JDBCDriverRuntime
dr– LastTask
dr– WorkManagerRuntimes
-r– ActiveConnectionsAverageCount 1
-r– ActiveConnectionsCurrentCount 0
-r– ActiveConnectionsHighCount 5
-r– ConnectionDelayTime 627
-r– ConnectionsTotalCount 5
-r– CurrCapacity 5
-r– CurrCapacityHighCount 4
-r– DeploymentState 2
-r– Enabled true
-r– FailedReserveRequestCount 0
-r– FailuresToReconnectCount 0
-r– HighestNumAvailable 5
-r– HighestNumUnavailable 0
-r– LastTask null
-r– LeakedConnectionCount 0
-r– ModuleId PegaRules
-r– Name PegaRules
-r– NumAvailable 5
-r– NumUnavailable 0
-r– PrepStmtCacheAccessCount 11852
-r– PrepStmtCacheAddCount 420
-r– PrepStmtCacheCurrentSize 50
-r– PrepStmtCacheDeleteCount 370
-r– PrepStmtCacheHitCount 11432
-r– PrepStmtCacheMissCount 420
-r– Properties {serverName=localhost, SID=prpc612, portNumber=1521, user=SYSTEM}
-r– ReserveRequestCount 11844
-r– State Running
-r– Type JDBCDataSourceRuntime
-r– VersionJDBCDriver oracle.jdbc.OracleDriver
-r– WaitSecondsHighCount 0
-r– WaitingForConnectionCurrentCount 0
-r– WaitingForConnectionFailureTotal 0
-r– WaitingForConnectionHighCount 0
-r– WaitingForConnectionSuccessTotal 4
-r– WaitingForConnectionTotal 0
-r– WorkManagerRuntimes null
-r-x clearStatementCache Void :
-r-x dumpPool Void :
-r-x dumpPoolProfile Void :
-r-x forceShutdown Void :
-r-x forceSuspend Void :
-r-x poolExists Boolean : String(name)
-r-x preDeregister Void :
-r-x reset Void :
-r-x resume Void :
-r-x shrink Void :
-r-x shutdown Void :
-r-x start Void :
-r-x suspend Void :
-r-x testPool String

How to a Create Active Directory Authentication Provider from WLST in Weblogic


Step 1 – Set the environment
C:\Oracle\Middleware\user_projects\domains\TestDomain\bin>setDomainEnv.cmd
Step 2 – Create a new Admin Account
C:\Oracle\Middleware\user_projects\domains\TestDomain>java weblogic.security.utils.AdminAccount weblogic welcome123 .
Note: Don’t forget to add a dot(.) at the end.
Step 3 – Verify the creation of a new DefaultAuthenticatorInit.ldift file.
C:\Oracle\Middleware\user_projects\domains\TestDomain>dirDirectory of C:\Oracle\Middleware\user_projects\domains\TestDomain
11/29/2010  10:27 AM    <DIR>          .
11/29/2010  10:27 AM    <DIR>          ..
10/27/2010  10:56 AM    <DIR>          autodeploy
10/27/2010  10:56 AM    <DIR>          bin
10/27/2010  10:56 AM    <DIR>          config
10/27/2010  10:56 AM    <DIR>          console-ext
11/29/2010  10:27 AM             3,380 DefaultAuthenticatorInit.ldift
10/29/2010  12:25 PM               156 edit.lok
10/27/2010  10:56 AM               472 fileRealm.properties
10/27/2010  10:56 AM    <DIR>          init-info
10/27/2010  10:56 AM    <DIR>          lib
10/29/2010  12:25 PM    <DIR>          pending
10/27/2010  10:56 AM    <DIR>          security
10/29/2010  12:11 PM    <DIR>          servers
10/27/2010  10:56 AM               318 startWebLogic.cmd
10/27/2010  10:56 AM               270 startWebLogic.sh
10/29/2010  12:25 PM    <DIR>          tmp
               5 File(s)          4,596 bytes
              12 Dir(s)  47,722,737,664 bytes free
You will see a DefaultAuthenticatorInit.ldift in the domain directory
Step 5 – Use the new DefaultAuthenticatorInit.ldift
Go to the following location
C:\Oracle\Middleware\user_projects\domains\TestDomain\security
Rename the existing DefaultAuthenticatorInit.ldift and place the DefaultAuthenticatorInit.ldift file in this directory that we just created.
Step 6 – Rename ldap directory
Now go to the following location.
C:\Oracle\Middleware\user_projects\domains\TestDomain\servers\AdminServer\data
Note:- This will delete all your existing users/groups so it is recomended to export the security realm data, or export the users.
Step 7 – Delete boot.properties file
Rename ldap directory to something else.
Delete the boot.properties file from the following location
C:\Oracle\Middleware\user_projects\domains\TestDomain\servers\AdminServer\security
Step 8- Start your Weblogic Server  using startWebLogic.cmd and provide the credentials at the prompt.
Enter username to boot WebLogic server: weblogic
Enter password to boot WebLogic server: welcome123
Step 9 - Log in to Weblogic Console using the new admin user.

How we can provide custom authentication for apache webserver

How we can achive ?
Create authen.txt with the username and password separated by colon
authen.txt
sampleuser : sampleuser
Then use the htpasswd to encrypt the password
Apache2\bin>htpasswd.exe -b authen.txt  sampleuser sampleuser 
Automatically using MD5 format.
Updating password for user testuser
Add the following in the httpd.conf file present in C:\Program Files\Apache Group\Apache2\bin
LoadModule weblogic_module modules/mod_wl128_20.so
<Location />
SetHandler weblogic-handler
WebLogicHost localhost
WebLogicPort 7001
Debug ALL
WLLogFile c:/Saple/wlproxy.log
WLTempDir c:/Saple
AuthUserFile C:/Saple/ authen.txt
AuthName “This is a protected area” 
AuthType Basic 
Require valid-user
</Location>
Also copy WL_HOME\server\plugin\win\32\mod_wl_22.so to C:\Program Files\Apache Group\Apache2\modules
Restart the Apache Server.
Now if we try to access any unprotected resource on Weblogic Server, a BASIC Authentication Window will be popped up for authentication against Apache.
If authentication is successful, the request will go through provided we set the following in the config.xml
<enforce-valid-basic-auth-credentials>false</enforce-valid-basic-auth-credentials>
Otherwise Weblogic Server will try to validate the BASIC authentication Header.

Configuring two way SSL between Client and Weblogic server with Apache proxying the request.


Configure Apache for SSL
Create the certificates using openssl (present in apache_home\bin) using the below steps:
openssl genrsa -des3 -out server.key 1024
openssl req -config ..\conf\openssl.cnf -new -key server.key -out localhost
openssl x509 -req -days 730 -in localhost -signkey server.key -out server.crt
Add the following in the httpd.conf file
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
Listen 443
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile “C:\Program Files\Apache Group\Apache2\conf\server.crt”
SSLCertificateKeyFile “C:\Program Files\Apache Group\Apache2\conf\server.key”
SSLCACertificateFile “C:\Documents and Settings\Administrator\Desktop\cert\IntermediateCA.cer”
#SSLLog “C:\Program Files\Apache Group\Apache2\conf\ssl.log”
#SSLLogLevel debug
</VirtualHost>
Configure SSL between Apache and Weblogic Server
Add the following in the Location Directive
SecureProxy ON
TrustedCAFile C:\bea101\wlserver_10.0\server\lib\CertGenCA.pem
RequireSSLHostMatch false
Configure Apache to Request for Client Certificate
Add the following in the Location Directive
SSLVerifyClient optional_no_ca
SSLOptions +ExportCertData
Configure Weblogic Server for 2-way SSL
mydomain> Servers> myserver>Keystores & SSL > Advanced Options
Hostname Verification: None
Two Way Client Cert Behavior: Client Certs Requested but not enforced
Apache_SSL> Domain Wide Security Settings> Realms> myrealm> Authentication Providers> DefaultIdentityAsserter
Trusted Client Principals: provide CN of the Client Certificate
Types: X509
Details:
Use Default User Name Mapper: Checked
Default User Name Mapper Attribute Type: CN
Base64Decoding Required: Checked
Go the security realm and create a user wih the username as CN of the certificate
Add the following in the config.xml
<Server ClientCertProxyEnabled=”true”
Configure the Web Application
The Web Application should require client cert authentication.
Add the following in the web.xml
<context-param>
<param-name>weblogic.httpd.clientCertProxy</param-name>
<param-value>true</param-value>
</context-param>
Add the following in the weblogic.xml
<principal-name> CN of the certificate</principal-name>