{"id":12471,"date":"2019-05-30T11:41:01","date_gmt":"2019-05-30T09:41:01","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/"},"modified":"2019-05-30T11:41:01","modified_gmt":"2019-05-30T09:41:01","slug":"can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/","title":{"rendered":"Can you start two (or more) PostgreSQL instances against the same data directory?"},"content":{"rendered":"<p>As PostgreSQL does not know the concept of running multiple instances against the same files on disk (e.g. like Oracle RAC) it should not be possible to start two or more instances against the same data directory. If that would work the result can only be corruption. In this post we will look at how PostgreSQL is detecting that and what mechanism are build in to avoid the situation of having multiple instances working against the same files on disk.<\/p>\n<p><!--more--><\/p>\n<p>To start with we create a new cluster:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] mkdir \/var\/tmp\/pgtest\n12:16:46 postgres@rhel8pg:\/home\/postgres\/ [PGDEV] initdb -D \/var\/tmp\/pgtest\/\nThe files belonging to this database system will be owned by user \"postgres\".\nThis user must also own the server process.\n\nThe database cluster will be initialized with locales\n  COLLATE:  en_US.utf8\n  CTYPE:    en_US.utf8\n  MESSAGES: en_US.utf8\n  MONETARY: de_CH.UTF-8\n  NUMERIC:  de_CH.UTF-8\n  TIME:     en_US.UTF-8\nThe default database encoding has accordingly been set to \"UTF8\".\nThe default text search configuration will be set to \"english\".\n\nData page checksums are disabled.\n\nfixing permissions on existing directory \/var\/tmp\/pgtest ... ok\ncreating subdirectories ... ok\nselecting dynamic shared memory implementation ... posix\nselecting default max_connections ... 100\nselecting default shared_buffers ... 128MB\nselecting default timezone ... Europe\/Zurich\ncreating configuration files ... ok\nrunning bootstrap script ... ok\nperforming post-bootstrap initialization ... ok\nsyncing data to disk ... ok\n\ninitdb: warning: enabling \"trust\" authentication for local connections\nYou can change this by editing pg_hba.conf or using the option -A, or\n--auth-local and --auth-host, the next time you run initdb.\n\nSuccess. You can now start the database server using:\n\n    pg_ctl -D \/var\/tmp\/pgtest\/ -l logfile start\n<\/pre>\n<p>We use a dedicated port and then start it up:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] export PGPORT=8888\npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] pg_ctl -D \/var\/tmp\/pgtest start\nwaiting for server to start....2019-05-16 12:17:22.399 CEST [7607] LOG:  starting PostgreSQL 12devel on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3), 64-bit\n2019-05-16 12:17:22.403 CEST [7607] LOG:  listening on IPv6 address \"::1\", port 8888\n2019-05-16 12:17:22.403 CEST [7607] LOG:  listening on IPv4 address \"127.0.0.1\", port 8888\n2019-05-16 12:17:22.409 CEST [7607] LOG:  listening on Unix socket \"\/tmp\/.s.PGSQL.8888\"\n2019-05-16 12:17:22.446 CEST [7608] LOG:  database system was shut down at 2019-05-16 12:16:54 CEST\n2019-05-16 12:17:22.455 CEST [7607] LOG:  database system is ready to accept connections\n done\nserver started\n\npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] psql -p 8888 -c \"select version()\" postgres\n                                                  version                                                  \n-----------------------------------------------------------------------------------------------------------\n PostgreSQL 12devel on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3), 64-bit\n(1 row)\n<\/pre>\n<p>What happens when we want to start another instance against that data directory?<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] pg_ctl -D \/var\/tmp\/pgtest start\npg_ctl: another server might be running; trying to start server anyway\nwaiting for server to start....2019-05-16 12:18:26.252 CEST [7629] FATAL:  lock file \"postmaster.pid\" already exists\n2019-05-16 12:18:26.252 CEST [7629] HINT:  Is another postmaster (PID 7607) running in data directory \"\/var\/tmp\/pgtest\"?\n stopped waiting\npg_ctl: could not start server\nExamine the log output.\n<\/pre>\n<p>When PostgreSQL is starting up it will look at a file called &#8220;postmaster.pid&#8221; which exists in the data directory once the instance is started. If that file exists PostgreSQL will not start up another instance against the same data directory. Once the instance is stopped the file is removed:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] pg_ctl -D \/var\/tmp\/pgtest\/ stop\nwaiting for server to shut down....2019-05-16 12:48:50.636 CEST [7896] LOG:  received fast shutdown request\n2019-05-16 12:48:50.641 CEST [7896] LOG:  aborting any active transactions\n2019-05-16 12:48:50.651 CEST [7896] LOG:  background worker \"logical replication launcher\" (PID 7903) exited with exit code 1\n2019-05-16 12:48:50.651 CEST [7898] LOG:  shutting down\n2019-05-16 12:48:50.685 CEST [7896] LOG:  database system is shut down\n done\nserver stopped\npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] ls -al \/var\/tmp\/pgtest\/postmaster.pid\nls: cannot access '\/var\/tmp\/pgtest\/postmaster.pid': No such file or directory\n<\/pre>\n<p>At least by default this is not possible to start two or more instances as PostgreSQL checks if postmaster.pid already exists. Lets remove that file and try again:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] rm \/var\/tmp\/pgtest\/postmaster.pid\npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] pg_ctl -D \/var\/tmp\/pgtest start\nwaiting for server to start....2019-05-16 12:20:17.754 CEST [7662] LOG:  starting PostgreSQL 12devel on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3), 64-bit\n2019-05-16 12:20:17.756 CEST [7662] LOG:  could not bind IPv6 address \"::1\": Address already in use\n2019-05-16 12:20:17.756 CEST [7662] HINT:  Is another postmaster already running on port 8888? If not, wait a few seconds and retry.\n2019-05-16 12:20:17.756 CEST [7662] LOG:  could not bind IPv4 address \"127.0.0.1\": Address already in use\n2019-05-16 12:20:17.756 CEST [7662] HINT:  Is another postmaster already running on port 8888? If not, wait a few seconds and retry.\n2019-05-16 12:20:17.756 CEST [7662] WARNING:  could not create listen socket for \"localhost\"\n2019-05-16 12:20:17.756 CEST [7662] FATAL:  could not create any TCP\/IP sockets\n2019-05-16 12:20:17.756 CEST [7662] LOG:  database system is shut down\n stopped waiting\npg_ctl: could not start server\nExamine the log output.\n<\/pre>\n<p>Again, this does not work and even the initial instance was shutdown because PostgreSQL detected that the lock file is not there anymore:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\n2019-05-16 12:20:22.540 CEST [7607] LOG:  could not open file \"postmaster.pid\": No such file or directory\n2019-05-16 12:20:22.540 CEST [7607] LOG:  performing immediate shutdown because data directory lock file is invalid\n2019-05-16 12:20:22.540 CEST [7607] LOG:  received immediate shutdown request\n2019-05-16 12:20:22.540 CEST [7607] LOG:  could not open file \"postmaster.pid\": No such file or directory\n2019-05-16 12:20:22.544 CEST [7612] WARNING:  terminating connection because of crash of another server process\n2019-05-16 12:20:22.544 CEST [7612] DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.\n2019-05-16 12:20:22.544 CEST [7612] HINT:  In a moment you should be able to reconnect to the database and repeat your command.\n2019-05-16 12:20:22.549 CEST [7664] WARNING:  terminating connection because of crash of another server process\n2019-05-16 12:20:22.549 CEST [7664] DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.\n<\/pre>\n<p>Lets start the first instance again:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] pg_ctl -D \/var\/tmp\/pgtest\/ start\nwaiting for server to start....2019-05-16 12:22:20.136 CEST [7691] LOG:  starting PostgreSQL 12devel on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3), 64-bit\n2019-05-16 12:22:20.140 CEST [7691] LOG:  listening on IPv6 address \"::1\", port 8888\n2019-05-16 12:22:20.140 CEST [7691] LOG:  listening on IPv4 address \"127.0.0.1\", port 8888\n2019-05-16 12:22:20.148 CEST [7691] LOG:  listening on Unix socket \"\/tmp\/.s.PGSQL.8888\"\n2019-05-16 12:22:20.193 CEST [7693] LOG:  database system was interrupted; last known up at 2019-05-16 12:17:22 CEST\n.2019-05-16 12:22:21.138 CEST [7693] LOG:  database system was not properly shut down; automatic recovery in progress\n2019-05-16 12:22:21.143 CEST [7693] LOG:  redo starts at 0\/15D3420\n2019-05-16 12:22:21.143 CEST [7693] LOG:  invalid record length at 0\/15D3458: wanted 24, got 0\n2019-05-16 12:22:21.143 CEST [7693] LOG:  redo done at 0\/15D3420\n2019-05-16 12:22:21.173 CEST [7691] LOG:  database system is ready to accept connections\n done\nserver started\n\npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] psql -p 8888 -c \"select version()\" postgres\n                                                  version                                                  \n-----------------------------------------------------------------------------------------------------------\n PostgreSQL 12devel on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3), 64-bit\n(1 row)\n<\/pre>\n<p>Lets change the port for the second instance and then try again to start it against the same data directory:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] export PGPORT=8889\npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] pg_ctl -D \/var\/tmp\/pgtest\/ start\npg_ctl: another server might be running; trying to start server anyway\nwaiting for server to start....2019-05-16 12:24:41.700 CEST [7754] FATAL:  lock file \"postmaster.pid\" already exists\n2019-05-16 12:24:41.700 CEST [7754] HINT:  Is another postmaster (PID 7741) running in data directory \"\/var\/tmp\/pgtest\"?\n stopped waiting\npg_ctl: could not start server\nExamine the log output.\n<\/pre>\n<p>Does not work as well, which is good. Lets be a bit more nasty and truncate the postmaster.pid file:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] cat \/var\/tmp\/pgtest\/postmaster.pid \n7790\n\/var\/tmp\/pgtest\n1558002434\n8888\n\/tmp\nlocalhost\n  8888001    819201\nready   \npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] cat \/dev\/null &gt; \/var\/tmp\/pgtest\/postmaster.pid\npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] cat \/var\/tmp\/pgtest\/postmaster.pid\n<\/pre>\n<p>The pid file is now empty and right after emptying that file we can see this in the PostgreSQL log file:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\n019-05-16 12:30:14.140 CEST [7790] LOG:  lock file \"postmaster.pid\" contains wrong PID: 0 instead of 7790\n2019-05-16 12:30:14.140 CEST [7790] LOG:  performing immediate shutdown because data directory lock file is invalid\n2019-05-16 12:30:14.140 CEST [7790] LOG:  received immediate shutdown request\n2019-05-16 12:30:14.149 CEST [7795] WARNING:  terminating connection because of crash of another server process\n2019-05-16 12:30:14.149 CEST [7795] DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.\n2019-05-16 12:30:14.149 CEST [7795] HINT:  In a moment you should be able to reconnect to the database and repeat your command.\n2019-05-16 12:30:14.160 CEST [7790] LOG:  database system is shut down\n<\/pre>\n<p>So even that case it is detected and PostgreSQL protects you from starting up another instance against the same data directory. Lets try something else and modify PGDATA in the postmaster.pid file:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] cat \/var\/tmp\/pgtest\/postmaster.pid \n7896\n\/var\/tmp\/pgtest\n1558002751\n8888\n\/tmp\nlocalhost\n  8888001    851969\nready   \n\npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] sed -i  's\/\/var\/tmp\/pgtest\/\/var\/tmp\/pgtest2\/g' \/var\/tmp\/pgtest\/postmaster.pid \npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] cat \/var\/tmp\/pgtest\/postmaster.pid\n7896\n\/var\/tmp\/pgtest2\n1558002751\n8888\n\/tmp\nlocalhost\n  8888001    851969\nready   \n<\/pre>\n<p>Although we changed PGDATA PostgreSQL will not start up another instance against this data directory:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@rhel8pg:\/home\/postgres\/ [PGDEV] pg_ctl -D \/var\/tmp\/pgtest\/ start\npg_ctl: another server might be running; trying to start server anyway\nwaiting for server to start....2019-05-16 12:35:28.540 CEST [7973] FATAL:  lock file \"postmaster.pid\" already exists\n2019-05-16 12:35:28.540 CEST [7973] HINT:  Is another postmaster (PID 7896) running in data directory \"\/var\/tmp\/pgtest\"?\n stopped waiting\npg_ctl: could not start server\nExamine the log output.\n<\/pre>\n<p>So by default you can not get PostgreSQL to start two or even more instances against the same data directory. There is an comment about this behaviour in src\/backend\/postmaster\/postmaster.c in the source code:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\n                \/*\n                 * Once a minute, verify that postmaster.pid hasn't been removed or\n                 * overwritten.  If it has, we force a shutdown.  This avoids having\n                 * postmasters and child processes hanging around after their database\n                 * is gone, and maybe causing problems if a new database cluster is\n                 * created in the same place.  It also provides some protection\n                 * against a DBA foolishly removing postmaster.pid and manually\n                 * starting a new postmaster.  Data corruption is likely to ensue from\n                 * that anyway, but we can minimize the damage by aborting ASAP.\n                 *\/\n<\/pre>\n<p>&#8220;Once a minute&#8221; might be critical and we might be able to start a second one if we are fast enough, so lets try again. This time we start the first one, remove the lock file and immediately start another one using another port:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\nexport PGPORT=8888\npg_ctl -D \/var\/tmp\/pgtest start\nrm -f \/var\/tmp\/pgtest\/postmaster.pid\nexport PGPORT=8889\npg_ctl -D \/var\/tmp\/pgtest start\n<\/pre>\n<p>And here you have it:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@rhel8pg:\/home\/postgres\/ [pg120] ps -ef | grep postgres\npostgres  1445     1  0 May27 ?        00:00:00 \/usr\/lib\/systemd\/systemd --user\npostgres  1456  1445  0 May27 ?        00:00:00 (sd-pam)\nroot      9780   786  0 06:09 ?        00:00:00 sshd: postgres [priv]\npostgres  9783  9780  0 06:09 ?        00:00:00 sshd: postgres@pts\/1\npostgres  9784  9783  0 06:09 pts\/1    00:00:00 -bash\npostgres 10302     1  0 06:19 ?        00:00:00 \/u01\/app\/postgres\/product\/DEV\/db_1\/bin\/postgres -D \/var\/tmp\/pgtest\npostgres 10304 10302  0 06:19 ?        00:00:00 postgres: checkpointer   \npostgres 10305 10302  0 06:19 ?        00:00:00 postgres: background writer   \npostgres 10306 10302  0 06:19 ?        00:00:00 postgres: walwriter   \npostgres 10307 10302  0 06:19 ?        00:00:00 postgres: autovacuum launcher   \npostgres 10308 10302  0 06:19 ?        00:00:00 postgres: stats collector   \npostgres 10309 10302  0 06:19 ?        00:00:00 postgres: logical replication launcher   \npostgres 10313     1  0 06:19 ?        00:00:00 \/u01\/app\/postgres\/product\/DEV\/db_1\/bin\/postgres -D \/var\/tmp\/pgtest\npostgres 10315 10313  0 06:19 ?        00:00:00 postgres: checkpointer   \npostgres 10316 10313  0 06:19 ?        00:00:00 postgres: background writer   \npostgres 10317 10313  0 06:19 ?        00:00:00 postgres: walwriter   \npostgres 10318 10313  0 06:19 ?        00:00:00 postgres: autovacuum launcher   \npostgres 10319 10313  0 06:19 ?        00:00:00 postgres: stats collector   \npostgres 10320 10313  0 06:19 ?        00:00:00 postgres: logical replication launcher   \npostgres 10327  9784  0 06:19 pts\/1    00:00:00 ps -ef\n<\/pre>\n<p>Conclusion: PostgreSQL does some basic checks to avoid starting two instances against the same files on disk. But if you really want (and of course you should never do that) then you can achieve that =&gt; with all the consequences! Don&#8217;t do it!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As PostgreSQL does not know the concept of running multiple instances against the same files on disk (e.g. like Oracle RAC) it should not be possible to start two or more instances against the same data directory. If that would work the result can only be corruption. In this post we will look at how [&hellip;]<\/p>\n","protected":false},"author":29,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[229],"tags":[77],"type_dbi":[],"class_list":["post-12471","post","type-post","status-publish","format-standard","hentry","category-database-administration-monitoring","tag-postgresql"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Can you start two (or more) PostgreSQL instances against the same data directory? - dbi Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Can you start two (or more) PostgreSQL instances against the same data directory?\" \/>\n<meta property=\"og:description\" content=\"As PostgreSQL does not know the concept of running multiple instances against the same files on disk (e.g. like Oracle RAC) it should not be possible to start two or more instances against the same data directory. If that would work the result can only be corruption. In this post we will look at how [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-05-30T09:41:01+00:00\" \/>\n<meta name=\"author\" content=\"Daniel Westermann\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@westermanndanie\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Daniel Westermann\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/\"},\"author\":{\"name\":\"Daniel Westermann\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d08e9bd996a89bd75c0286cbabf3c66\"},\"headline\":\"Can you start two (or more) PostgreSQL instances against the same data directory?\",\"datePublished\":\"2019-05-30T09:41:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/\"},\"wordCount\":472,\"commentCount\":0,\"keywords\":[\"PostgreSQL\"],\"articleSection\":[\"Database Administration &amp; Monitoring\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/\",\"name\":\"Can you start two (or more) PostgreSQL instances against the same data directory? - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\"},\"datePublished\":\"2019-05-30T09:41:01+00:00\",\"author\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d08e9bd996a89bd75c0286cbabf3c66\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/www.dbi-services.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Can you start two (or more) PostgreSQL instances against the same data directory?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d08e9bd996a89bd75c0286cbabf3c66\",\"name\":\"Daniel Westermann\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/31350ceeecb1dd8986339a29bf040d4cd3cd087d410deccd8f55234466d6c317?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/31350ceeecb1dd8986339a29bf040d4cd3cd087d410deccd8f55234466d6c317?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/31350ceeecb1dd8986339a29bf040d4cd3cd087d410deccd8f55234466d6c317?s=96&d=mm&r=g\",\"caption\":\"Daniel Westermann\"},\"description\":\"Daniel Westermann is Principal Consultant and Technology Leader Open Infrastructure at dbi services. He has more than 15 years of experience in management, engineering and optimization of databases and infrastructures, especially on Oracle and PostgreSQL. Since the beginning of his career, he has specialized in Oracle Technologies and is Oracle Certified Professional 12c and Oracle Certified Expert RAC\/GridInfra. Over time, Daniel has become increasingly interested in open source technologies, becoming \u201cTechnology Leader Open Infrastructure\u201d and PostgreSQL expert. \u00a0Based on community or EnterpriseDB tools, he develops and installs complex high available solutions with PostgreSQL. He is also a certified PostgreSQL Plus 9.0 Professional and a Postgres Advanced Server 9.4 Professional. He is a regular speaker at PostgreSQL conferences in Switzerland and Europe. Today Daniel is also supporting our customers on AWS services such as AWS RDS, database migrations into the cloud, EC2 and automated infrastructure management with AWS SSM (System Manager). He is a certified AWS Solutions Architect Professional. Prior to dbi services, Daniel was Management System Engineer at LC SYSTEMS-Engineering AG in Basel. Before that, he worked as Oracle Developper &amp;\u00a0Project Manager at Delta Energy Solutions AG in Basel (today Powel AG). Daniel holds a diploma in Business Informatics (DHBW, Germany). His branch-related experience mainly covers the pharma industry, the financial sector, energy, lottery and telecommunications.\",\"sameAs\":[\"https:\/\/x.com\/westermanndanie\"],\"url\":\"https:\/\/www.dbi-services.com\/blog\/author\/daniel-westermann\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Can you start two (or more) PostgreSQL instances against the same data directory? - dbi Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/","og_locale":"en_US","og_type":"article","og_title":"Can you start two (or more) PostgreSQL instances against the same data directory?","og_description":"As PostgreSQL does not know the concept of running multiple instances against the same files on disk (e.g. like Oracle RAC) it should not be possible to start two or more instances against the same data directory. If that would work the result can only be corruption. In this post we will look at how [&hellip;]","og_url":"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/","og_site_name":"dbi Blog","article_published_time":"2019-05-30T09:41:01+00:00","author":"Daniel Westermann","twitter_card":"summary_large_image","twitter_creator":"@westermanndanie","twitter_misc":{"Written by":"Daniel Westermann","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/"},"author":{"name":"Daniel Westermann","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d08e9bd996a89bd75c0286cbabf3c66"},"headline":"Can you start two (or more) PostgreSQL instances against the same data directory?","datePublished":"2019-05-30T09:41:01+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/"},"wordCount":472,"commentCount":0,"keywords":["PostgreSQL"],"articleSection":["Database Administration &amp; Monitoring"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/","url":"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/","name":"Can you start two (or more) PostgreSQL instances against the same data directory? - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2019-05-30T09:41:01+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d08e9bd996a89bd75c0286cbabf3c66"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/can-you-start-two-or-more-postgresql-instances-against-the-same-data-directory\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Can you start two (or more) PostgreSQL instances against the same data directory?"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d08e9bd996a89bd75c0286cbabf3c66","name":"Daniel Westermann","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/31350ceeecb1dd8986339a29bf040d4cd3cd087d410deccd8f55234466d6c317?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/31350ceeecb1dd8986339a29bf040d4cd3cd087d410deccd8f55234466d6c317?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/31350ceeecb1dd8986339a29bf040d4cd3cd087d410deccd8f55234466d6c317?s=96&d=mm&r=g","caption":"Daniel Westermann"},"description":"Daniel Westermann is Principal Consultant and Technology Leader Open Infrastructure at dbi services. He has more than 15 years of experience in management, engineering and optimization of databases and infrastructures, especially on Oracle and PostgreSQL. Since the beginning of his career, he has specialized in Oracle Technologies and is Oracle Certified Professional 12c and Oracle Certified Expert RAC\/GridInfra. Over time, Daniel has become increasingly interested in open source technologies, becoming \u201cTechnology Leader Open Infrastructure\u201d and PostgreSQL expert. \u00a0Based on community or EnterpriseDB tools, he develops and installs complex high available solutions with PostgreSQL. He is also a certified PostgreSQL Plus 9.0 Professional and a Postgres Advanced Server 9.4 Professional. He is a regular speaker at PostgreSQL conferences in Switzerland and Europe. Today Daniel is also supporting our customers on AWS services such as AWS RDS, database migrations into the cloud, EC2 and automated infrastructure management with AWS SSM (System Manager). He is a certified AWS Solutions Architect Professional. Prior to dbi services, Daniel was Management System Engineer at LC SYSTEMS-Engineering AG in Basel. Before that, he worked as Oracle Developper &amp;\u00a0Project Manager at Delta Energy Solutions AG in Basel (today Powel AG). Daniel holds a diploma in Business Informatics (DHBW, Germany). His branch-related experience mainly covers the pharma industry, the financial sector, energy, lottery and telecommunications.","sameAs":["https:\/\/x.com\/westermanndanie"],"url":"https:\/\/www.dbi-services.com\/blog\/author\/daniel-westermann\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/12471","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=12471"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/12471\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=12471"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=12471"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=12471"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=12471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}