The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to upgrade PostgreSQL to 9.x on cPanel?

Discussion in 'Database Discussions' started by Zion Ahead, Feb 3, 2011.

  1. Zion Ahead

    Zion Ahead Well-Known Member

    Joined:
    Nov 10, 2006
    Messages:
    347
    Likes Received:
    0
    Trophy Points:
    16
    What is the easiest, sure way to upgrade Postgresql on a cpanel box to version 9.0 without losing current databases?
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Hello Zion,

    I'm not certain it is advisable to update to 9.x on cPanel, since postgres has not been set to work yet with cPanel interface, so it is possible that it might not function or it might end up not working with PhpPgAdmin either.

    Since postgres is installed by rpms, you can simply update the postgres rpms to a higher version. Here are the rpms I have on my system (I do have an older installation of postgres):

    Code:
    # rpm -qa|grep -i postgres
    postgresql-7.4.30-1.el4_8.1
    postgresql-libs-7.4.30-1.el4_8.1
    postgresql-devel-7.4.30-1.el4_8.1
    postgresql-server-7.4.30-1.el4_8.1
    Again, if you switch out to different rpms, you may break postgres working, so I would not advise doing this.

    You would want to copy your existing databases before proceeding by both taking a dump of the postgres databases and copying the /var/lib/pgsql files and folders:

    Code:
    su - postgres
    pg_dumpall > /tmp/pg110202
    exit
    cp -R /var/lib/pgsql /var/lib/pgsql.bak110202
    If you had to restore those databases, you'd do the following:

    Code:
    su - postgres
    psql -f /tmp/pg110202 template1
    exit
    Thanks.
     
  3. Zion Ahead

    Zion Ahead Well-Known Member

    Joined:
    Nov 10, 2006
    Messages:
    347
    Likes Received:
    0
    Trophy Points:
    16
    Thanks. I gave it a shot on v9 and it worked well, but now I have two versions installed?

    root@server7 [~]# rpm -qa|grep -i postgres
    postgresql-devel-8.1.22-1.el5_5.1
    postgresql90-server-9.0.2-2PGDG.rhel5
    postgresql-libs-8.1.22-1.el5_5.1
    postgresql90-libs-9.0.2-2PGDG.rhel5
    postgresql-libs-8.1.22-1.el5_5.1
    postgresql-server-8.1.22-1.el5_5.1
    postgresql90-devel-9.0.2-2PGDG.rhel5
    postgresql-8.1.22-1.el5_5.1
    postgresql-devel-8.1.22-1.el5_5.1
    postgresql90-9.0.2-2PGDG.rhel5
    root@server7 [~]# psql --version
    psql (PostgreSQL) 8.1.22
    contains support for command-line editing
     
  4. Zion Ahead

    Zion Ahead Well-Known Member

    Joined:
    Nov 10, 2006
    Messages:
    347
    Likes Received:
    0
    Trophy Points:
    16
    I'm afraid to do an rpm -e on the 8x version rpm's incase it deletes the databases
     
  5. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    You'd want to remove the old version rpms, which I'd suggest removing all the rpm again and then re-adding the new postgresql rpms. Again, if you have any issues, please revert to the old rpms again at that point.

    Next, you will probably need to restart postgres after switching the rpms to the new ones.

    Finally, it's possible there are changes for directory or data structures for this newer version, which I wouldn't know about and you'd need to research on their site to see any consequences for this change to the 9.x version.
     
  6. Zion Ahead

    Zion Ahead Well-Known Member

    Joined:
    Nov 10, 2006
    Messages:
    347
    Likes Received:
    0
    Trophy Points:
    16
    I deleted the 8x rpm's via rpm -e method.

    Now:

    Code:
    root@server7 [/scripts]# ./restartsrv_postgresql
    chown: `postgres:postgres': invalid user
    
    /var/lib/pgsql/9.0/data is missing. Use "service postgresql initdb" to initialize the cluster first.
                                                               [FAILED]
    root@server7 [/scripts]# service postgresql initdb
    postgresql: unrecognized service
    root@server7 [/scripts]# ./restartsrv_postgres
    
    /var/lib/pgsql/9.0/data is missing. Use "service postgresql initdb" to initialize the cluster first.
                                                               [FAILED]
    root@server7 [/scripts]# service postgresql initd
    postgresql: unrecognized service
    root@server7 [/scripts]# service postgresql-9.0 initdb
    Initializing database: chown: `postgres:postgres': invalid user
                                                               [FAILED]
    root@server7 [/scripts]# service postgresql-9.0 start
    
    /var/lib/pgsql/9.0/data is missing. Use "service postgresql initdb" to initialize the cluster first.
                                                               [FAILED]
    root@server7 [/scripts]# su - postgres
    su: user postgres does not exist
     
  7. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Since the user doesn't exist, you probably want to create the user now:

    Code:
    adduser postgres
    I did want to point out (as I already stated was the likely cause and warned about) that postgres 9 has a different directory structure:

    http://davidghedini.blogspot.com/2010/10/install-postgresql-9-on-centos.html

    This shows some of the differences. I really think going this route with a cPanel machine is the wrong path to take, but it is entirely your decision of course.
     
  8. Zion Ahead

    Zion Ahead Well-Known Member

    Joined:
    Nov 10, 2006
    Messages:
    347
    Likes Received:
    0
    Trophy Points:
    16
    Can someone help me upgrade to at least 8.4x?
     
  9. DavidGhedini

    DavidGhedini Registered

    Joined:
    Oct 18, 2011
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    #9 DavidGhedini, Oct 18, 2011
    Last edited: Oct 18, 2011
  10. hermit

    hermit Active Member

    Joined:
    Sep 22, 2004
    Messages:
    35
    Likes Received:
    1
    Trophy Points:
    8
    I need to upgrade to at least version 8.3 for a customer. Is there an upgrade path for the 8.4 rpms at this point? I'd prefer to go to 9 so I don't have to go through this again.

    Thanks
     
  11. hermit

    hermit Active Member

    Joined:
    Sep 22, 2004
    Messages:
    35
    Likes Received:
    1
    Trophy Points:
    8
    A thread at the bottom for an upgrade path from 8.1 to 8.3 was started over three years ago? I really need to do at least the 8.3. Should I just do a manual install and forget the 'supported option' at this point?

    Thank You
     
Loading...

Share This Page