db_unixodbc_admin.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <?xml version="1.0" encoding='ISO-8859-1'?>
  2. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  4. <!-- Include general documentation entities -->
  5. <!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
  6. %docentities;
  7. ]>
  8. <!-- Module User's Guide -->
  9. <chapter>
  10. <title>&adminguide;</title>
  11. <section>
  12. <title>Overview</title>
  13. <para>
  14. This module allows to use the unixodbc package with &kamailio;. It have been
  15. tested with mysql and the odbc connector, but it should work also with
  16. other database. The auth_db module works.
  17. </para>
  18. <para>
  19. For more information, see the <ulink url="http://www.unixodbc.org/">
  20. http://www.unixodbc.org/</ulink> project web page.
  21. </para>
  22. <para>
  23. To see what DB engines can be used via unixodbc, look at
  24. <ulink url="http://www.unixodbc.org/drivers.html">
  25. http://www.unixodbc.org/drivers.html</ulink>.
  26. </para>
  27. </section>
  28. <section>
  29. <title>Dependencies</title>
  30. <section>
  31. <title>&kamailio; Modules</title>
  32. <para>
  33. The following modules must be loaded before this module:
  34. <itemizedlist>
  35. <listitem>
  36. <para>
  37. <emphasis>No dependencies on other &kamailio; modules</emphasis>.
  38. </para>
  39. </listitem>
  40. </itemizedlist>
  41. </para>
  42. </section>
  43. <section>
  44. <title>External Libraries or Applications</title>
  45. <para>
  46. The following libraries or applications must be installed before running
  47. &kamailio; with this module loaded:
  48. <itemizedlist>
  49. <listitem>
  50. <para>
  51. <emphasis>None</emphasis>.
  52. </para>
  53. </listitem>
  54. </itemizedlist>
  55. </para>
  56. </section>
  57. </section>
  58. <section>
  59. <title>Parameters</title>
  60. <section>
  61. <title><varname>ping_interval</varname> (int)</title>
  62. <para>
  63. Sets the ping time interval.
  64. </para>
  65. <para>
  66. <emphasis>
  67. Default value is <quote>300</quote> seconds.
  68. </emphasis>
  69. </para>
  70. <example>
  71. <title>Set the <quote>ping_interval</quote> parameter</title>
  72. <programlisting format="linespecific">
  73. ...
  74. modparam("db_unixodbc", "ping_interval", 600)
  75. ...
  76. </programlisting>
  77. </example>
  78. </section>
  79. <section>
  80. <title><varname>auto_reconnect</varname> (int)</title>
  81. <para>
  82. Turns on or off the auto_reconnect mode.
  83. </para>
  84. <para>
  85. <emphasis>
  86. Default value is <quote>1</quote>, this means it is enabled.
  87. </emphasis>
  88. </para>
  89. <example>
  90. <title>Set the <quote>auto_reconnect</quote> parameter</title>
  91. <programlisting format="linespecific">
  92. ...
  93. modparam("db_unixodbc", "auto_reconnect", 0)
  94. ...
  95. </programlisting>
  96. </example>
  97. </section>
  98. <section>
  99. <title><varname>use_escape_common</varname> (int)</title>
  100. <para>
  101. Escape values in query using internal escape_common() function.
  102. It escapes single quote ''', double quote '"', backslash '\',
  103. and NULL characters.
  104. </para>
  105. <para>
  106. You should enable this parameter if you know that the ODBC driver
  107. considers the above characters as special (for marking begin and end
  108. of a value, escape other characters ...). It prevents against SQL
  109. injection.
  110. </para>
  111. <para>
  112. <emphasis>
  113. Default value is <quote>0</quote> (0 = disabled; 1 = enabled).
  114. </emphasis>
  115. </para>
  116. <example>
  117. <title>Set the <quote>use_escape_common</quote> parameter</title>
  118. <programlisting format="linespecific">
  119. ...
  120. modparam("db_unixodbc", "use_escape_common", 1)
  121. ...
  122. </programlisting>
  123. </example>
  124. </section>
  125. </section>
  126. <section>
  127. <title>Functions</title>
  128. <para>
  129. NONE
  130. </para>
  131. </section>
  132. <section>
  133. <title>Installation and Running</title>
  134. <section>
  135. <title>Installing</title>
  136. <para>
  137. Prerequirement: you should first install unixodbc (or another program that
  138. implements the odbc standard, such iodbc), your database, and the right
  139. connector. Set the DSN in the odbc.ini file and the connector drivers in
  140. the odbcinst.ini file.
  141. </para>
  142. </section>
  143. <section>
  144. <title>Configuring and Running</title>
  145. <para>
  146. In the openser.conf file, add the line:
  147. </para>
  148. <programlisting format="linespecific">
  149. ....
  150. loadmodule "/usr/local/lib/kamailio/modules/db_unixodbc.so"
  151. ....
  152. </programlisting>
  153. <para>
  154. You should also uncomment this:
  155. </para>
  156. <programlisting format="linespecific">
  157. ....
  158. loadmodule "/usr/local/lib/kamailio/modules/auth.so"
  159. loadmodule "/usr/local/lib/kamailio/modules/auth_db.so"
  160. modparam("usrloc", "db_mode", 2)
  161. modparam("auth_db", "calculate_ha1", yes)
  162. modparam("auth_db", "password_column", "password")
  163. ....
  164. </programlisting>
  165. <para>
  166. and setting the DSN specified in the odbc.ini, inserting this with the
  167. url adding this line:
  168. </para>
  169. <programlisting format="linespecific">
  170. ....
  171. modparam("usrloc|auth_db", "db_url",
  172. "unixodbc://openser:openserrw@localhost/my_dsn")
  173. ....
  174. </programlisting>
  175. <para>
  176. replacing my_dsn with the correct value.
  177. </para>
  178. <para>
  179. HINT: if unixodbc don't want to connect to mysql server, try restarting
  180. mysql server with:
  181. </para>
  182. <programlisting format="linespecific">
  183. shell>safe_mysqld --user=mysql --socket=/var/lib/mysql/mysql.sock
  184. </programlisting>
  185. <para>
  186. The connector search the socket in /var/lib/mysql/mysql.sock and not
  187. in /tmp/mysql.sock
  188. </para>
  189. </section>
  190. </section>
  191. </chapter>