Asterisk13 Realtime Configuration on Centos7

Hello Dear Fellows
I Installed Asterisk 13 on Cent OS 7 in which MariaDB Database is installed on it.

I made proper configurations on:Res_mysql.conf / extconfig.conf / sip.conf /extensions.conf /modules.conf and finally I created suitable database and tables and I inserted some values in them .

how ever apparently asterisk cannot load my database information so that I can register my users. I checked “core show peers” and RealTime Architecture was disabled.

I Highly appreciate any hint that what the problem would be ? I attached my configured files in the following. Best Regards

Res_Mysql.conf
[general]
dbhost=127.0.0.1
dbname=asteriskDB
dbuser=root
dbpass=123a123A
dbport=3306

Extconfig.conf
[setting]
Sippers=>mysql , general , sip_buddies
Extentions=> mysql,general , extensions


Sip.conf
[general]

context= from-sip ;
bindport=5060;
bindaddr=0.0.0.0;
disallow=all;
allow=gsm
allow=ulaw
registerattempts=10
registertimeout=20

dbhost=127.0.0.1
dbname=asteriskDB
dbuser=root
dbpass=123a123A
dbport=3306

Extensions.conf

[general]
dbhost=127.0.0.1
dbname=asteriskDB
dbuser=root
dbpass=123a123A
dbport=3306

[globals];
[from-sip]
Switch =>Realtime

Modules.conf

Autoload=yes
Load =>res_config_mysql.so
load => func_realtime.so
Load =>app_realtime.so
Load =>pbx_realtime.so

create database if not exists asteriskDB;
use asteriskDB;


  1. Create Tables (sip_buddies & Extensions)

CREATE TABLE sip_buddies (
id int(11) NOT NULL auto_increment,
name varchar(80) NOT NULL,
callerid varchar(80) default NULL,
defaultuser varchar(80) NOT NULL,
regexten varchar(80) NOT NULL,
secret varchar(80) default NULL,
mailbox varchar(50) default NULL,
accountcode varchar(20) default NULL,
context varchar(80) default NULL,
amaflags varchar(7) default NULL,
callgroup varchar(10) default NULL,
canreinvite char(3) default ‘yes’,
defaultip varchar(15) default NULL,
dtmfmode varchar(7) default NULL,
fromuser varchar(80) default NULL,
fromdomain varchar(80) default NULL,
fullcontact varchar(80) default NULL,
host varchar(31) NOT NULL,
insecure varchar(4) default NULL,
language char(2) default NULL,
md5secret varchar(80) default NULL,
nat varchar(5) NOT NULL default ‘no’,
deny varchar(95) default NULL,
permit varchar(95) default NULL,
mask varchar(95) default NULL,
pickupgroup varchar(10) default NULL,
port varchar(5) NOT NULL,
qualify char(3) default NULL,
restrictcid char(1) default NULL,
rtptimeout char(3) default NULL,
rtpholdtimeout char(3) default NULL,
type varchar(6) NOT NULL default ‘friend’,
disallow varchar(100) default ‘all’,
allow varchar(100) default ‘g729;ilbc;gsm;ulaw;alaw’,
musiconhold varchar(100) default NULL,
regseconds int(11) NOT NULL default ‘0’,
ipaddr varchar(15) NOT NULL,
cancallforward char(3) default ‘yes’,
lastms int(11) NOT NULL,
useragent char(255) default NULL,
regserver varchar(100) default NULL,
PRIMARY KEY (id),
UNIQUE KEY name (name),
KEY name_2 (name)
) ENGINE=MyISAM AUTO_INCREMENT=893 DEFAULT CHARSET=latin1;
CREATE TABLE extensions (
id int(11) NOT NULL auto_increment,
context varchar(20) NOT NULL default ‘’,
exten varchar(20) NOT NULL default ‘’,
priority tinyint(4) NOT NULL default ‘0’,
app varchar(20) NOT NULL default ‘’,
appdata varchar(128) NOT NULL default ‘’,
PRIMARY KEY (context,exten,priority),
KEY id (id)
) ENGINE=MyISAM AUTO_INCREMENT=257 DEFAULT CHARSET=latin1;


  1. Insert into Tables (sip_buddies & Extensions)

INSERT INTO asteriskDB.sip_buddies (
NAME, defaultuser, secret, context, HOST, nat, qualify, TYPE)
VALUES (
‘1000’, ‘1000’, ‘1234’, ‘from-sip’, ‘dynamic’, ‘yes’, ‘no’, ‘friend’);
;

INSERT INTO asteriskDB.sip_buddies (
NAME, defaultuser, secret, context, HOST, nat, qualify, TYPE)
VALUES (
‘2000’, ‘2000’, ‘1234’, ‘from-sip’, ‘dynamic’, ‘yes’, ‘no’, ‘friend’);

