{"id":878,"date":"2019-03-28T22:26:45","date_gmt":"2019-03-28T15:26:45","guid":{"rendered":"https:\/\/trichev.com\/blog\/?p=878"},"modified":"2019-03-28T22:33:48","modified_gmt":"2019-03-28T15:33:48","slug":"postgresql-upgrade-on-red-hat-7","status":"publish","type":"post","link":"https:\/\/trichev.com\/blog\/2019\/03\/28\/postgresql-upgrade-on-red-hat-7\/","title":{"rendered":"PostgreSQL upgrade on Red Hat 7"},"content":{"rendered":"<p><strong>Installation<\/strong><br \/>\nFollowing instructions from here https:\/\/www.postgresql.org\/download\/linux\/redhat\/:<br \/>\nSelect version: 9.6 (I needed 9.6 because of my specific product requirements)<br \/>\nSelect platform: RHEL7<br \/>\nInstall the repository RPM: <code>yum install https:\/\/download.postgresql.org\/pub\/repos\/yum\/9.6\/redhat\/rhel-7-x86_64\/pgdg-redhat96-9.6-3.noarch.rpm<\/code><br \/>\n<code><br \/>\nyum install postgresql96 postgresql96-server postgresql96-libs postgresql96-contrib<br \/>\n\/usr\/pgsql-9.6\/bin\/postgresql96-setup initdb<\/code><\/p>\n<p>My previous PostgreSQL was 9.2 and it was installed from RHEL repo, so all directories and configs are standards.<\/p>\n<p><strong>Upgrade<\/strong><br \/>\nThis is important! You can&#8217;t use pg_upgrade in this particular upgrade, because they *censored* changed &#8220;unix_socket_directory parameter&#8221; to &#8220;unix_socket_directories&#8221;. Check this out &#8211; https:\/\/www.postgresql.org\/docs\/9.3\/release-9-3.html#AEN114343. Luckily there&#8217;s a workaround:<\/p>\n<pre><code>mv \/usr\/bin\/pg_ctl{,-orig}\r\necho '#!\/bin\/bash' &gt; \/usr\/bin\/pg_ctl\r\necho '\"$0\"-orig \"${@\/unix_socket_directory\/unix_socket_directories}\"' &gt;&gt;  \/usr\/bin\/pg_ctl\r\nchmod +x \/usr\/bin\/pg_ctl\r\n<\/code><\/pre>\n<p>Let&#8217;s stop the old PostgreSQL 9.2 service and disable it<br \/>\n<code>systemctl stop postgresql<br \/>\nsystemctl disable postgresql<\/code><\/p>\n<p>Finally actual upgrade:<\/p>\n<pre><code>su - postgres\r\n#with --check first\r\n\/usr\/pgsql-9.6\/bin\/pg_upgrade --old-bindir=\/usr\/bin\/ --new-bindir=\/usr\/pgsql-9.6\/bin\/ --old-datadir=\/var\/lib\/pgsql\/data --new-datadir=\/var\/lib\/pgsql\/9.6\/data\/ --check\r\n#if everything is ok, then\r\n\/usr\/pgsql-9.6\/bin\/pg_upgrade --old-bindir=\/usr\/bin\/ --new-bindir=\/usr\/pgsql-9.6\/bin\/ --old-datadir=\/var\/lib\/pgsql\/data --new-datadir=\/var\/lib\/pgsql\/9.6\/data\/\r\n<\/code><\/pre>\n<p>Undo the &#8220;hack&#8221;:<br \/>\n<code>mv -f \/usr\/bin\/pg_ctl{-orig,}<\/code><\/p>\n<pre><code>systemctl enable postgresql-9.6\r\nsystemctl start postgresql-9.6\r\nsystemctl status postgresql-9.6\r\n<\/code><\/pre>\n<p>Let&#8217;s run this analyze_new_cluster.sh:<\/p>\n<pre><code>su - postgres\r\n\/var\/lib\/pgsql\/analyze_new_cluster.sh\r\n<\/code><\/pre>\n<p>and also check DB version<\/p>\n<pre><code>psql -d \r\nSHOW server_version;\r\n\\q\r\n<\/code><\/pre>\n<p>&nbsp;<br \/>\nLinks:<br \/>\n<a href=\"https:\/\/www.postgresql.org\/download\/linux\/redhat\/\">https:\/\/www.postgresql.org\/download\/linux\/redhat\/<\/a><br \/>\n<a href=\"https:\/\/dba.stackexchange.com\/questions\/50135\/pg-upgrade-unrecognized-configuration-parameter-unix-socket-directory\">https:\/\/dba.stackexchange.com\/questions\/50135\/pg-upgrade-unrecognized-configuration-parameter-unix-socket-directory<\/a><br \/>\n<a href=\"https:\/\/www.postgresql.org\/docs\/9.3\/release-9-3.html#AEN114343\">https:\/\/www.postgresql.org\/docs\/9.3\/release-9-3.html#AEN114343<\/a><br \/>\n<a href=\"https:\/\/support.code42.com\/Administrator\/6\/Planning_and_installing\/PostgreSQL_upgrade_on_Red_Hat\">https:\/\/support.code42.com\/Administrator\/6\/Planning_and_installing\/PostgreSQL_upgrade_on_Red_Hat<\/a><br \/>\n<a href=\"http:\/\/www.uptimemadeeasy.com\/databases\/upgrade-postgresql\/\">http:\/\/www.uptimemadeeasy.com\/databases\/upgrade-postgresql\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Installation Following instructions from here https:\/\/www.postgresql.org\/download\/linux\/redhat\/: Select version: 9.6 (I needed 9.6 because of my specific product requirements) Select platform: RHEL7 Install the repository RPM: yum install https:\/\/download.postgresql.org\/pub\/repos\/yum\/9.6\/redhat\/rhel-7-x86_64\/pgdg-redhat96-9.6-3.noarch.rpm yum install postgresql96 postgresql96-server postgresql96-libs postgresql96-contrib \/usr\/pgsql-9.6\/bin\/postgresql96-setup initdb My previous PostgreSQL was 9.2 and it was installed from RHEL repo, so all directories and configs are standards. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[32,260,86,14,11],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/posts\/878"}],"collection":[{"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/comments?post=878"}],"version-history":[{"count":5,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/posts\/878\/revisions"}],"predecessor-version":[{"id":883,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/posts\/878\/revisions\/883"}],"wp:attachment":[{"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/media?parent=878"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/categories?post=878"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trichev.com\/blog\/wp-json\/wp\/v2\/tags?post=878"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}