Re: Can't get named_sdb to load postgres modules?

Todd Lyons <[email protected]> Wed, 13 May 2009 09:27:15 -0700
Newsgroups gmane.network.dns.bind9.dlz
Message-ID <[email protected]>
On Wed, May 13, 2009 at 7:25 AM, Mike Toler
<[email protected]> wrote:
> Two steps forward, one step back.

It sometimes feels that way :-/

>
> I went to the Redhat site and got the latest official compile from them
> (9.3.4-10, pretty old) and installed it.

Why did you use that one instead of the 9.5.1 version?  Or did the
9.5.1 src rpm not build for you?

> Step forward:  The logs show DLZ modules at least loading.
> [root@vm-nfs-01 ~]# named_sdb -d 5 -g -c /etc/named.conf

Hmmmm, you're still using named_sdb instead of named-sdb?
rpm -qs bind-sdb

Did it by chance build a separate bind-dlz package? (I have never seen
it and I expect the answer to be no, but I'm asking it anyway).

> 13-May-2009 14:14:01.911 starting BIND 9.3.4-P1 -d 5 -g -c
> /etc/named.conf
> 13-May-2009 14:14:01.912 found 1 CPU, using 1 worker thread
> 13-May-2009 14:14:01.912 SDB ldap zone database module loaded.
> 13-May-2009 14:14:01.913 SDB postgreSQL DB zone database module loaded.
> 13-May-2009 14:14:01.913 SDB directory DB zone database module loaded.

Not really.  It shows SDB support loading, not DLZ support.  They are
not the same.  It's just that the two patches are usually applied at
the same time.  Google for bind sdb and go to their project website
and you'll see the difference.

> 13-May-2009 14:14:01.917 loading configuration from '/etc/named.conf'
>
> The step back, it doesn't like "dlz"???  wahuh??
>
> 13-May-2009 14:14:01.918 /etc/named.conf:188: unknown option 'dlz'
> 13-May-2009 14:14:01.919 load_configuration: failure
> 13-May-2009 14:14:01.919 loading configuration: failure
> 13-May-2009 14:14:01.919 exiting (due to fatal error)
>
> I dumbed it down as much as I could.   Does this old a version of
> named_sdb have some other format for the DLZ zones??

I would deduce that particular version doesn't have dlz support.  Does
your output match this:

CentOS52[root@ivut01 ~]# strings /usr/sbin/named-sdb | grep -i dlz
dns_dlzstrtoargv
dns_sdlzregister
dns_dlzcreate
dns_dlzallowzonexfr
dns_sdlz_putrr
dns_sdlzunregister
dns_dlzfindzone
dns_sdlz_putnamedrr
dlz_drivers_init() failed: %s
../../contrib/dlz/drivers/sdlz_helper.c
Unregistering DLZ postgres driver.
Registering DLZ postgres driver.
../../contrib/dlz/drivers/dlz_postgres_driver.c
dns_sdlz_putrr returned error. Error code was: %s
dns_sdlz_putnamedrr returned error. Error code was: %s
dns_sdlzregister() failed: %s
Unregistering DLZ mysql driver.
../../contrib/dlz/drivers/dlz_mysql_driver.c
Registering DLZ mysql driver.
Unregistering DLZ bdb driver.
Registering DLZ bdb driver.
../../contrib/dlz/drivers/dlz_bdb_driver.c
Unregistering DLZ bdbhpt driver.
Registering DLZ bdbhpt driver.
../../contrib/dlz/drivers/dlz_bdbhpt_driver.c
Unregistering DLZ filesystem driver.
Registering DLZ filesystem driver.
../../contrib/dlz/drivers/dlz_filesystem_driver.c
Unregistering DLZ ldap driver.
../../contrib/dlz/drivers/dlz_ldap_driver.c
Registering DLZ ldap driver.
dlz_ldap_create() failed: %s
Unregistering DLZ odbc driver.
../../contrib/dlz/drivers/dlz_odbc_driver.c
Registering DLZ odbc driver.

If you don't get nearly that output, it appears the version you got
does not have the DLZ patch applied.

I manually started bind-sdb with -d 2 (or higher) and got this output.
 It is yelling out that it loads DLZ support before SDB support.  It
appears that SDB prints out stuff at debug level 1, whereas DLZ
requires debug level 2.  Check to see that yours spits out the DLZ
lines too when you using debug level 2 or higher.

CentOS52[root@ivut01 ~]# /usr/sbin/named-sdb -u named -t
/var/named/chroot -g -d 2
13-May-2009 09:05:42.107 starting BIND 9.5.1-P1-RedHat-9.5.1-1.P1iv -u
named -t /var/named/chroot -g -d 2
13-May-2009 09:05:42.107 adjusted limit on open files from 1024 to 1048576
13-May-2009 09:05:42.107 found 1 CPU, using 1 worker thread
13-May-2009 09:05:42.108 using up to 4096 sockets
13-May-2009 09:05:42.108 Registering DLZ postgres driver.
13-May-2009 09:05:42.108 Registering SDLZ driver 'postgres'
13-May-2009 09:05:42.113 Registering DLZ driver 'postgres'
13-May-2009 09:05:42.113 Registering DLZ mysql driver.
13-May-2009 09:05:42.114 Registering SDLZ driver 'mysql'
13-May-2009 09:05:42.114 Registering DLZ driver 'mysql'
13-May-2009 09:05:42.114 Registering DLZ filesystem driver.
13-May-2009 09:05:42.114 Registering SDLZ driver 'filesystem'
13-May-2009 09:05:42.116 Registering DLZ driver 'filesystem'
13-May-2009 09:05:42.116 Registering DLZ bdb driver.
13-May-2009 09:05:42.117 Registering SDLZ driver 'bdb'
13-May-2009 09:05:42.117 Registering DLZ driver 'bdb'
13-May-2009 09:05:42.117 Registering DLZ bdbhpt driver.
13-May-2009 09:05:42.117 Registering SDLZ driver 'bdbhpt'
13-May-2009 09:05:42.117 Registering DLZ driver 'bdbhpt'
13-May-2009 09:05:42.117 Registering DLZ ldap driver.
13-May-2009 09:05:42.117 Registering SDLZ driver 'ldap'
13-May-2009 09:05:42.118 Registering DLZ driver 'ldap'
13-May-2009 09:05:42.118 Registering DLZ odbc driver.
13-May-2009 09:05:42.118 Registering SDLZ driver 'odbc'
13-May-2009 09:05:42.118 Registering DLZ driver 'odbc'
13-May-2009 09:05:42.118 SDB ldap zone database module loaded.
13-May-2009 09:05:42.118 SDB postgreSQL DB zone database module loaded.
13-May-2009 09:05:42.118 SDB sqlite3 DB zone database module loaded.
13-May-2009 09:05:42.123 SDB directory DB zone database module loaded.
13-May-2009 09:05:42.138 loading configuration from '/etc/named.conf'
13-May-2009 09:05:42.143 using default UDP/IPv4 port range: [1024, 65535]
13-May-2009 09:05:42.147 using default UDP/IPv6 port range: [1024, 65535]
13-May-2009 09:05:42.152 listening on IPv4 interface lo, 127.0.0.1#53
13-May-2009 09:05:42.157 listening on IPv4 interface eth0, 192.168.100.57#53
13-May-2009 09:05:42.162 listening on IPv6 interface lo, ::1#53
13-May-2009 09:05:42.168 Loading 'Mysql zone' using driver mysql
13-May-2009 09:05:42.172 Loading SDLZ driver.
13-May-2009 09:05:42.177 SDLZ driver loaded successfully.
13-May-2009 09:05:42.177 DLZ driver loaded successfully.

Then it spits out a bunch of stuff about the zones it loads but
nothing about the DLZ zone.  The line at timestamp 09:05:42.168 above
appears in all regular output, so under normal conditions, that is all
that indicates that DLZ is being used.  It's done here:

      /* write log message */
      isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
            DNS_LOGMODULE_DLZ, ISC_LOG_INFO,
            "Loading '%s' using driver %s", dlzname, drivername);

So I would expect to see in your case:
  Loading 'Postgress zone' using driver postgres

That's when we will know that your bind-sdb has dlz support and is
establishing a connection to the postgres db.

> dlz "postgres zone" {
>   database "postgres 1
>   {host=int-dbs port=5432 dbname=dns_data user=postgres}
>   {select zone from dns_records where zone = '%zone%'}
>   {select ttl, type, mx_priority, case when lower(type)='txt' then '\"'
>         || data || '\"' when lower(type)='soa' then data || ' ' ||
> resp_person || ' '
>         || serial || ' ' || refresh || ' ' || retry || ' ' || expire ||
> ' ' || minimum
>         else data end from dns_records where zone = '%zone%' and host =
> '%record%'}";
> };

I don't see anything wrong.  It should work as far as I can tell.
Since no Postgres people have chimed in, I'll guess that most of us
are using either mysql or ldap for the backend data store.

-- 
Regards...      Todd

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com