Shadow Database Step-by-Step Configuration Guide
Introduction
Throughout this section, all actions are performed as root unless otherwise stated. All root actions could be performed as another user if sudo is utilised. All root root commands are shown with the # shell prompt and non-root with the $ shell prompt.
The prerequisites are:
-
Centos 6.6 64 bit system
-
Base Reality system installed (before any databases are created)
-
The preferred storage configuration for the server is to have separate disks for each part of the Reality system to improve performance. These can either be physical disks or virtual disks if employed in a virtual environment for testing.
Disk preparation
A suggested layout used in this example may be:
|
/dev/sdb1 |
1004M |
/clogs |
holds the transaction logs for the databases |
|
/dev/sdb2 |
1012M |
/rawlog |
holds the rawlog file |
|
/dev/sdc1 |
2.0G |
/real0 |
holds the primary database |
|
/dev/sdd1 |
2.0G |
/real1 |
holds the shadow database |
|
/dev/sde1 |
2.0G |
/images |
holds tape images from saves |
Each partition needs to be created on the disks. Therefore, using the partition for real0 (/dev/sdc) as a detailed example:
# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xf9e68c45.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1): ¿
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261): ¿
Using default value 261
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 83
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
This is then repeated for real1 and images but in this example, clogs and rawlog are two separate partitions on the same disk. In this case, we select primary partition 1 to use half of the disk (1 to 130) for clogs and primary partition 2 to use the remainder for the rawlog file (131 to 261).
We then format each of the partitions as ext2. Using real0 again as the detailed example:
# mkfs.ext2 -b 4096 /dev/sdc1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524112 blocks
26205 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
The other partitions are formatted in the same way:
# mkfs.ext2 -b 4096 /dev/sdb1 # mkfs.ext2 -b 4096 /dev/sdb2 # mkfs.ext2 -b 4096 /dev/sdd1 # mkfs.ext2 -b 4096 /dev/sde1
Mounting the disks
Each of the created partitions will need mount points to allow them to be accessed.
# mkdir /real0 # mkdir /real1 # mkdir /rawlog # mkdir /clogs # mkdir /images
These point mounts need to be added to /etc/fstab for mounting at boot-time.
/dev/sdb1 /clogs ext2 defaults 0 0 /dev/sdb2 /rawlog ext2 defaults 0 0 /dev/sdc1 /real0 ext2 defaults 0 0 /dev/sdd1 /real1 ext2 defaults,noauto 0 0 /dev/sde1 /images ext2 defaults 0 0
Note that real1 is not to be automatically mounted in normal operation. However, if real1 is the live database, a reboot will not mount it correctly. Therefore, in this instance, the real1 partition will need to be mounted and real0 unmounted. Reality can then be started as normal with realstart.
The partitions need to be mounted before we can proceed:
# mount /real0 # mount /real1 # mount /images # mount /clogs # mount /rawlog
The databases, clogs and the file-save storage area are owned by a dedicated user for example, dbases. Therefore, we create the user and unlock it by setting a password.
# useradd dbases # passwd dbases
The four mount points need to be changed to their new ownership with:
# chown dbases /real0 # chown dbases /real1 # chown dbases /images # chown dbases /clogs
Rawlog configuration
A rawlog is required for transaction logging as part of shadow database functions. This is simpler to create as a file under linux as /rawlog/raw.log. We need to stop Reality, make the raw log then restart Reality. The raw.log will be smaller (900M) than the entire size of the partition (1012M) to leave some overhead space.
# killreal # mklog -rs 900 -t /rawlog/raw.log Formating 900 blocks 900 blocks written File size = 900.00 Mbytes # realstart
In order for the partitions to be found and mounted by the shadow processes, we need to add both to the /etc/shadowfstab file.
/dev/sdd1 /real1 /dev/sdc1 /real0
We can now create the databases that will form the shadow database pair. To be able to tell if the live or shadow is being used, they are named as pdbase0 and pdbase1 respectively. We need to create the databases as the dbases (database owner) user.
# su dbases $ mkdbase /real0/pdbase0 pdbase0 $ mkdbase /real1/pdbase1 pdbase1 $ exit
File-save/tape configuration
As the images mount point is to be used by both databases, we need to create database specific directories within it.
# su dbases $ mkdir /images/pdbase0 $ mkdir /images/pdbase1 $ exit
In order to be able to load file-saves produced in one database on to the other database, tape definitions need to be created on each database. As we are using tape images on disk in the images partition, the file-save image on both databases with be image.rti. The live database configuration needs to be modified:
# killreal # su dbases $ vi /real0/pdbase0/configs/config
by adding the lines:
Tape3=/images/pdbase0/image.rti TapeDevType3=9 Tape4=/images/pdbase1/image.rti TapeDevType4=9
Therefore, on the live database (pdbase0), tape 3 is the live database tape image drive and tape 4 the shadow databases tape image drive.
On the shadow (pdbase1), we perform a similar action on its configuration:
$ vi /real1/pdbase1/configs/config
by adding the lines:
Tape3=/images/pdbase1/image.rti TapeDevType3=9 Tape4=/images/pdbase0/image.rti TapeDevType4=9
This results in tape 3 always being the live database's tape image and tape 4 the shadow's tape image.
As real1 is only used when the shadow is active and not in normal operation, we need to ensure it is not mounted before we restart the Reality daemon as root.
$ exit # umount /real1 # realstart
At this point, the databases are configured and shadow database configuration can be enabled.
Setting up the shadow database configuration
Setting up a shadow database configuration is via the tlmenu utility and must be performed as the database owner, dbases, on the main database pdbase0.
# su dbases $ tlmenu pdabse0
From this point, the normal installation guides can be followed to enable the shadow database and transaction logging processes.