annotate Sphinx/source/plugins/mysql.rst @ 154:365427cebb64

mysql
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 10 Jul 2018 14:45:40 +0200
parents
children 86be4710bbae
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 Compilation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 -----------
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 Static linking
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 ^^^^^^^^^^^^^^
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 .. highlight:: text
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 The procedure to compile these plugins is similar to that for the
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 :ref:`core of Orthanc <compiling>`. The following commands should work
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 for most UNIX-like distribution (including GNU/Linux)::
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 $ mkdir BuildMySQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 $ cd BuildMySQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 $ cmake ../MySQL/ -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE=Release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 $ make
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 The compilation will produce 2 shared libraries, each containing one plugin for Orthanc:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 * ``OrthancMySQLIndex`` replaces the default SQLite index of Orthanc by MySQL.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 * ``OrthancMySQLStorage`` makes Orthanc store the DICOM files it receives into MySQL.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 Microsoft Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 ^^^^^^^^^^^^^^^^^
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 Pre-compiled binaries for Microsoft Windows `are also available
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 <http://www.orthanc-server.com/browse.php?path=/plugin-mysql>`__.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 Dynamic linking on Ubuntu 16.04
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 .. highlight:: text
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 If static linking is not desired, here are build instructions for
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 Ubuntu 16.04 (provided build dependencies for the :ref:`core of
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 Orthanc <compiling>` have already been installed)::
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 $ sudo apt-get install libmysqlclient-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 $ mkdir BuildMySQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 $ cd BuildMySQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 $ cmake ../MySQL/ -DCMAKE_BUILD_TYPE=Release \
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 -DALLOW_DOWNLOADS=ON \
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 -DUSE_SYSTEM_GOOGLE_TEST=OFF \
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 -DUSE_SYSTEM_ORTHANC_SDK=OFF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 $ make
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 Usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 -----
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 You of course first have to :ref:`install Orthanc <binaries>`, with a
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 version above 0.9.5. You then have to **create a database** dedicated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 to Orthanc on some MySQL/MariaDB server. Please refer to the `MySQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 <https://dev.mysql.com/doc/refman/8.0/en/database-use.html>`__.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 .. highlight:: json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 Once Orthanc is installed and the database is created, you must add a
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 section in the :ref:`configuration file <configuration>` that
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 specifies the address of the **MySQL/MariaDB server together with your
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 credentials**. You also have to tell Orthanc in which path it can find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 the plugins: This is done by properly modifying the ``Plugins``
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 option. You could for instance adapt the following configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 file::
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 "Name" : "MyOrthanc",
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 "MySQL" : {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 "EnableIndex" : true,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 "EnableStorage" : true,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 "Host" : "localhost", // For Windows or network connections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 "Port" : 3306, // For Windows or network connections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 "UnixSocket" : "/var/run/mysqld/mysqld.sock", // For UNIX on localhost
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 "Database" : "orthanc",
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 "Username" : "orthanc",
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 "Password" : "orthanc",
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 "Lock" : true // See section about Locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 },
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 "Plugins" : [
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 "/home/user/orthanc-databases/BuildMySQL/libOrthancMySQLIndex.so",
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 "/home/user/orthanc-databases/BuildMySQL/libOrthancMySQLStorage.so"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 ]
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 **Important:** The ``EnableIndex`` and ``EnableStorage`` options must
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 be explicitly set to ``true``, otherwise Orthanc will continue to use
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 its default SQLite back-end and the filesystem storage area.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 **Remark:** When using the ``Storage`` MySQL plugin, the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 are stored as blobs in the database. This might actually consume more
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 space than the DICOM file itself.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 Note that a typical usage of the MySQL plugin is to enable only the
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 ``Index``, using the default filesystem storage for DICOM files.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 .. highlight:: text
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 Orthanc must of course be **restarted** after the modification of its
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 configuration file. The log will contain an output similar to::
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 $ ./Orthanc Configuration.json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 W0710 14:25:35.143828 main.cpp:1298] Orthanc version: 1.3.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 W0710 14:25:35.146528 OrthancInitialization.cpp:120] Reading the configuration from: "./Configuration.json"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 [...]
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 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
128 W0710 14:25:35.175927 PluginsManager.cpp:269] Registering plugin 'mysql-index' (version mainline)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 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
130 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
131 W0710 14:25:35.177172 PluginsManager.cpp:269] Registering plugin 'mysql-storage' (version mainline)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 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
133 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
134 W0710 14:25:35.246150 main.cpp:1098] Using a custom database from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 W0710 14:25:35.246210 main.cpp:1109] Using a custom storage area from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 [...]
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 W0710 14:25:37.073633 main.cpp:683] Orthanc has started
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 Advanced options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 ----------------
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 Several advanced options are available as well to fine-tune the
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 configuration of the MySQL plugins. They are documented below.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 Locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 ^^^^^^^
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 .. highlight:: json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 By default, the plugins lock the database (using `MySQL/MariaDB
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 "GET_LOCK()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 <https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_get-lock>`__)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 to prevent other instances of Orthanc from using the same database. If
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 you want several instances of Orthanc to share the same database, set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 the ``Lock`` option to ``false`` in the configuration file.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 Obviously, one must be very cautious when sharing the same database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 between instances of Orthanc. In particular, all these instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 should share the same configuration.