astricon 2013: "asterisk and database"

35
Francesco PRIOR @priorfra

Upload: francesco-prior

Post on 10-May-2015

2.763 views

Category:

Technology


5 download

DESCRIPTION

A very practical discussion on how to connect Asterisk with Relational Databases using ODBC database abstraction layer. This session will cover the basics of MySQL/ODBC installation, configuration and integration with Asterisk. Additionally will be made practical examples about the benefits of this union: improving dialplan with SQL Queries, store Call Detail Records (CDR) in DB, implementing Realtime Architecture (ARA). Proposed session is for those who do not yet know benefits of connecting an Asterisk box to a database or are interested to learn about it through a very simple step-by-step demo.

TRANSCRIPT

Page 1: Astricon 2013: "Asterisk and Database"

Francesco PRIOR

@priorfra

Page 2: Astricon 2013: "Asterisk and Database"

.: Numbers

Page 3: Astricon 2013: "Asterisk and Database"

.: Numbers

types of people in the world:Those who understand binary,

and those who don't.

There are only

Page 4: Astricon 2013: "Asterisk and Database"

.: Happy Birthday

Page 5: Astricon 2013: "Asterisk and Database"

INTRO 2

I’m freelancer:“The idea is my boss”.

[Pablo Bernasconi – TEDx Cordoba]

.: About Me

Page 6: Astricon 2013: "Asterisk and Database"

INTRO 2.: Astricon 2012

Available on:

Page 7: Astricon 2013: "Asterisk and Database"

You need

this book !

.: The Definitive Guide

Page 8: Astricon 2013: "Asterisk and Database"

.: Summary

Page 9: Astricon 2013: "Asterisk and Database"

“In order to get you into the right frame of mind for what follows, we want you to picture a Dagwood sandwich.”

[Asterisk™: The Definitive Guide]

.: Sandwich Layers

Page 10: Astricon 2013: "Asterisk and Database"

.: Premises

Page 11: Astricon 2013: "Asterisk and Database"

root@ubuntu001:~# apt-get install mysql-server

Select a strong password

root@ubuntu001:~# /usr/bin/mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

.: MySQL: installation

Page 12: Astricon 2013: "Asterisk and Database"

mysql> CREATE DATABASE asterisk;Query OK, 0 rows affected (0.00 sec)

root@ubuntu001:~# mysql -u asterisk -p asteriskEnter password:mysql>

.: MySQL: configuration

root@ubuntu001:~# mysql -u root -pmysql> CREATE USER 'asterisk'@'%' IDENTIFIED BY 'some_secret_password';Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON asterisk.* TO 'asterisk'@'%';

Page 13: Astricon 2013: "Asterisk and Database"

root@ubuntu001:~# apt-get install libmyodbc

root@ubuntu001:~# apt-get install unixODBC unixODBC-dev

.: ODBC: installation

Page 14: Astricon 2013: "Asterisk and Database"

Edit /etc/odbc.ini

Edit /etc/odbcinst.ini

.: ODBC: configuration

Page 15: Astricon 2013: "Asterisk and Database"

./configure

make install

.: Asterisk: installation

./make menuselect

Page 16: Astricon 2013: "Asterisk and Database"

/etc/asterisk/res_odbc.conf

/etc/asterisk/func_odbc.conf

.: Asterisk: configuration

Page 17: Astricon 2013: "Asterisk and Database"

Show changes in system

.: Checks

Page 18: Astricon 2013: "Asterisk and Database"

/etc/asterisk/res_odbc.conf

/etc/asterisk/func_odbc.conf

/etc/odbc.ini

/etc/odbcinst.ini

.: Resuming

Page 19: Astricon 2013: "Asterisk and Database"

.: Access from Dialplan

Page 20: Astricon 2013: "Asterisk and Database"

extensions.conf SQL Queries

SELECT

UPDATE

EXEC Procedure

SELECT

………

.: Access from Dialplan

Page 21: Astricon 2013: "Asterisk and Database"

/etc/asterisk/func_odbc.conf

create a table

.: Access from Dialplan

…a practical example.

Page 22: Astricon 2013: "Asterisk and Database"

/etc/asterisk/extensions.conf

.: Access from Dialplan

Page 23: Astricon 2013: "Asterisk and Database"

.: CDR saved in Database

Page 24: Astricon 2013: "Asterisk and Database"

Call Detail Records

.: CDR saved in DB

Page 25: Astricon 2013: "Asterisk and Database"

.: CDR saved in DB

More details with customized fields.

Page 26: Astricon 2013: "Asterisk and Database"

/etc/asterisk/cdr_adaptive_odbc.conf

*CLI> module reload cdr_adaptive_odbc.so

.: CDR saved in DB

Page 27: Astricon 2013: "Asterisk and Database"

.: Now, a Demo

Call now to test Dialplan and CDR on Database.

281 864 ****It will execute:

Phone Number no loger available

Page 28: Astricon 2013: "Asterisk and Database"

.: Now, a Demo

Page 29: Astricon 2013: "Asterisk and Database"

.: Asterisk Realtime Architecture

Page 30: Astricon 2013: "Asterisk and Database"

/etc/asterisk

sip.conf

iax.conf

voicemail.conf

musiconhold.conf

queues.conf

.......

ARA

.: Asterisk Realtime ArchitectureConfiguration saved in DB

Static/Dynamic

Page 31: Astricon 2013: "Asterisk and Database"

• SIP/IAX peers/users• Dialplan• Queue Members• Access Control Lists• Voicemail boxes• MeetMe conferences• Music on Hold

.: Asterisk Realtime Architecture

Page 32: Astricon 2013: "Asterisk and Database"

[settings]

sippeers => odbc,asterisk,ast_sippeers

extensions => odbc,asterisk,dialplan

/etc/asterisk/extconfig.conf

.: Asterisk Realtime Architecture

Page 33: Astricon 2013: "Asterisk and Database"

Centralized

Server 1 Server 2 Server 3 Server N

• Sip Peers/Users

• Voicemail

• Extensions

Scalable

Replicable

.: Asterisk Realtime Architecture

Page 34: Astricon 2013: "Asterisk and Database"

.: Conclusion

REFERENCES:

Asterisk Project Wiki

[https://wiki.asterisk.org/wiki/display/AST/Realtime+Database+Configuration]

Asterisk: The Definitive Guide, 4th Edition

[http://shop.oreilly.com/product/0636920025894.do]

Page 35: Astricon 2013: "Asterisk and Database"

.: Any Questions ?

PRIOR Francesco

[email protected]

@priorfra