<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/en/2166/4/9/_/styles/combined.css?spaceKey=AST&forWysiwyg=true" type="text/css">
</head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
<h2><a href="https://wiki.asterisk.org/wiki/display/AST/Realtime+Database+Configuration">Realtime Database Configuration</a></h2>
<h4>Page <b>edited</b> by <a href="https://wiki.asterisk.org/wiki/display/~mnicholson">Matthew Nicholson</a>
</h4>
<div id="versionComment">
<b>Comment:</b>
Added note about preloading realtime modules.<br />
</div>
<br/>
<h4>Changes (1)</h4>
<div id="page-diffs">
<table class="diff" cellpadding="0" cellspacing="0">
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >That doesn't happen when you use a static file in the file system. Although this might be interpreted as a bug or limitation, it is not. <br> <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">{info} <br>To use static realtime with certain core configuration files (e.g. {{features.conf}}, {{cdr.conf}}, {{cel.conf}}, {{indications.conf}}, etc.) the realtime backend you wish to use must be preloaded in {{modules.conf}}. <br> <br>{noformat} <br>[modules] <br>preload => res_odbc.so <br>preload => res_config_odbc.so <br>{noformat} <br>{info} <br> <br></td></tr>
<tr><td class="diff-unchanged" >h5. Realtime SIP friends <br> <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
</table>
</div> <h4>Full Content</h4>
<div class="notificationGreySide">
<h3><a name="RealtimeDatabaseConfiguration-Introduction"></a>Introduction</h3>
<p>The Asterisk Realtime Architecture is a new set of drivers and functions implemented in Asterisk. <br/>
The benefits of this architecture are many, both from a code management standpoint and from an installation perspective. <br/>
The ARA is designed to be independent of storage. Currently, most drivers are based on SQL, but the architecture should be able to handle other storage methods in the future, like LDAP. </p>
<p>The main benefit comes in the database support. In Asterisk v1.0 some functions supported MySQL database, some PostgreSQL and other ODBC. With the ARA, we have a unified database interface internally in Asterisk, so if one function supports database integration, all databases that has a realtime driver will be supported in that function. <br/>
Currently there are three realtime database drivers:</p>
<ol>
        <li>ODBC: Support for UnixODBC, integrated into Asterisk The UnixODBC subsystem supports many different databases, please check www.unixodbc.org for more information.</li>
        <li>MySQL: Native support for MySQL, integrated into Asterisk</li>
        <li>PostgreSQL: Native support for Postgres, integrated into Asterisk</li>
