User Tools

Site Tools


tutorials:kamailio-and-mongodb

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorials:kamailio-and-mongodb [2015/09/08 21:31]
miconda [Version Table Records]
tutorials:kamailio-and-mongodb [2019/01/07 09:24]
henningw small addtion
Line 1: Line 1:
 ====== Kamailio and MongoDB ====== ====== Kamailio and MongoDB ======
  
-====== Kamailio Database ​======+Details about how to use Kamailio with a MongoDB backend. 
 +===== Kamailio Database =====
  
 The **use** command in mongodb client **mongo** creates the database if it doesn'​t exit: The **use** command in mongodb client **mongo** creates the database if it doesn'​t exit:
Line 18: Line 19:
 Note that a database is not shown by the above command if it is empty -- you need to add some records to it. Note that a database is not shown by the above command if it is empty -- you need to add some records to it.
  
-===== Version Table =====+==== Version Table ====
  
 Kamailio uses version table to check if the structure of a database table has the structure version the C code expects. Kamailio uses version table to check if the structure of a database table has the structure version the C code expects.
Line 37: Line 38:
 </​code>​ </​code>​
  
-==== Version Table Records ​====+=== Version Table Records ===
  
 Add the records for the other Kamailio tables you are going to use. Some examples: Add the records for the other Kamailio tables you are going to use. Some examples:
Line 51: Line 52:
 > db.getCollection("​version"​).insert({table_name:​ "​watchers",​ table_version:​ NumberInt(3) }) > db.getCollection("​version"​).insert({table_name:​ "​watchers",​ table_version:​ NumberInt(3) })
  
-db.getCollection("​version"​).insert({table_name:​ "​active_watchers",​ table_version:​ NumberInt(11) })+db.getCollection("​version"​).insert({table_name:​ "​active_watchers",​ table_version:​ NumberInt(11) })
  
 </​code>​ </​code>​
  
 To learn what is the version number for a specific table, look inside **lib/​srdb1/​schema/​**,​ there is an xml file with the name of the table and inside it you should see the **version** attribute. To learn what is the version number for a specific table, look inside **lib/​srdb1/​schema/​**,​ there is an xml file with the name of the table and inside it you should see the **version** attribute.
-===== Other Tables ===== 
  
-MongoDB doesn'​t have a schema definition for documents stored in a collection.+==== Other Tables ====
  
-===== DB URL =====+MongoDB doesn'​t have a schema definition for documents stored in a collection. It is not required to create a collection before inserting a record to it. 
 + 
 +Anyhow, if you want, you can create the collections in advance, using: 
 + 
 +<​code>​ 
 +> db.createCollection("​tablename"​) 
 +</​code>​ 
 +===== Kamailio Config ===== 
 + 
 +==== DB URL ==== 
 + 
 +You need to load the "​db_mongodb"​ module in the configuration.
  
 The corresponding database URL in kamailio.cfg:​ The corresponding database URL in kamailio.cfg:​
Line 74: Line 85:
 <​code>​ <​code>​
 #!define DBURL "​mongodb://​username:​password@localhost/​kamailio"​ #!define DBURL "​mongodb://​username:​password@localhost/​kamailio"​
 +</​code>​
 +
 +==== Other Parameters ====
 +
 +If you store location records in MongoDB, set the following parameter for usrloc modules:
 +
 +<​code>​
 +modparam("​usrloc",​ "​db_insert_null",​ 1)
 </​code>​ </​code>​
tutorials/kamailio-and-mongodb.txt · Last modified: 2019/01/07 09:24 by henningw