Rackspace cloud server using Arch Linux and pdns with sqlite 3 backend

Wow that title was a mouthful.

I need a tertiary DNS server that is remote from any of my current networks.  Doing this using a dedicated server is expensive so I am testing out Rackspace’s cloud service.

I decided to go with Arch, pdns and sqlite as this would allow me to have a minimal server.  I am attempting this on a 256Mb server but can upgrade if necessary.

As I have not used Arch Linux in anger as a server, I haven’t used Sqlite ever and I have only installed pdns once before and that install was 4 years ago and is still running this should be an interesting side project.

It took about 2 minutes for the server to be setup and for me to be logged in via SSH.

My first task was to check for running processes – The answer was zero just how I like it.  There is an agetty process running but I am guessing this is the console access from the cloud service control panel.


[root@backup-nameserver-test ~]# free -m
total       used       free     shared    buffers     cached
Mem:           241         71        170          0          5         30
-/+ buffers/cache:         35        206
Swap:          509          0        509

It looks like I have 71Mb to run pdns in. I have a feeling this won’t be enough so an upgrade will be required.

First task was to check that pacman was configured and up to date.

pacman -Syy

And everything is up to date and pacman is working.

Next was to install pdns with sqlite backend.
Here is where my first problem hit.

[root@backup-nameserver-test ~]# pacman -S pdns-sqlite
:: The following packages should be upgraded first :
pacman
:: Do you want to cancel the current operation
:: and upgrade these packages now? [Y/n] Y

resolving dependencies...
looking for inter-conflicts...

Targets (11): linux-api-headers-3.3.2-1  glibc-2.15-10  libarchive-3.0.4-1  pth-2.0.7-4  libksba-1.2.0-2  libassuan-2.0.3-1  pinentry-0.8.1-3  dirmngr-1.1.0-4  gnupg-2.0.19-2  gpgme-1.3.1-4  pacman-4.0.3-1

Total Download Size:    11.27 MB
Total Installed Size:   56.88 MB

