技術ブログ
Database as a Service - Automated は、"Automated"という名称のとおり、いくつかのオペレーションを自動化できる仕組みが用意されています。
データベースにおいて、もっとも重要なオペレーションであるバックアップについては、自動的に実行される仕組みがあります。その基本となるのが、bkup_apiコマンドです。
bash-4.1# /var/opt/oracle/bkup_api/bkup_api --help
Usage: bkup_api [options]
Backup [bkup_start, bkup_status, bkup_stop, bkup_chkcfg, bkup_chgcfg]
Recover [recover_start, recover_status, recover_stop, recover_list]
Delete [bkup_delete] Tag [get_tag]
Wallet [update_wallet] Clean [clean_archlogs]
Options:
-h, --help show this help message and exit
--rargs="-option args string"
Paremeters for the Recovery tool, they must be in
format "-pitr TAG20140117T061554 -data"
-k, --keep takes a long-term retetion backup
--tag=--tag=DBAAS or JAAS
generates a retore point with the specified tag
-b --bkup=JAAS20140805T2121, --bkup=--bkup=JAAS20140805T2121
Backup tag to be deleted only long term retetion
backups can be deleted [JAAS]
-r 15, --retention_days=15
The recovery windows that it will be used
-c 7, --bkup_cycle=7 Backup policy days
-p *******, --password=*******
User password for oss connection
bash-4.1#
バックアップの実行は簡単で、rootユーザーでbkup_api bkup_startを実行するだけです。
-bash-4.1# /var/opt/oracle/bkup_api/bkup_api bkup_start
########### DBAAS BACKUP API ######################
* Action: bkup_start
* log: /var/opt/oracle/bkup_api/bkup_api.log
-bash-4.1# ** process started with PID: 1928
** see log file for monitor progress
-------------------------------------
-bash-4.1#
バックアップ完了前にコマンドはリターンし、プロンプトが返ります。
バックアップの状態を確認するにはbkup_api bkup_statusを実行します。
-bash-4.1# /var/opt/oracle/bkup_api/bkup_api bkup_status
########### DBAAS BACKUP API ######################
* Action: bkup_status
* log: /var/opt/oracle/bkup_api/bkup_api.log
* Current backup settings:
catalog: no
type: diskoss
* DBAAS utility logfile: /home/oracle/bkup/log/obkup.log
* Last registered Bkup: 12-07 09:31 API::1928:: Starting dbaas backup process
* Bkup state: running
**************************************************
API:: Oracle database state is up and running
API:: Performing backup to local storage (primary backup)
API:: Executing rman instructions
*
* RETURN CODE:0
##################################################
-bash-4.1# /var/opt/oracle/bkup_api/bkup_api bkup_status
########### DBAAS BACKUP API ######################
* Action: bkup_status
* log: /var/opt/oracle/bkup_api/bkup_api.log
* Current backup settings:
catalog: no
type: diskoss
* DBAAS utility logfile: /home/oracle/bkup/log/obkup.log
* Last registered Bkup: 12-07 09:31 API::1928:: Starting dbaas backup process
* Bkup state: running
**************************************************
API:: Oracle database state is up and running
API:: Performing backup to local storage (primary backup)
API:: Executing rman instructions
API:: ...... OK
API:: Backup to local storage is completed
API:: Clean MOTD.
API:: Performing backup to cloud storage (secondary backup)
API:: Executing rman instructions
*
* RETURN CODE:0
##################################################
-bash-4.1# /var/opt/oracle/bkup_api/bkup_api bkup_status
########### DBAAS BACKUP API ######################
* Action: bkup_status
* log: /var/opt/oracle/bkup_api/bkup_api.log
* Current backup settings:
catalog: no
type: diskoss
* DBAAS utility logfile: /home/oracle/bkup/log/obkup.log
* Last registered Bkup: 12-07 09:31 API::1928:: Starting dbaas backup process
* Bkup state: finished
**************************************************
* API History: API steps
12-07 09:31 API:: NEW PROCESS 1928
12-07 09:31 API:: Starting dbaas backup process
12-07 09:31 API:: Requesting the number of backups in your system ....
12-07 09:31 API:: Your system has 1 backups
12-07 09:31 API:: Running the following command: /home/oracle/bkup/obkup
12-07 09:55 API:: The dbaas backup process is completed
12-07 09:55 API:: Searching for the new dbaas backup tag:
12-07 09:55 API:: Multiple new dbaas backups were created
12-07 09:55 API:: * TAG20151207T094129
12-07 09:55 API:: * TAG20151207T094906
12-07 09:55 API:: * TAG20151207T094924
12-07 09:55 API:: Your new dbaas backup tag is TAG20151207T095506
12-07 09:55 API:: BKUP COMPLETE YOUR BKUP TAG TAG20151207T095506
*************************************************
* Backup steps
API:: Oracle database state is up and running
API:: Performing backup to local storage (primary backup)
API:: Executing rman instructions
API:: ...... OK
API:: Backup to local storage is completed
API:: Clean MOTD.
API:: Performing backup to cloud storage (secondary backup)
API:: Executing rman instructions
API:: ......OK
API:: Backup to cloud storage is completed
API:: Clean MOTD.
API:: Validating the backup repository:
API:: All backup pieces are ok
API:: Starting backup of config files
API:: at time: 2015-12-07:09:55:40
API:: Creating directories to store config files
API:: Determining the oracle database id
API:: DBID: 1425569508
API:: Compressing config files into tar files
API:: .... OK
API:: Uploading config files to cloud storage
API:: Completed at time: 2015-12-07:09:55:46
API:: Config files backup ended successfully
API:: All requested tasks are completed
*
* RETURN CODE:0
##################################################
-bash-4.1#
なお、バックアップはcrontabに登録されているため、毎日01:01頃に実行されます。
-bash-4.1# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
01 01 * * * root /var/opt/oracle/bkup_api/bkup_api bkup_start←★
15 03 * * 6 oracle /var/opt/oracle/cleandb/cleandblogs.pl
-bash-4.1#
ただし、確認した限り、Oracle Database Cloud ServiceのCompute Node(Oracle Linux)のタイムゾーン設定はUTCのようでした。このため、日本時間で運用していると、(おそらく)想定外の時間にバックアップが実行されることに注意が必要です。Compute Node(Oracle Linux)のタイムゾーン設定をJSTにすればOKだと思いますが、気になる方はサポートに確認してみてください。