OCI CLIを使用したMySQL HeatWave構成の作成 (2024/04/18)

OCI CLIを使用したMySQL HeatWave構成の作成 (2024/04/18)

https://blogs.oracle.com/mysql/post/creating-a-mysql-heatwave-configuration-with-the-oci-cli

投稿者: Scott Stroz | MySQL Developer Advocate


これは、OCI CLIを使用してMySQL HeatWaveリソースを管理する方法を示すためのシリーズの5番目の投稿です。この投稿では、MySQL HeatWaveインスタンスの構成の作成方法と、この構成を使用して新しいインスタンスを作成する方法について説明します。



前提条件


次の例のいずれかを実行する前に、OCI CLIをインストールする必要があります。CLIがインストールされていない場合は、次の手順に従って CLIをインストールおよび構成します。



構成の作成


構成は、同じシェイプおよびシステム変数を持つ複数のインスタンスを迅速にスピンアップする場合に便利です。デフォルト構成は多数ありますが、必要に応じてカスタム構成を作成する必要がある場合があります。



コマンドJSONの生成


このシリーズ全体で行ったように、最初にテンプレートJSONファイルを生成して新しい構成を作成します。このJSONファイルを作成するコマンドは次のとおりです。


oci mysql configuration create --generate-full-command-json-input > config-create.json


このコマンドが完了すると、config-create.jsonという名前のtehファイルが次のようになります。


{
  "compartmentId": "string",
  "definedTags": {
    "tagNamespace1": {
      "tagKey1": "tagValue1",
      "tagKey2": "tagValue2"
    },
    "tagNamespace2": {
      "tagKey1": "tagValue1",
      "tagKey2": "tagValue2"
    }
  },
  "description": "string",
  "displayName": "string",
  "freeformTags": {
    "tagKey1": "tagValue1",
    "tagKey2": "tagValue2"
  },
  "initVariables": {
    "lowerCaseTableNames": "string"
  },
  "maxWaitSeconds": 0,
  "parentConfigurationId": "string",
  "shapeName": "string",
  "variables": {
    "autocommit": true,
    "bigTables": true,
    "binlogExpireLogsSeconds": 0,
    "binlogRowMetadata": "string",
    "binlogRowValueOptions": "string",
    "binlogTransactionCompression": true,
    "completionType": "string",
    "connectTimeout": 0,
    "connectionMemoryChunkSize": 0,
    "connectionMemoryLimit": 0,
    "cteMaxRecursionDepth": 0,
    "defaultAuthenticationPlugin": "string",
    "foreignKeyChecks": true,
    "generatedRandomPasswordLength": 0,
    "globalConnectionMemoryLimit": 0,
    "globalConnectionMemoryTracking": true,
    "groupReplicationConsistency": "string",
    "informationSchemaStatsExpiry": 0,
    "innodbBufferPoolDumpPct": 0,
    "innodbBufferPoolInstances": 0,
    "innodbBufferPoolSize": 0,
    "innodbDdlBufferSize": 0,
    "innodbDdlThreads": 0,
    "innodbFtEnableStopword": true,
    "innodbFtMaxTokenSize": 0,
    "innodbFtMinTokenSize": 0,
    "innodbFtNumWordOptimize": 0,
    "innodbFtResultCacheLimit": 0,
    "innodbFtServerStopwordTable": "string",
    "innodbLockWaitTimeout": 0,
    "innodbLogWriterThreads": true,
    "innodbMaxPurgeLag": 0,
    "innodbMaxPurgeLagDelay": 0,
    "innodbStatsPersistentSamplePages": 0,
    "innodbStatsTransientSamplePages": 0,
    "interactiveTimeout": 0,
    "localInfile": true,
    "mandatoryRoles": "string",
    "maxAllowedPacket": 0,
    "maxBinlogCacheSize": 0,
    "maxConnectErrors": 0,
    "maxConnections": 0,
    "maxExecutionTime": 0,
    "maxHeapTableSize": 0,
    "maxPreparedStmtCount": 0,
    "mysqlFirewallMode": true,
    "mysqlZstdDefaultCompressionLevel": 0,
    "mysqlxConnectTimeout": 0,
    "mysqlxDeflateDefaultCompressionLevel": 0,
    "mysqlxDeflateMaxClientCompressionLevel": 0,
    "mysqlxDocumentIdUniquePrefix": 0,
    "mysqlxEnableHelloNotice": true,
    "mysqlxIdleWorkerThreadTimeout": 0,
    "mysqlxInteractiveTimeout": 0,
    "mysqlxLz4DefaultCompressionLevel": 0,
    "mysqlxLz4MaxClientCompressionLevel": 0,
    "mysqlxMaxAllowedPacket": 0,
    "mysqlxMinWorkerThreads": 0,
    "mysqlxReadTimeout": 0,
    "mysqlxWaitTimeout": 0,
    "mysqlxWriteTimeout": 0,
    "mysqlxZstdDefaultCompressionLevel": 0,
    "mysqlxZstdMaxClientCompressionLevel": 0,
    "netReadTimeout": 0,
    "netWriteTimeout": 0,
    "parserMaxMemSize": 0,
    "queryAllocBlockSize": 0,
    "queryPreallocSize": 0,
    "regexpTimeLimit": 0,
    "sortBufferSize": 0,
    "sqlMode": "string",
    "sqlRequirePrimaryKey": true,
    "sqlWarnings": true,
    "threadPoolDedicatedListeners": true,
    "threadPoolMaxTransactionsLimit": 0,
    "timeZone": "string",
    "tmpTableSize": 0,
    "transactionIsolation": "string",
    "waitTimeout": 0
  },
  "waitForState": [
    "ACCEPTED|IN_PROGRESS|FAILED|SUCCEEDED|CANCELING|CANCELED"
  ],
  "waitIntervalSeconds": 0
}