Proceed with installation? [Y/n] Y
:: Retrieving packages from core...
linux-api-headers-3.3.2-1-x86_64                                                                                    594.3K  472.5K/s 00:00:01 [#######################################################################################] 100%
glibc-2.15-10-x86_64                                                                                                  7.6M  697.8K/s 00:00:11 [#######################################################################################] 100%
libarchive-3.0.4-1-x86_64                                                                                           529.3K  462.1K/s 00:00:01 [#######################################################################################] 100%
pth-2.0.7-4-x86_64                                                                                                   75.9K  166.0K/s 00:00:00 [#######################################################################################] 100%
libksba-1.2.0-2-x86_64                                                                                              109.9K  240.3K/s 00:00:00 [#######################################################################################] 100%
libassuan-2.0.3-1-x86_64                                                                                             76.5K  167.1K/s 00:00:00 [#######################################################################################] 100%
pinentry-0.8.1-3-x86_64                                                                                              93.8K  205.4K/s 00:00:00 [#######################################################################################] 100%
dirmngr-1.1.0-4-x86_64                                                                                              163.9K  239.2K/s 00:00:01 [#######################################################################################] 100%
gnupg-2.0.19-2-x86_64                                                                                              1449.6K  742.6K/s 00:00:02 [#######################################################################################] 100%
gpgme-1.3.1-4-x86_64                                                                                                207.9K  258.9K/s 00:00:01 [#######################################################################################] 100%
pacman-4.0.3-1-x86_64                                                                                               508.4K  475.9K/s 00:00:01 [#######################################################################################] 100%
(11/11) checking package integrity                                                                                                             [#######################################################################################] 100%
(11/11) checking for file conflicts                                                                                                            [#######################################################################################] 100%
error: failed to commit transaction (conflicting files)
glibc: /usr/bin/tzselect exists in filesystem
glibc: /usr/sbin/zdump exists in filesystem
glibc: /usr/sbin/zic exists in filesystem
Errors occurred, no packages were upgraded.

A quick google and as per usual arch problems, lots of posts and a quick solutions was found…
https://bbs.archlinux.org/viewtopic.php?id=138954

[root@backup-nameserver-test ~]# pacman -S tzdata
:: The following packages should be upgraded first :
pacman
:: Do you want to cancel the current operation
:: and upgrade these packages now? [Y/n] n

resolving dependencies...
looking for inter-conflicts...

Targets (1): tzdata-2012c-1

Total Download Size:    0.13 MB
Total Installed Size:   5.41 MB

Proceed with installation? [Y/n] y
:: Retrieving packages from core...
tzdata-2012c-1-any                                                                                                  132.9K  231.5K/s 00:00:01 [#######################################################################################] 100%
(1/1) checking package integrity                                                                                                               [#######################################################################################] 100%
(1/1) checking for file conflicts                                                                                                              [#######################################################################################] 100%
(1/1) upgrading tzdata                                                                                                                         [#######################################################################################] 100%

[root@backup-nameserver-test ~]# pacman -S pdns-sqlite
:: The following packages should be upgraded first :
pacman
:: Do you want to cancel the current operation
:: and upgrade these packages now? [Y/n] y

resolving dependencies...
looking for inter-conflicts...

Targets (11): linux-api-headers-3.3.2-1  glibc-2.15-10  libarchive-3.0.4-1  pth-2.0.7-4  libksba-1.2.0-2  libassuan-2.0.3-1  pinentry-0.8.1-3  dirmngr-1.1.0-4  gnupg-2.0.19-2  gpgme-1.3.1-4  pacman-4.0.3-1

Total Download Size:    0.00 MB
Total Installed Size:   56.88 MB

Proceed with installation? [Y/n] y
(11/11) checking package integrity                                                                                                             [#######################################################################################] 100%
(11/11) checking for file conflicts                                                                                                            [#######################################################################################] 100%
( 1/11) upgrading linux-api-headers                                                                                                            [#######################################################################################] 100%
( 2/11) upgrading glibc                                                                                                                        [#######################################################################################] 100%
warning: /etc/locale.gen installed as /etc/locale.gen.pacnew
Generating locales...
en_US.UTF-8... done
en_US.ISO-8859-1... done
Generation complete.
( 3/11) upgrading libarchive                                                                                                                   [#######################################################################################] 100%
( 4/11) installing pth                                                                                                                         [#######################################################################################] 100%
( 5/11) installing libksba                                                                                                                     [#######################################################################################] 100%
( 6/11) installing libassuan                                                                                                                   [#######################################################################################] 100%
( 7/11) installing pinentry                                                                                                                    [#######################################################################################] 100%
Optional dependencies for pinentry
gtk2: for gtk2 backend
qt: for qt4 backend
( 8/11) installing dirmngr                                                                                                                     [#######################################################################################] 100%
( 9/11) installing gnupg                                                                                                                       [#######################################################################################] 100%
Optional dependencies for gnupg
curl: gpg2keys_curl
libldap: gpg2keys_ldap
libusb-compat: scdaemon
texinfo: documentation
(10/11) installing gpgme                                                                                                                       [#######################################################################################] 100%
(11/11) upgrading pacman                                                                                                                       [#######################################################################################] 100%
>>> Run `pacman-key --init` to set up your pacman keyring.

So that is pdns installed? Unfortunately not. You need to install the pdnsd as well which drags the postgres and mysql libs in…

With pdnsd installed I now needed to edit the configuration file at /etc/powerdns/pdns.conf

Initially I just wanted to see if it would start. I can then go onto getting it working as a slave.

/etc/rc.d/pdns start

[root@backup-nameserver-test ~]# free -m
total       used       free     shared    buffers     cached
Mem:           241        184         57          0          8        134
-/+ buffers/cache:         41        200
Swap:          509          1        508

Memory still looks ok. I doubt if I will have 57Mb of DNS zones on this server.

Creating the database;

mkdir /var/lib/sqlite3
sqlite3 /var/lib/sqlite3/pdns.db

Copy and paste the sql commands from this page http://doc.powerdns.com/gsqlite.html#id447152

Then type this command in and check the results are the same. This confirms the database has been created ok.

sqlite> .schema
CREATE TABLE domains (
id                INTEGER PRIMARY KEY,
name              VARCHAR(255) NOT NULL COLLATE NOCASE,
master            VARCHAR(128) DEFAULT NULL,
last_check        INTEGER DEFAULT NULL,
type              VARCHAR(6) NOT NULL,
notified_serial   INTEGER DEFAULT NULL,
account           VARCHAR(40) DEFAULT NULL
);
CREATE TABLE records (
id              INTEGER PRIMARY KEY,
domain_id       INTEGER DEFAULT NULL,
name            VARCHAR(255) DEFAULT NULL,
type            VARCHAR(10) DEFAULT NULL,
content         VARCHAR(65535) DEFAULT NULL,
ttl             INTEGER DEFAULT NULL,
prio            INTEGER DEFAULT NULL,
change_date     INTEGER DEFAULT NULL
);
CREATE TABLE supermasters (
ip          VARCHAR(25) NOT NULL,
nameserver  VARCHAR(255) NOT NULL COLLATE NOCASE,
account     VARCHAR(40) DEFAULT NULL
);
CREATE INDEX domain_id ON records(domain_id);
CREATE UNIQUE INDEX name_index ON domains(name);
CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX rec_name_index ON records(name);
sqlite> .quit

Now edit the pdns.conf file and edit the

#################################
# launch        Which backends to launch and order to query them in
#
launch=gsqlite3
gsqlite-database=/var/lib/sqlite3/pdns.db

You will also need to create a user and groupname and chown the /var/lib/sqlite3 directory and contents. Then set this in the pdns.conf file.

I added the IP address of my primary nameserver to the supermasters table and restarted pdns. It all starts up and says it is working. There are no errors in the log files but it is not doing any transfers.

More on this later…. (I will update this when I have a little more time to spend on it)

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.