Forum OpenACS Q&A: ns_db not enabled

Collapse
Posted by Jose Mercado on
I am just starting out with ACSpg.  I got everything installed and
configured correctly (or so I thought).  When I start the server I
get the following error:

[24/Apr/2000:12:56:41][16614.1026][-sched-] Error: nsd.tcl: command
"ns_db" is not enabled

Any ideas?  My impression was that I didn't actually need to enable
ns_db.

TIA,
    Jose

Collapse
Posted by Daniel Wickstrom on
It sounds like the postgres driver is not getting loaded. You should have something like the following in your logs before you get to the ns_db error:


[24/Apr/2000:18:27:41][8240.1][-main-] Notice: loading: /usr/local/aolserver/bin/postgres.so
[24/Apr/2000:18:27:41][8240.1][-main-] Notice: PostgreSQL loaded.


If not, you need to compile the postgres driver and make sure it is in the bin directory.
Collapse
Posted by Jose Mercado on
I thought I was telling aolserver to load it correctly.
I am certina that it is compiled and in aolserver/bin.
Alos, I have the following in nsd.tcl:

ns_section "ns/db/drivers"
ns_param  postgres    ${bindir}/postgres.so

ns_section "ns/db/driver/postgres"
ns_param  datestyle    iso

Collapse
Posted by Daniel Wickstrom on
That looks o.k., but do you actually see in the log file that the driver was loaded correctly?
Collapse
Posted by Jose Mercado on
Nope.
Collapse
Posted by Don Baccus on
Well, what is in the log, then?  There should be an error message.
Collapse
Posted by Jose Mercado on
The first error I get is as follows:

[24/Apr/2000:14:17:38][16730.1024][-main-] Error: nsd.db: no such default pool: main

In my nsd.tcl this is set up with:

ns_section "ns/db/pool/main"
ns_param  Driver            postgres
ns_param  Connections      4
ns_param  MaxOpen          1000000000
ns_param  MaxIdle          1000000000
ns_param  DataSource        10.69.69.69::test
ns_param  User              web
ns_param  Verbose          Off
ns_param  LogSQLErrors      Off
ns_param  ExtendedTableInfo  On

I get no other errors until the stuff that starts happening with
Error: nsd.tcl: command "ns_db" is not enabled.

If more output would be useful here goes.

[24/Apr/2000:15:08:47][16759.1026][-sched-] Error: nsd.tcl: command "ns_db" is not enabled
command "ns_db" is not enabled
    while executing
"ns_db gethandle"
    invoked from within
"set db [ns_db gethandle]..."
    (procedure "ug_init_serve_group_pages" line 2)
    invoked from within
"ug_init_serve_group_pages"
    ("eval" body line 1)
    invoked from within
"eval [concat [list $proc] $args]"
    (procedure "ad_run_scheduled_proc" line 43)
    invoked from within
"ad_run_scheduled_proc {f t 1 ug_init_serve_group_pages {} 956603326 0 t}"

Is teh Main pool problem a cause or a result of th e teh postgres module's failure to load?  There seems to be no mention at all of the
postgres module in the aolserver output, what am I missing here?

Collapse
Posted by Dan Wickstrom on
Are you running postgres on different machine than aolserver? Is so, postgres might not be allowing external tcp connections. By default it only allows connections from the localhost. Check out pg_hba.conf in your postgres data directory. If you're running it on the same machine as aolserver then change:


ns_param DataSource 10.69.69.69::test

to:

ns_param DataSource localhost::test

Also make sure that you're actually loading the data model into the "test" database.

Collapse
Posted by Don Baccus on
It sounds like you need something like this in your nsd.tcl:
ns_section "ns/db/drivers"
ns_param    postgres       "nspostgres.so"
This tells AOLserver to load up nspostgres.so. The name - postgres - must use the driver name you're using in your database pool definition.
Collapse
Posted by Jose Mercado on
I changed the ip to loaclhost.  That seems to have made the pool error go away.  The ns_db error persists, however.
Collapse
Posted by Jose Mercado on
Nevermind, I was wrong.  The pool not found error is still there.
Collapse
Posted by Don Baccus on
Do you have the two lines I mention in your nsd.tcl?

You'll get nowhere without them.  If you see no hint that nspostgres.so isn't being loaded, and you see no error, then you
don't have these lines.

Collapse
Posted by Tom Jackson on

I kept leaving out the following section which lead to a similar error:

ns_section "ns/server/servername/db" ns_param Pools "*" ns_param DefaultPool "main" ;# Or whatever your default pool is!

This tells AOLserver to actually use the pools defined in you nsd.tcl file.

Collapse
Posted by Don Baccus on
Yep, Tom's pointed out another good one.  Jose, you better check to make sure you have that in your nsd.tcl file, too.
Collapse
Posted by Ben Adida on
If you're getting ns_db not enabled, it absolutely means that your driver didn't load correctly. Go through your log file and search for "postgres.so" and see if it's loading it up. If not, you need to make sure that you've got the right name for your .so file, that the permissions are correct (e.g. execute permissions for nsadmin), that your param file has all the right settings to load postgres.so as a DB driver. The pool errors should be dealt with once you know you're loading the driver for sure.
Collapse
Posted by Jose Mercado on
Okay, so I recompiled the postgres driver, made certain that the pool lines and the driver lines where in nsd.tcl, and even checked the perms on the files in question.  Yet, there is still no sign of the postgres module being loaded.

# cat log/server.log | grep postgres
[25/Apr/2000:12:09:26][17641.1024][-main-] Notice: nsd.tcl: sourcing: /webroot/test/acspg/tcl/postgres.tcl

...But nothing about the postgres module being loaded or failing to load.

Collapse
Posted by Don Baccus on
Post your nsd.tcl file here so we can take a look.  Please use <pre></pre> to make it easier to read.
Collapse
Posted by Jose Mercado on
My nsd.tcl looks like this:


#
# nsd.tcl --  The AOLserver Startup Script
#
#      This is a Tcl script that is sourced when AOLserver starts up.
#      A detailed reference is in "doc/config.txt".
#

ns_log notice "nsd.tcl: starting to read config file..."


#
# Set some Tcl variables that are commonly used throughout this file.
#

set httpport               8000
set httpsport              8443

#set hostname               [ns_info hostname]
#set address                [ns_info address]
set hostname		   "localhost"
set address		   127.0.0.1

set servername             "server1"
set serverdesc             "AOL3 Test Server"

set homedir                [file dirname [ns_info config]]
set bindir                 [file dirname [ns_info nsd]]

set pageroot               /webroot/test/acspg/www
set directoryfile          index.adp,index.html,index.htm,index.tcl

# nsssl: Only loads if keyfile.pem and certfile.pem exist.
set sslkeyfile             ${homedir}/servers/${servername}/modules/nsssl/keyfile.pem
set sslcertfile            ${homedir}/servers/${servername}/modules/nsssl/certfile.pem

# nscp: Uncomment the sample password and log in with "nsadmin", password "x",#       type "ns_crypt newpassword salt" and put the new encrypted string below.
#set nscp_user ""
set nscp_user              "web:t2GqvvaiIUbF2:"
# sample user="nsadmin", pw="x"

#
# Global server parameters
#
ns_section "ns/parameters"
ns_param   home            $homedir
ns_param   debug           false


#
# Thread library (nsthread) parameters
#
ns_section "ns/threads"
ns_param   mutexmeter      true      ;# measure lock contention
#ns_param   stacksize [expr 128*1024] ;# Per-thread stack size for hungry C modules.

#
# MIME types.
#
#  Note: AOLserver already has an exhaustive list of MIME types, but in
#  case something is missing you can add it here.
#
ns_section "ns/mimetypes"
ns_param   default         "*/*"     ;# MIME type for unknown extension
ns_param   noextension     "*/*"     ;# MIME type for missing extension
#ns_param   ".xls"          "application/vnd.ms-excel"

#
# Create pools for ACS
#

ns_section "ns/db/pool/main"
ns_param   Driver            postgres
ns_param   Connections       4
ns_param   MaxOpen           1000000000
ns_param   MaxIdle           1000000000
ns_param   DataSource        localhost::test
ns_param   User              web
ns_param   Verbose           Off
ns_param   LogSQLErrors      Off
ns_param   ExtendedTableInfo  On

ns_section "ns/db/pool/subquery"
ns_param   Driver            postgres
ns_param   Connections       4
ns_param   MaxOpen           1000000000
ns_param   MaxIdle           1000000000
ns_param   DataSource        localhost::test
ns_param   User              web
ns_param   Verbose           Off
ns_param   LogSQLErrors      Off
ns_param   ExtendedTableInfo  On

ns_section "ns/db/pool/log"
ns_param   Driver            postgres
ns_param   Connections       4
ns_param   MaxOpen           1000000000
ns_param   MaxIdle           1000000000
ns_param   DataSource        localhost::test
ns_param   User              web
ns_param   Verbose           Off
ns_param   LogSQLErrors      Off
ns_param   ExtendedTableInfo  On


#
# Stuff for Postgresql
#

ns_section "ns/db/drivers"
ns_param   postgres     ${bindir}/postgres.so
ns_section "ns/db/driver/postgres"
ns_param   datestyle    iso

############################################################
#
# Server-level configuration
#
#  There is only one server in AOLserver, but this is helpful when multiple
#  servers share the same configuration file.  This file assumes that only
#  one server is in use so it is set at the top in the "server" Tcl variable.
#  Other host-specific values are set up above as Tcl variables, too.
#

ns_section "ns/servers"
ns_param   $servername     $serverdesc


#
# Server parameters
#
ns_section "ns/server/${servername}"
ns_param   directoryfile   $directoryfile
ns_param   pageroot        $pageroot
ns_param   globalstats     true      ;# Enable built-in statistics
ns_param   urlstats        true      ;# Enable URL statistics
ns_param   maxurlstats     1000      ;# Max number of URL's to do stats on
ns_param   enabletclpages  true     ;# Parse tcl files in pageroot (dangerous)
# Directory listings -- use an ADP or a Tcl proc to generate them.
#ns_param   directoryadp    $pageroot/dirlist.adp ;# Choose one or the other
#ns_param   directoryproc   _ns_dirlist           ;#  ...but not both!
#ns_param   directorylisting simple               ;# Can be simple or fancy

#
# ADP (AOLserver Dynamic Page) configuration
#
ns_section "ns/server/${servername}/adp"
ns_param   map             "/*.adp"  ;# Extensions to parse as ADP's
#ns_param   map             "/*.html" ;# Any extension can be mapped
ns_param   enableexpire    false     ;# Set "Expires: now" on all ADP's
ns_param   enabledebug     false     ;# Allow Tclpro debugging with "?debug"

# ADP special pages
#ns_param   errorpage      ${pageroot}/errorpage.adp ;# Pretty-print ADP scripting errors


#
# ADP custom parsers -- see adp.c
#
ns_section "ns/server/${servername}/adp/parsers"
ns_param   adp             ".adp"

#
# TCL
#

ns_section "ns/server/${servername}/tcl"
ns_param   Library        /webroot/test/acspg/tcl

#
# Socket driver module (HTTP)  -- nssock
#
ns_section "ns/server/${servername}/module/nssock"
ns_param   port            $httpport
ns_param   hostname        $hostname
ns_param   address         $address


#
# Socket driver module (HTTPS) -- nsssl
#
#  nsssl does not load unless sslkeyfile/sslcertfile exist (above).
#
ns_section "ns/server/${servername}/module/nsssl"
ns_param   port            $httpsport
ns_param   hostname        $hostname
ns_param   address         $address
ns_param   keyfile         $sslkeyfile
ns_param   certfile        $sslcertfile

#
# Control port -- nscp
#
#  nscp does not load unless nscp_user is a valid user.
#
ns_section "ns/server/${servername}/module/nscp"
ns_param   port            9999
ns_param   address         "127.0.0.1" ;# LOCALHOST IS RECOMMENDED

ns_section "ns/server/${servername}/module/nscp/users"
ns_param   user            $nscp_user


#
# Access log -- nslog
#
ns_section "ns/server/${servername}/module/nslog"
ns_param   rolllog         true      ;# Should we roll log?
ns_param   rollonsignal    true      ;# Roll log on SIGHUP
ns_param   rollhour        0         ;# Time to roll log
ns_param   maxbackup       5         ;# Max number to keep around when rolling

#
# CGI interface -- nscgi
#
ns_section "ns/server/${servername}/module/nscgi"
#ns_param   map "GET  /cgi /usr/local/cgi"
#ns_param   map "POST /cgi /usr/local/cgi"


#
# Set up db pools for ACS
#

ns_section "ns/server/${servername}/db"
ns_param   Pools           "*"
ns_param   DefaultPool     "main"

ns_section "ns/parameters"
ns_param   auxconfigdir   /webroot/test/acspg/parameters

#
# Modules to load
#
ns_section "ns/server/${servername}/modules"
ns_param   nssock          ${bindir}/nssock.so
ns_param   nslog           ${bindir}/nslog.so
ns_param   nscgi           ${bindir}/nscgi.so
#ns_param   nsperm         ${bindir}/nsperm.so

## nsssl: loads only if requisite files already exist (see top of this file).
if { [file exists $sslcertfile] && [file exists $sslkeyfile] } {
    ns_param nsssl ${bindir}/nsssle.so
} else {
    ns_log warning "nsd.tcl: nsssl not loaded because key/cert files do not exist."
}

# nscp: loads only if nscp_user is set (see top of this file).
if { $nscp_user != "" } {
    ns_param nscp ${bindir}/nscp.so
} else {
    ns_log warning "nsd.tcl: nscp not loaded because user/password is not set."
}

ns_log notice "nsd.tcl: finished reading config file."

Collapse
Posted by Don Baccus on
<pre>ns_section "ns/db/drivers"
ns_param  postgres    ${bindir}/postgres.so
</pre>
The makefile distributed with AOLserver3 creates the binary
nspostgres.so, not postgres.so.  Are you sure you have the
right name?
<p>You probably need execute these lines BEFORE you define the pools, not after (I've never tried them after so don't know for sure, but it seems reasonable that they just do one pass over the thing).
<p>
Stick with it, you're getting close!
Collapse
Posted by Jose Mercado on
Yeah, I compiled the "enhanced postgres driver" which I got from a link off of the ACS/pq page.  I have tried both this driver and the one that comes with aolserver 3.  Both gave me the same errors.
Collapse
Posted by Don Baccus on
Here's something else that appears to be missing from your nsd.tcl file (if it is there and I've missed it, my apologies up front):

    ns_section "ns/db/pools"
        ns_param   main            "main"
        ns_param   subquery        "subquery"
        ns_param   log             "log"

Collapse
Posted by Jose Mercado on
Yes, I was leaving out that section.  Once I put that in, the server finished starting with out any problems.  HOWEVER, I tried going to http://mymachine:8000/ and my browser complains about teh document containing no data.  Going to http://mymachine:8000/index.tcl doesn't work either.  Any ideas?  I have already checked the perms on teh files and they are correct.
Collapse
23: BTW, my logs say.... (response to 1)
Posted by Jose Mercado on
[26/Apr/2000:14:42:16][19111.5126][-conn1-] Error: Ns_PgExec: result status: 7 message: ERROR:  No such function 'bpchar' with the specified attributes

[26/Apr/2000:14:42:16][19111.5126][-conn1-] Error: Filter sec_read_security_info returned error #1: Database operation "1row" failed (exception NSDB, "Query was not a statement returning rows.")
[26/Apr/2000:14:42:16][19111.5126][-conn1-] Error: nsd.tcl: Invalid return code from filter proc: Critical filter sec_read_security_info failed. (must be filter_ok, filter_return, or filter_break)

Is this some sort of postgrel incompatibility or something?

Collapse
Posted by Brent Fulgham on
See my post on the "Security Error" thread.  This seems to be a Postgres 6.5.3 bug.
Collapse
Posted by Don Baccus on
More specifically, use PG 7.0 with the latest openACS sources.