Setting Up a Dual DrawMGT System
Contents
Introduction
A dual DrawMGT system contains an internal (secure, primary) and and external (shared, secondary) systems. The systems are basically independent from each other, but synchronized. See Dual System DrawMGT Design and Implementation Notes
Setting Up a Dual System
Note, that internal and external systems can be on the same computer on a development system.
All of the examples below assumes that the primary and secondary instances are centos1.tibi1959.hu-dev1 and centos1.tibi1959.hu-dev2, and the primary and secondary main directories and databases are linthal114dev1 respectively linthal114dev2'.
Instance Setting of the Systems
Create the instance settings for the two systems first, e.g. centos1.tibi1959.hu-dev1 and centos1.tibi1959.hu-dev2. See this instance settings in CVS branch V11_4_PROD-BRANCH.
The new settings for the internal system (centos1.tibi1959.hu-dev1):
11a12,13 > $_CFG['SubSiteId'] = 1; > 17a20 > include_once $_CFG['BaseDir']."/cfg/$_SITE/site/config/SubSiteSettings".$_CFG['SubSiteId'].".php"; 20a24,30 > // -- Database mirroring > > $_CFG['Feature']['DbMirroring'] = true; > $_CFG['EventDaemon']['EnableMap'][EventTypeRef_MirrorIn] = 1; > $_CFG['EventDaemon']['EnableMap'][EventTypeRef_MirrorOut] = 1; > // -- RemoteBaseURL should use the same path as users from browser > $_CFG['SubSiteSettings']['RemoteBaseURL'] = 'http://localhost/dev/linthal114dev2/'; > // -- RemoteMirrorURL can be different from RemoteBaseURL > // $_CFG['SubSiteSettings']['RemoteMirrorURL'] = 'http://localhost/dev/linthal114dev2/'; > // -- WARNING: apache user should have the possibility to use ssh without password > $_CFG['SubSiteSettings']['RemoteCopy'] = '/usr/bin/rsync -a %s centos1.tibi1959.hu:/var/www/html/dev/linthal114dev2/var/linthal/centos1.tibi1959.hu-dev2/%s 2>&1'; > 36c46 < $_CFG['HeaderTitle2'] = 'PSW Limmern Development System (dev), ' . $_CFG['CodeVersion']; --- > $_CFG['HeaderTitle2'] = 'PSW Limmern Development System (dev1 - internal), ' . $_CFG['CodeVersion'];
The new settings for the shared system (centos1.tibi1959.hu-dev2):
11a12,13 > $_CFG['SubSiteId'] = 2; > 17a20 > include_once $_CFG['BaseDir']."/cfg/$_SITE/site/config/SubSiteSettings".$_CFG['SubSiteId'].".php"; 20a24,27 > // -- Database mirroring > > $_CFG[ 'Feature' ][ 'DbMirroring' ] = true; > $_CFG[ 'AllowedRestReqIPs' ] = array( '192.168.1.21' ); > 36c43 < $_CFG['HeaderTitle2'] = 'PSW Limmern Development System (dev), ' . $_CFG['CodeVersion']; --- > $_CFG['HeaderTitle2'] = 'PSW Limmern Development System (dev2 - shared), ' . $_CFG['CodeVersion'];
Checking Out The Development System
Checkout to primary system first as usual (assumed CVS user: ntibor, main development directory: /var/www/html/dev, apache user: apache, site: linthal, instance: centos1.tibi1959.hu-dev1):
cd linthal114dev/app/etc # go to an 11.4 or 12.x system ./checkout.pl -v -r 114 -u tibor -d /var/www/html/dev -w apache linthal centos1.tibi1959.hu-dev1
Checkout the secondary system similarly:
cd linthal114dev1app/etc # go to an 11.4 or 12.x system ./checkout.pl -v -r 114 -u tibor -d /var/www/html/dev -w apache linthal centos1.tibi1959.hu-dev2
Note, that it is recommended to use one system, e.g. the primary as master. That means, that every files in app, lib and cfg/.../site are edited in the primary system and the changes are copied to the shared system, to avoid that we are getting confused what should be checked in CVS and where. There is a small shell script, which can make the copy with rsync very quickly:
cd linthal114dev1app/etc ./mirrorFiles.sh linthal114dev2 linthal
Migrating Database and Generating System Components
There is a chicken and egg problem, so at the first time run setup.sh on both systems as described in the next paragraph. It is not necessary at subsequent run.
Create the versioning, mirroring schema and trigger files, by calling app/etc/genMeta.pl -b.
cd linthal114dev1/app/etc ./genMeta.pl -b ./loadSystem.sh -l -v dev dev1 ./genMeta.pl
The same for the secondary system:
cd linthal114dev2/app/etc ./genMeta.pl -b ./loadSystem.sh -l -v dev dev2 ./genMeta.pl
After these steps you will have two databases (linthal114dev1stg, linthal114dev2stg) as staging area with one table (MirrorRecords). The table MirrorRecords contains all records to be mirrored. The field processStatus shows the state of the mirroring:
- 0 - not processed, just inserted
- 1 - already read
- 2 - processed
- -1 - error occurred, needs manual intervention
Note, that from version 11.5 the loadSystem.sh is using the old primary database on the secondary system. So, if the two systems are not on the same computer, the old primary database should be temporarily copied to the secondary computer manually.
Setup Directories and Permissions
Run setup.sh for both systems as root as usual:
su cd /var/www/html/dev/linthal114dev1/app/install ./setup.sh linthal centos1.tibi1959.hu-dev1 apache drawmgt cd /var/www/html/dev/linthal114dev2/app/install ./setup.sh linthal centos1.tibi1959.hu-dev2 apache drawmgt
Setup Event Records
Not necessary anymore. The records are created automatically.
The new event records (Resceduling Mirroring (in), Resceduling Mirroring (out)) must be inserted manually into the database of the internal system:
mysql -uroot -psqladmin linthal114dev1 mysql> insert into Events values( 3, 21, 0, 7, 3, 0, 2, 0, null, now(),now(),now(),now(), 60, 'Resceduling Mirroring (in)' ); mysql> insert into Events values( 4, 22, 0, 7, 3, 0, 2, 0, null, now(),now(),now(),now(), 60, 'Resceduling Mirroring (out)' );
Start Event Dispatcher
The event dispatcher should be run every minutes from crontab or it can be started manually in test phase. All database mirroring jobs will be done by the event dispatcher on the internal system. You can set the re-scheduling time smaller then 60sec, e.g. 5sec on the development system to allow to process records nearly immediately if you start the event dispatcher from the command line:
cd linthal114dev1 php app/event/lib/EventDispatcher.php
Copying var/.../data
It is necessary to synchronize the directory var/.../data of the external system to the internal system, to achieve, that the document files are copied to the internal system. If you want to do so, enter the following line into root's crontab on the internal system if the two systems are on the same machine (development system):
* * * * * /usr/local/bin/rsync -aq /home/linthal/www/html/linthal115beta2/var/linthal/zg.softxs.ch-beta2/data/* /home/linthal/www/html/linthal115beta1/var/linthal/zg.softxs.ch-beta1/data
or the next line if the two systems are on different systems (in this case root should use rsync without password):
* * * * * /usr/local/bin/rsync -aq hostname_of_external_system:/home/linthal/www/html/linthal115beta2/var/linthal/zg.softxs.ch-beta2/data/\* /home/linthal/www/html/linthal115beta1/var/linthal/zg.softxs.ch-beta1/data