ubuntu16.04 postgresql9.6 database migration for huge data installed using apt

 

Because our company used the postgresql9.6 database installed online by apt at the beginning of the database installation. Recently, the service needs to be containerized, so the database needs to be migrated, but because the apt installation is different from the source installation database migration method.

First of all, I used ubuntu16.04 for this test. The database version is postgresql9.6

The premise of migrating the database is that the database version and the server system must be consistent with the information before the migration

Then install the same version of postgresql database as before on the new machine according to the apt installation method

1、安装postgreSQL
sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.6

Modify the configuration file of postgresql after installation

vim /etc/postgresql/9.6/main/postgresql.conf
修改data_directory = '/opt/pgdata'   pgdata是你从其他服务器上拉取过来的目录
然后systemctl restart postgresql

Possible problems

psql: FATAL:  database locale is incompatible with operating system
DETAIL:  The database was initialized with LC_COLLATE "zh_CN.UTF-8",  which is not recognized by setlocale().
HINT:  Recreate the database with another locale or install the missing locale.

solution

localedef -f UTF-8 -i zh_CN zh_CN.UTF-8

Then after restarting postgresql, view the database information as the new database information

 

Guess you like

Origin blog.csdn.net/wjg1314521/article/details/108335819