1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
|
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
<!-- Include general documentation entities -->
<!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
%docentities;
]>
<!-- Module User's Guide -->
<chapter>
<title>&adminguide;</title>
<section>
<title>Overview</title>
<para>
This is a module which provides MySQL connectivity for Kamailio.
It implements the DB API defined in Kamailio.
</para>
</section>
<section>
<title>Dependencies</title>
<section>
<title>&kamailio; Modules</title>
<para>
The following modules must be loaded before this module:
<itemizedlist>
<listitem>
<para>
<emphasis>No dependencies on other &kamailio; modules</emphasis>.
</para>
</listitem>
</itemizedlist>
</para>
</section>
<section>
<title>External Libraries or Applications</title>
<para>
The following libraries or applications must be installed before running
&kamailio; with this module loaded:
<itemizedlist>
<listitem>
<para>
<emphasis>mysql</emphasis> - the development libraries forthe Mysql database. In some Linux distributions named "libmysqlclient-dev".
</para>
</listitem>
</itemizedlist>
</para>
</section>
</section>
<section>
<title>Parameters</title>
<section>
<title><varname>ping_interval</varname> (integer)</title>
<para>
Time interval in seconds to send ping messages to MySQL server in order to keep
the connection open.
</para>
<para>
<emphasis>
Default value is 300 (5 min).
</emphasis>
</para>
<example>
<title>Set <varname>ping_interval</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("db_mysql", "ping_interval", 600)
...
</programlisting>
</example>
</section>
<section>
<title><varname>timeout_interval</varname> (integer)</title>
<para>
Time interval (in seconds) after that an connection attempt, read or write request
is aborted. The value counts three times, as several retries are done
from the driver before it gives up.
</para>
<para>
The read timeout parameter is ignored on MySQL driver versions prior to
<quote>5.1.12</quote>, <quote>5.0.25</quote> and <quote>4.1.22</quote>.
The write timeout parameter is ignored on versions prior to <quote>5.1.12</quote>
and <quote>5.0.25</quote>, the <quote>4.1</quote> release don't support it at all.
</para>
<para>
<emphasis>
Default value is 2 (6 sec).
</emphasis>
</para>
<example>
<title>Set <varname>timeout_interval</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("db_mysql", "timeout_interval", 2)
...
</programlisting>
</example>
</section>
<section>
<title><varname>auto_reconnect</varname> (integer)</title>
<para>
Configure whether the module should automatically reconnect to MySQL server if the
connection was lost.
</para>
<para>
<emphasis>
Default value is 1 (1 - on / 0 - off).
</emphasis>
</para>
<example>
<title>Set <varname>auto_reconnect</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("db_mysql", "auto_reconnect", 0)
...
</programlisting>
</example>
</section>
<section id="db_mysql.p.insert_delayed">
<title><varname>insert_delayed</varname> (integer)</title>
<para>
If set to 1, all INSERT SQL queries will be sent to MySQL server as
INSERT DELAYED.
</para>
<para>
<emphasis>
Default value is 0 (1 - on / 0 - off).
</emphasis>
</para>
<example>
<title>Set <varname>insert_delayed</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("db_mysql", "insert_delayed", 1)
...
</programlisting>
</example>
</section>
</section>
<section>
<title>Functions</title>
<para>
No function exported to be used from configuration file.
</para>
</section>
<section>
<title>Installation</title>
<para>
Because it dependes on an external library, the mysql module is not
compiled and installed by default. You can use one of these options.
</para>
<itemizedlist>
<listitem>
<para>
- edit the "Makefile" and remove "db_mysql" from "excluded_modules"
list. Then follow the standard procedure to install &kamailio;:
"make all; make install".
</para>
</listitem>
<listitem>
<para>
- from command line use: 'make all include_modules="db_mysql";
make install include_modules="db_mysql"'.
</para>
</listitem>
</itemizedlist>
</section>
<section>
<title>Reading configuration from my.cnf</title>
<para>
In order to take into account specific mysql client options, a my.cnf config group can be passed using the <emphasis>db_url</emphasis> module parameter. This is done by setting <emphasis>[group]</emphasis> in front of or instead of the host part. The following examples are valid <emphasis>db_url</emphasis> definitions, which include a my.cnf group:
</para>
<itemizedlist>
<listitem>mysql://user:pass@[group]host:port/db</listitem>
<listitem>mysql://user:pass@[group]:port/db</listitem>
<listitem>mysql://user:pass@[group]/db</listitem>
<listitem>mysql://[group]/db</listitem>
</itemizedlist>
<example>
<title>Set a my.cnf group in <varname>db_url</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("usrloc", "db_url", "mysql://[kamailio]/kamailio)
...
</programlisting>
</example>
<example>
<title>Adding a kamailio group to my.cnf</title>
<programlisting format="linespecific">
...
[kamailio]
socket = /path/to/mysql.sock
user = kamailiouser
password = kamailiopass
default-character-set = utf8
...
</programlisting>
</example>
<para>
In addition to the given group, also the <emphasis>[client]</emphasis> section is read, in the order given in my.cnf. So if you for example specify a <emphasis>socket</emphasis> in both your specific group and the client group, then the value is taken from the last one.
</para>
<example>
<title>Using [client] and specific group</title>
<programlisting format="linespecific">
...
[client]
socket = /var/run/mysql/mysqld.sock
[kamailio]
socket = /path/to/mysqld.sock
user = kamailiouser
password = kamailiopass
default-character-set = utf8
...
</programlisting>
</example>
<para>
In the example given above, the socket <emphasis>/path/to/mysqld.sock</emphasis> is used by &kamailio; because both <emphasis>[kamailio]</emphasis> and <emphasis>[client]</emphasis> define this option, and the latter overwrites the first.
</para>
</section>
</chapter>
|