[OCI]OCI CLIからAutonomous Databaseの自動起動/停止スケジュールを設定してみた
はじめに
Autonomous Databaseの自動起動/停止のスケジューリングができるようになり、とても便利になりました。
今回はOCI CLIから自動起動/停止のスケジューリングの設定を行う方法を確認しました。
oci db autonomous-database updateコマンドの"--scheduled-operation"オプションで設定できることがわかったのですが、スケジュールを指定するフォーマットがわからなかったので、"--generate-param-json-input"オプションで確認してみました。
1.自動起動/停止スケジュールを指定するJSONの書式確認
[opc@work ~]$ oci db autonomous-database update --generate-param-json-input scheduled-operations
[
{
"dayOfWeek": {
"name": "string"
},
"scheduledStartTime": "string",
"scheduledStopTime": "string"
},
{
"dayOfWeek": {
"name": "string"
},
"scheduledStartTime": "string",
"scheduledStopTime": "string"
}
]
[opc@work ~]$
[opc@work ~]$ oci db autonomous-database update --generate-param-json-input scheduled-operations
[
{
"dayOfWeek": {
"name": "string"
},
"scheduledStartTime": "string",
"scheduledStopTime": "string"
},
{
"dayOfWeek": {
"name": "string"
},
"scheduledStartTime": "string",
"scheduledStopTime": "string"
}
]
[opc@work ~]$
こちらによると、"dayOfWeek"の"name"に曜日、"scheduledStartTime"に起動時間、"scheduledStopTime"に停止時間を指定するようです。起動/停止時間はUTCで指定します。
2.JSONファイルの作成
ということで、設定内容を記述した以下のようなJSONファイルを作成します。
[
{
"day-of-week": {
"name": "MONDAY"
},
"scheduled-start-time": "08:00",
"scheduled-stop-time": "20:00"
},
{
"day-of-week": {
"name": "TUESDAY"
},
"scheduled-start-time": "08:00",
"scheduled-stop-time": "20:00"
},
{
"day-of-week": {
"name": "WEDNESDAY"
},
"scheduled-start-time": "08:00",
"scheduled-stop-time": "20:00"
},
{
"day-of-week": {
"name": "THURSDAY"
},
"scheduled-start-time": "08:00",
"scheduled-stop-time": "20:00"
},
{
"day-of-week": {
"name": "FRIDAY"
},
"scheduled-start-time": "08:00",
"scheduled-stop-time": "20:00"
},
{
"day-of-week": {
"name": "SATURDAY"
},
"scheduled-start-time": "10:00",
"scheduled-stop-time": "18:00"
},
{
"day-of-week": {
"name": "SUNDAY"
},
"scheduled-start-time": "10:00",
"scheduled-stop-time": "18:00"
}
]
3.OCI CLIで自動起動/停止スケジュールを設定
こちらのファイルを指定して、"oci db autonomous-database update --scheduled-operations"コマンドを実行します。
[opc@work ~]$ oci db autonomous-database update --autonomous-database-id ocid1.autonomousdatabase.oc1.ap-tokyo-1.xxxxxxxxxxxxxxxxxxxx --scheduled-operations file://scheduled-operations.json
WARNING: Updates to freeform-tags and defined-tags and whitelisted-ips and standby-whitelisted-ips and nsg-ids and customer-contacts and scheduled-operations will replace any existing values. Are you sure you want to continue? [y/N]: y
{
"data": {
"apex-details": {
"apex-version": "21.1.6",
"ords-version": "21.3.2.327.1419"
},
<省略>
"scheduled-operations": [
{
"day-of-week": {
"name": "MONDAY"
},
"scheduled-start-time": "08:00",
"scheduled-stop-time": "20:00"
},
{
"day-of-week": {
"name": "TUESDAY"
},
"scheduled-start-time": "08:00",
"scheduled-stop-time": "20:00"
},
{
"day-of-week": {
"name": "WEDNESDAY"
},
"scheduled-start-time": "08:00",
"scheduled-stop-time": "20:00"
},
{
"day-of-week": {
"name": "THURSDAY"
},
"scheduled-start-time": "08:00",
"scheduled-stop-time": "20:00"
},
{
"day-of-week": {
"name": "FRIDAY"
},
"scheduled-start-time": "08:00",
"scheduled-stop-time": "20:00"
},
{
"day-of-week": {
"name": "SATURDAY"
},
"scheduled-start-time": "10:00",
"scheduled-stop-time": "18:00"
},
{
"day-of-week": {
"name": "SUNDAY"
},
"scheduled-start-time": "10:00",
"scheduled-stop-time": "18:00"
}
],
<省略>
4.設定内容の確認
設定が完了したので、"oci db autonomous-database get"コマンドで設定内容を確認してみます。
[opc@work ~]$ oci db autonomous-database get --autonomous-database-id ocid1.autonomousdatabase.oc1.ap-tokyo-1.xxxxxxxxxxxxxxxxxxxx
{
"data": {
"apex-details": {
"apex-version": "21.1.6",
"ords-version": "21.3.2.327.1419"
},
<略>
"scheduled-operations": [
{
"day-of-week": {
"name": "MONDAY"
},
"scheduled-start-time": "08:00",
"scheduled-stop-time": "20:00"
},
{
"day-of-week": {
"name": "TUESDAY"
},
"scheduled-start-time": "08:00",
"scheduled-stop-time": "20:00"
},
{
"day-of-week": {
"name": "WEDNESDAY"
},
"scheduled-start-time": "08:00",
"scheduled-stop-time": "20:00"
},
{
"day-of-week": {
"name": "THURSDAY"
},
"scheduled-start-time": "08:00",
"scheduled-stop-time": "20:00"
},
{
"day-of-week": {
"name": "FRIDAY"
},
"scheduled-start-time": "08:00",
"scheduled-stop-time": "20:00"
},
{
"day-of-week": {
"name": "SATURDAY"
},
"scheduled-start-time": "10:00",
"scheduled-stop-time": "18:00"
},
{
"day-of-week": {
"name": "SUNDAY"
},
"scheduled-start-time": "10:00",
"scheduled-stop-time": "18:00"
}
],
<略>
JSONファイルで記述した自動起動/停止スケジュールが設定されていることが確認できました。
コンソールで設定内容が反映されているか確認してみます。
Autonomous Databaseの詳細画面の「自動開始/停止スケジュール:」の編集をクリックします。
Author And Source
この問題について([OCI]OCI CLIからAutonomous Databaseの自動起動/停止スケジュールを設定してみた), 我々は、より多くの情報をここで見つけました https://qiita.com/500InternalServerError/items/6d55a27fe413fff10d60著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .