Conf/Db

From AOLserver Wiki
Jump to navigation Jump to search

ns_section "ns/db/drivers"

part of AOLServer Config Reference

There are database drivers for a number of popular databases Modules#Database_Drivers

 ns_section "ns/db/drivers"
   ns_param   postgres_driver nspostgres.so

You can define as many pools as you need.

   ns_section "ns/db/pools"
   ns_param   postgres_pool  "Postgres Pool"

Configure this pool

 ns_section "ns/db/pool/postgres_pool"
   ns_param   driver          postgres_driver
   ns_param   datasource      HOSTNAME:PORT:database_name
   ns_param   user            user_name
   ns_param   password        password
   ns_param   connections     5         ;# The maximum number of db handles to open
   ns_param   logsqlerrors    true      ;# Verbose SQL query error logging
   ns_param   verbose         false     ;# Verbose error logging
   ns_param   maxidle         600       ;# Max time to keep idle db connections open
   ns_param   maxopen         3600      ;# Max time to keep active db connections open


Loading the nsdb module

The nsdb.so module must be loaded in the virtual server

 ns_section "ns/server/${server_name}/modules"
     ns_param nsdb ${bindir}/nsdb.so

Accessing DB pools

In the case of virtual servers you can give different virtual servers access to different databases, or you can let them access them all.

 ns_section "ns/server/${server_name}/db"
   ns_param pools          *            ;# Wildcard gives access to all
   ns_param defaultpool    postgres_pool