このJSONファイルのvariablesプロパティには、この構成を使用してインスタンスが作成されるときに設定されるシステム変数が含まれています。このデモで使用するプロパティのみを含めるように、このファイルを変更します。更新されたファイルは次のとおりです。


{
  "compartment-id": "ocid1.compartment.oc1.{more text}",
  "description": "A Demo configuration create with the OCI CLI",
  "displayName": "OCI CLI Configuration Demo",
  "shapeName": "MySQL.8",
  "variables": {
    "sqlMode": "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION "
  }
}


この構成ファイルでは、構成が存在するコンパートメントのcompartmetnIdを指定します。説明、displayNameおよびシェイプも指定します。変数プロパティで、sqlModeの値を指定します。この構成を使用して作成するインスタンスはすべて、同じsqlModeを持ちます。



コマンドの実行


このJSON構成ファイルを使用して新しい構成を作成するには、次のコマンドを実行します:


oci mysql configuration create --from-json file://{path to file}


コマンドが完了すると、次のような出力が表示されます。


{
  "data": {
    "compartment-id": "ocid1.compartment.oc1.{more text}",
    "defined-tags": {
      "Oracle-Recommended-Tags": {
        "ResourceOwner": "default/sstroz"
      },
      "Oracle-Tags": {
        "CreatedBy": "default/sstroz",
        "CreatedOn": "2024-04-17T13:27:43.977Z"
      }
    },
    "description": "A Demo configuration create with the OCI CLI",
    "display-name": "OCI CLI Configuration Demo",
    "freeform-tags": {},
    "id": "ocid1.mysqlconfiguration.oc1.{more text}",
    "init-variables": {
      "lower-case-table-names": "CASE_SENSITIVE"
    },
    "lifecycle-state": "ACTIVE",
    "parent-configuration-id": "ocid1.mysqlconfiguration.oc1.{more text}",
    "shape-name": "MySQL.8",
    "time-created": "2024-04-17T13:27:44.026000+00:00",
    "time-updated": "2024-04-17T13:27:44.026000+00:00",
    "type": "CUSTOM",
    "variables": {
      "autocommit": null,
      "big-tables": null,
      "binlog-expire-logs-seconds": 3600,
      "binlog-row-metadata": null,
      "binlog-row-value-options": "PARTIAL_JSON",
      "binlog-transaction-compression": null,
      "completion-type": null,
      "connect-timeout": null,
      "connection-memory-chunk-size": null,
      "connection-memory-limit": null,
      "cte-max-recursion-depth": null,
      "default-authentication-plugin": null,
      "foreign-key-checks": null,
      "generated-random-password-length": null,
      "global-connection-memory-limit": null,
      "global-connection-memory-tracking": null,
      "group-replication-consistency": "BEFORE_ON_PRIMARY_FAILOVER",
      "information-schema-stats-expiry": null,
      "innodb-buffer-pool-dump-pct": null,
      "innodb-buffer-pool-instances": 4,
      "innodb-buffer-pool-size": 51539607552,
      "innodb-ddl-buffer-size": null,
      "innodb-ddl-threads": null,
      "innodb-ft-enable-stopword": null,
      "innodb-ft-max-token-size": null,
      "innodb-ft-min-token-size": null,
      "innodb-ft-num-word-optimize": null,
      "innodb-ft-result-cache-limit": 33554432,
      "innodb-ft-server-stopword-table": null,
      "innodb-lock-wait-timeout": null,
      "innodb-log-writer-threads": null,
      "innodb-max-purge-lag": null,
      "innodb-max-purge-lag-delay": 300000,
      "innodb-stats-persistent-sample-pages": null,
      "innodb-stats-transient-sample-pages": null,
      "interactive-timeout": null,
      "local-infile": true,
      "mandatory-roles": "public",
      "max-allowed-packet": null,
      "max-binlog-cache-size": 4294967296,
      "max-connect-errors": null,
      "max-connections": 4000,
      "max-execution-time": null,
      "max-heap-table-size": null,
      "max-prepared-stmt-count": null,
      "mysql-firewall-mode": null,
      "mysql-zstd-default-compression-level": null,
      "mysqlx-connect-timeout": null,
      "mysqlx-deflate-default-compression-level": null,
      "mysqlx-deflate-max-client-compression-level": null,
      "mysqlx-document-id-unique-prefix": null,
      "mysqlx-enable-hello-notice": null,
      "mysqlx-idle-worker-thread-timeout": null,
      "mysqlx-interactive-timeout": null,
      "mysqlx-lz4-default-compression-level": null,
      "mysqlx-lz4-max-client-compression-level": null,
      "mysqlx-max-allowed-packet": null,
      "mysqlx-min-worker-threads": null,
      "mysqlx-read-timeout": null,
      "mysqlx-wait-timeout": null,
      "mysqlx-write-timeout": null,
      "mysqlx-zstd-default-compression-level": null,
      "mysqlx-zstd-max-client-compression-level": null,
      "net-read-timeout": null,
      "net-write-timeout": null,
      "parser-max-mem-size": null,
      "query-alloc-block-size": null,
      "query-prealloc-size": null,
      "regexp-time-limit": null,
      "sort-buffer-size": null,
      "sql-mode": "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION ",
      "sql-require-primary-key": null,
      "sql-warnings": null,
      "thread-pool-dedicated-listeners": null,
      "thread-pool-max-transactions-limit": null,
      "time-zone": "UTC",
      "tmp-table-size": null,
      "transaction-isolation": null,
      "wait-timeout": null
    }
  },
  "etag": "4df39f8{more text}"
}


