透過的暗号化の設定方法
IIJ GIOインフラストラクチャーP2の仮想サーバでクライアントツールを使用して、PostgreSQLインスタンスで透過的暗号化を設定します。psqlなどのクライアントツールでログインし、walletを作成します。
以下は、ユーザsystem、パスワード(########)を使用して、psqlでテーブルスペースsecure_tablespace01に透過的暗号化を設定する例です。マスターキーのパスフレーズは「%%%%%%%%」です。
$ psql -U system -h <IPアドレス> -d <データベース名> |
Password for user system: ######## |
postgres=# SELECT pgx_set_master_key('%%%%%%%%'); |
pgx_set_master_key |
-------------------- |
(1 row) |
postgres=# CREATE TABLESPACE SECURE_TABLESPACE01 LOCATION '/pgdata/postgres/pg_tblspc/' WITH (tablespace_encryption_algorithm = 'AES256'); |
WARNING: tablespace location should not be inside the data directory |
CREATE TABLESPACE |
postgres=# SELECT spcname, spcencalgo FROM pg_tablespace ts, pgx_tablespaces tsx WHERE ts.oid = tsx.spctablespace and ts.spcname = 'secure_tablespace01'; |
spcname | spcencalgo |
---------------------+------------ |
secure_tablespace01 | AES256 |
(1 row) |
【注意】
透過的暗号化を設定した場合、スケジュールバックアップを取得していても障害時にサービス側では復旧できません。任意のバックアップを取得することを推奨します。
【注意】
サービスコントロールパネルより再起動を行った直後は、暗号化されたデータを参照すると以下のエラーとなります。データを参照する場合は、pgx_open_keystoreにパスフレーズを入力してキーストアをオープンしてください。
ERROR: could not encrypt or decrypt data because the keystore is not open
HINT: Open the existing keystore, or set the master encryption key to create and open a new keystore