Skip to main content

How to Upgrade PostgreSQL from 9.6 to 10.0 on Ubuntu 16


A Step-by-Step Guide to upgrade postgresql from 9-6 to 10 on ubuntu 16

1.Make a backup. Make sure that your database is not being updated.

  pg_dumpall > outputfile

 2. Install Postgres 10.
            a) Create the file /etc/apt/sources.list.d/pgdg.list and add a line for the repository
                   deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main
         
            b) Import the repository signing key, and update the package lists
                  wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt-get update

3. Run sudo apt-get install postgresql-10. A newer version will be installed side-by-side with the earlier version.

4. Run pg_lsclusters:

Ver  Cluster   Port     Status  Owner      Data        directory Log file
9.6   main       5433    online    postgres   /9.6/main   /var/log/postgresql/postgresql-9.6-main.log
10    main       5432    online   postgres   /10/main   /var/log/postgresql/postgresql-10-main.log

There already is a cluster main for 10 (since this is created by default on package installation). This is done so that a fresh installation works out of the box without the need to create a cluster first, but of course it clashes when you try to upgrade 9.6/main when 10/main also exists. The recommended procedure is to remove the 10 cluster with pg_dropcluster and then upgrade with pg_upgradecluster. 

5. Stop the 10 cluster and drop it: sudo pg_dropcluster 10 main --stop

6. Stop all processes and services writing to the database. Stop the database:
           sudo systemctl stop postgresql

7. Upgrade the 9.6 cluster: sudo pg_upgradecluster -m upgrade 9.6 main

8. Run pg_lsclusters. Your 9.6 cluster should now be "down", and the 10 cluster should be online at 5432:

Ver  Cluster   Port     Status  Owner      Data        directory Log file
9.6   main       5433    down    postgres   /9.6/main   /var/log/postgresql/postgresql-9.6-main.log
10    main       5432    online   postgres   /10/main   /var/log/postgresql/postgresql-10-main.log

Comments

Popular posts from this blog

When Should Developers Use AI to Plan vs Just Start Coding?

When and How Should Developers Use AI — Plan First or Start Generating Code? Last week, a developer on our team opened an AI tool before writing a single line of code. The task? Change a button label. A few minutes later, the AI had suggested architecture improvements, refactoring strategies, testing layers, and performance considerations… for a one-line change. We laughed. But it revealed something important: Using AI isn’t the challenge anymore. Knowing  when and how  to use it is. The Real Decision: Generate Code or Think First? Today, developers face a new daily choice: Should I ask AI to generate code right away… or should I use AI to help me plan first? Starting with code feels fast. It gives you that dopamine hit of "done." But without clarity, rapid generation often leads to rework, hidden bugs, and "spaghetti code" that just happens to be syntax-perfect. Great developers use AI differently. They decide  whether the problem needs thinking or typing . A memor...

Securing Your Emails: A Simple Guide to Email Authentication and Best Practices

Email security is crucial in today's digital landscape, and implementing authentication measures like DMARC, SPF, and DKIM can go a long way in safeguarding your domain. Here's an easy-to-follow guide to ensure your emails are authenticated and delivered securely: 1. Implement DMARC, SPF, and DKIM: Follow these steps for popular email services: Postmark Refer to the instructions provided in this link SendGrid Check the relevant information on their platform. Mailchimp Follow the recommended steps on their platform. 2. Validate Forward and Reverse DNS Records: Make sure your sending domains or IPs have valid forward and reverse DNS records (PTR records). Check resources for each service: Postmark Provides coverage for this aspect. SendGrid  Find the necessary information here Mailchimp Follow the guidelines specified by Mailchimp. 3. Maintain Low Spam Rates: Keep spam rates below 0.3% in Postmaster Tools and consider configuring Google Postmaster for additional insights into...

Sending Emails in Laravel with Gmail SMTP

This post will help you to fix issue like  Error : Swift_TransportException in StreamBuffer . php line 268 : Connection could not be established with host smtp . gmail . com [ Connection refused #111] Sending emails is crucial for any web application. Usually, an email is sent to notify the user of some kind of activity.Here are the steps to send email in laravel using Gmail SMTP. Generally Gmail is not recommended to send emails on live server, but if you just using it for testing purpose then follow these steps: 1. Visit   https://myaccount.google.com/security   make sure you have allowed  less secure app  to YES. 2. Unlock captcha on  https://accounts.google.com/b/0/DisplayUnlockCaptcha . 3. Generate APP password  Turn on 2-Step Verification for your account  https://myaccount.google.com/security. Your app might not support the latest security standards. Try changing a few settings to allow less secure...