annotate Sphinx/source/plugins/mysql.rst @ 336:a5f7fc9fb611

Orthanc 1.6.0
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 18 Mar 2020 15:15:39 +0100
parents f29d75bc5c25
children 011b01ccf52d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 .. _mysql:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 MySQL/MariaDB plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 =====================
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 .. contents::
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 The Orthanc project provides two **official** plugins to replace the
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 default storage area (on the filesystem) and the default SQLite index
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 by a MySQL or a MariaDB database.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 For general information, check out the `official homepage of the
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 plugins <http://www.orthanc-server.com/static.php?page=mysql>`__.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15
230
0a1c9ef57b52 warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 158
diff changeset
16 **Warning:** According to `this thread on our discussion group
231
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 230
diff changeset
17 <https://groups.google.com/d/msg/orthanc-users/yV3LSTh_TjI/Fb4ShaYMBAAJ>`__,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 230
diff changeset
18 the MySQL/MariaDB plugins require MySQL 8.x if running on Microsoft
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 230
diff changeset
19 Windows.
230
0a1c9ef57b52 warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 158
diff changeset
20
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 Compilation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 -----------
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 Static linking
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 ^^^^^^^^^^^^^^
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 .. highlight:: text
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 The procedure to compile these plugins is similar to that for the
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 :ref:`core of Orthanc <compiling>`. The following commands should work
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 for most UNIX-like distribution (including GNU/Linux)::
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 $ mkdir BuildMySQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 $ cd BuildMySQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 $ cmake ../MySQL/ -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE=Release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 $ make
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 The compilation will produce 2 shared libraries, each containing one plugin for Orthanc:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 * ``OrthancMySQLIndex`` replaces the default SQLite index of Orthanc by MySQL.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 * ``OrthancMySQLStorage`` makes Orthanc store the DICOM files it receives into MySQL.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 Microsoft Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 ^^^^^^^^^^^^^^^^^
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 Pre-compiled binaries for Microsoft Windows `are also available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 <http://www.orthanc-server.com/browse.php?path=/plugin-mysql>`__.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 Dynamic linking on Ubuntu 16.04
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 .. highlight:: text
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 If static linking is not desired, here are build instructions for
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 Ubuntu 16.04 (provided build dependencies for the :ref:`core of
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 Orthanc <compiling>` have already been installed)::
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 $ sudo apt-get install libmysqlclient-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 $ mkdir BuildMySQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 $ cd BuildMySQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 $ cmake ../MySQL/ -DCMAKE_BUILD_TYPE=Release \
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 -DALLOW_DOWNLOADS=ON \
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 -DUSE_SYSTEM_GOOGLE_TEST=OFF \
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 -DUSE_SYSTEM_ORTHANC_SDK=OFF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 $ make
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 Usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 -----
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 You of course first have to :ref:`install Orthanc <binaries>`, with a
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 version above 0.9.5. You then have to **create a database** dedicated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 to Orthanc on some MySQL/MariaDB server. Please refer to the `MySQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 <https://dev.mysql.com/doc/refman/8.0/en/database-use.html>`__.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 .. highlight:: json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 Once Orthanc is installed and the database is created, you must add a
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 section in the :ref:`configuration file <configuration>` that
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 specifies the address of the **MySQL/MariaDB server together with your
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 credentials**. You also have to tell Orthanc in which path it can find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 the plugins: This is done by properly modifying the ``Plugins``
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 option. You could for instance adapt the following configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 file::
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 "Name" : "MyOrthanc",
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 "MySQL" : {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 "EnableIndex" : true,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 "EnableStorage" : true,
158
86be4710bbae note about sockets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
96 "Host" : "localhost", // For TCP connections (notably Windows)
86be4710bbae note about sockets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
97 "Port" : 3306, // For TCP connections (notably Windows)
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 "UnixSocket" : "/var/run/mysqld/mysqld.sock", // For UNIX on localhost
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 "Database" : "orthanc",
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 "Username" : "orthanc",
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 "Password" : "orthanc",
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 "Lock" : true // See section about Locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 },
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 "Plugins" : [
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 "/home/user/orthanc-databases/BuildMySQL/libOrthancMySQLIndex.so",
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 "/home/user/orthanc-databases/BuildMySQL/libOrthancMySQLStorage.so"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 ]
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109
158
86be4710bbae note about sockets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
110 **Important 1:** The ``EnableIndex`` and ``EnableStorage`` options must
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 be explicitly set to ``true``, otherwise Orthanc will continue to use
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 its default SQLite back-end and the filesystem storage area.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
158
86be4710bbae note about sockets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
114 **Important 2:** To force a TCP connection on the ``localhost`` in
86be4710bbae note about sockets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
115 UNIX (i.e. to instruct Orthanc not to use UNIX socket), the
86be4710bbae note about sockets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
116 ``UnixSocket`` can be set to the empty string.
86be4710bbae note about sockets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
117
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 **Remark:** When using the ``Storage`` MySQL plugin, the DICOM files
158
86be4710bbae note about sockets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
119 are stored as blobs in the database. This might actually consume more
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 space than the DICOM file itself.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 Note that a typical usage of the MySQL plugin is to enable only the
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 ``Index``, using the default filesystem storage for DICOM files.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 .. highlight:: text
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 Orthanc must of course be **restarted** after the modification of its
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 configuration file. The log will contain an output similar to::
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 $ ./Orthanc Configuration.json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 W0710 14:25:35.143828 main.cpp:1298] Orthanc version: 1.3.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 W0710 14:25:35.146528 OrthancInitialization.cpp:120] Reading the configuration from: "./Configuration.json"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 [...]
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 W0710 14:25:35.173652 main.cpp:671] Loading plugin(s) from: /home/jodogne/Subversion/orthanc-databases/BuildMySQL/libOrthancMySQLIndex.so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 W0710 14:25:35.175927 PluginsManager.cpp:269] Registering plugin 'mysql-index' (version mainline)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 W0710 14:25:35.176213 PluginsManager.cpp:168] Performance warning: The database index plugin was compiled against an old version of the Orthanc SDK, consider upgrading
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 W0710 14:25:35.176323 main.cpp:671] Loading plugin(s) from: /home/jodogne/Subversion/orthanc-databases/BuildMySQL/libOrthancMySQLStorage.so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 W0710 14:25:35.177172 PluginsManager.cpp:269] Registering plugin 'mysql-storage' (version mainline)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 W0710 14:25:35.180684 PluginsManager.cpp:168] Your MySQL server cannot store DICOM files larger than 16MB
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 W0710 14:25:35.180714 PluginsManager.cpp:168] => Consider increasing "max_allowed_packet" in "my.cnf" if this limit is insufficient for your use
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 W0710 14:25:35.246150 main.cpp:1098] Using a custom database from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 W0710 14:25:35.246210 main.cpp:1109] Using a custom storage area from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 [...]
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 W0710 14:25:37.073633 main.cpp:683] Orthanc has started
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 Advanced options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 ----------------
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 Several advanced options are available as well to fine-tune the
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 configuration of the MySQL plugins. They are documented below.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 Locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 ^^^^^^^
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 .. highlight:: json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 By default, the plugins lock the database (using `MySQL/MariaDB
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 "GET_LOCK()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 <https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_get-lock>`__)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 to prevent other instances of Orthanc from using the same database. If
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 you want several instances of Orthanc to share the same database, set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 the ``Lock`` option to ``false`` in the configuration file.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168
270
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
169 In the absence of locking, the same limitation apply to the
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
170 MySQL/MariaDB plugins than to the PostgreSQL plugins (i.e. at most one
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
171 instance of Orthanc writing to the database). For more information,
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
172 please check out the :ref:`documentation for PostgreSQL
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 231
diff changeset
173 <postgresql-lock>`.