Migrating OpenSIPS location table to Kamailio format

From Integrics Wiki
Revision as of 20:26, 20 February 2015 by Danthony (talk | contribs)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This applies to OpenSIPS 1.4.4 and Kamailio 3.3.2, although it may work with other versions as well.


OpenSIPS->Kamailio:

Integrics does the following on sip0 and sip1:

cpan Math::BigInt::FastCalc

enswitch install kamailio-ha

vi /etc/kamailio/kamailio.cfg # and set the database URL

Update haresources on sip0 and sip1:

change "opensips" to "kamailio" in /etc/ha.d/haresources

Stop OpenSIPS on sip0:

sudo /etc/ha.d/resource.d/opensips stop

Remove OpenSIPS init script on sip0 and sip1:

sudo rm /etc/ha.d/resource.d/opensips

Update version for location table on enswitchbd0:

update version set table_version='5' where table_name='location';


Convert OpenSIPS version of location table to work with Kamailio on enswitchdb0:


RENAME TABLE location TO location_old_opensips;

CREATE TABLE `location` (

 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `ruid` varchar(64) NOT NULL DEFAULT ,
 `username` varchar(64) NOT NULL DEFAULT ,
 `domain` varchar(64) DEFAULT NULL,
 `contact` varchar(255) NOT NULL DEFAULT ,
 `received` varchar(128) DEFAULT NULL,
 `path` varchar(128) DEFAULT NULL,
 `expires` datetime NOT NULL DEFAULT '2020-05-28 21:32:15',
 `q` float(10,2) NOT NULL DEFAULT '1.00',
 `callid` varchar(255) NOT NULL DEFAULT 'Default-Call-ID',
 `cseq` int(11) NOT NULL DEFAULT '1',
 `last_modified` datetime NOT NULL DEFAULT '1900-01-01 00:00:01',
 `flags` int(11) NOT NULL DEFAULT '0',
 `cflags` int(11) NOT NULL DEFAULT '0',
 `user_agent` varchar(255) NOT NULL DEFAULT ,
 `socket` varchar(64) DEFAULT NULL,
 `methods` int(11) DEFAULT NULL,
 `instance` varchar(255) DEFAULT NULL,
 `reg_id` int(11) NOT NULL DEFAULT '0',
 `replicate` int(10) unsigned NOT NULL DEFAULT '0',
 `state` tinyint(1) unsigned NOT NULL DEFAULT '0',
 PRIMARY KEY (`id`),
 KEY `account_contact_idx` (`username`,`domain`,`contact`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1 SELECT * FROM location_old;


Add link for Kamailio init script on sip0 and sip1:

sudo ln -sf /opt/enswitch/current/etc/init.d/debian/kamailio /etc/ha.d/resource.d/kamailio

Start Kamailio on sip0:

sudo /etc/ha.d/resource.d/kamailio start

Test calls on sip0:

Run hb_takeover on sip1 and test:

/usr/share/heartbeat/hb_takeover

Run hb_takeover on sip0 and test again:

/usr/share/heartbeat/hb_takeover


Kamailio->OpenSIPS:

Update haresources

change "kamailio" to “opensips” in /etc/ha.d/haresources

Stop Kamailio:

sudo /etc/ha.d/resource.d/kamailio stop


Remove Kamailio init script:

sudo rm /etc/ha.d/resource.d/kamailio

Update version for location table

update version set table_version='1004' where table_name='location';


Convert Kamailio version of location table to work with OpenSIPS:

(

RENAME TABLE location TO location_old_kamailio;

)

CREATE TABLE `location` (

 `username` varchar(64) NOT NULL DEFAULT ,
 `domain` varchar(128) NOT NULL DEFAULT ,
 `contact` varchar(255) NOT NULL DEFAULT ,
 `received` varchar(255) DEFAULT NULL,
 `path` varchar(255) DEFAULT NULL,
 `expires` datetime NOT NULL DEFAULT '2020-01-01 00:00:00',
 `q` float(10,2) NOT NULL DEFAULT '1.00',
 `callid` varchar(255) NOT NULL DEFAULT 'Default-Call-ID',
 `cseq` int(11) NOT NULL DEFAULT '42',
 `last_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
 `replicate` int(10) unsigned NOT NULL DEFAULT '0',
 `state` tinyint(1) unsigned NOT NULL DEFAULT '0',
 `flags` int(11) NOT NULL DEFAULT '0',
 `cflags` int(11) NOT NULL DEFAULT '0',
 `user_agent` varchar(100) NOT NULL DEFAULT ,
 `socket` varchar(128) DEFAULT NULL,
 `methods` int(11) DEFAULT NULL,
 `id` int(10) NOT NULL DEFAULT '0',
 `ruid` varchar(64) NOT NULL DEFAULT ,
 `reg_id` int(11) NOT NULL DEFAULT '0',
 `instance` varchar(255) DEFAULT NULL,
 KEY `username` (`username`,`domain`,`contact`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1 SELECT * FROM location_old_kamailio;

Add link for OpenSIPS init script:

sudo ln -sf /opt/enswitch/current/etc/init.d/debian/opensips /etc/ha.d/resource.d/opensips


Start OpenSIPS:

sudo /etc/ha.d/resource.d/opensips start