annotate Sphinx/source/plugins/postgresql.rst @ 290:6cbcdb965ad3

Orthanc 1.5.8
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 16 Oct 2019 15:13:27 +0200
parents f29d75bc5c25
children a5f7fc9fb611
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
25fa874803ab plugins inside book
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 .. _postgresql:
25fa874803ab plugins inside book
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
25fa874803ab plugins inside book
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3
25fa874803ab plugins inside book
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 PostgreSQL plugins
25fa874803ab plugins inside book
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 ==================
25fa874803ab plugins inside book
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
7 .. contents::
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
8
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
9 The Orthanc project provides two **official** plugins to replace the
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
10 default storage area (on the filesystem) and the default SQLite index
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
11 by a PostgreSQL database.
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
12
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
13 For general information, check out the `official homepage of the
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
14 plugins <http://www.orthanc-server.com/static.php?page=postgresql>`__.
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
15
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
16
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
17
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
18 Compilation
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
19 -----------
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
20
128
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
21 Static linking
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
22 ^^^^^^^^^^^^^^
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
23
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
24 .. highlight:: text
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
25
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
26 The procedure to compile these plugins is similar to that for the
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
27 :ref:`core of Orthanc <compiling>`. The following commands should work
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
28 for most UNIX-like distribution (including GNU/Linux)::
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
29
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
30 $ mkdir BuildPostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
31 $ cd BuildPostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
32 $ cmake ../PostgreSQL -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE=Release
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
33 $ make
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
34
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
35 The compilation will produce 2 shared libraries, each containing one plugin for Orthanc:
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
36
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
37 * ``OrthancPostgreSQLIndex`` replaces the default SQLite index of Orthanc by PostgreSQL.
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
38 * ``OrthancPostgreSQLStorage`` makes Orthanc store the DICOM files it receives into PostgreSQL.
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
39
128
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
40
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
41 Microsoft Windows and Apple OS X
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
42 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
43
28
dc235678897c webviewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 27
diff changeset
44 Pre-compiled binaries for Microsoft Windows `are also available
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
45 <http://www.orthanc-server.com/browse.php?path=/plugin-postgresql>`__.
30
79b6d3ea92aa dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 28
diff changeset
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
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
48 is available courtesy of `Osimis <http://osimis.io/>`__.
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
49
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
50
263
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
51 .. _postgresql-ubuntu1604:
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
52
128
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
53 Dynamic linking on Ubuntu 16.04
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
54 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
55
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
56 .. highlight:: text
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
57
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
58 If static linking is not desired, here are build instructions for
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
59 Ubuntu 16.04 (provided build dependencies for the :ref:`core of
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
60 Orthanc <compiling>` have already been installed)::
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
61
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
62 $ sudo apt-get install libpq-dev postgresql-server-dev-all
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
63 $ mkdir BuildPostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
64 $ cd BuildPostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
65 $ cmake ../PostgreSQL -DCMAKE_BUILD_TYPE=Release \
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
66 -DALLOW_DOWNLOADS=ON \
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
67 -DUSE_SYSTEM_GOOGLE_TEST=OFF \
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
68 -DUSE_SYSTEM_ORTHANC_SDK=OFF
128
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
69 $ make
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
70
263
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
71
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
72 .. _postgresql-cmake:
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
73
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
74 Dynamic linking on other GNU/Linux distributions
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
75 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
76
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
77 .. highlight:: text
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
78
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
79 The build instructions should always be very similar to those for
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
80 :ref:`Ubuntu 16.04 <postgresql-ubuntu1604>`. One difficulty that could
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
81 however arise is that it is possible that the CMake environment that
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
82 is shipped with the GNU/Linux distribution cannot locate a recent
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
83 version of the development headers for PostgreSQL. This leads to an
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
84 error while invoking CMake that looks like::
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
85
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
86 -- Could NOT find PostgreSQL (missing: PostgreSQL_TYPE_INCLUDE_DIR)
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
87
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
88 In such a situation, please add your version of PostgreSQL to the
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
89 macro ``PostgreSQL_ADDITIONAL_VERSIONS`` that is defined at the end of
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
90 the `Resources/CMake/PostgreSQLConfiguration.cmake file
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
91 <https://bitbucket.org/sjodogne/orthanc-databases/src/default/Resources/CMake/PostgreSQLConfiguration.cmake>`__ in the sources of the project.
39609c9a2c41 note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 181
diff changeset
92
128
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
93
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
94 Usage
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
95 -----
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
96
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
97 .. highlight:: json
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
98
31
93bbfaf0e62c worklist instructions migrated to a specific page, indexing of Osimis Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 30
diff changeset
99 You of course first have to :ref:`install Orthanc <binaries>`, with a
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
100 version above 0.9.5. You then have to **create a database** dedicated
28
dc235678897c webviewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 27
diff changeset
101 to Orthanc on some PostgreSQL server. Please refer to the `PostgreSQL
dc235678897c webviewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 27
diff changeset
102 documentation
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
103 <https://www.postgresql.org/docs/current/static/tutorial-createdb.html>`__.
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
104
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
105 Once Orthanc is installed and the database is created, you must add a
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
106 section in the :ref:`configuration file <configuration>` that
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
107 specifies the address of the **PostgreSQL server together with your
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
108 credentials**. You also have to tell Orthanc in which path it can find
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
109 the plugins: This is done by properly modifying the ``Plugins``
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
110 option. You could for instance adapt the following configuration
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
111 file::
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
112
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
113 {
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
114 "Name" : "MyOrthanc",
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
115 "PostgreSQL" : {
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
116 "EnableIndex" : true,
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
117 "EnableStorage" : true,
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
118 "Host" : "localhost",
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
119 "Port" : 5432,
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
120 "Database" : "orthanc",
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
121 "Username" : "orthanc",
181
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
122 "Password" : "orthanc",
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
123 "EnableSsl" : false // New in version 3.0
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
124 },
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
125 "Plugins" : [
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
126 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so",
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
127 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so"
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
128 ]
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
129 }
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
130
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
131 **Important:** The ``EnableIndex`` and ``EnableStorage`` options must
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
132 be explicitly set to ``true``, otherwise Orthanc will continue to use
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
133 its default SQLite back-end and the filesystem storage area.
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
134
181
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
135 **Remark 1:** When using the ``Storage`` PostgreSQL plugin, the DICOM
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
136 files are stored as large objects in the database. This might
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
137 actually consume more space than the DICOM file itself. We have
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
138 observed overhead up to 40%. However, it seems this overhead is
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
139 temporary and comes from Write-Ahead Logging. Check this `discussion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
140 <https://groups.google.com/d/msg/orthanc-users/pPzHOpb--iw/QkKZ808gIgAJ>`__
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
141 on the Orthanc Users group for more info).
118
a30abf63ccba postgres: reference to forum for space usage
amazy
parents: 94
diff changeset
142
181
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
143 **Remark 2:** A typical usage of the PostgreSQL plugin is to enable
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
144 only the ``Index``, and to use the default filesystem storage for
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
145 DICOM files (on a NAS with proper disaster recovery strategies). This
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
146 setup provides best performance for large-scale databases.
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
147
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
148 **Remark 3:** Setting the ``EnableSsl`` to ``true`` forces the use of
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
149 `SSL connections
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
150 <https://www.postgresql.org/docs/current/libpq-ssl.html>`__ between
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
151 Orthanc and the PostgreSQL server. It is a synonym for
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
152 ``sslmode=require`` in connections URI (see below). Setting
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
153 ``EnableSsl`` to ``false`` corresponds to ``sslmode=disable``
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
154 (i.e. SSL is not used, even if it is both available in Orthanc and
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
155 PostgreSQL). To choose other values for the SSL mode (i.e. ``allow``
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
156 and ``prefer``), please use connection URIs.
118
a30abf63ccba postgres: reference to forum for space usage
amazy
parents: 94
diff changeset
157
a30abf63ccba postgres: reference to forum for space usage
amazy
parents: 94
diff changeset
158
94
b0a71b880ca0 fix link + remark about disk usage overhead
Alain Mazy <alain@mazy.be>
parents: 81
diff changeset
159
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
160 .. highlight:: text
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
161
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
162 Orthanc must of course be **restarted** after the modification of its
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
163 configuration file. The log will contain an output similar to::
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
164
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
165 $ ./Orthanc Configuration.json
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
166 W0212 16:30:34.576972 11285 main.cpp:632] Orthanc version: 0.8.6
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
167 W0212 16:30:34.577386 11285 OrthancInitialization.cpp:80] Using the configuration from: Configuration.json
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
168 [...]
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
169 W0212 16:30:34.598053 11285 main.cpp:379] Registering a plugin from: /home/jodogne/Subversion/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
170 W0212 16:30:34.598470 11285 PluginsManager.cpp:258] Registering plugin 'postgresql-index' (version 1.0)
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
171 W0212 16:30:34.598491 11285 PluginsManager.cpp:148] Using PostgreSQL index
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
172 W0212 16:30:34.608289 11285 main.cpp:379] Registering a plugin from: /home/jodogne/Subversion/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
173 W0212 16:30:34.608916 11285 PluginsManager.cpp:258] Registering plugin 'postgresql-storage' (version 1.0)
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
174 W0212 16:30:34.608947 11285 PluginsManager.cpp:148] Using PostgreSQL storage area
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
175 [...]
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
176 W0212 16:30:34.674648 11285 main.cpp:530] Orthanc has started
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
177
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
178
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
179 .. highlight:: json
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
180
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
181 Instead of specifying explicit authentication parameters, you can also
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
182 use the `PostgreSQL connection URIs syntax
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
183 <https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING>`__. For
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
184 instance::
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
185
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
186 {
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
187 "Name" : "MyOrthanc",
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
188 "PostgreSQL" : {
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
189 "EnableIndex" : true,
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
190 "EnableStorage" : true,
181
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
191 "ConnectionUri" : "postgresql://username:password@localhost:5432/database?sslmode=prefer"
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
192 },
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
193 "Plugins" : [
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
194 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so",
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
195 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so"
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
196 ]
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
197 }
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
198
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
199
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
200 **Remark:** The Debian Med project maintains `another useful set of
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
201 instructions
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
202 <https://anonscm.debian.org/viewvc/debian-med/trunk/packages/orthanc-postgresql/trunk/debian/README.Debian?view=markup>`__.
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
203
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
204
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
205 Advanced options
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
206 ----------------
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
207
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
208 Several advanced options are available as well to fine-tune the
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
209 configuration of the PostgreSQL plugins. They are documented below.
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
210
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
211
270
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
212 .. _postgresql-lock:
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
213
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
214 Locking
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
215 ^^^^^^^
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
216
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
217 .. highlight:: json
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
218
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
219 By default, the plugins lock the database (using `PostgreSQL advisory
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
220 locks
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
221 <https://www.postgresql.org/docs/current/static/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS>`__)
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
222 to prevent other instances of Orthanc from using the same PostgreSQL
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
223 database. If you want several instances of Orthanc to share the same
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
224 database, set the ``Lock`` option to ``false`` in the configuration
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
225 file::
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
226
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
227 {
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
228 "Name" : "MyOrthanc",
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
229 "PostgreSQL" : {
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
230 "EnableIndex" : true,
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
231 "EnableStorage" : true,
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
232 "Lock" : false,
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
233 "ConnectionUri" : "postgresql://username:password@localhost:5432/database"
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
234 },
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
235 "Plugins" : [
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
236 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so",
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
237 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so"
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
238 ]
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
239 }
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
240
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
241 Obviously, one must be very cautious when sharing the same database
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
242 between instances of Orthanc. In particular, all these instances
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
243 should share the same configuration.
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
244
270
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
245 Furthermore, the core of Orthanc does not currently support the replay
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
246 of database transactions, which is necessary to deal with conflicts
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
247 between several instances of Orthanc that would simultaneously write
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
248 to the database.
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
249
290
6cbcdb965ad3 Orthanc 1.5.8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 270
diff changeset
250 As a consequence, as of Orthanc 1.5.8, when connecting multiple
270
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
251 Orthanc to a single database by setting ``Lock`` to ``false``, there
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
252 should only be one instance of Orthanc acting as a writer and all the
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
253 other instances of Orthanc acting as readers only. Be careful to set
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
254 the option ``SaveJobs`` to ``false`` in the configuration file of all
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
255 the instances of Orthanc acting as readers.
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
256
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
257 A refactoring is needed to improve the core of Orthanc in that
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
258 respect, for which we are looking for funding/donation from the
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
259 industry. Some issues reported in our bug tracker call for this
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
260 refactoring: `issue 83
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
261 <https://bitbucket.org/sjodogne/orthanc/issues/83/>`__, `issue 121
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
262 <https://bitbucket.org/sjodogne/orthanc/issues/121/>`__, `issue 151
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
263 <https://bitbucket.org/sjodogne/orthanc/issues/151/>`__.
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
264
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
265
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
266
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
267 Keep-alive
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
268 ^^^^^^^^^^
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
269
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
270 .. highlight:: text
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
271
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
272 After some period of inactivity (users have reported 10 hours), you
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
273 might `experience an error
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
274 <https://bitbucket.org/sjodogne/orthanc/issues/15/postgresql-exceptions-after-time>`__
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
275 such as::
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
276
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
277 E0220 03:20:51.562601 PluginsManager.cpp:163] Exception in database back-end: Error in PostgreSQL: server closed the connection unexpectedly.
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
278 This probably means the server terminated abnormally before or while processing the request.
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
279 E0220 06:51:03.924868 PluginsManager.cpp:163] Exception in database back-end: Error in PostgreSQL: no connection to the server
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
280
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
281 This is due to a timeout in the PostgreSQL server. Please make sure to
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
282 `enable keep-alive
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
283 <http://dba.stackexchange.com/questions/97534/is-there-a-timeout-option-for-remote-access-to-postgresql-database>`__
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
284 in the configuration of your PostgreSQL server