Mercurial > hg > orthanc-book
annotate Sphinx/source/plugins/postgresql.rst @ 154:365427cebb64
mysql
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 10 Jul 2018 14:45:40 +0200 |
parents | 61050d813d74 |
children | c7551e19ae95 |
rev | line source |
---|---|
24 | 1 .. _postgresql: |
2 | |
3 | |
4 PostgreSQL plugins | |
5 ================== | |
6 | |
27 | 7 .. contents:: |
8 | |
9 The Orthanc project provides two **official** plugins to replace the | |
10 default storage area (on the filesystem) and the default SQLite index | |
11 by a PostgreSQL database. | |
12 | |
13 For general information, check out the `official homepage of the | |
14 plugins <http://www.orthanc-server.com/static.php?page=postgresql>`__. | |
15 | |
16 | |
17 | |
18 Compilation | |
19 ----------- | |
20 | |
128 | 21 Static linking |
22 ^^^^^^^^^^^^^^ | |
23 | |
27 | 24 .. highlight:: text |
25 | |
154 | 26 The procedure to compile these plugins is similar to that for the |
27 | 27 :ref:`core of Orthanc <compiling>`. The following commands should work |
154 | 28 for most UNIX-like distribution (including GNU/Linux):: |
27 | 29 |
154 | 30 $ mkdir BuildPostgreSQL |
31 $ cd BuildPostgreSQL | |
32 $ cmake ../PostgreSQL -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE=Release | |
27 | 33 $ make |
34 | |
35 The compilation will produce 2 shared libraries, each containing one plugin for Orthanc: | |
36 | |
37 * ``OrthancPostgreSQLIndex`` replaces the default SQLite index of Orthanc by PostgreSQL. | |
38 * ``OrthancPostgreSQLStorage`` makes Orthanc store the DICOM files it receives into PostgreSQL. | |
39 | |
128 | 40 |
41 Microsoft Windows and Apple OS X | |
42 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
43 | |
28 | 44 Pre-compiled binaries for Microsoft Windows `are also available |
27 | 45 <http://www.orthanc-server.com/browse.php?path=/plugin-postgresql>`__. |
30 | 46 A package for `Apple's Mac OS X |
94
b0a71b880ca0
fix link + remark about disk usage overhead
Alain Mazy <alain@mazy.be>
parents:
81
diff
changeset
|
47 <http://www.osimis.io/en/download.html>`__ |
128 | 48 is available courtesy of `Osimis <http://osimis.io/>`__. |
27 | 49 |
50 | |
128 | 51 Dynamic linking on Ubuntu 16.04 |
52 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
53 | |
54 .. highlight:: text | |
55 | |
56 If static linking is not desired, here are build instructions for | |
57 Ubuntu 16.04 (provided build dependencies for the :ref:`core of | |
58 Orthanc <compiling>` have already been installed):: | |
59 | |
60 $ sudo apt-get install libpq-dev postgresql-server-dev-all | |
154 | 61 $ mkdir BuildPostgreSQL |
62 $ cd BuildPostgreSQL | |
63 $ cmake ../PostgreSQL -DCMAKE_BUILD_TYPE=Release \ | |
64 -DALLOW_DOWNLOADS=ON \ | |
65 -DUSE_SYSTEM_GOOGLE_TEST=OFF \ | |
66 -DUSE_SYSTEM_ORTHANC_SDK=OFF | |
128 | 67 $ make |
68 | |
69 | |
27 | 70 Usage |
71 ----- | |
72 | |
73 .. highlight:: json | |
74 | |
31
93bbfaf0e62c
worklist instructions migrated to a specific page, indexing of Osimis Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
30
diff
changeset
|
75 You of course first have to :ref:`install Orthanc <binaries>`, with a |
154 | 76 version above 0.9.5. You then have to **create a database** dedicated |
28 | 77 to Orthanc on some PostgreSQL server. Please refer to the `PostgreSQL |
78 documentation | |
27 | 79 <https://www.postgresql.org/docs/current/static/tutorial-createdb.html>`__. |
80 | |
81 Once Orthanc is installed and the database is created, you must add a | |
82 section in the :ref:`configuration file <configuration>` that | |
83 specifies the address of the **PostgreSQL server together with your | |
84 credentials**. You also have to tell Orthanc in which path it can find | |
85 the plugins: This is done by properly modifying the ``Plugins`` | |
86 option. You could for instance adapt the following configuration | |
87 file:: | |
88 | |
89 { | |
90 "Name" : "MyOrthanc", | |
91 "PostgreSQL" : { | |
92 "EnableIndex" : true, | |
93 "EnableStorage" : true, | |
94 "Host" : "localhost", | |
95 "Port" : 5432, | |
96 "Database" : "orthanc", | |
97 "Username" : "orthanc", | |
98 "Password" : "orthanc" | |
99 }, | |
100 "Plugins" : [ | |
154 | 101 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so", |
102 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so" | |
27 | 103 ] |
104 } | |
105 | |
154 | 106 **Important:** The ``EnableIndex`` and ``EnableStorage`` options must |
107 be explicitly set to ``true``, otherwise Orthanc will continue to use | |
108 its default SQLite back-end and the filesystem storage area. | |
27 | 109 |
154 | 110 **Remark:** When using the ``Storage`` PostgreSQL plugin, the DICOM |
111 files are stored as large objects in the database. This might | |
112 actually consume more space than the DICOM file itself. We have | |
113 observed overhead up to 40%. However, it seems this overhead is | |
114 temporary and comes from Write-Ahead Logging. Check this `discussion | |
115 <https://groups.google.com/d/msg/orthanc-users/pPzHOpb--iw/QkKZ808gIgAJ>`__ | |
116 on the Orthanc Users group for more info). | |
118 | 117 |
154 | 118 Note that a typical usage of the PostgreSQL plugin is to enable only |
119 the ``Index``, and to use the default filesystem storage for DICOM | |
120 files. | |
118 | 121 |
122 | |
94
b0a71b880ca0
fix link + remark about disk usage overhead
Alain Mazy <alain@mazy.be>
parents:
81
diff
changeset
|
123 |
27 | 124 .. highlight:: text |
125 | |
126 Orthanc must of course be **restarted** after the modification of its | |
127 configuration file. The log will contain an output similar to:: | |
128 | |
129 $ ./Orthanc Configuration.json | |
130 W0212 16:30:34.576972 11285 main.cpp:632] Orthanc version: 0.8.6 | |
131 W0212 16:30:34.577386 11285 OrthancInitialization.cpp:80] Using the configuration from: Configuration.json | |
132 [...] | |
154 | 133 W0212 16:30:34.598053 11285 main.cpp:379] Registering a plugin from: /home/jodogne/Subversion/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so |
27 | 134 W0212 16:30:34.598470 11285 PluginsManager.cpp:258] Registering plugin 'postgresql-index' (version 1.0) |
135 W0212 16:30:34.598491 11285 PluginsManager.cpp:148] Using PostgreSQL index | |
154 | 136 W0212 16:30:34.608289 11285 main.cpp:379] Registering a plugin from: /home/jodogne/Subversion/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so |
27 | 137 W0212 16:30:34.608916 11285 PluginsManager.cpp:258] Registering plugin 'postgresql-storage' (version 1.0) |
138 W0212 16:30:34.608947 11285 PluginsManager.cpp:148] Using PostgreSQL storage area | |
139 [...] | |
140 W0212 16:30:34.674648 11285 main.cpp:530] Orthanc has started | |
141 | |
142 | |
143 .. highlight:: json | |
144 | |
145 Instead of specifying explicit authentication parameters, you can also | |
146 use the `PostgreSQL connection URIs syntax | |
147 <https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING>`__. For | |
148 instance:: | |
149 | |
150 { | |
151 "Name" : "MyOrthanc", | |
152 "PostgreSQL" : { | |
153 "EnableIndex" : true, | |
154 "EnableStorage" : true, | |
155 "ConnectionUri" : "postgresql://username:password@localhost:5432/database" | |
156 }, | |
157 "Plugins" : [ | |
154 | 158 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so", |
159 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so" | |
27 | 160 ] |
161 } | |
162 | |
163 | |
164 **Remark:** The Debian Med project maintains `another useful set of | |
165 instructions | |
166 <https://anonscm.debian.org/viewvc/debian-med/trunk/packages/orthanc-postgresql/trunk/debian/README.Debian?view=markup>`__. | |
167 | |
168 | |
169 Advanced options | |
170 ---------------- | |
171 | |
172 Several advanced options are available as well to fine-tune the | |
173 configuration of the PostgreSQL plugins. They are documented below. | |
174 | |
175 | |
176 Locking | |
177 ^^^^^^^ | |
178 | |
179 .. highlight:: json | |
180 | |
181 By default, the plugins lock the database (using `PostgreSQL advisory | |
182 locks | |
183 <https://www.postgresql.org/docs/current/static/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS>`__) | |
184 to prevent other instances of Orthanc from using the same PostgreSQL | |
185 database. If you want several instances of Orthanc to share the same | |
186 database, set the ``Lock`` option to ``false`` in the configuration | |
187 file:: | |
188 | |
189 { | |
190 "Name" : "MyOrthanc", | |
191 "PostgreSQL" : { | |
192 "EnableIndex" : true, | |
193 "EnableStorage" : true, | |
194 "Lock" : false, | |
195 "ConnectionUri" : "postgresql://username:password@localhost:5432/database" | |
196 }, | |
197 "Plugins" : [ | |
154 | 198 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so", |
199 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so" | |
27 | 200 ] |
201 } | |
202 | |
203 Obviously, one must be very cautious when sharing the same database | |
204 between instances of Orthanc. In particular, all these instances | |
205 should share the same configuration. | |
206 | |
207 | |
208 Keep-alive | |
209 ^^^^^^^^^^ | |
210 | |
211 .. highlight:: text | |
212 | |
213 After some period of inactivity (users have reported 10 hours), you | |
214 might `experience an error | |
215 <https://bitbucket.org/sjodogne/orthanc/issues/15/postgresql-exceptions-after-time>`__ | |
216 such as:: | |
217 | |
218 E0220 03:20:51.562601 PluginsManager.cpp:163] Exception in database back-end: Error in PostgreSQL: server closed the connection unexpectedly. | |
219 This probably means the server terminated abnormally before or while processing the request. | |
220 E0220 06:51:03.924868 PluginsManager.cpp:163] Exception in database back-end: Error in PostgreSQL: no connection to the server | |
221 | |
222 This is due to a timeout in the PostgreSQL server. Please make sure to | |
223 `enable keep-alive | |
224 <http://dba.stackexchange.com/questions/97534/is-there-a-timeout-option-for-remote-access-to-postgresql-database>`__ | |
225 in the configuration of your PostgreSQL server |