I've managed some
time to take a look at setting up OpenSIPS with Cassandra as it's cache
store. In one of my blog post I showed how to setup opensips and redis (which is also now updated for new Hiredis installation github path).
The advanatges can be numerious while we are using Cassandra and Redis individually or together from one opensips which are outlined in a very detailed article by Vlad Paiu - One of the developers and contributors of OpenSIPS project.
Possible use cases from the opensips documentation page are; Password caching for DB authentication
or Simple but distributed billing. With recent new developments going on specially on cacheDB are its now possible to have a distirubuted OpenSIPS cluster with a shared CacheDB backbone and all iternal data is available across all the opensips node for example dialog profiles of callers, loadbalanced resources statuses.
Over all these CacheDB modules enable multiple OpenSIPS instances to share internal data like number of calls, registration, call counters, billing data, IP balcklists etc. Refer to this presentation at Cluecon-2012.
So lets get started to integrate OpenSIPS 1.8 with Cassandra. Installation process for OpenSIPS 1.8 has been changed a little bit. Install all the libraries and packages as mentioned in this post.
Once after the repositiores are installed we need to install
thrift-0.6.1 which is the Cassandra's interfcing client used by
OpenSIPS.
UPDATE[28-July-2013]: As commented by a respected viewer; we need to install C++ boost libraries for OpenSIPS 1.9 on Debian 6. See comment by RQ in the comments section for further details.
I tried installing the newest version of thrift but OpenSIPS won't compile and give errors. So next, download and extract the 1.8 version of OpenSIPS and execute the 'make menuconfig' command.
The advanatges can be numerious while we are using Cassandra and Redis individually or together from one opensips which are outlined in a very detailed article by Vlad Paiu - One of the developers and contributors of OpenSIPS project.
Possible use cases from the opensips documentation page are; Password caching for DB authentication
or Simple but distributed billing. With recent new developments going on specially on cacheDB are its now possible to have a distirubuted OpenSIPS cluster with a shared CacheDB backbone and all iternal data is available across all the opensips node for example dialog profiles of callers, loadbalanced resources statuses.
Over all these CacheDB modules enable multiple OpenSIPS instances to share internal data like number of calls, registration, call counters, billing data, IP balcklists etc. Refer to this presentation at Cluecon-2012.
So lets get started to integrate OpenSIPS 1.8 with Cassandra. Installation process for OpenSIPS 1.8 has been changed a little bit. Install all the libraries and packages as mentioned in this post.
OPENSIPS 1.8 INSTALLATION
root@OpenSIPS-CAS:~# wget http://archive.apache.org/dist/thrift/0.6.1/thrift-0.6.1.tar.gz root@OpenSIPS-CAS:~# tar zxvf thrift-0.6.1.tar.gz root@OpenSIPS-CAS:~# cd thrift-0.6.1/ root@OpenSIPS-CAS:~# ./configure root@OpenSIPS-CAS:~# make root@OpenSIPS-CAS:~# make install
UPDATE[28-July-2013]: As commented by a respected viewer; we need to install C++ boost libraries for OpenSIPS 1.9 on Debian 6. See comment by RQ in the comments section for further details.
I tried installing the newest version of thrift but OpenSIPS won't compile and give errors. So next, download and extract the 1.8 version of OpenSIPS and execute the 'make menuconfig' command.
root@OpenSIPS-CAS:~#wget http://opensips.org/pub/opensips/1.8.2/src/opensips-1.8.2-svn9601_src.tar.gz root@OpenSIPS-CAS:~#tar zxvf opensips-1.8.2-svn9601_src.tar.gz root@OpenSIPS-CAS:~#cd opensips-1.8.2-tls/ root@OpenSIPS-CAS:~#make menuconfigA menu will open up like this.
Press Right arrow key on the first option and goto the following sub menu.
Now pressing right arrow key will take us to the module selection menu where we have to select which modules we need to install. Make sure to select the Cassandra module.
Once the modules' selection is made press left arrow key to go back to the figure 2. Select "Save Changes" and press enter. A list of suggested libraries and packages will show up at the bottom of the screen for help.
Do change installation paths and other flags according to your requirements.
Press left arrow key again to go back to main menu as in figure 1. Select "Compile And Install OpenSIPS" and press Enter. If everything goes well our opensips will be installed successfully. Follow the steps as mentioned in this post to setup the opensips LSB script (/etc/init.d/opensips); default opensips file; and creating the opensips DB.
CASSANDRA INSTALLATION
The OpenSIPS installation process is complete till here, now take a look at the cassandra installation.root@CAS-N1:~# vim /etc/apt/sources.listAdd the follwoing lines at the bottom of the apt/sources.list file.
deb http://www.apache.org/dist/cassandra/debian 10x main
deb-src http://www.apache.org/dist/cassandra/debian 10x main
Save and exit the file. and run apt-get update.
root@CAS-N1:~# apt-get update
If any keys error is encountered at the update then we need to add the keys using following command. (Make sure to change the '4BD736A82B5C1B00' string with the one you're seeing on your screen)
Once the key is successfully added execute the apt-get update once again and after that install cassandra.root@CAS-N1:~#gpg --keyserver wwwkeys.pgp.net --recv-keys 4BD736A82B5C1B00 root@CAS-N1:~#gpg --export --armor 4BD736A82B5C1B00 | sudo apt-key add -
I highly recommend to go through the following links to get quick know how about cassandra working and its files.root@CAS-N1:~#apt-get install cassandra
Planning a Cassandra Cluster Deployment
Cassandra’s data model cheat sheet
Node and Cluster Configuration (cassandra.yaml)
Configuring and Starting a Cassandra Cluster
Edit the /etc/init.d/cassandra.yaml file and change the cluster name and any other property as needed. Start cassandra and verify that it is running in processes. I edited the following:
listen_address: 192.168.56.3
broadcast_address: 192.168.56.255
rpc_address: 0.0.0.0
rpc_port: 9160
root@CAS-N1:~#vim /etc/cassandra/cassandra.yaml
root@CAS-N1:~#/etc/init.d/cassandra start root@CAS-N1:~#ps -ef | grep cass
If cassandra has started successfully then connect to cassandra-cli and creake a keyspace for opensips to use.
root@CAS-N1:~# cassandra-cli --host 192.168.56.3 --port 9160Connected to: "Test Cluster" on 192.168.56.3/9160 Welcome to Cassandra CLI version 1.0.12 Type 'help;' or '?' for help. Type 'quit;' or 'exit;' to quit. [default@unknown]CREATE KEYSPACE opensips WITH placement_strategy = 'SimpleStrategy' AND strategy_options = {replication_factor:2};a43901e0-6263-11e2-0000-af8ddedd2ed7 Waiting for schema agreement... ... schemas agree across the cluster
[default@unknown]quit;OPENSIPS CONFIGURATIONS FOR CASSANDRA
Now, everything is ready. Time to open up the opensips configurations file and load the module for cassandra.root@OpenSIPS-CAS:~# vim /etc/opensips/opensips.cfgloadmodule "cachedb_cassandra.so" modparam("cachedb_cassandra", "cachedb_url","cassandra:group1://192.168.56.3:9160/opensips_cdrs") modparam("cachedb_cassandra", "connection_timeout",1000) modparam("cachedb_cassandra", "send_timeout",1000) modparam("cachedb_cassandra", "receive_timeout",1000) modparam("cachedb_cassandra", "wr_consistency_level",1) modparam("cachedb_cassandra", "rd_consistency_level",1)
Go throught the OpenSIPS Cassandra module documentation; we can start using Cassandra as our KVP backend by using the following commands in our opensips.cfg main route;
cache_store("cassandra:group1","key","$ru value") cache_fetch("cassandra:cluster1","key",$avp(10)) cache_remove("cassandra:cluster1","key");
That is all , now its upto users to take advantage from this according to their needs.
Thanks for reading.
Reference URLS:
http://wiki.apache.org/cassandra/GettingStarted
http://www.opensips.org/html/docs/modules/1.8.x/cachedb_cassandra.html
http://wiki.apache.org/cassandra/Operations
http://www.sinbadsoft.com/blog/cassandra-data-model-cheat-sheet/
http://news.ycombinator.com/item?id=1244914
http://www.datastax.com/docs/0.8/configuration/node_configuration#init-properties
http://www.datastax.com/docs/0.8/install/cluster_init
http://www.datastax.com/docs/0.8/cluster_architecture/cluster_planning#node-init-config
http://www.datastax.com/docs/1.0/ddl/keyspaces
http://wiki.apache.org/cassandra/FAQ#clustername_mismatch
http://lzyeval.blogspot.com/2012/02/install-cassandra-in-debian-ubuntu.html
Comments