このJSONのvariablesプロパティを見ると、sqlMode変数のみを指定しても、他の変数にデフォルトが設定されていることがわかります。また、typeプロパティの値はCUSTOMです。



カスタム構成の一覧表示


デフォルトのMySQl HetWave構成は多数あり、この記事では構成のリストについて説明しました。すべてのカスタム構成のリストを表示するには、次のコマンドを実行します。


oci mysql configuration list --compartment-id {compartment ID} --type custom


他のカスタム構成がない場合は、作成した構成が表示されます。


{
  "data": [
    {
      "compartment-id": "ocid1.compartment.oc1.{more text}",
      "defined-tags": {
        "Oracle-Recommended-Tags": {
          "ResourceOwner": "default/sstroz"
        },
        "Oracle-Tags": {
          "CreatedBy": "default/sstroz",
          "CreatedOn": "2024-04-17T13:27:43.977Z"
        }
      },
      "description": "A Demo configuration create with the OCI CLI",
      "display-name": "OCI CLI Configuration Demo",
      "freeform-tags": {},
      "id": "ocid1.mysqlconfiguration.oc1.{more text}",
      "lifecycle-state": "ACTIVE",
      "shape-name": "MySQL.8",
      "time-created": "2024-04-17T13:27:44.026000+00:00",
      "time-updated": "2024-04-17T13:27:44.026000+00:00",
      "type": "CUSTOM"
    }
  ]
}



構成の使用


構成を作成したら、これを使用して新しいMySQL HeatWaveインスタンスを作成できます。まず、HeatWaveインスタンスの作成に使用できるJSONファイルを生成します。


oci mysql db-system create --generate-full-command-json-input  > create-from-config.json


create-from-config.jsonファイルは、次のようになります。


