Asterisk Full RealTime Database example
eduguru 2 Comments `accountcode` varchar(20) default NULL, `adminpin`, `adminpin` varchar(20) default NULL, `allow` varchar(100) default 'g729;ilbc;gsm;ulaw;alaw', `amaflags` varchar(7) default NULL, `announce` varchar(128) default NULL, `announce_frequency` int(11) default NULL, `announce_holdtime` varchar(128) default NULL, `announce_round_seconds` int(11) default NULL, `app`, `app` varchar(20) NOT NULL default '', `appdata` varchar(128) NOT NULL default '', `appdata`) values ('from-sip', `attach` varchar(4) NOT NULL default 'yes', `callback` varchar(10) NOT NULL, `callerid` varchar(80) default NULL, `callgroup` varchar(10) default NULL, `cancallforward` char(3) default 'yes', `canreinvite` char(3) default 'yes', `context` varchar(128) default NULL, `context` varchar(20) NOT NULL default '', `context` varchar(50) NOT NULL, `context` varchar(80) default NULL, `context`) ) ENGINE=MyISAM AUTO_INCREMENT=2001 DEFAULT CHARSET=latin1; CREATE TABLE `queue_table` ( `name` varchar(128) NOT NULL, `context`) VALUES ('my_queue', `customer_id` varchar(11) NOT NULL default '0', `defaultip` varchar(15) default NULL, `defaultuser` varchar(80) NOT NULL, `delete` varchar(4) NOT NULL default 'no', `deny` varchar(95) default NULL, `dialout` varchar(10) NOT NULL, `disallow` varchar(100) default 'all', `domain`, `domain` varchar(128) NOT NULL default '', `dtmfmode` varchar(7) default NULL, `email` varchar(50) NOT NULL, `envelope` varchar(4) NOT NULL default 'no', `eventmemberstatus` tinyint(1) default NULL, `eventwhencalled` tinyint(1) default NULL, `exten` varchar(20) NOT NULL default '', `forcegreetings` varchar(4) NOT NULL default 'no', `forcename` varchar(4) NOT NULL default 'no', `fromdomain` varchar(80) default NULL, `fromuser` varchar(80) default NULL, `fullcontact` varchar(80) default NULL, `fullname` varchar(150) NOT NULL, `hidefromdir` varchar(4) NOT NULL default 'yes', `host` varchar(31) NOT NULL, `insecure` varchar(4) default NULL, `interface`, `interface` varchar(128) default NULL, `interface`) ) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; CREATE TABLE `meetme` ( `confno` varchar(80) NOT NULL default '0', `ipaddr` varchar(15) NOT NULL, `joinempty` varchar(128) default NULL, `language` char(2) default NULL, `lastms` int(11) NOT NULL, `leavewhenempty` varchar(128) default NULL, `mailbox` varchar(11) NOT NULL default '0', `mailbox` varchar(50) default NULL, `mask` varchar(95) default NULL, `maxlen` int(11) default NULL, `md5secret` varchar(80) default NULL, `memberdelay` int(11) default NULL, `membername`, `membername` varchar(40) default NULL, `members` int(11) NOT NULL default '0', `members`) VALUES ('my_conf', `monitor_format` varchar(128) default NULL, `monitor_join` tinyint(1) default NULL, `musiconhold` varchar(100) default NULL, `musiconhold` varchar(128) default NULL, `name` varchar(80) NOT NULL, `nat` varchar(5) NOT NULL default 'no', `nextaftercmd` varchar(4) NOT NULL default 'yes', `operator` varchar(4) NOT NULL default 'no', `pager` varchar(50) NOT NULL, `password` varchar(5) NOT NULL default '0', `paused` int(11) default NULL, `paused`) VALUES (1, `paused`) VALUES (2, `penalty`, `penalty` int(11) default NULL, `periodic_announce` varchar(50) default NULL, `periodic_announce_frequency` int(11) default NULL, `permit` varchar(95) default NULL, `pickupgroup` varchar(10) default NULL, `pin`, `pin` varchar(20) default NULL, `port` varchar(5) NOT NULL, `priority` tinyint(4) NOT NULL default '0', `priority`), `qualify` char(3) default NULL, `queue_callswaiting` varchar(128) default NULL, `queue_holdtime` varchar(128) default NULL, `queue_lessthan` varchar(128) default NULL, `queue_minutes` varchar(128) default NULL, `queue_name`, `queue_name` varchar(128) default NULL, `queue_reporthold` varchar(128) default NULL, `queue_seconds` varchar(128) default NULL, `queue_thankyou` varchar(128) default NULL, `queue_thereare` varchar(128) default NULL, `queue_youarenext` varchar(128) default NULL, `regexten` varchar(80) NOT NULL, `regseconds` int(11) NOT NULL default '0', `regserver` varchar(100) default NULL, `reportholdtime` tinyint(1) default NULL, `restrictcid` char(1) default NULL, `retry` int(11) default NULL, `review` varchar(4) NOT NULL default 'no', `ringinuse` tinyint(1) default NULL, `rtpholdtimeout` char(3) default NULL, `rtptimeout` char(3) default NULL, `saycid` varchar(4) NOT NULL default 'yes', `sayduration` varchar(4) NOT NULL default 'no', `saydurationm` tinyint(4) NOT NULL default '1', `secret` varchar(80) default NULL, `sendvoicemail` varchar(4) NOT NULL default 'no', `servicelevel` int(11) default NULL, `setinterfacevar` tinyint(1) default NULL, `stamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `strategy` varchar(128) default NULL, `timeout` int(11) default NULL, `timeoutrestart` tinyint(1) default NULL, `type` varchar(6) NOT NULL default 'friend', `tz` varchar(10) NOT NULL default 'central', `useragent` char(255) default NULL, `username`, `username` varchar(64) NOT NULL default '', `weight` int(11) default NULL, `wrapuptime` int(11) default NULL, '_*0', '_9X.', '_X.', '', ''), '${CALLERID(num)}@from-sip'), '${EXTEN}@from-sip'), '1000', '11111111', '12121111111', '12122222222', '12127777777', '12129999999', '2000', '4444', '5555', 'Dial', 'dynamic', 'friend'); ; INSERT INTO asteriskrealtime.sip_buddies ( NAME, 'friend'); inster the dial-plan in the extensions table insert into `extensions`(`context`, 'from-sip', 'from-sip'); Insert the two extensions 1000 and 2000 as members: INSERT INTO `queue_member_table` (`uniqueid`, 'MeetMe', 'my_conf'); add voicemail to ext 1000 & 2000: INSERT INTO asteriskrealtime.voicemail_users (customer_id, 'my_queue'), 'no', 'Queue', 'SIP/${EXTEN:1}@deltathree'), 'SIP/${EXTEN}|30'), 'SIP/1000', 'SIP/1000@from-sip', 'SIP/1000|60'), 'SIP/2000', 'SIP/2000@from-sip', 'SIP/2000|60'), 'sipauth.deltathree.com', 'User-A', 'User-B', 'UserA@myemail.com'); ; INSERT INTO asteriskrealtime.voicemail_users (customer_id, 'UserB@myemail.com'); Insert the new queue "my_queue": INSERT INTO `queue_table` (`name`, 'VoiceMail', 'VoiceMailMain', ${EXTEN}, 0); ; INSERT INTO `queue_member_table` (`uniqueid`, 0); insert the conference bridge: INSERT INTO `meetme` (`confno`, 0); Restart asterisk and go into the CLI: asterisk -rx "restart now" asterisk -r Check the asterisk realtime status localhost*CLI> realtime mysql status general connected to asteriskrealtime@127.0., 1, 1234, 2, 3, 4, 5 are "off" turn to "on" chkconfig --level 345 mysqld on set your mysql root password (in needed): mysqladmin -u root password password go into the mysql CLI: mysql -u root -p insert the "password" Cr, and start it if needed: /etc/init.d/mysqld status /etc/init.d/mysqld start in order to start mysql after reboot check the status chkconfig | grep mysql If 3, Asterisk Full RealTime Database example, change the extconfig.conf file as follow [settings] sippeers => mysql, Configure asterisk MySql connection: create the res_mysql.conf file in /etc/asterisk vi /etc/asterisk/res_mysql.conf enter the following: [general] dbhost = 127.0.0.1 dbname = asteriskrealtime dbuser , context, defaultuser, email ) VALUES ('1000', email ) VALUES ('2000', extensions voicemail => mysql, fullname, general, Hangup, HOST, KEY `id` (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=257 DEFAULT CHARSET=latin1; CREATE TABLE `voicemail_users` ( `uniqueid` int(11) NOT NULL auto_increment, KEY `mailbox_context` (`mailbox`, KEY `name_2` (`name`) ) ENGINE=MyISAM AUTO_INCREMENT=893 DEFAULT CHARSET=latin1; CREATE TABLE `extensions` ( `id` int(11) NOT NULL auto_increment, mailbox, meetme Configure sip.conf and exensioncs.conf sip.conf should Register your account and DID with the SIP provider Change the default context to "from-sip" for the inbound calls from the SIP provider. , nat, NULL, PASSWORD, port 3306 with username root for 12 seconds., PRIMARY KEY (`confno`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; verify that all tables created: mysql> show tables; +----------------------------+ | Tables_in_asteriskrealtime | +-------------------, PRIMARY KEY (`context`, PRIMARY KEY (`id`), PRIMARY KEY (`name`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; CREATE TABLE `queue_member_table` ( `uniqueid` int(10) unsigned NOT NULL auto_increment, PRIMARY KEY (`uniqueid`), qualify, queue_member_table meetme => mysql, queue_table queue_members => mysql, secret, sip_buddies extensions => mysql, TYPE) VALUES ( '1000', TYPE) VALUES ( '2000', TYPE) VALUES ( 'deltathree', UNIQUE KEY `name` (`name`), UNIQUE KEY `queue_interface` (`queue_name`, voicemail_users queues => mysql, we we call it "asteriskrealtime" create database if not exists `asteriskrealtime`; change to the asteriskrealtime database: use asteriskrealtime; now we will create the following tables: sip_buddies e, we will use a very short files instead in order to simplefy the setup: cp /etc/asterisk/extensions.conf /etc/asterisk/extensions.conf_orig cp /etc/asterisk/extconfig.conf /etc/asterisk/extconfig.conf_, yes
Configure asterisk MySql connection: create the res_mysql.conf file in /etc/asterisk vi /etc/asterisk/res_mysql.conf enter the following: [general] dbhost = 127.0.0.1 dbname
Read more