FreeSWITCH Databases
About
The default FreeSWITCH configuration uses a series of SQLite databases that are stored the /usr/local/freeswitch/db directory of a FreeSWITCH installation. This configuration can be changed to connect to other databases like PostgreSQL (native) or MySQL (via ODBC).
Click here to expand Table of Contents
- 1 DSN connection strings
- 1.1 DSN Format
- 1.2 SQLite DSNs
- 1.3 PostgreSQL DSNs
- 2 ODBC DSNs
- 2.1 DSN with username and password
- 2.2 DSN with username
- 2.3 DSN only
- 2.4 DSN-less
- 3 Modules that use databases
- 4 Configuring FreeSWITCH to use databases
- 4.1 recovery
- 4.2 mod_sofia
- 4.3 mod_limit
- 4.4 mod_voicemail
- 4.5 mod_lcr
- 4.6 mod_nibblebill
DSN connection strings
The FreeSWITCH core provides the API for modules to make connections to databases. These database connections are defined with data source names (DSN) in XML configuration params like "core-db-dsn", "odbc-dsn", etc.
FreeSWITCH currently supports the following DSN types:
- PostgreSQL
- ODBC
- SQLite
DSN Format
The generic DSN format is
<type>://<connection string>
SQLite DSNs
sqlite://filename
sqlite:///usr/local/freeswitch/db/mega.db
Note the 3rd / to indicate a local absolute path.
PostgreSQL DSNs
pgsql://hostaddr=127.0.0.1 dbname=freeswitch user=freeswitch password= options='-c client_min_messages=NOTICE' application_name='freeswitch'"
ODBC DSNs
Now (2012-11) that FreeSWITCH supports multiple core database options (PostgreSQL, ODBC, SQLite), the format for the DSN has changed so that FreeSWITCH knows which database type to use.
The following DSN (data source name) formats are valid for ODBC databases:
DSN with username and password
```xml
```or
<param name="core-db-dsn" value="odbc://database:username:password"/>
DSN with username
Note the colon at the end.
<param name="core-db-dsn" value="database:username:"/>
or
<param name="core-db-dsn" value="odbc://database:username"/>
DSN only
Note the two colons at the end.
<param name="core-db-dsn" value="database::"/>
or
<param name="core-db-dsn" value="odbc://database"/>
The following formats NO LONGER WORK (since v1.2.4)
<param name="core-db-dsn" value="database"/> <param name="core-db-dsn" value="database:password"/>
DSN-less
DSN-less connections are also possible. Such connections don't require setting up in odbc.ini.
Essentially the syntax is the same options you would have in odbc.ini name-value pairs, separated by ;
MyODBC example (OPTION=67108864 enables batched statements):
<param name="core-db-dsn" value="odbc://DRIVER=mysql;SERVER=a.b.c.d;UID=username;PWD=secretpassword;DATABASE=freeswitch;OPTION=67108864">
Modules that use databases
Instead of using the default SQLite database as the internal FreeSWITCH database, you can use any core database type. This works for.
- mod_db
- mod_voicemail - Voicemail module.
- mod_sofia - SIP module.
- mod_dingaling
- mod_cidlookup
- mod_lcr
Configuring FreeSWITCH to use databases
For the core:
conf/autoload_configs/switch.conf.xml
<param name="core-db-dsn" value="odbc://tuxza:admin:pass" />
Add or uncomment the following line in appropriate config file within <settings></settings>
<param name="odbc-dsn" value="odbc://your_dsn_name:your_db_user:your_db_password"/>
recovery
For call recovery, if track-calls is on. This is stored in a table called "recovery".
In switch.conf.xml:
<param name="core-recovery-db-dsn" value="odbc://your_dsn_name:your_db_user:your_db_password"/>
mod_sofia
Adding your odbc-dsn param setting under global_settings will NOT work. It has to be put within <settings></settings> in each sip profile.
sip_profiles/external.xml
sip_profiles/internal.xml
sip_profiles/internal-ipv6.xml
mod_limit
- db.conf.xml
mod_voicemail
- voicemail.conf.xml
mod_lcr
- lcr.conf.xml
mod_nibblebill
- nibblebill.conf.xml
You will have to create the database table as described in MOD_Nibblebill
Comments:
FreeSWITCH 1.10.x Release notes Posted by livem at Oct 09, 2020 02:11 |
---|