Debian Codegraph @

src/modules/db_mysql/README

raw
1 mysql Module
2
3 Daniel-Constantin Mierla
4
5 <[email protected]>
6
7 Edited by
8
9 Daniel-Constantin Mierla
10
11 <[email protected]>
12
13 Copyright © 2006 Voice Sistem SRL
14 __________________________________________________________________
15
16 Table of Contents
17
18 1. Admin Guide
19
20 1. Overview
21 2. Dependencies
22
23 2.1. Kamailio Modules
24 2.2. External Libraries or Applications
25
26 3. Parameters
27
28 3.1. ping_interval (integer)
29 3.2. server_timezone (integer)
30 3.3. timeout_interval (integer)
31 3.4. auto_reconnect (integer)
32 3.5. insert_delayed (integer)
33 3.6. update_affected_found (integer)
34 3.7. opt_ssl_mode (integer)
35 3.8. opt_ssl_ca (string)
36
37 4. Functions
38 5. Installation
39 6. Reading configuration from my.cnf
40
41 List of Examples
42
43 1.1. Set ping_interval parameter
44 1.2. Set server_timezone parameter
45 1.3. Set timeout_interval parameter
46 1.4. Set auto_reconnect parameter
47 1.5. Set insert_delayed parameter
48 1.6. Set update_affected_found parameter
49 1.7. Set opt_ssl_mode parameter
50 1.8. Set opt_ssl_ca parameter
51 1.9. Set a my.cnf group in db_url parameter
52 1.10. Adding a kamailio group to my.cnf
53 1.11. Using [client] and specific group
54
55 Chapter 1. Admin Guide
56
57 Table of Contents
58
59 1. Overview
60 2. Dependencies
61
62 2.1. Kamailio Modules
63 2.2. External Libraries or Applications
64
65 3. Parameters
66
67 3.1. ping_interval (integer)
68 3.2. server_timezone (integer)
69 3.3. timeout_interval (integer)
70 3.4. auto_reconnect (integer)
71 3.5. insert_delayed (integer)
72 3.6. update_affected_found (integer)
73 3.7. opt_ssl_mode (integer)
74 3.8. opt_ssl_ca (string)
75
76 4. Functions
77 5. Installation
78 6. Reading configuration from my.cnf
79
80 1. Overview
81
82 This is a module which provides MySQL connectivity for Kamailio. It
83 implements the DB API defined in Kamailio.
84
85 2. Dependencies
86
87 2.1. Kamailio Modules
88 2.2. External Libraries or Applications
89
90 2.1. Kamailio Modules
91
92 The following modules must be loaded before this module:
93 * No dependencies on other Kamailio modules.
94
95 2.2. External Libraries or Applications
96
97 The following libraries or applications must be installed before
98 running Kamailio with this module loaded:
99 * mysql - the development libraries for the MySQL database. In some
100 Linux distributions named "libmysqlclient-dev". MariaDB - the
101 development libraries for the MariaDB database. In some Linux
102 distributions named "libmariadbclient-dev".
103
104 3. Parameters
105
106 3.1. ping_interval (integer)
107 3.2. server_timezone (integer)
108 3.3. timeout_interval (integer)
109 3.4. auto_reconnect (integer)
110 3.5. insert_delayed (integer)
111 3.6. update_affected_found (integer)
112 3.7. opt_ssl_mode (integer)
113 3.8. opt_ssl_ca (string)
114
115 3.1. ping_interval (integer)
116
117 Time interval in seconds to send ping messages to MySQL server in order
118 to keep the connection open.
119
120 Default value is 300 (5 min).
121
122 Example 1.1. Set ping_interval parameter
123 ...
124 modparam("db_mysql", "ping_interval", 600)
125 ...
126
127 3.2. server_timezone (integer)
128
129 Control if kamailio converts a time to string using the local timezone
130 or if MySQL will convert it using FROM_UNIXTIME. This option is useful
131 if kamailio and the database are configured for different timezones.
132
133 Default value is 0 (use local conversion)
134
135 Example 1.2. Set server_timezone parameter
136 ...
137 modparam("db_mysql", "server_timezone", 1)
138 ...
139
140 3.3. timeout_interval (integer)
141
142 Time interval (in seconds) after that a connection attempt, read or
143 write request is aborted. The value counts three times, as several
144 retries are done from the driver before it gives up.
145
146 The read timeout parameter is ignored on MySQL driver versions prior to
147 “5.1.12”, “5.0.25” and “4.1.22”. The write timeout parameter is ignored
148 on versions prior to “5.1.12” and “5.0.25”, the “4.1” release don't
149 support it at all.
150
151 Default value is 2 (6 sec).
152
153 Example 1.3. Set timeout_interval parameter
154 ...
155 modparam("db_mysql", "timeout_interval", 2)
156 ...
157
158 3.4. auto_reconnect (integer)
159
160 Configure whether the module should automatically reconnect to MySQL
161 server if the connection was lost.
162
163 Default value is 1 (1 - on / 0 - off).
164
165 Example 1.4. Set auto_reconnect parameter
166 ...
167 modparam("db_mysql", "auto_reconnect", 0)
168 ...
169
170 3.5. insert_delayed (integer)
171
172 If set to 1, all INSERT SQL queries will be sent to MySQL server as
173 INSERT DELAYED.
174
175 Default value is 0 (1 - on / 0 - off).
176
177 Example 1.5. Set insert_delayed parameter
178 ...
179 modparam("db_mysql", "insert_delayed", 1)
180 ...
181
182 3.6. update_affected_found (integer)
183
184 If set to 1, all UPDATE SQL queries will return the number of matched
185 rows instead of the number of "updated" rows.
186
187 Default value is 0 (1 - on / 0 - off).
188
189 Example 1.6. Set update_affected_found parameter
190 ...
191 modparam("db_mysql", "update_affected_found", 1)
192 ...
193
194 3.7. opt_ssl_mode (integer)
195
196 Control how the connection to MySQL server is done in regards to
197 SSL/TLS. If set to 1, SSL/TLS mode is disabled.
198
199 The 'include/mysql.h' starting with MySQL 5.7.11 defines the values for
200 this option as enum: 'mysql_ssl_mode { SSL_MODE_DISABLED=1,
201 SSL_MODE_PREFERRED, SSL_MODE_REQUIRED, SSL_MODE_VERIFY_CA,
202 SSL_MODE_VERIFY_IDENTITY}'.
203
204 Note: if the value of this parameter is 1, it enforces
205 SSL_MODE_DISABLED, any other value is passed to the mysql_options(),
206 not checking if it is defined.
207
208 MariaDB client configuration uses the following values: 0, 1 use plain,
209 2/3/4 for MYSQL_OPT_SSL_ENFORCE, 5 for MYSQL_OPT_SSL_VERIFY_SERVER_CERT
210 (see MariaDB Connector/C documentation) Other values are ignored.
211
212 Default value is 0 (0 - off).
213
214 Example 1.7. Set opt_ssl_mode parameter
215 ...
216 modparam("db_mysql", "opt_ssl_mode", 1)
217 ...
218
219 3.8. opt_ssl_ca (string)
220
221 Configures the CA certs used to verify the MySQL server cert when SSL
222 is enabled.
223
224 Required when opt_ssl_mode = 4 or 5 and db_mysql is built with
225 libmysqlclient.
226
227 Default value is NULL (NULL - not configured).
228
229 Example 1.8. Set opt_ssl_ca parameter
230 ...
231 modparam("db_mysql", "opt_ssl_ca", "/etc/ssl/certs/mysql-ca.pem")
232 ...
233
234 4. Functions
235
236 No function exported to be used from configuration file.
237
238 5. Installation
239
240 Because it depends on an external library, the mysql module is not
241 compiled and installed by default. You can use one of these options.
242 * - edit the "Makefile" and remove "db_mysql" from "excluded_modules"
243 list. Then follow the standard procedure to install Kamailio: "make
244 all; make install".
245 * - from command line use: 'make all include_modules="db_mysql"; make
246 install include_modules="db_mysql"'.
247
248 6. Reading configuration from my.cnf
249
250 In order to take into account specific mysql client options, a my.cnf
251 config group can be passed using the db_url module parameter. This is
252 done by setting [group] in front of or instead of the host part. The
253 following examples are valid db_url definitions, which include a my.cnf
254 group:
255 * mysql://user:pass@[group]host:port/db
256 * mysql://user:pass@[group]:port/db
257 * mysql://user:pass@[group]/db
258 * mysql://[group]/db
259
260 Example 1.9. Set a my.cnf group in db_url parameter
261 ...
262 modparam("usrloc", "db_url", "mysql://[kamailio]/kamailio)
263 ...
264
265 Example 1.10. Adding a kamailio group to my.cnf
266 ...
267 [kamailio]
268 socket = /path/to/mysql.sock
269 user = kamailiouser
270 password = kamailiopass
271 default-character-set = utf8
272 ...
273
274 In addition to the given group, also the [client] section is read, in
275 the order given in my.cnf. So if you for example specify a socket in
276 both your specific group and the client group, then the value is taken
277 from the last one.
278
279 Example 1.11. Using [client] and specific group
280 ...
281 [client]
282 socket = /run/mysql/mysqld.sock
283
284 [kamailio]
285 socket = /path/to/mysqld.sock
286 user = kamailiouser
287 password = kamailiopass
288 default-character-set = utf8
289 ...
290
291 In the example given above, the socket /path/to/mysqld.sock is used by
292 Kamailio because both [kamailio] and [client] define this option, and
293 the latter overwrites the first.