DDT Server Installation Manual

Remi Lefebvre, (remi@debian.org)

This document describes how to install and setup a DDT server. The examples are from the actual configuration on dhis.net.


Table of Contents
1. DNS
2. Database
3. Crontabs
List of Tables
3-1. Sample crontabs

Chapter 1. DNS

The name server must be authoritative for the given zone and must allow updates. This can be done with a section that looks like the following in /etc/bind/named.conf:

zone "dhis.net" {
    type master;
    file "/etc/bind/db.net.dhis";
    allow-update { 127.0.0.1; };
};

You also need to set a basic db.net.dhis file containing the SOA and NS records for the zone before you can use dynamic updates. This may look like this:

;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     localhost. root.localhost. (
                              1         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns0
@       IN      NS      ns1
ns0     IN      A       195.185.255.42
ns1     IN      A       195.185.255.42


Chapter 2. Database

The only supported database at the moment is postgresql. Other databases will be supported in the future but this is not a priority.

Tables for ddtd must be created with the ddt.sql file provided with the server distribution. The owner user, the database name et the access password must be specified in the server config file (typically /etc/ddtd.conf).

Here is the ddt.sql:

drop table userAccounts;
create table userAccounts (
	userAccountId	int8 UNIQUE,
	adminPassword	char(32),
	updatePassword	char(32),
	contactName	varchar(64),
	contactEmail	varchar(64),
	arch		varchar(16),
	os		varchar(16),
        hostStatus      int,
	lastAccess	abstime,
        fqdn            varchar(64) UNIQUE,
        ipAddress       varchar(16),
	PRIMARY KEY (userAccountId)
);

drop table dnsRecords;
drop sequence dnsrecords_dnsrecordid_seq;
create table dnsRecords (
	dnsRecordId	serial,
	userAccountId	int8,
	dname		varchar(64),
	type		int,
	data		varchar(128),
	PRIMARY KEY (dnsRecordId,userAccountId) 
);

The ddtd.conf file should look like this:

--dbname dhisdb
--dbuser remi
--dbpass AbCdE
--serverport 1052
--clientport 1052


Chapter 3. Crontabs

You might want to install some crontabs for doing database backups and vacuums. Vacuums reorder the database and it greatly improves performances to do them regularly, the frequency depending on the number of accesses that are performed. The crontabs may look something like this:

Table 3-1. Sample crontabs

# vacuum the database 4 times a day
# backup the database every night

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# min   hour    dom     mon     dow     command
30      7       *       *       *       ~/crons/backup.sh
0       */6     *       *       *       ~/crons/vacuum.sh

#!/bin/sh

export PGPASSWORD=xxxxxx

psql -c vacuum ddtdb > /dev/null

#!/bin/sh

export PGPASSWORD=xxxxxx

pg_dump ddtdb | gpg -e --batch --armor -r 0x0F3F6242 | mail -s "DDT database backup" remi@debian.org