INSERT INTO extensions(context,exten,priority,app,appdata)
values

(‘from-sip’,‘12121111111’,1,‘Dial’,‘SIP/1000|60’),
(‘from-sip’,‘12122222222’,1,‘Dial’,‘SIP/2000|60’);

If your endpoints are able to register, you could add rtcachefriends=yes to the [general] section of sip.conf. Once they make a call, they will show in ‘sip show peers’.

mark*CLI> sip show peers
Name/username Host Dyn Forcerport Comedia ACL Port Status Description Realtime
1000/1000 192.168.1.66 D No No 5060 OK (3 ms) Cached RT
1001/1001 (Unspecified) D No No 0 UNREACHABLE Cached RT
2 sip peers [Monitored: 1 online, 1 offline Unmonitored: 0 online, 0 offline]

I used to use the MySQL setup, but would not be surprised if that became deprecated in the future in favor of odbc.

Thanks for your replay, actually the point is that endpoints can not be registered :confused: :frowning:

One thing I noticed…

When using mysql, the second part in extconfig.conf should be the name of the database unless that’s been changed.
sippers=>mysql,asteriskDB,sip_buddies
extensions => mysql,asteriskDB,extensions
For odbc, it would be general in this case.

Do you have any logging when the phone tries to register? Can you hard-code the endpoints in sip.conf and get it to work (just for testing purposes)?

Here’s how I have mine set up if it helps.

res_odbc.conf
[asterisk]
enabled => yes
dsn => asterisk-connector
username => asterisk
password => databasepassword
pooling => no
limit => 1
pre-connect => yes

res_config_odbc.conf
[settings]
connection = asterisk_connector

/etc/odbc.ini
[asterisk-connector]
Description = MySQL connection to ‘asterisk’ database
Driver = MySQL
Database = asterisk
Server = localhost
Port = 3306
Socket = /var/run/mysqld/mysqld.sock

/etc/odbcinst.ini
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage = 1

extconfig.conf
[settings]
sipusers => odbc,asterisk,sippeers
sippeers => odbc,asterisk,sippeers
iaxusers => odbc,asterisk,iaxpeers
iaxpeers => odbc,asterisk,iaxpeers
voicemail => odbc,asterisk,voicemail_users
queues => odbc,asterisk,queue_table
queue_members => odbc,asterisk,queue_member_table
meetme => odbc,asterisk,meetme

voicemail.conf if you want to store voicemail in the database
[general]
format=wav
odbcstorage=asterisk
odbctable=voicemessages

cdr_adaptive_odbc.conf for storing CDRs in the database
[adaptive_connection]
connection=asterisk
table=cdr

modules.conf
[modules]
autoload=yes

preload => func_periodic_hook.so
noload => res_fax.so
noload => res_config_ldap.so
noload => chan_iax2.so

; Resource modules currently not needed
noload => res_ael_share.so
noload => res_clialiases.so
noload => res_adsi.so
; PBX modules currently not needed
noload => pbx_ael.so
noload => pbx_dundi.so
; Channel modules currently not needed
noload => chan_oss.so
noload => chan_mgcp.so
noload => chan_skinny.so
noload => chan_phone.so
noload => chan_agent.so
noload => chan_unistim.so
noload => chan_alsa.so
; Application modules currently not needed
noload => app_nbscat.so
noload => app_amd.so
noload => app_minivm.so
noload => app_zapateller.so
noload => app_ices.so
noload => app_sendtext.so
noload => app_speech_utils.so
noload => app_mp3.so
noload => app_flash.so
noload => app_getcpeid.so
noload => app_setcallerid.so
noload => app_adsiprog.so
noload => app_forkcdr.so
noload => app_sms.so
noload => app_morsecode.so
noload => app_followme.so
noload => app_url.so
noload => app_alarmreceiver.so
noload => app_disa.so
noload => app_dahdiras.so
noload => app_senddtmf.so
noload => app_sayunixtime.so
noload => app_test.so
noload => app_externalivr.so
noload => app_image.so
noload => app_dictate.so
noload => res_calendar.so
noload => cel_sqlite3_custom.so
noload => cel_odbc.so
noload => cdr_odbc.so
noload => cel_manager.so
noload => cdr_manager.so
noload => res_phoneprov.so
noload => res_stun_monitor.so
noload => res_stasis_playback.so