{
  "adminPassword": "string",
  "adminUsername": "string",
  "availabilityDomain": "string",
  "backupPolicy": {
    "definedTags": {
      "tagNamespace1": {
        "tagKey1": "tagValue1",
        "tagKey2": "tagValue2"
      },
      "tagNamespace2": {
        "tagKey1": "tagValue1",
        "tagKey2": "tagValue2"
      }
    },
    "freeformTags": {
      "tagKey1": "tagValue1",
      "tagKey2": "tagValue2"
    },
    "isEnabled": true,
    "pitrPolicy": {
      "isEnabled": true
    },
    "retentionInDays": 0,
    "windowStartTime": "string"
  },
  "compartmentId": "string",
  "configurationId": "string",
  "crashRecovery": "ENABLED|DISABLED",
  "dataStorageSizeInGbs": 0,
  "databaseManagement": "ENABLED|DISABLED",
  "definedTags": {
    "tagNamespace1": {
      "tagKey1": "tagValue1",
      "tagKey2": "tagValue2"
    },
    "tagNamespace2": {
      "tagKey1": "tagValue1",
      "tagKey2": "tagValue2"
    }
  },
  "deletionPolicy": {
    "automaticBackupRetention": "string",
    "finalBackup": "string",
    "isDeleteProtected": true
  },
  "description": "string",
  "displayName": "string",
  "faultDomain": "string",
  "freeformTags": {
    "tagKey1": "tagValue1",
    "tagKey2": "tagValue2"
  },
  "hostnameLabel": "string",
  "ipAddress": "string",
  "isHighlyAvailable": true,
  "maintenance": {
    "windowStartTime": "string"
  },
  "maxWaitSeconds": 0,
  "mysqlVersion": "string",
  "port": 0,
  "portX": 0,
  "secureConnections": {
    "certificateGenerationType": "string",
    "certificateId": "string"
  },
  "shapeName": "string",
  "source": [
    "This parameter should actually be a JSON object rather than an array - pick one of the following object variants to use",
    {
      "backupId": "string",
      "sourceType": "BACKUP"
    },
    {
      "sourceType": "NONE"
    },
    {
      "dbSystemId": "string",
      "recoveryPoint": "2017-01-01T00:00:00+00:00",
      "sourceType": "PITR"
    },
    {
      "sourceType": "IMPORTURL",
      "sourceUrl": "string"
    }
  ],
  "subnetId": "string",
  "waitForState": [
    "ACCEPTED|IN_PROGRESS|FAILED|SUCCEEDED|CANCELING|CANCELED"
  ],
  "waitIntervalSeconds": 0
}


前に行ったように、このデモに必要なプロパティのみを使用するようにこのファイルを更新します。


{
  "adminPassword": "MySQL8IsGre@t!!",
  "adminUsername": "admin",
  "availabilityDomain": "mMVr:US-ASHBURN-AD-1",
  "backupPolicy": {
    "isEnabled": true,
    "pitrPolicy": {
      "isEnabled": true
    },
    "retentionInDays": 14
  },
  "compartmentId": "ocid1.compartment.oc1.{more text}",
  "configurationId": "ocid1.mysqlconfiguration.oc1.{more text}",
  "crashRecovery": "ENABLED",
  "dataStorageSizeInGbs": 50,
  "databaseManagement": "DISABLED",
  "description": "A HeatWave instance created with the OCI CLI using a configuration",
  "displayName": "OCI CLI Demo from Config",
  "isHighlyAvailable": false,
  "mysqlVersion": "8.3.0",
  "shapeName": "MySQL.8",
  "subnetId": "ocid1.subnet.oc1.{more text}",
  "waitForState": ["SUCCEEDED"]
}


この新しいインスタンスが作成されると、variablesプロパティの項目の値は、configurationIdを指定して設定されます。この場合、sqlModeをSTRICT_TRANS_TABLES、NO_ZERO_IN_DATE、NO_ZERO_DATE、ERROR_FOR_DIVISION_BY_ZERO、NO_ENGINE_SUBSTITUTIONに設定し、他の変数にデフォルト値を使用します。


MySQL HeatWaveインスタンスの作成の詳細は、この投稿を参照してください。



まとめ


構成を使用して、MySQL HeatWaveインスタンスの作成時にシステム変数またはグローバル変数を設定できます。カスタム構成を作成し、それを使用して新しいHeatWaveインスタンスを作成することで、システム変数またはグローバル変数を手動で更新することなく、作成するすべてのインスタンスが同じように構成されるようにできます。今後の投稿では、OCI CLIを使用したインバウンド・レプリケーション・チャネルの作成について説明します。


コメント

このブログの人気の投稿

Oracle RACによるメンテナンスのためのドレインとアプリケーション・コンティニュイティの仕組み (2023/11/01)

Oracle Cloud Infrastructure Secure Desktopsを発表: デスクトップ仮想化のためのOracleのクラウドネイティブ・サービス (2023/06/28)

Oracle Cloudのデータベースをオブジェクト・ストレージにバックアップする3つの方法 (2021/12/13)