Setting up RADIUS to send accounting packets to multiple database servers simultaneously
Hi, I would like to set up RADIUS to send accounting packets to a local MySQL database and a remote PostgreSQL database. From the research that I did, this does not seem to be possible unless having them set redundant to each other. Is there a possible way to achieve this, please? I have started by setting up RADIUS to write accounting packets to the remote PostgreSQL, which was successful. However, I needed to test that if the remote database is unavailable, RADIUS will still start up. Unfortunately, although I did the change below, RADIUS will not start if the PostgreSQL database is not available. How is it possible to accomplish this, if not as shown below, please? pool { # Connections to create during module instantiation. # If the server cannot create specified number of # connections during instantiation it will exit. # Set to 0 to allow the server to start without the # database being available. start = 0 Furthermore, I am attaching RADIUS debug logs showing what I've explained above. Thanks in advance. Kind Regards, SG
On 02/08/2022 10:09, Sea Gull wrote:
I would like to set up RADIUS to send accounting packets to a local MySQL database and a remote PostgreSQL database. From the research that I did, this does not seem to be possible unless having them set redundant to each other. Is there a possible way to achieve this, please?
Copy the sql module instance (/etc/raddb/mods-enabled/sql). Call one (for example) sql_local and the other sql_remote, and configure them appropriately - the local one for the mysql instance and the remote one for the postgresql instance: sql sql_local { ... } sql sql_remote { ... } then call them both - rather than sql do sql_local sql_remote
I have started by setting up RADIUS to write accounting packets to the remote PostgreSQL, which was successful. However, I needed to test that if the remote database is unavailable, RADIUS will still start up. Unfortunately, although I did the change below, RADIUS will not start if the PostgreSQL database is not available. How is it possible to accomplish this, if not as shown below, please?
pool { # Connections to create during module instantiation. # If the server cannot create specified number of # connections during instantiation it will exit. # Set to 0 to allow the server to start without the # database being available. start = 0
You've not set that - or at least not in the correct place. The debug output still shows the pool with "start = 5". Make sure you edit the pool section in /etc/raddb/mods-enabled/sql. -- Matthew
Hi Matthew, Thank you for the information provided. I have tried it out and managed to set up RADIUS to write accounting packets to both MySQL and PostgreSQL Databases. However, with regards to having RADIUS restarting when these are unavailable, I am still getting the below messages in debug, even though I have set *start=0 *and it is now showing so. Is there maybe somewhere else that I have to change apart from /etc/raddb/mods-enabled/sql please? rlm_sql (sql_local): Attempting to connect to database "radius" rlm_sql (sql_local): Initialising connection pool pool { start = 0 min = 3 max = 32 spare = 10 uses = 0 lifetime = 0 cleanup_interval = 30 idle_timeout = 60 retry_delay = 30 spread = no } rlm_sql (sql_local): Processing generate_sql_clients rlm_sql (sql_local) in generate_sql_clients: query is SELECT id, nasname, shortname, type, secret, server FROM nas rlm_sql (sql_local): 0 of 0 connections in use. You may need to increase "spare" rlm_sql (sql_local): Opening additional connection (0), 1 of 32 pending slots used rlm_sql_mysql: Starting connect to MySQL server rlm_sql_mysql: Couldn't connect to MySQL server radius@localhost:radius rlm_sql_mysql: MySQL error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) rlm_sql_mysql: Socket destructor called, closing socket rlm_sql (sql_local): Opening connection failed (0) Failed to load clients from SQL /etc/raddb/mods-enabled/sql_local[27]: Instantiation failed for module "sql_local" Thanks again. Kind Regards, SG On Tue, Aug 2, 2022 at 12:07 PM Matthew Newton <mcn@freeradius.org> wrote:
On 02/08/2022 10:09, Sea Gull wrote:
I would like to set up RADIUS to send accounting packets to a local MySQL database and a remote PostgreSQL database. From the research that I did, this does not seem to be possible unless having them set redundant to each other. Is there a possible way to achieve this, please?
Copy the sql module instance (/etc/raddb/mods-enabled/sql). Call one (for example) sql_local and the other sql_remote, and configure them appropriately - the local one for the mysql instance and the remote one for the postgresql instance:
sql sql_local { ... }
sql sql_remote { ... }
then call them both - rather than
sql
do
sql_local sql_remote
I have started by setting up RADIUS to write accounting packets to the remote PostgreSQL, which was successful. However, I needed to test that if the remote database is unavailable, RADIUS will still start up. Unfortunately, although I did the change below, RADIUS will not start if the PostgreSQL database is not available. How is it possible to accomplish this, if not as shown below, please?
pool { # Connections to create during module instantiation. # If the server cannot create specified number of # connections during instantiation it will exit. # Set to 0 to allow the server to start without the # database being available. start = 0
You've not set that - or at least not in the correct place. The debug output still shows the pool with "start = 5". Make sure you edit the pool section in /etc/raddb/mods-enabled/sql.
-- Matthew - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
rlm_sql (sql_local): Processing generate_sql_clients rlm_sql (sql_local) in generate_sql_clients: query is SELECT id, nasname, shortname, type, secret, server FROM nas You've trimmed the debug output a bit too tightly - what's the entire configuration for sql_local, not just for the pool?
However, it suggests that 'read_clients' is set to 'yes' in the "sql_local" module configuration. FreeRADIUS is trying to collect additional clients by reading from the 'nas' database table on startup. Graham
On Aug 4, 2022, at 5:11 AM, Sea Gull <seagull0044@gmail.com> wrote:
Thank you for the information provided. I have tried it out and managed to set up RADIUS to write accounting packets to both MySQL and PostgreSQL Databases. However, with regards to having RADIUS restarting when these are unavailable, I am still getting the below messages in debug, even though I have set *start=0 *and it is now showing so. Is there maybe somewhere else that I have to change apart from /etc/raddb/mods-enabled/sql please?
Please read the debug output:
... rlm_sql (sql_local): Processing generate_sql_clients rlm_sql (sql_local) in generate_sql_clients: query is SELECT id, nasname, shortname, type, secret, server FROM nas rlm_sql (sql_local): 0 of 0 connections in use. You may need to increase "spare" rlm_sql (sql_local): Opening additional connection (0), 1 of 32 pending slots used rlm_sql_mysql: Starting connect to MySQL server rlm_sql_mysql: Couldn't connect to MySQL server radius@localhost:radius rlm_sql_mysql: MySQL error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
You've set "read_clients = yes", but the SQL database is not available. How do you propose to read the clients from SQL when SQL is down? I have no idea why people make FreeRADIUS depend on an SQL database, and then insist that the SQL database is allowed to be randomly unavailable. That's just bad practice. Your options are: a) make sure that SQL is up. b) put clients into "clients.conf", and set "read_clients = no" Alan DeKok.
Hi Graham and Alan, Thank you for your help. Setting "start = 0" and "read_clients = no" allowed me to start RADIUS without the accounting DB being available. Unfortunately, I thought that setting "read_clients = yes" will read from the "clients.conf", in fact that is where I have set all my clients, as rightly pointed out by Alan. Thanks again. Kind Regards, SG On Thu, Aug 4, 2022 at 2:40 PM Alan DeKok <aland@deployingradius.com> wrote:
On Aug 4, 2022, at 5:11 AM, Sea Gull <seagull0044@gmail.com> wrote:
Thank you for the information provided. I have tried it out and managed to set up RADIUS to write accounting packets to both MySQL and PostgreSQL Databases. However, with regards to having RADIUS restarting when these are unavailable, I am still getting the below messages in debug, even though I have set *start=0 *and it is now showing so. Is there maybe somewhere else that I have to change apart from /etc/raddb/mods-enabled/sql please?
Please read the debug output:
... rlm_sql (sql_local): Processing generate_sql_clients rlm_sql (sql_local) in generate_sql_clients: query is SELECT id, nasname, shortname, type, secret, server FROM nas rlm_sql (sql_local): 0 of 0 connections in use. You may need to increase "spare" rlm_sql (sql_local): Opening additional connection (0), 1 of 32 pending slots used rlm_sql_mysql: Starting connect to MySQL server rlm_sql_mysql: Couldn't connect to MySQL server radius@localhost:radius rlm_sql_mysql: MySQL error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
You've set "read_clients = yes", but the SQL database is not available.
How do you propose to read the clients from SQL when SQL is down?
I have no idea why people make FreeRADIUS depend on an SQL database, and then insist that the SQL database is allowed to be randomly unavailable. That's just bad practice.
Your options are:
a) make sure that SQL is up.
b) put clients into "clients.conf", and set "read_clients = no"
Alan DeKok.
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
participants (4)
-
Alan DeKok -
Graham Clinch -
Matthew Newton -
Sea Gull