comparison 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
comparison
equal deleted inserted replaced
153:008091376e7a 154:365427cebb64
21 Static linking 21 Static linking
22 ^^^^^^^^^^^^^^ 22 ^^^^^^^^^^^^^^
23 23
24 .. highlight:: text 24 .. highlight:: text
25 25
26 The procedure to compile these plugins is similar of that for the 26 The procedure to compile these plugins is similar to that for the
27 :ref:`core of Orthanc <compiling>`. The following commands should work 27 :ref:`core of Orthanc <compiling>`. The following commands should work
28 for every UNIX-like distribution (including GNU/Linux):: 28 for most UNIX-like distribution (including GNU/Linux)::
29 29
30 $ mkdir Build 30 $ mkdir BuildPostgreSQL
31 $ cd Build 31 $ cd BuildPostgreSQL
32 $ cmake .. -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE=Release 32 $ cmake ../PostgreSQL -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE=Release
33 $ make 33 $ make
34 34
35 The compilation will produce 2 shared libraries, each containing one plugin for Orthanc: 35 The compilation will produce 2 shared libraries, each containing one plugin for Orthanc:
36 36
37 * ``OrthancPostgreSQLIndex`` replaces the default SQLite index of Orthanc by PostgreSQL. 37 * ``OrthancPostgreSQLIndex`` replaces the default SQLite index of Orthanc by PostgreSQL.
56 If static linking is not desired, here are build instructions for 56 If static linking is not desired, here are build instructions for
57 Ubuntu 16.04 (provided build dependencies for the :ref:`core of 57 Ubuntu 16.04 (provided build dependencies for the :ref:`core of
58 Orthanc <compiling>` have already been installed):: 58 Orthanc <compiling>` have already been installed)::
59 59
60 $ sudo apt-get install libpq-dev postgresql-server-dev-all 60 $ sudo apt-get install libpq-dev postgresql-server-dev-all
61 $ cmake .. -DCMAKE_BUILD_TYPE=Release \ 61 $ mkdir BuildPostgreSQL
62 -DALLOW_DOWNLOADS=ON \ 62 $ cd BuildPostgreSQL
63 -DUSE_SYSTEM_GOOGLE_TEST=OFF \ 63 $ cmake ../PostgreSQL -DCMAKE_BUILD_TYPE=Release \
64 -DUSE_SYSTEM_ORTHANC_SDK=OFF 64 -DALLOW_DOWNLOADS=ON \
65 -DUSE_SYSTEM_GOOGLE_TEST=OFF \
66 -DUSE_SYSTEM_ORTHANC_SDK=OFF
65 $ make 67 $ make
66 68
67 69
68 Usage 70 Usage
69 ----- 71 -----
70 72
71 .. highlight:: json 73 .. highlight:: json
72 74
73 You of course first have to :ref:`install Orthanc <binaries>`, with a 75 You of course first have to :ref:`install Orthanc <binaries>`, with a
74 version above 0.9.1. You then have to **create a database** dedicated 76 version above 0.9.5. You then have to **create a database** dedicated
75 to Orthanc on some PostgreSQL server. Please refer to the `PostgreSQL 77 to Orthanc on some PostgreSQL server. Please refer to the `PostgreSQL
76 documentation 78 documentation
77 <https://www.postgresql.org/docs/current/static/tutorial-createdb.html>`__. 79 <https://www.postgresql.org/docs/current/static/tutorial-createdb.html>`__.
78 80
79 Once Orthanc is installed and the database is created, you must add a 81 Once Orthanc is installed and the database is created, you must add a
84 option. You could for instance adapt the following configuration 86 option. You could for instance adapt the following configuration
85 file:: 87 file::
86 88
87 { 89 {
88 "Name" : "MyOrthanc", 90 "Name" : "MyOrthanc",
89 [...]
90 "PostgreSQL" : { 91 "PostgreSQL" : {
91 "EnableIndex" : true, 92 "EnableIndex" : true,
92 "EnableStorage" : true, 93 "EnableStorage" : true,
93 "Host" : "localhost", 94 "Host" : "localhost",
94 "Port" : 5432, 95 "Port" : 5432,
95 "Database" : "orthanc", 96 "Database" : "orthanc",
96 "Username" : "orthanc", 97 "Username" : "orthanc",
97 "Password" : "orthanc" 98 "Password" : "orthanc"
98 }, 99 },
99 "Plugins" : [ 100 "Plugins" : [
100 "/home/user/OrthancPostgreSQL/Build/libOrthancPostgreSQLIndex.so", 101 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so",
101 "/home/user/OrthancPostgreSQL/Build/libOrthancPostgreSQLStorage.so" 102 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so"
102 ] 103 ]
103 } 104 }
104 105
105 Note that ``EnableIndex`` and ``EnableStorage`` must be explicitly set 106 **Important:** The ``EnableIndex`` and ``EnableStorage`` options must
106 to true, otherwise Orthanc will continue to use its default SQLite 107 be explicitly set to ``true``, otherwise Orthanc will continue to use
107 back-end. 108 its default SQLite back-end and the filesystem storage area.
108 109
109 **Remark:** When using the ``Storage`` PostgreSQL plugin, the DICOM files are stored as large objects in the database. This might actually consume more space than the DICOM file itself. We have observed overhead up to 40%. However, it seems this overhead is temporary and comes from Write-Ahead Logging. Check this `discussion <https://groups.google.com/d/msg/orthanc-users/pPzHOpb--iw/QkKZ808gIgAJ>`__ on the Orthanc Users group for more info). 110 **Remark:** When using the ``Storage`` PostgreSQL plugin, the DICOM
110 111 files are stored as large objects in the database. This might
111 Note that a typical usage of the PostgreSQL plugin is to enable only the ``Index`` and continue using the default filesystem storage for DICOM files. 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).
117
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.
112 121
113 122
114 123
115 .. highlight:: text 124 .. highlight:: text
116 125
119 128
120 $ ./Orthanc Configuration.json 129 $ ./Orthanc Configuration.json
121 W0212 16:30:34.576972 11285 main.cpp:632] Orthanc version: 0.8.6 130 W0212 16:30:34.576972 11285 main.cpp:632] Orthanc version: 0.8.6
122 W0212 16:30:34.577386 11285 OrthancInitialization.cpp:80] Using the configuration from: Configuration.json 131 W0212 16:30:34.577386 11285 OrthancInitialization.cpp:80] Using the configuration from: Configuration.json
123 [...] 132 [...]
124 W0212 16:30:34.598053 11285 main.cpp:379] Registering a plugin from: /home/jodogne/Subversion/OrthancPostgreSQL/Build/libOrthancPostgreSQLIndex.so 133 W0212 16:30:34.598053 11285 main.cpp:379] Registering a plugin from: /home/jodogne/Subversion/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so
125 W0212 16:30:34.598470 11285 PluginsManager.cpp:258] Registering plugin 'postgresql-index' (version 1.0) 134 W0212 16:30:34.598470 11285 PluginsManager.cpp:258] Registering plugin 'postgresql-index' (version 1.0)
126 W0212 16:30:34.598491 11285 PluginsManager.cpp:148] Using PostgreSQL index 135 W0212 16:30:34.598491 11285 PluginsManager.cpp:148] Using PostgreSQL index
127 W0212 16:30:34.608289 11285 main.cpp:379] Registering a plugin from: /home/jodogne/Subversion/OrthancPostgreSQL/Build/libOrthancPostgreSQLStorage.so 136 W0212 16:30:34.608289 11285 main.cpp:379] Registering a plugin from: /home/jodogne/Subversion/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so
128 W0212 16:30:34.608916 11285 PluginsManager.cpp:258] Registering plugin 'postgresql-storage' (version 1.0) 137 W0212 16:30:34.608916 11285 PluginsManager.cpp:258] Registering plugin 'postgresql-storage' (version 1.0)
129 W0212 16:30:34.608947 11285 PluginsManager.cpp:148] Using PostgreSQL storage area 138 W0212 16:30:34.608947 11285 PluginsManager.cpp:148] Using PostgreSQL storage area
130 [...] 139 [...]
131 W0212 16:30:34.674648 11285 main.cpp:530] Orthanc has started 140 W0212 16:30:34.674648 11285 main.cpp:530] Orthanc has started
132 141
138 <https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING>`__. For 147 <https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING>`__. For
139 instance:: 148 instance::
140 149
141 { 150 {
142 "Name" : "MyOrthanc", 151 "Name" : "MyOrthanc",
143 [...]
144 "PostgreSQL" : { 152 "PostgreSQL" : {
145 "EnableIndex" : true, 153 "EnableIndex" : true,
146 "EnableStorage" : true, 154 "EnableStorage" : true,
147 "ConnectionUri" : "postgresql://username:password@localhost:5432/database" 155 "ConnectionUri" : "postgresql://username:password@localhost:5432/database"
148 }, 156 },
149 "Plugins" : [ 157 "Plugins" : [
150 "/home/user/OrthancPostgreSQL/Build/libOrthancPostgreSQLIndex.so", 158 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so",
151 "/home/user/OrthancPostgreSQL/Build/libOrthancPostgreSQLStorage.so" 159 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so"
152 ] 160 ]
153 } 161 }
154 162
155 163
156 **Remark:** The Debian Med project maintains `another useful set of 164 **Remark:** The Debian Med project maintains `another useful set of
178 database, set the ``Lock`` option to ``false`` in the configuration 186 database, set the ``Lock`` option to ``false`` in the configuration
179 file:: 187 file::
180 188
181 { 189 {
182 "Name" : "MyOrthanc", 190 "Name" : "MyOrthanc",
183 [...]
184 "PostgreSQL" : { 191 "PostgreSQL" : {
185 "EnableIndex" : true, 192 "EnableIndex" : true,
186 "EnableStorage" : true, 193 "EnableStorage" : true,
187 "Lock" : false, 194 "Lock" : false,
188 "ConnectionUri" : "postgresql://username:password@localhost:5432/database" 195 "ConnectionUri" : "postgresql://username:password@localhost:5432/database"
189 }, 196 },
190 "Plugins" : [ 197 "Plugins" : [
191 "/home/user/OrthancPostgreSQL/Build/libOrthancPostgreSQLIndex.so", 198 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so",
192 "/home/user/OrthancPostgreSQL/Build/libOrthancPostgreSQLStorage.so" 199 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so"
193 ] 200 ]
194 } 201 }
195 202
196 Obviously, one must be very cautious when sharing the same database 203 Obviously, one must be very cautious when sharing the same database
197 between instances of Orthanc. In particular, all these instances 204 between instances of Orthanc. In particular, all these instances