February 2, 2011

Quick Disaster Recovery (DR) setup with 2010.2


With 2010.2, you now have an easy way to maintain a DR server for your main Perforce server. Here is a quick overview on how to set one up:

Configure a second server exactly the same as your primary server. Same volumes, Perforce settings, everything. This is essential for making sure that all your triggers, depot mappings and everything work on the DR server.

Now you are going to create all the required entries in the configuration table on the master server as follows:

(Note: these commands must be run as a super user, and they are example commands only since you have to modify certain parameters for your environment.)
p4 configure set replica1#P4PORT=1666
p4 configure set replica1#P4TARGET=masterserver:1666
p4 configure set replica1#server=3
p4 configure set "replica1#startup.1=pull -i 1 -J (location and prefix of rotated journal)"
p4 configure set "replica1#startup.2=pull -u -i 1"
p4 configure set "replica1#startup.3=pull -u -i 1"
p4 configure set "replica1#db.replication=readonly"
p4 configure set "replica1#lbr.replication=readonly"
p4 configure set replica1#serviceUser=service
 (Set the security for all servers to at least 1, ideally to 3. This will require passwords for all the users.)
p4 configure set security=3
 (Create the service user account. Add "Type: service" to the user specification before saving it.)
p4 user -f service
 (Set a password for the service user)
p4 passwd service
 (Set an unlimited timeout for the service group and put the service1 user in it.)
p4 group service_group
(Give the service user super user access. It is a very restricted account, so this isn't a security problem.)
p4 protect

Next take a checkpoint of the Master server and then copy it to the DR server and restore it into the P4ROOT directory. Then copy all of the Perforce depot files from the Master to the DR server making sure they are in the same location on the DR that they were on the Master. You also need to copy the license file from the Master server's P4ROOT into the DR server's P4ROOT directory. If you do not plan to change the IP address of the DR machine when you fail over, then you need to request a duplicate license file from [email protected] for your DR server. Additionally, you should copy over any triggers or other scripts that your server is using as well.

On the DR server, run the following commands to start up the DR server:

(Create a valid ticket on the replica server for the service1 user.)
p4 -u service1 -p masterserver:1666 login
p4d -r $P4ROOT -In replica1 -q -d

Now your DR server is up and running and will keep the DR server in sync with the Master server. If you ever need to fail over to the DR server. You can simply stop the DR server, then restart it without the -In replica1 parameter, and since it is configured exactly the same as the Master server, it will start up as the Master server now. When you have the original master server repaired from whatever caused you to fail to the DR server, then you can simply repeat the above process on the original master to set it up as the DR now.

This same type of configuration can also be used as a read only replica server to offload some of the work from the master server using the p4broker http://www.perforce.com/perforce/r10.2/manuals/p4sag/11_broker.html#1056059.

For more details on this and all other aspects of replication, please refer to the System Administrators Guide http://www.perforce.com/perforce/r10.2/manuals/p4sag/10_replication.html#1056059.