Applications Manager ナレッジベース

Applications Managerのデータベースを手動で移行する


注意

本ナレッジの内容はサポート用です。
サポート時に案内があった場合にのみ実施してください。

事前準備

手順を続行する前に、新旧のPgsqlのポート番号を確認してください。
新しいPgsqlポート番号:Applications Managerインストールフォルダー/working/pgsql/data/amdb/postgres_ext.conf
古いPgsqlポート番号:Applications Managerインストールフォルダー/working/pgsql_9/data/amdb/postgres_ext.conf

新しいPgsql(バージョン10/11)の例:
ポート= 15435
PgServerPath = Applications Managerインストールフォルダー/working/pgsql/bin

古いPgsql(バージョン9)の例:
ポート= 15436
PgServerPath = Applications Managerインストールフォルダー/working/pgsql_9/bin

移行手順

  • 事前準備で正しいポート番号を確認し、以下のコマンドでポート番号を置きかえて実行してください。
  • 「Applications Managerインストールフォルダー」はユーザー様の環境でApplications Managerをインストールしているフォルダーをご参照し、置き換えてください。
  • 太字がコマンド、赤字が置き換えが必要な箇所を示しております。

1.以下のコマンドを実行して、DBサーバーを停止します

※新旧両方のpgsqlの操作が必要になります。コマンド前のパス指定にご注意ください。
Windows:

Applications Managerインストールフォルダー/working/pgsql/bin> pg_ctl.exe -w -D ../data/amdb -o -p15435 stop -s -m fast
Applications Managerインストールフォルダー/working/pgsql_9/bin> pg_ctl.exe -w -D ../data/amdb -o -p15436 stop -s -m fast

Linux:

Applications Managerインストールフォルダー/working/pgsql/bin>./pg_ctl -w -D ../data/amdb -o -p15435 stop -s -m fast
Applications Managerインストールフォルダー/working/pgsql_9/bin>./pg_ctl -w -D ../data/amdb -o -p15436 stop -s -m fast

※Applications Managerをrootユーザーでインストールされている場合は、以下のコマンドを使用します。

Applications Managerインストールフォルダー/working/pgsql/bin>su --postgres -c Applications Managerインストールフォルダー/working/pgsql/bin/pg_ctl -w -D Applications Managerインストールフォルダー/working/pgsql/data/amdb -o -p15435 stop -s -m fast
Applications Managerインストールフォルダー/working/pgsql_9/bin>su --postgres -c "Applications Managerインストールフォルダー/working/pgsql_9/bin/pg_ctl -w -D Applications Managerインストールフォルダー/working/pgsql_9/data/amdb -o -p15436 stop -s -m fast"

2.以下のコマンドを実行して、DBサーバーを起動します。

※新旧両方のpgsqlの操作が必要になります。コマンド前のパス指定にご注意ください。
Windows:

Applications Managerインストールフォルダー/working/pgsql/bin>pg_ctl.exe -w -D ../data/amdb -o -p15435 start
Applications Managerインストールフォルダー/working/pgsql_9/bin>pg_ctl.exe -w -D ../data/amdb -o -p15436 start

Linux:

Applications Managerインストールフォルダー/working/pgsql/bin>./pg_ctl -w -D ../data/amdb -o -p15435 start
Applications Managerインストールフォルダー/working/pgsql_9/bin>./pg_ctl -w -D ../data/amdb -o -p15436 start

※Applications Managerがrootユーザーとしてインストールされている場合は、以下のコマンドを使用します。

Applications Managerインストールフォルダー/working/pgsql/bin>su --postgres -c "Applications Managerインストールフォルダー/working/pgsql/bin/pg_ctl -w -D Applications Managerインストールフォルダー/working/pgsql/data/amdb -o -p15435 start"
Applications Managerインストールフォルダー/working/pgsql_9/bin>su --postgres -c "Applications Managerインストールフォルダー/working/pgsql_9/bin/pg_ctl -w -D Applications Managerインストールフォルダー/working/pgsql_9/data/amdb -o -p15436 start"

権限の問題がある場合は、サーバー上のすべてのユーザーに対してApplications Managerの作業ディレクトリに完全な権限を付与してください。

3. 以下のコマンドを個別に実行して、AMDBおよび必要な拡張機能を作成します。

Windows:

Applications Managerインストールフォルダー/working/pgsql/bin> set PGPASSWORD = appmanager
Applications Managerインストールフォルダー/working/pgsql/bin> psql.exe -U postgres -p 15435 -h localhost

postgres =#DROP DATABASE IF EXISTS amdb;
postgres =#CREATE DATABASE amdb;
postgres =#\ c amdb;
amdb =#CREATE EXTENSION "pgcrypto";
amdb =#CREATE EXTENSION CITEXT;
amdb =#CREATE EXTENSION pg_stat_statements;
amdb =#CREATE EXTENSION amcheck;
amdb =#\q

