Amazon RDS for Db2 參數 - Amazon Relational Database Service

Amazon RDS for Db2 參數

Amazon RDS for Db2 使用三種類型的參數:資料庫管理員組態參數、登錄變數和資料庫組態參數。您可以透過參數群組管理前兩種類型,並透過 rdsadmin.update_db_param 預存程序更新最後一個類型。

依預設,RDS for Db2 資料庫執行個體會使用 Db2 資料庫和資料庫執行個體專用的資料庫參數群組。此參數群組包含 IBM Db2 資料庫引擎的參數,特別是資料庫管理員組態參數和登錄變數。如需使用參數群組的相關資訊,請參閱 Amazon RDS 的參數群組

RDS for Db2 資料庫組態參數會設為您已選取之儲存引擎的預設值。如需 Db2 參數的詳細資訊,請參閱 IBM Db2 文件中的 Db2 資料庫組態參數

檢視參數群組中的參數

資料庫管理員組態參數和登錄變數是在參數群組中設定。您可以使用 AWS Management Console、AWS CLI 或 RDS API 來檢視特定 Db2 版本的資料庫管理員組態參數和登錄變數。

檢視資料庫參數群組的參數值
  1. 登入 AWS Management Console,開啟位於 https://console.aws.amazon.com/rds/ 的 Amazon RDS 主控台。

  2. 在導覽窗格中,選擇 Parameter groups (參數群組)

    資料庫參數群組隨即會出現在清單中。

  3. 選擇參數群組的名稱,以查看其參數清單。

您可以執行 describe-engine-default-parameters 命令來檢視 Db2 版本的資料庫管理員組態參數和登錄變數。為 --db-parameter-group-family 選項指定下列其中一個值:

  • db2-ae-11.5

  • db2-se-11.5

例如,若要檢視 Db2 Standard Edition 11.5 的參數,請執行下列命令:

aws rds describe-engine-default-parameters --db-parameter-group-family db2-se-11.5

此命令會產生類似下列範例的輸出:

{ "EngineDefaults": { "Parameters": [ { "ParameterName": "agent_stack_sz", "ParameterValue": "1024", "Description": "You can use this parameter to determine the amount of memory that is allocated by Db2 for each agent thread stack.", "Source": "engine-default", "ApplyType": "static", "DataType": "integer", "AllowedValues": "256-32768", "IsModifiable": false }, { "ParameterName": "agentpri", "ParameterValue": "-1", "Description": "This parameter controls the priority given to all agents and to other database manager instance processes and threads by the operating system scheduler. This priority determines how CPU time is allocated to the database manager processes, agents, and threads relative to other processes and threads running on the machine.", "Source": "engine-default", "ApplyType": "static", "DataType": "integer", "AllowedValues": "1-99", "IsModifiable": false }, ... ] } }

若要檢視 Db2 Standard Edition 11.5 的可修改參數,請執行下列命令:

在 Linux、macOS 或 Unix 中:

aws rds describe-engine-default-parameters \ --db-parameter-group-family db2-se-11.5 \ --query 'EngineDefaults.Parameters[?IsModifiable==`true`].{ParameterName:ParameterName, DefaultValue:ParameterValue}'

在 Windows 中:

aws rds describe-engine-default-parameters ^ --db-parameter-group-family db2-se-11.5 ^ --query 'EngineDefaults.Parameters[?IsModifiable==`true`].{ParameterName:ParameterName, DefaultValue:ParameterValue}'

若要檢視資料庫參數群組的參數值,請搭配下列必要參數使用 DescribeDBParameters 作業。

  • DBParameterGroupName

使用 Db2 命令檢視所有參數

您可以使用 Db2 命令來檢視資料庫管理員組態參數、資料庫組態參數和登錄變數的設定。

