DBSource
,
DBUsername
, and DBAuth
are
passed to DBI like this:DBI->connect(DBSource, DBUsername, DBAuth)
DBSource
is a specification, which usually starts
with dbi:drivername:...
, but the exact meaning of
these variables depends on the Perl DBD driver you use. For more
information about the syntax of DBSource
,
DBUsername
, and DBAuth
for
different database vendors, see Section 19. Using SQL with various database vendors.DBSource
, DBUsername
, and
DBAuth
parameters. Whenever Radiator tries to connect
to a database, SQL tries to connect to the first
DBSource
listed, using the first
DBUsername
and DBAuth
parameters. If that connection fails, it tries the second, third and so
on, until all the databases are tried, and finally gives up without
replying to the NAS. This gives your NAS the opportunity to fall back to
another RADIUS server if all your SQL databases are down. You can change
this default behaviour with the RoundRobinOnFailure
configuration parameter. For more information, see Section 3.8.8. RoundRobinOnFailure.AuthSelect select PASSWORD from SUBSCRIBERS where USERNAME=? and CLIENT=? AuthSelectParam %0 AuthSelectParam %N
USERNAME
column), and
%N (NAS id) will be used to replace the second (the one
for the CLIENT
column).dbi:drivername:
. There is no standard for the text
following the driver name, consult the details for your DBD (database
driver) documentation. You can use any of the special characters described
in Section 3.3. Special formatters. Here are some
examples.# Connect to MySQL database called radius. Typically defaults to Unix socket DBSource dbi:mysql:database=radius # Or... Use SQLIte file called users.db located in the DbDir directory DBSource dbi:SQLite:%D/users.db # Or... Connect to the Oracle SID called users DBSource dbi:Oracle:users # Or... Connect to PostgreSQL database called radius on localhost, default port DBSource dbi:Pg:dbname=radius;host=127.0.0.1
DBSource dbi:mysql:%{GlobalVar:databasename} radiusd -config_file xxxxxx.cfg databasename=radius
# For SQLite, it is ignored DBUsername ignored # For Oracle, it is the name of the Oracle user to log in as DBUsername scott
DBUsername
. For
some databases, this has a different meaning. For example, for SQLite it
is meaningless and can be ignored. You can use any of the special
characters described in Section 3.3. Special formatters.# For SQLite, it is ignored DBAuth ignored # For Oracle, it is Oracle password for DBUsername DBAuth tiger
SQLRetries
limit is reached. For more
information about SQLRetries
, see Section 3.8.7. SQLRetries.ConnectTimeout
is not defined,
Timeout
is also be used when trying to connect or
disconnect an SQL database specified by
DBSource
.Timeout
period, Radiator considers the SQL server
to be failed, and stops trying to contact the SQL server until the
FailureBackoffTime
is expired. The default value for
Timeout
is 60
seconds. If you set
Timeout to 0
, no timeouts are implemented, and Radiator
relies on the underlying implementation to timeout any SQL
operations.# Set the timeout to two seconds Timeout 2
Timeout
is not supported on
Perl for Windows. On Windows platforms, the timeout usually is determined
by the TCP timeouts built in to your Windows TCP stack.DBSource
. In this
case, the value of Timeout
must be larger than the
timeout value in DBSource
.Timeout
to 0
If you are using Sybase
ODBC libraries.600
(10 minutes).# Try again after 3 minutes FailureBackoffTime 180
DBSource
list to be
tried next instead of the first one.# Try to skip databases that have become slow to respond RoundRobinOnFailure
DBSource
. If this parameter
is not set, value of Timeout
is used for connection
handling. For more information about Timeout
, see
Section 3.8.5. Timeout.ConnectTimeout
, SQL
connection timeout can different than Timeout
that is
used for SQL queries.# DB driver connect timeout is shorter than 20 seconds # but we want 2 second query timeout ConnectTimeout 20 Timeout 2
SQLRecoveryFile
and logging all failed queries of one
day into a one file:# Log all failed SQL queries to a log file per day SQLRecoveryFile %L/sqlfailures-%Y-%m-%d
func()
to configure the database
connection in customised ways. The hook is called with 2 arguments. The
first is a reference to the clause object that is making the connection.
The second argument is the DBH handle to the newly connected
database.ConnectionHook sub {$_[1]->func(-access_mode => 'read_write',\ -isolation_level => 'read_committed',\ -lock_resolution => 'wait',\ 'ib_set_tx_param')}
$object
,
$dbsource
, $dbusername
,
$dbauth
. $object
is the SqlDb
object trying to connect. The other parameters are the currently used
values for DBSource
, DBUsername
,
and DBAuth
.ConnectionAttemptFailedHook sub { \ my $self = $_[0]; my $dbsource = $_[1]; \ my $dbusername = $_[2]; my $dbauth = $_[3]; \ $self->log($main::LOG_ERR, "Could not connect to SQL database with DBI->connect \ $dbsource, $dbusername, $dbauth: $@ $DBI::errstr"); }
$object
. $object
is
the SqlDb object that was trying to connect.NoConnectionsHook sub { \ my $self = $_[0]; \ $self->log($main::LOG_ERR, "Could not connect to any SQL database"); }
goodies/addressallocator.sql
for a configuration
sample.radiusd
to use asynchronous SQL queries. This flag is
not set by default and the queries are synchronous which means no
processing is done before the reply, or timeout, is received from the SQL
database. With asynchronous queries, radiusd
can do
other processing while the query is being processed by the database. When
the the database result is ready, radiusd
continues
from the point where the asynchronous query was started.AsynchronousSQL
and the parameters typically used
with it:
# See goodies/addressallocator.cfg for full example # Run address allocator in asynchronous mode <AddressAllocator SQL> # Other parameters AsynchronousSQL AsynchronousSQLConnections 10 ConnectSQLAtStartup RoundRobinQueries </AddressAllocator>
goodies/addressallocator.sql
for a configuration
sample.goodies/addressallocator.sql
for a configuration
sample.