Difference between revisions of "Updating PostgreSQL"

From Observer GigaFlow Support | VIAVI Solutions Inc.
Jump to: navigation, search
Line 1: Line 1:
 
It is possible to do a file system copy of postgres and use the db tools to perform an upgrade
 
It is possible to do a file system copy of postgres and use the db tools to perform an upgrade
 
Create a folder to contain the original data on the new target server
 
Create a folder to contain the original data on the new target server
  /opt/postgresql/orig/
+
  mkdir /opt/postgresql/orig/
  
 
On the source (orig) server, stop postgres and move the current (should be small) data folder
 
On the source (orig) server, stop postgres and move the current (should be small) data folder

Revision as of 08:50, 18 October 2016

It is possible to do a file system copy of postgres and use the db tools to perform an upgrade Create a folder to contain the original data on the new target server

mkdir /opt/postgresql/orig/

On the source (orig) server, stop postgres and move the current (should be small) data folder

/etc/init.d/postgresql-95 stop


Now perform the copy

cd /opt/
rsync -av postgresql root@172.21.40.132:/opt/postgresql/orig/

On the new server copy the existing data folder (just in case)

/etc/init.d/postgresql-95 stop
mv /opt/postgresql/pg95/data /opt/postgresql/pg95/orig95
mkdir /opt/postgresql/pg95/data
chown -R postgres:postgres /opt/postgresql/pg95/data

"su" to the postgres user

su - postgres

Create base db on server

/opt/postgresql/pg95/bin/initdb /opt/postgresql/pg95/data

Exist "su" on new server and start service

exit
mkdir /opt/postgresql/pg95/data/pg_log
chown postgres:postgres /opt/postgresql/pg95/data/pg_log
/etc/init.d/postgresql-95 start

On the new server run the following

mv /opt/postgresql/pg95/data /opt/postgresql/pg95/orig95
pg_upgrade -v -d /opt/postgresql/orig/data -D /opt/postgresql/pg95/data -b /opt/postgresql/orig/bin/ -B /opt/postgresql/pg95/bin/