</ol>
<h5><a name="RealtimeDatabaseConfiguration-Twomodes%3AStaticandRealtime"></a>Two modes: Static and Realtime</h5>
<p>The ARA realtime mode is used to dynamically load and update objects. This mode is used in the SIP and IAX2 channels, as well as in the voicemail system. For SIP and IAX2 this is similar to the v1.0 MYSQL_FRIENDS functionality. With the ARA, we now support many more databases for dynamic configuration of phones. </p>
<p>The ARA static mode is used to load configuration files. For the Asterisk modules that read configurations, there's no difference between a static file in the file system, like extensions.conf, and a configuration loaded from a database. <br/>
You just have to always make sure the var_metric values are properly set and ordered as you expect in your database server if you're using the static mode with ARA (either sequentially or with the same var_metric value for everybody). </p>
<p>If you have an option that depends on another one in a given configuration file (i.e, 'musiconhold' depending on 'agent' from agents.conf) but their var_metric are not sequential you'll probably get default values being assigned for those options instead of the desired ones. You can still use the same var_metric for all entries in your DB, just make sure the entries are recorded in an order that does not break the option dependency. </p>
<p>That doesn't happen when you use a static file in the file system. Although this might be interpreted as a bug or limitation, it is not.</p>
<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>To use static realtime with certain core configuration files (e.g. <tt>features.conf</tt>, <tt>cdr.conf</tt>, <tt>cel.conf</tt>, <tt>indications.conf</tt>, etc.) the realtime backend you wish to use must be preloaded in <tt>modules.conf</tt>.
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>[modules]
preload => res_odbc.so
preload => res_config_odbc.so
</pre>
</div></div></td></tr></table></div>
<h5><a name="RealtimeDatabaseConfiguration-RealtimeSIPfriends"></a>Realtime SIP friends</h5>
<p>The SIP realtime objects are users and peers that are loaded in memory when needed, then deleted. This means that Asterisk currently can't handle voicemail notification and NAT keepalives for these peers. Other than that, most of the functionality works the same way for realtime friends as for the ones in static configuration. </p>
<p>With caching, the device stays in memory for a specified time. More information about this is to be found in the sip.conf sample file. </p>
<p>If you specify a separate family called "sipregs" SIP registration data will be stored in that table and not in the "sippeers" table.</p>
<h5><a name="RealtimeDatabaseConfiguration-RealtimeH.323friends"></a>Realtime H.323 friends</h5>
<p>Like SIP realtime friends, H.323 friends also can be configured using dynamic realtime objects.</p>
<h5><a name="RealtimeDatabaseConfiguration-Newfunctioninthedialplan%3ATheRealtimeSwitch"></a>New function in the dial plan: The Realtime Switch</h5>
<p>The realtime switch is more than a port of functionality in v1.0 to the new architecture, this is a new feature of Asterisk based on the ARA. The realtime switch lets your Asterisk server do database lookups of extensions in realtime from your dial plan. You can have many Asterisk servers sharing a dynamically updated dial plan in real time with this solution. <br/>
Note that this switch does NOT support Caller ID matching, only extension name or pattern matching.</p>
<h5><a name="RealtimeDatabaseConfiguration-Capabilities"></a>Capabilities</h5>
<p>The realtime Architecture lets you store all of your configuration in databases and reload it whenever you want. You can force a reload over the AMI, Asterisk Manager Interface or by calling Asterisk from a shell script with </p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">asterisk -rx "reload"</pre>
</div></div>
<p>You may also dynamically add SIP and IAX devices and extensions and making them available without a reload, by using the realtime objects and the realtime switch.</p>
<h5><a name="RealtimeDatabaseConfiguration-Configurationinextconfig.conf"></a>Configuration in extconfig.conf</h5>
<p>You configure the ARA in extconfig.conf (yes, it's a strange name, but is was defined in the early days of the realtime architecture and kind of stuck). </p>
<p>The part of Asterisk that connects to the ARA use a well defined family name to find the proper database driver. The syntax is easy: </p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false"><family> => <realtime driver>,<db name>[,<table>]</pre>
</div></div>
<p>The options following the realtime driver identified depends on the driver. </p>
<p>Defined well-known family names are:</p>
<ul>
        <li>sippeers, sipusers - SIP peers and users</li>
        <li>sipregs - SIP registrations</li>
        <li>iaxpeers, iaxusers - IAX2 peers and users</li>
        <li>voicemail - Voicemail accounts</li>
        <li>extensions - Realtime extensions (switch)</li>
        <li>meetme - MeetMe conference rooms</li>
        <li>queues - Queues</li>
        <li>queue_members - Queue members</li>
        <li>musiconhold - Music On Hold classes</li>
        <li>queue_log - Queue logging</li>
</ul>
<p>Voicemail storage with the support of ODBC described in <a href="/wiki/display/AST/ODBC+Voicemail+Storage" title="ODBC Voicemail Storage">ODBC Voicemail Storage</a>.</p>
<h5><a name="RealtimeDatabaseConfiguration-Limitations"></a>Limitations</h5>
<p>Currently, realtime extensions do not support realtime hints. There is a workaround available by using func_odbc. See the sample func_odbc.conf for more information.</p>
<h5><a name="RealtimeDatabaseConfiguration-FreeTDSsupportedwithconnectionpooling"></a>FreeTDS supported with connection pooling</h5>
<p>In order to use a FreeTDS-based database with realtime, you need to turn connection pooling on in res_odbc.conf. This is due to a limitation within the FreeTDS protocol itself. Please note that this includes databases such as MS SQL Server and Sybase. This support is new in the current release. </p>
<p>You may notice a performance issue under high load using UnixODBC. The UnixODBC driver supports threading but you must specifically enable threading within the UnixODBC configuration file like below for each engine: </p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">Threading = 2</pre>
</div></div>
<p>This will enable the driver to service many requests at a time, rather than serially.</p>
</div>
<div id="commentsSection" class="wiki-content pageSection">
<div style="float: right;" class="grey">
<a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
<span style="padding: 0px 5px;">|</span>
<a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
<a href="https://wiki.asterisk.org/wiki/display/AST/Realtime+Database+Configuration">View Online</a>
|
<a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=4620317&revisedVersion=5&originalVersion=4">View Changes</a>
|
<a href="https://wiki.asterisk.org/wiki/display/AST/Realtime+Database+Configuration?showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>