檢視設定
  1. 連線至 Db2 資料庫。在下列範例中,將 database_namemaster_usernamemaster_password 取代為您自己的資訊。

    db2 "connect to database_name user master_username using master_password"
  2. 尋找支援的 Db2 版本。

    db2 "select service_level, fixpack_num from table(sysproc.env_get_inst_info()) as instanceinfo"
  3. 檢視特定 Db2 版本的參數。

    • 執行下列命令來檢視資料庫管理員組態參數:

      db2 "select cast(substr(name,1,24) as varchar(24)) as name, case when value_flags = 'NONE' then '' else value_flags end flags, cast(substr(value,1,64) as varchar(64)) as current_value from sysibmadm.dbmcfg order by name asc with UR"
    • 執行下列命令來檢視所有資料庫組態參數:

      db2 "select cast(substr(name,1,24) as varchar(24)) as name, case when value_flags = 'NONE' then '' else value_flags end flags, cast(substr(value,1,64) as varchar(64)) as current_value from table(db_get_cfg(null)) order by name asc, member asc with UR"
    • 執行下列命令來檢視目前設定的登錄變數:

      db2 "select cast(substr(reg_var_name,1,50) as varchar(50)) as reg_var_name, cast(substr(reg_var_value,1,50) as varchar(50)) as reg_var_value, level from table(env_get_reg_variables(null)) order by reg_var_name,member with UR"

修改參數群組中的參數

您可以使用 AWS Management Console、AWS CLI 或 RDS API,修改自訂參數群組中的資料庫管理員組態參數和登錄變數。如需更多詳細資訊,請參閱 Amazon RDS 資料庫執行個體的資料庫參數群組

修改資料庫管理員組態參數和登錄變數
  1. 建立自訂參數群組。如需建立資料庫參數群組的詳細資訊,請參閱在 Amazon RDS 中建立資料庫參數群組

  2. 修改該自訂參數群組中的參數。如需修改參數群組的相關詳細資訊,請參閱 修改 Amazon RDS 中的資料庫參數群組中的參數

修改資料庫管理員組態參數和登錄變數
  1. 執行 create-db-parameter-group 命令來建立自訂參數群組。

    包含下列必要選項:

    • --db-parameter-group-name – 您要建立之參數群組的名稱。

    • --db-parameter-group-family – Db2 引擎版本和主要版本。有效值:db2-se-11.5db2-ae-11.5

    • --description – 此參數群組的描述。

    如需建立資料庫參數群組的詳細資訊,請參閱在 Amazon RDS 中建立資料庫參數群組

  2. 修改您透過執行 modify-db-parameter-group 命令所建立的自訂參數群組中的參數。

    包含下列必要選項:

    • --db-parameter-group-name – 您所建立的參數群組之名稱。

    • --parameters – 參數名稱、值,以及參數更新套用方法的陣列。

    如需修改參數群組的相關詳細資訊,請參閱 修改 Amazon RDS 中的資料庫參數群組中的參數

修改資料庫管理員組態參數和登錄變數
  1. 使用 CreateDBParameterGroup 作業來建立自訂資料庫參數群組。

    包含下列必要參數:

    • DBParameterGroupName

    • DBParameterGroupFamily

    • Description

    如需建立資料庫參數群組的詳細資訊,請參閱在 Amazon RDS 中建立資料庫參數群組

  2. 修改您透過使用 ModifyDBParameterGroup 作業所建立的自訂參數群組中的參數。

    包含下列必要參數:

    • DBParameterGroupName

    • Parameters

    如需修改參數群組的相關詳細資訊,請參閱 修改 Amazon RDS 中的資料庫參數群組中的參數

使用 Db2 命令修改資料庫組態參數

您可以使用 Db2 命令修改資料庫組態參數。

修改資料庫組態參數
  1. 連線至 rdsadmin 資料庫。在下列範例中,將 master_usernamemaster_password 取代為您的資訊。

    db2 "connect to rdsadmin user master_username using master_password"
  2. 呼叫 rdsadmin.update_db_param 預存程序來變更資料庫組態參數。如需更多詳細資訊,請參閱 rdsadmin.update_db_param

    db2 "call rdsadmin.update_db_param( 'database_name', 'parameter_to_modify', 'changed_value', 'restart_database')"