table asterisk.sippeers
CREATE TABLE IF NOT EXISTS sippeers (
id int(11) NOT NULL AUTO_INCREMENT,
name varchar(80) NOT NULL DEFAULT ‘’,
context varchar(80) DEFAULT ‘from-internal-sip’,
callingpres enum(‘allowed_not_screened’,‘allowed_passed_screen’,‘allowed_failed_screen’,‘allowed’,‘prohib_not_screened’,‘prohib_passed_screen’,‘prohib_failed_screen’,‘prohib’,‘unavailable’) DEFAULT ‘allowed_not_screened’,
deny varchar(95) DEFAULT NULL,
permit varchar(95) DEFAULT NULL,
secret varchar(80) DEFAULT NULL,
md5secret varchar(80) DEFAULT NULL,
remotesecret varchar(250) DEFAULT NULL,
transport enum(‘tcp’,‘udp’,‘tcp,udp’) DEFAULT NULL,
host varchar(31) NOT NULL DEFAULT ‘dynamic’,
nat varchar(32) NOT NULL DEFAULT ‘force_rport,comedia’,
type enum(‘user’,‘peer’,‘friend’) NOT NULL DEFAULT ‘friend’,
accountcode varchar(20) DEFAULT NULL,
amaflags varchar(13) DEFAULT NULL,
callgroup varchar(10) DEFAULT NULL,
callerid varchar(80) DEFAULT NULL,
defaultip varchar(15) DEFAULT NULL,
dtmfmode varchar(7) DEFAULT ‘rfc2833’,
fromuser varchar(80) DEFAULT NULL,
fromdomain varchar(80) DEFAULT NULL,
insecure varchar(4) DEFAULT NULL,
language char(2) DEFAULT NULL,
mailbox varchar(50) DEFAULT NULL,
pickupgroup varchar(10) DEFAULT NULL,
qualify char(3) DEFAULT ‘yes’,
regexten varchar(80) DEFAULT NULL,
rtptimeout char(3) DEFAULT NULL,
rtpholdtimeout char(3) DEFAULT NULL,
setvar varchar(100) DEFAULT NULL,
disallow varchar(100) DEFAULT ‘all’,
allow varchar(100) DEFAULT ‘ulaw;alaw;gsm’,
fullcontact varchar(80) NOT NULL DEFAULT ‘’,
ipaddr varchar(45) NOT NULL DEFAULT ‘’,
port mediumint(5) unsigned NOT NULL DEFAULT ‘0’,
defaultuser varchar(80) NOT NULL DEFAULT ‘’,
subscribecontext varchar(80) DEFAULT NULL,
directmedia enum(‘yes’,‘no’) DEFAULT ‘no’,
trustrpid enum(‘yes’,‘no’) DEFAULT NULL,
sendrpid enum(‘yes’,‘no’) DEFAULT NULL,
progressinband enum(‘never’,‘yes’,‘no’) DEFAULT NULL,
promiscredir enum(‘yes’,‘no’) DEFAULT NULL,
useclientcode enum(‘yes’,‘no’) DEFAULT NULL,
callcounter enum(‘yes’,‘no’) DEFAULT NULL,
busylevel int(10) unsigned DEFAULT NULL,
allowoverlap enum(‘yes’,‘no’) DEFAULT ‘yes’,
allowsubscribe enum(‘yes’,‘no’) DEFAULT ‘yes’,
allowtransfer enum(‘yes’,‘no’) DEFAULT ‘yes’,
ignoresdpversion enum(‘yes’,‘no’) DEFAULT ‘no’,
videosupport enum(‘yes’,‘no’,‘always’) DEFAULT ‘no’,
maxcallbitrate int(10) unsigned DEFAULT NULL,
rfc2833compensate enum(‘yes’,‘no’) DEFAULT ‘yes’,
session-timers enum(‘originate’,‘accept’,‘refuse’) DEFAULT ‘accept’,
session-expires int(5) unsigned DEFAULT ‘1800’,
session-minse int(5) unsigned DEFAULT ‘90’,
session-refresher enum(‘uac’,‘uas’) DEFAULT ‘uas’,
t38pt_usertpsource enum(‘yes’,‘no’) DEFAULT NULL,
outboundproxy varchar(250) DEFAULT NULL,
callbackextension varchar(250) DEFAULT NULL,
registertrying enum(‘yes’,‘no’) DEFAULT ‘yes’,
timert1 int(5) unsigned DEFAULT ‘500’,
timerb int(8) unsigned DEFAULT NULL,
qualifyfreq int(5) unsigned DEFAULT ‘120’,
contactpermit varchar(250) DEFAULT NULL,
contactdeny varchar(250) DEFAULT NULL,
lastms int(11) NOT NULL DEFAULT ‘0’,
regserver varchar(100) NOT NULL DEFAULT ‘’,
regseconds int(11) NOT NULL DEFAULT ‘0’,
useragent varchar(50) NOT NULL DEFAULT ‘’,
PRIMARY KEY (id),
UNIQUE KEY name (name),
KEY name_2 (name)
) ENGINE=MyISAM