Linux:

Applications Managerインストールフォルダー/working/pgsql/bin>export PGPASSWORD = appmanager
Applications Managerインストールフォルダー/working/pgsql/bin>psql -U postgres -p 15435 -h localhost

※Applications Managerがrootユーザーとしてインストールされている場合は、以下のコマンドを使用します。
Applications Managerインストールフォルダー/working/pgsql/bin>su --postgres -c "Applications Managerインストールフォルダー/working/pgsql/bin/psql -U postgres -p 15435 -h localhost"

postgres =#DROP DATABASE IF EXISTS amdb;
postgres =#CREATE DATABASE amdb;
postgres =#\ c amdb;
amdb =#CREATE EXTENSION "pgcrypto";
amdb =#CREATE EXTENSION CITEXT;
amdb =#CREATE EXTENSION pg_stat_statements;
amdb =#CREATE EXTENSION amcheck;
amdb =#\ q

4.以下のコマンドを実行します。

Windows:

Applications Managerインストールフォルダー/working/pgsql_9/bin>set PGPASSWORD=appmanager
Applications Managerインストールフォルダー/working/pgsql_9/bin>pg_dump.exe -U postgres -p 15436 -h localhost -c -v -f Applications Managerインストールフォルダー絶対パス/dump9.sql amdb
Applications Managerインストールフォルダー/working/pgsql_9/bin>cd Applications Managerインストールフォルダー絶対パス/working/pgsql/bin
Applications Managerインストールフォルダー/working/pgsql/bin>set PGPASSWORD=appmanager
Applications Managerインストールフォルダー/working/pgsql/bin>psql.exe -U postgres -p 15435 -h localhost -d amdb -c -v -f Applications Managerインストールフォルダー絶対パス/dump9.sql

Linux:

Applications Managerインストールフォルダー/working/pgsql_9/bin> export PGPASSWORD=appmanager
Applications Managerインストールフォルダー/working/pgsql_9/bin> ./pg_dump -U postgres -p 15436 -h localhost -c -v -f Applications Managerインストールフォルダー絶対パス/dump9.sql amdb
Applications Managerインストールフォルダー/working/pgsql_9/bin> cd Applications Managerインストールフォルダー絶対パス/working/pgsql/bin
Applications Managerインストールフォルダー/working/pgsql/bin> export PGPASSWORD=appmanager
Applications Managerインストールフォルダー/working/pgsql/bin> ./psql -U postgres -p 15435 -h localhost -d amdb -c -v -f Applications Managerインストールフォルダー絶対パス/dump9.sql

※Applications Managerがrootユーザーとしてインストールされている場合は、以下のコマンドを使用します。

Applications Managerインストールフォルダー/working/pgsql_9/bin> su - postgres -c 'Applications Managerインストールフォルダー絶対パス/working/pgsql_9/bin/pg_dump -U postgres -p 15436 -h localhost -c -v -f Applications Managerインストールフォルダー絶対パス/dump9.sql amdb'

Applications Managerインストールフォルダー/working/pgsql_9/bin> su - postgres -c 'Applications Managerインストールフォルダー絶対パス/working/pgsql/bin/psql -U postgres -p 15435 -h localhost -d amdb -c -v -f Applications Managerインストールフォルダー絶対パス/dump9.sql'

5.以下のコマンドを実行して、DBサーバーを停止します。

※新旧両方のpgsqlの操作が必要になります。コマンド前のパス指定にご注意ください。
Windows:

Applications Managerインストールフォルダー/working/pgsql/bin> pg_ctl.exe -w -D ../data/amdb -o -p15435 stop -s -m fast
Applications Managerインストールフォルダー/working/pgsql_9/bin> pg_ctl.exe -w -D ../data/amdb -o -p15436 stop -s -m fast

Linux:

Applications Managerインストールフォルダー/working/pgsql/bin>./pg_ctl -w -D ../data/amdb -o -p15435 stop -s -m fast
Applications Managerインストールフォルダー/working/pgsql_9/bin>./pg_ctl -w -D ../data/amdb -o -p15436 stop -s -m fast

※Applications Managerがrootユーザーとしてインストールされている場合は、以下のコマンドを使用します。

Applications Managerインストールフォルダー/working/pgsql/bin>su --postgres -c "Applications Managerインストールフォルダー/working/pgsql/bin/pg_ctl -w -D Applications Managerインストールフォルダー/working/pgsql/data/amdb -o -p15435 stop -s -m fast"
Applications Managerインストールフォルダー/working/pgsql_9/bin>su --postgres -c "Applications Managerインストールフォルダー/working/pgsql_9/bin/pg_ctl -w -D Applications Managerインストールフォルダー/working/pgsql_9/data/amdb -o -p15436 stop -s -m fast"

6.Applications Managerを起動

Applications Managerをサービスとして起動し、問題がないか確認してください。