Monday, April 18, 2011

How to enable memory-to-memory session replication for an existing server?

I received this interesting question last week from a wsadminlib user in Chicago.   Wsadminlib.py contains two methods which make the task easy:  createReplicationDomain() and setServerSessionReplication().

First, I connected my wsadmin client to the deployment manager and execfile'd wsadminlib.py:

root@ding6:/home/ding/tmp# /opt/WAS70/profiles/v7default/bin/wsadmin.sh -lang jython -host zwasxxxx.raleigh.ibm.com -port 8879 -user xxxxxx -password xxxxxx
WASX7209I: Connected to process "dmgr" on node WAS00Manager using SOAP connector;  The type of process is: DeploymentManager
WASX7031I: For help, enter: "print Help.help()"
wsadmin>
wsadmin>execfile('wsadminlib.py')
$Id: wsadminlib.py 104 2010-02-15 19:06:18Z ding $
wsadmin>



Next I issued the createReplicationDomain() command and saved it:

wsadmin>domainName = "andyDomain"
wsadmin>numReplicas = -1
wsadmin>                                  
wsadmin>createReplicationDomain( domainName, numReplicas )
wsadmin>                                  
wsadmin>save()

Browsing to the admin console confirms the domain was created: Environment-> Replication Domains



Clicking one step further shows the number of replicas is set to 'Entire Domain', which corresponds to -1 in the wsadminlib.py command.



Then I issued the setServerSessionReplication() command to enable replication on the application server using the just-created domain, and saved it too.

wsadmin>nodeName = "ndnode1"
wsadmin>serverName = "server1"
wsadmin>domainName = "andyDomain"
wsadmin>dataReplicationMode = "BOTH"
wsadmin>
wsadmin>setServerSessionReplication( nodeName, serverName, domainName, dataReplicationMode )
wsadmin>
wsadmin>save()

Finally, browsing to the admin console once again confirms that the server has memory-to-memory replication enabled: Servers-> server1-> Session Management-> Distributed Environment Settings



And clicking one step further shows the selected domain name (ie, andyDomain) and replication mode (ie, both client and server):




Wsadminlib.py also contains methods which create clusters with replication enabled.  I have used those methods in years past.  This question was interesting to me because I can't remember ever enabling replication for existing servers.

For more information about configuring replication, please browse wsadminlib.py itself.  Search for the word 'replication' to discover several special-purpose and general-purpose methods.  Read the prologues of each method.  They usually give a good description of the acceptable parameters.