IBM Support

[Db2] ローカル鍵ストアを使用した暗号化データベースの HADR ペアを構築する方法

Question & Answer


Question

暗号化データベースで、ローカル鍵ストアを使用して HADR 環境を構築する場合の手順を教えてください。

Answer

ローカル鍵ストアを使用して暗号化データベースの HADR 環境を構築する場合は、以下の手順を実施してください。
ただし、ローカル鍵ストアを使用した HADR 環境の構築は可能ですが、推奨はされておりません。
HADR 環境内のすべてのデータベースが同じ鍵ストアに対するアクセス権限を持つことが推奨されています。 この鍵ストアは、共有ファイル・システム上の PKCS12 鍵ストアでも、KMIP 鍵マネージャーや PKCS11 ハードウェア・セキュリティー・モジュールのような中央管理型の鍵ストアでも構いません。 各々が別々の PKCS12 鍵ストアを使用すると、手動でそれらの同期を保たなければならなくなるので、それはお勧めしません。
はじめに:
以下の手順は、共有ファイル・システムの利用を含め、HADR のプライマリおよびスタンバイ両サーバーでローカル鍵ストアがすでに作成されており、KEYSTORE_LOCATION データベース・マネージャー構成パラメーターが適切に設定されていることを前提としています。
  1. プライマリ・データベースのバックアップを取得し、バックアップ・イメージをスタンバイ・サーバーに転送します。
    db2 backup db db1 to <path_to_backup>
  2. プライマリ・データベースで使用されているマスター鍵を確認します。
    db2pd -db db1 -encrypt
    
    Database Member 0 -- Database DB1 -- Active -- Up 0 days 00:00:09 -- Date 2022-07-25-07.14.37.311043
    Encryption Info:
       Object Name:               DB1
       Object Type:               DATABASE
       Encyrption Key Info:
              Encryption Algorithm: AES
         Encryption Algorithm Mode: CBC
             Encryption Key Length: 256
                  Master Key Label: DB2_SYSGEN_db2inst1_DB1_2022-07-24-21.54.17_050E4C45
     Master Key Rotation Timestamp: 2022-07-24-21.54.17.000000
       Master Key Rotation Appl ID: *LOCAL.DB2.220722075903
       Master Key Rotation Auth ID: DB2V115
         Previous Master Key Label: DB2_SYSGEN_db2inst1_DB1_2022-07-24-21.54.17_050E4C45
       KeyStore Info:
                     KeyStore Type: PKCS12
                 KeyStore Location: /home/db2inst1/server.p12
                KeyStore Host Name: myhost1.xxx.xxx.xxx
               KeyStore IP Address: x.x.x.x
          KeyStore IP Address Type: IPV4
  3. 手順 2 で確認したマスター鍵を、tmpkd.raw という名前の鍵ストアにエクスポートします。(手順 3 及び手順 4 は、HADR ペアが個別のローカル鍵ストアを使用する場合にのみ必要な手順です。セントラル鍵ストアや共有ファイル・システム上の鍵ストアを使用する場合には不要です。)
    gsk8capicmd_64 -cert -export -db $HOME/keystore.p12 -stashed -label DB2_SYSGEN_db2inst1_DB1_2022-07-24-21.54.17_050E4C45 -target $HOME/tmpkd.raw -target_type pkcs12 -target_pw "Passw0rd4tmp"
  4. 取り出したマスター鍵を保管した鍵ストア (tmpkd.*) を、scp コマンド等を使用してスタンバイ・サーバーに転送し、スタンバイ側の鍵ストアにマスター鍵をインポートします。
    gsk8capicmd_64 -cert -import -db $HOME/tmpkd.raw -pw "Passw0rd4tmp" -target $HOME/keystore.p12 -target_type pkcs12 -stashed 
  5. 手順 1 で取得したバックアップ・イメージをスタンバイ・サーバーにリストアします。
    db2 restore db db1 from <path_to_backup> encrypt 
    スタンバイ側で新たなマスター鍵が生成されます。
    db2pd -db db1 -encrypt
    
    Database Member 0 -- Database DB1 -- Active -- Up 0 days 00:00:19 -- Date 2022-07-25-07.15.20.531359
    Encryption Info:
       Object Name:               DB1
       Object Type:               DATABASE
       Encyrption Key Info:
              Encryption Algorithm: AES
         Encryption Algorithm Mode: CBC
             Encryption Key Length: 256
                  Master Key Label: DB2_SYSGEN_db2inst1_DB1_2022-07-25-07.12.29_D721A2CE   <<
     Master Key Rotation Timestamp: 2022-07-25-07.12.30.000000
       Master Key Rotation Appl ID: *LOCAL.db2inst1.220725055027
       Master Key Rotation Auth ID: DB2V115
         Previous Master Key Label: DB2_SYSGEN_db2inst1_DB1_2022-07-25-07.12.29_D721A2CE
       KeyStore Info:
                     KeyStore Type: PKCS12
                 KeyStore Location: /home/db2inst1/server.p12
                KeyStore Host Name: myhost2.xxx.xxx.xxx
               KeyStore IP Address: x.x.x.x
          KeyStore IP Address Type: IPV4
  6. プライマリ、スタンバイ双方で、HADR 環境で必要な構成パラメーター (HADR_LOCAL_HOST、HADR_REMOTE_HOST など) を設定します。
  7. スタンバイ、プライマリの順で、START HADR コマンドを実行します。
    db2 start hadr on database db1 as standby
    db2 start hadr on database db1 as primary
    START HADR コマンドの実行後、スタンバイ・データベースのマスター鍵がプライマリ・データベースと同じものにロ―テートされます。
    db2pd -db db1 -enc
    
    Database Member 0 -- Database DB1 -- Standby -- Up 0 days 00:02:02 -- Date 2022-08-01-22.48.59.729037
    Encryption Info:
       Object Name:               DB1
       Object Type:               DATABASE
       Encyrption Key Info:
              Encryption Algorithm: AES
         Encryption Algorithm Mode: CBC
             Encryption Key Length: 256
                  Master Key Label: DB2_SYSGEN_db2inst1_DB1_2022-07-24-21.54.17_050E4C45   <<
     Master Key Rotation Timestamp: 2022-08-01-22.47.30.000000
       Master Key Rotation Appl ID: DB2 HADR STANDBY KEY ROTATION ID
       Master Key Rotation Auth ID: DB2 HADR PRIMARY DRIVEN KEY ROTATION
         Previous Master Key Label: DB2_SYSGEN_db2inst1_DB1_2022-07-25-07.12.29_D721A2CE
       KeyStore Info:
                     KeyStore Type: PKCS12
                 KeyStore Location: /home/db2inst1/server.p12
                KeyStore Host Name: myhost2.xxxx.xxx.xxx.xxx
               KeyStore IP Address: x.x.x.x
          KeyStore IP Address Type: IPV4
    注:
    上記 db2pd の出力は、HADR 開始後のログ適用により、プライマリ、スタンバイ双方のマスター鍵が同期されたことを示しています。そのため、スタンバイ上での最初のリストアの際に、プライマリ・データベースと同じマスター鍵を明示的に指定する必要はありません。スタンバイ側で新たなマスター鍵を生成したくない場合、手順 5 で以下のような RESTORE コマンドを実行して、プライマリ・データベースと同じマスター鍵を使用できます。
    db2 restore db db1 ENCRYPT CIPHER AES KEY LENGTH 256 MASTER KEY LABEL DB2_SYSGEN_db2inst1_DB1_2022-07-25-07.12.29_D721A2CE
お問合せ先
技術的な内容に関して、パスポート・アドバンテージの契約のもと Db2 テクニカル・サポートへお問い合わせください。
Db2 テクニカル・サポート

[{"Type":"MASTER","Line of Business":{"code":"LOB10","label":"Data and AI"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"ARM Category":[{"code":"a8m500000008PlyAAE","label":"HADR-\u003EHADR Setup"},{"code":"a8m500000008PmnAAE","label":"Security and Plug-Ins-\u003EEncryption"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"10.5.0;11.1.0;11.5.0"}]

Document Information

Modified date:
21 August 2023

UID

ibm16615617