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 CLI、 或 RDS API,檢視特定 Db2 AWS Management Console版本的資料庫管理員組態參數和登錄變數。

檢視資料庫參數群組的參數值
  1. 登入 AWS Management Console 並開啟位於 https://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 }, ... ] } }

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

對於 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,修改自訂參數群組中的資料庫管理員組態參數和登錄變數。如需詳細資訊,請參閱RDSAmazon資料庫執行個體的資料庫參數群

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

  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 Amazon 中創建數據庫參數組

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

    包含下列必要選項:

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

    • --parameters – 參數更新的參數名稱、值和應用程式方法陣列。

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

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

    包含下列必要參數:

    • DBParameterGroupName

    • DBParameterGroupFamily

    • Description

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

  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')"