From dceee6e0ba3e36475df829ea35eb433839bde081 Mon Sep 17 00:00:00 2001 From: yangdsh Date: Sat, 23 Nov 2019 20:21:51 +0000 Subject: [PATCH] support Oracle flash back; auto-fix metric type; compile ojdbc --- client/controller/build.gradle | 1 + client/driver/driver_config.py | 4 +++ client/driver/fabfile.py | 37 ++++++++++++++------ client/driver/oracleScripts/archiveLog.sh | 11 ++++++ client/driver/oracleScripts/createRestore.sh | 33 +++++++++++++++++ client/driver/oracleScripts/flashBack.sh | 13 +++++++ client/driver/oracleScripts/removeRestore.sh | 10 ++++++ server/website/website/db/base/parser.py | 13 ++++++- 8 files changed, 111 insertions(+), 11 deletions(-) create mode 100644 client/driver/oracleScripts/archiveLog.sh create mode 100644 client/driver/oracleScripts/createRestore.sh create mode 100644 client/driver/oracleScripts/flashBack.sh create mode 100644 client/driver/oracleScripts/removeRestore.sh diff --git a/client/controller/build.gradle b/client/controller/build.gradle index 703db99..2c898d0 100644 --- a/client/controller/build.gradle +++ b/client/controller/build.gradle @@ -52,6 +52,7 @@ dependencies { // For Oracle, create the directory client/controller/libs and copy the driver // (e.g., ojdbc8.jar) into it. The driver must be manually downloaded from Oracle. + dependencies {compile files('lib/ojdbc8.jar')} } run { diff --git a/client/driver/driver_config.py b/client/driver/driver_config.py index f8fa089..d17f60b 100644 --- a/client/driver/driver_config.py +++ b/client/driver/driver_config.py @@ -68,6 +68,10 @@ PG_DATADIR = '/var/lib/postgresql/9.6/main' # ORACLE-SPECIFIC OPTIONS >>> ORACLE_AWR_ENABLED = False +ORACLE_FLASH_BACK = True +RESTORE_POINT = 'tpcc_point' +RECOVERY_FILE_DEST = '/opt/oracle/oradata/ORCL' +RECOVERY_FILE_DEST_SIZE = '15G' #========================================================== diff --git a/client/driver/fabfile.py b/client/driver/fabfile.py index a579d6c..65678e6 100644 --- a/client/driver/fabfile.py +++ b/client/driver/fabfile.py @@ -415,15 +415,23 @@ def upload_batch(result_dir=None, sort=True, upload_code=None): @task def dump_database(): dumpfile = os.path.join(dconf.DB_DUMP_DIR, dconf.DB_NAME + '.dump') - if file_exists(dumpfile): + if not dconf.ORACLE_FLASH_BACK and file_exists(dumpfile): LOG.info('%s already exists ! ', dumpfile) return False - LOG.info('Dump database %s to %s', dconf.DB_NAME, dumpfile) + if dconf.ORACLE_FLASH_BACK: + LOG.info('create restore point %s for database %s in %s', dconf.RESTORE_POINT, + dconf.DB_NAME, dconf.RECOVERY_FILE_DEST) + else: + LOG.info('Dump database %s to %s', dconf.DB_NAME, dumpfile) if dconf.DB_TYPE == 'oracle': - run_sql_script('dumpOracle.sh', dconf.DB_USER, dconf.DB_PASSWORD, - dconf.DB_NAME, dconf.DB_DUMP_DIR) + if dconf.ORACLE_FLASH_BACK: + run_sql_script('createRestore.sh', dconf.RESTORE_POINT, + dconf.RECOVERY_FILE_DEST_SIZE, dconf.RECOVERY_FILE_DEST) + else: + run_sql_script('dumpOracle.sh', dconf.DB_USER, dconf.DB_PASSWORD, + dconf.DB_NAME, dconf.DB_DUMP_DIR) elif dconf.DB_TYPE == 'postgres': run('PGPASSWORD={} pg_dump -U {} -h {} -F c -d {} > {}'.format( @@ -434,19 +442,28 @@ def dump_database(): return True +@task +def clean_recovery(): + run_sql_script('removeRestore.sh', dconf.RESTORE_POINT) + cmds = ("""rman TARGET / <= 0, \ '{} wrong metric type: {} (start={}, end={}, diff={})'.format( met_name, MetricType.name(met_info.metric_type), start_val,