table asterisk.voicemail_users
CREATE TABLE IF NOT EXISTS voicemail_users (
uniqueid int(11) NOT NULL AUTO_INCREMENT,
customer_id varchar(11) NOT NULL DEFAULT ‘0’,
context varchar(50) NOT NULL,
mailbox varchar(11) NOT NULL DEFAULT ‘0’,
password varchar(32) NOT NULL DEFAULT ‘0’,
fullname varchar(150) NOT NULL,
email varchar(50) NOT NULL,
pager varchar(50) NOT NULL,
tz varchar(10) NOT NULL DEFAULT ‘eastern’,
attach varchar(4) NOT NULL DEFAULT ‘no’,
saycid varchar(4) NOT NULL DEFAULT ‘no’,
dialout varchar(10) NOT NULL,
callback varchar(10) NOT NULL,
review varchar(4) NOT NULL DEFAULT ‘no’,
operator varchar(4) NOT NULL DEFAULT ‘no’,
envelope varchar(4) NOT NULL DEFAULT ‘no’,
sayduration varchar(4) NOT NULL DEFAULT ‘no’,
saydurationm tinyint(4) NOT NULL DEFAULT ‘1’,
sendvoicemail varchar(4) NOT NULL DEFAULT ‘no’,
delete varchar(4) NOT NULL DEFAULT ‘no’,
nextaftercmd varchar(4) NOT NULL DEFAULT ‘yes’,
forcename varchar(4) NOT NULL DEFAULT ‘no’,
forcegreetings varchar(4) NOT NULL DEFAULT ‘no’,
hidefromdir varchar(4) NOT NULL DEFAULT ‘yes’,
maxmsg int(11) NOT NULL DEFAULT ‘100’,
format varchar(8) NOT NULL DEFAULT ‘wav’,
stamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (uniqueid),
KEY mailbox_context (mailbox,context)
) ENGINE=MyISAM

table asterisk.voicemessages
CREATE TABLE IF NOT EXISTS voicemessages (
uniqueid bigint(20) unsigned NOT NULL AUTO_INCREMENT,
msgnum int(4) DEFAULT NULL,
dir varchar(80) DEFAULT NULL,
context varchar(80) DEFAULT NULL,
macrocontext varchar(80) DEFAULT NULL,
callerid varchar(40) DEFAULT NULL,
origtime varchar(40) DEFAULT NULL,
duration varchar(20) DEFAULT NULL,
mailboxuser varchar(80) DEFAULT NULL,
mailboxcontext varchar(80) DEFAULT NULL,
recording blob,
read tinyint(1) DEFAULT ‘0’,
flag varchar(10) DEFAULT NULL,
msg_id bigint(20) NOT NULL,
PRIMARY KEY (uniqueid),
UNIQUE KEY uniqueid (uniqueid)
) ENGINE=MyISAM

table asterisk.cdr
CREATE TABLE IF NOT EXISTS cdr (
start datetime NOT NULL DEFAULT ‘0000-00-00 00:00:00’,
answer datetime NOT NULL,
end datetime NOT NULL,
clid varchar(80) NOT NULL DEFAULT ‘’,
src varchar(80) NOT NULL DEFAULT ‘’,
dst varchar(80) NOT NULL DEFAULT ‘’,
dcontext varchar(80) NOT NULL DEFAULT ‘’,
channel varchar(80) NOT NULL DEFAULT ‘’,
dstchannel varchar(80) NOT NULL DEFAULT ‘’,
lastapp varchar(80) NOT NULL DEFAULT ‘’,
lastdata varchar(80) NOT NULL DEFAULT ‘’,
duration int(11) NOT NULL DEFAULT ‘0’,
billsec int(11) NOT NULL DEFAULT ‘0’,
disposition varchar(45) NOT NULL DEFAULT ‘’,
amaflags int(11) NOT NULL DEFAULT ‘0’,
accountcode varchar(20) NOT NULL DEFAULT ‘’,
uniqueid varchar(32) NOT NULL DEFAULT ‘’,
userfield varchar(255) NOT NULL DEFAULT ‘’,
peeraccount varchar(20) NOT NULL DEFAULT ‘’,
linkedid varchar(32) NOT NULL DEFAULT ‘’,
sequence int(11) NOT NULL DEFAULT ‘0’,
KEY start (start),
KEY dst (dst)
) ENGINE=MyISAM

I have the other tables too if you’d like them.

Thanks a lot Dude! It did worked using your ODBC configuration :smile:

Why is the use of direct mysql connection deprecated? Is odbc better way to connect to a database? Anyway ill try this solution too and reply with the conclusion. I had otheers problems trying to set odbc before

ODBC is preferred so that the Asterisk development team doesn’t have to pay attention to a wide array of database-specific connectors - it means they can remain more focused on solving problems specific to Asterisk, and less to solving database connectivity issues.

2 Likes