<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>DaemonAdmin/PostgreSQL</title><revhistory><revision><revnumber>10</revnumber><date>2012-12-25 21:30:22</date><authorinitials>ClintonEbadi</authorinitials></revision><revision><revnumber>9</revnumber><date>2012-12-25 21:06:10</date><authorinitials>ClintonEbadi</authorinitials><revremark>every time I make a plan it turns out it doesn't work</revremark></revision><revision><revnumber>8</revnumber><date>2012-12-11 08:01:40</date><authorinitials>ClintonEbadi</authorinitials><revremark>document extracting the host key</revremark></revision><revision><revnumber>7</revnumber><date>2012-12-10 08:03:05</date><authorinitials>ClintonEbadi</authorinitials><revremark>the mystery is solved for the third time, this time let's write it down</revremark></revision><revision><revnumber>6</revnumber><date>2012-12-10 00:58:59</date><authorinitials>ClintonEbadi</authorinitials><revremark>more info</revremark></revision><revision><revnumber>5</revnumber><date>2012-12-10 00:48:58</date><authorinitials>ClintonEbadi</authorinitials><revremark>look ma, it's not outdated anymore, just not very useful!</revremark></revision><revision><revnumber>4</revnumber><date>2012-04-23 04:20:23</date><authorinitials>ClintonEbadi</authorinitials><revremark>postgres is definitely not in afs any more</revremark></revision><revision><revnumber>3</revnumber><date>2008-07-07 04:28:17</date><authorinitials>localhost</authorinitials><revremark>converted to 1.6 markup</revremark></revision><revision><revnumber>2</revnumber><date>2007-02-07 14:08:19</date><authorinitials>212.15.185.210</authorinitials></revision><revision><revnumber>1</revnumber><date>2007-02-07 14:05:55</date><authorinitials>212.15.185.210</authorinitials></revision></revhistory></articleinfo><para>Warning: postgresql configuration is not controlled by a Debian package, but it should be. Ideally <code>pg_hba.conf</code> and <code>pg_ident.conf</code> would be managed by <ulink url="https://wiki.hcoop.net/DaemonAdmin/PostgreSQL/DomTool#">DomTool</ulink>, or some other system management daemon. In the meantime, here's what we're doing. </para><para>Current node is fritz, with Postgres 8.1 on port 5422, and Postgres 9.1 on 5433. Note that navajos/bog can only use Postgres 9.1, and support for 8.1 will be removed once mire has been decommissioned. </para><para>The source code of <ulink url="https://wiki.hcoop.net/DaemonAdmin/PostgreSQL/DomTool#">DomTool</ulink>'s dbms module is useful as documentation. </para><section><title>Tablespaces</title><para>Each user has a table space in <code>/srv/database/$PATHBITS/$USER/{postgres,postgres-9.1}</code>, created by the <code>create-user-database</code> script. </para><para>Tablespaces are an artifact from when we stored databases in afs. There may be some organizational advantage as well, but future admins should revisit the issue. </para></section><section><title>Authentication</title><para>The <code>pg_hba.conf</code> of every install must explicitely list the allowed hosts. Firewall rules on both sides should be opened. </para><para>Additionally, there must be a rule to allow clients on the database server to connect to itself over tcp for various administrative functions, since <ulink url="https://wiki.hcoop.net/DaemonAdmin/PostgreSQL/DomTool#">DomTool</ulink> is configured to use TCP for maintaining node independence. </para><para>Postgres 8.1 uses ident (<code>pidentd</code> specifically). It's a hack, but GSSAPI support wasn't quite functional enough, or at least we'll say it wasn't. </para><para>Postgres 9.1 uses GSSAPI and ident. An <code>pg_ident.conf</code> is used to map <code>$USER/daemon@HCOOP.NET</code> to the Postgres user <code>$USER</code>. This has the advantage that <code>$USER@HCOOP.NET</code> resolves to the same database user. See the <ulink url="http://www.postgresql.org/docs/9.1/static/auth-methods.html#KERBEROS-AUTH">postgres auth docs</ulink> for details; we're using a pretty standard set up. </para><para>Unfortunately, there's no way to universally grant CGI processes kerberos tickets from a keytab. Requiring members to deal with the kerberos API in CGIs seems a bit much, so the web nodes still use ident to identify members, but only after attempting GSSAPI based authentication. This is less than ideal, see <ulink url="https://bugzilla.hcoop.net/show_bug.cgi?id=937"/> for progress on eliminating ident. The user shell nodes should not need ident because the user always has tickets, and any servers will be running under k5start also with tickets. </para><section><title>Kerberos Service Key</title><para>Remeber to create and extract a service key for postgres. <emphasis role="strong">Note that the keytab is not the system wide keytab, but a postgres specific one</emphasis>. You must also chown it to be readable by only the postgres server account. </para><screen><![CDATA[addprinc -randkey postgres/$HOST.hcoop.net
ktadd -k /etc/postgresql-common/krb5.keytab postgres/$HOST.hcoop.net]]></screen><para>(where <code>$HOST</code> is the name Kerberos and reverse DNS name for the node, not the <code>postgres</code> alias). </para></section></section><section><title>Network</title><para>Always remember to set <code>listen_addresses = '*'</code>, or (better) the IP that postgres should really listen on. Otherwise, connections will fail mysteriously. </para><!--rule (<hr>) is not applicable to DocBook--><para> <ulink url="https://wiki.hcoop.net/DaemonAdmin/PostgreSQL/CategoryNeedsWork#">CategoryNeedsWork</ulink> <ulink url="https://wiki.hcoop.net/DaemonAdmin/PostgreSQL/CategorySystemAdministration#">CategorySystemAdministration</ulink> </para></section></article>