aptを使用してインストールされた巨大なデータのubuntu16.04postgresql9.6データベースの移行

 

当社は、データベースインストールの開始時にaptによってオンラインでインストールされたpostgresql9.6データベースを使用したためです。最近、サービスをコンテナ化する必要があるため、データベースを移行する必要がありますが、aptインストールはソースインストールデータベースの移行方法とは異なります。

まず、このテストにはubuntu16.04を使用しました。データベースのバージョンはpostgresql9.6です。

データベースを移行する前提は、データベースのバージョンとサーバーシステムが移行前の情報と一致している必要があることです。

次に、aptインストール方法に従って、以前と同じバージョンのpostgresqlデータベースを新しいマシンにインストールします。

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

インストール後にpostgresqlの構成ファイルを変更します

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

考えられる問題

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.

解決

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

次に、postgresqlを再起動した後、データベース情報を新しいデータベース情報として表示します

 

おすすめ

転載: blog.csdn.net/wjg1314521/article/details/108335819