<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Ruslan&#39;s Tech Blog</title>
    <link>https://blog.bekenev.net/tags/postgres.html</link>
    <description>Software development related stuff</description>
    <language>en-us</language>
    <lastBuildDate>Sat, 26 Oct 2019 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://blog.bekenev.net/tags/postgres/feed.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Run multiple PostgreSQL instances on one machine</title>
      <link>https://blog.bekenev.net/2019/10/26/multiple-postgres-instances.html</link>
      <pubDate>Sat, 26 Oct 2019 00:00:00 +0000</pubDate>
      <guid>https://blog.bekenev.net/2019/10/26/multiple-postgres-instances.html</guid>
      <description>&lt;p&gt;I&amp;rsquo;m on Ubuntu 18.04 having PostgreSQL 10.10 installed.&#xA;For testing I had to run PostgreSQL 9.5 along with 10.10.&lt;/p&gt;&#xA;&lt;h1 id=&#34;installation&#34;&gt;Installation&lt;/h1&gt;&#xA;&lt;p&gt;If you don&amp;rsquo;t know how to install version 9 on Ubuntu 18.04 check &lt;a href=&#34;https://www.postgresql.org/download/linux/ubuntu/&#34;&gt;this doc on postgres site&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To install version 9.5 just run:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;sudo apt install postgresql-9.5&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;That&amp;rsquo;s it. You should not face any other issues.&lt;/p&gt;&#xA;&lt;h1 id=&#34;usage&#34;&gt;Usage&lt;/h1&gt;&#xA;&lt;p&gt;I&amp;rsquo;ve been always starting postgres instance with &lt;code&gt;sudo service postgresql start&lt;/code&gt; but now,&#xA;when we have two different version we should use:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;sudo systemctl start postgresql@9.5-main&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The &lt;code&gt;9.5-main&lt;/code&gt; at the end is the cluster name. Cluster is something we always have per database version. You can find all the clusters you have on your machine with:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;pg_lsclusters&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The output looks like this:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Ver Cluster Port Status Owner    Data directory               Log file&#xA;9.5 main    5432 online   postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log&#xA;10  main    5432 down postgres /var/lib/postgresql/10/main  /var/log/postgresql/postgresql-10-main.log&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can see that right now I have 9.5 running and 10 down.&lt;/p&gt;&#xA;&lt;p&gt;To run version 10 again just stop the 9.5 instance and run &lt;code&gt;sudo systemctl start postgresql@10-main&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;If you want to run both instances simultaneously then you have to edit &lt;code&gt;postgresql.conf&lt;/code&gt; of your version&#xA;(every version&amp;rsquo;s config file is in its own directory under &lt;code&gt;/etc/postgresql&lt;/code&gt;) and set another port to listen in one of your versions.&lt;/p&gt;&#xA;</description>
    </item>
  </channel>
</rss>
