Updated the knob/metric output samples for each of the Oracle versions we support since my fix changed all of them.

This commit is contained in:
dvanaken
2019-11-05 19:39:34 -05:00
committed by Dana Van Aken
parent e1b29eaafa
commit cf19380107
19 changed files with 44991 additions and 46524 deletions

View File

@@ -42,8 +42,8 @@
"control_files": "/opt/oracle/oradata/ORCLCDB/control01.ctl",
"control_management_pack_access": "DIAGNOSTIC+TUNING",
"core_dump_dest": "/opt/oracle/diag/rdbms/orclcdb/ORCLCDB/cdump",
"cpu_count": "4",
"cpu_min_count": "4",
"cpu_count": "8",
"cpu_min_count": "8",
"create_bitmap_area_size": "8388608",
"cursor_bind_capture_destination": "memory+disk",
"cursor_invalidation": "IMMEDIATE",
@@ -64,8 +64,8 @@
"db_block_checksum": "TYPICAL",
"db_block_size": "8192",
"db_cache_advice": "ON",
"db_cache_size": "0",
"db_file_multiblock_read_count": "128",
"db_cache_size": "16777216",
"db_file_multiblock_read_count": "29",
"db_files": "200",
"db_flash_cache_size": "0",
"db_flashback_retention_target": "1440",
@@ -93,7 +93,7 @@
"disk_asynch_io": "TRUE",
"dispatchers": "(PROTOCOL=TCP) (SERVICE=ORCLCDBXDB)",
"distributed_lock_timeout": "60",
"dml_locks": "2216",
"dml_locks": "4328",
"dnfs_batch_size": "4096",
"dst_upgrade_insert_conv": "TRUE",
"enable_automatic_maintenance_pdb": "TRUE",
@@ -138,7 +138,7 @@
"java_pool_size": "0",
"java_restrict": "none",
"java_soft_sessionspace_limit": "0",
"job_queue_processes": "80",
"job_queue_processes": "160",
"large_pool_size": "0",
"ldap_directory_access": "NONE",
"ldap_directory_sysauth": "no",
@@ -240,12 +240,12 @@
"parallel_degree_policy": "MANUAL",
"parallel_execution_message_size": "16384",
"parallel_force_local": "FALSE",
"parallel_max_servers": "80",
"parallel_max_servers": "160",
"parallel_min_degree": "1",
"parallel_min_percent": "0",
"parallel_min_servers": "8",
"parallel_min_servers": "16",
"parallel_min_time_threshold": "AUTO",
"parallel_servers_target": "80",
"parallel_servers_target": "160",
"parallel_threads_per_cpu": "1",
"permit_92_wrap_format": "TRUE",
"pga_aggregate_limit": "2147483648",
@@ -258,7 +258,7 @@
"plsql_warnings": "DISABLE:ALL",
"pre_page_sga": "TRUE",
"private_temp_table_prefix": "ORA$PTT_",
"processes": "320",
"processes": "640",
"query_rewrite_enabled": "TRUE",
"query_rewrite_integrity": "enforced",
"read_only_open_delayed": "FALSE",
@@ -271,9 +271,10 @@
"replication_dependency_tracking": "TRUE",
"resource_limit": "TRUE",
"resource_manage_goldengate": "FALSE",
"resource_manager_cpu_allocation": "4",
"resource_manager_cpu_allocation": "8",
"resource_manager_plan": "SCHEDULER[0x4D52]:DEFAULT_MAINTENANCE_PLAN",
"result_cache_max_result": "5",
"result_cache_max_size": "8060928",
"result_cache_max_size": "1179648",
"result_cache_mode": "MANUAL",
"result_cache_remote_expiration": "0",
"resumable_timeout": "0",
@@ -287,14 +288,14 @@
"service_names": "ORCLCDB",
"session_cached_cursors": "50",
"session_max_open_files": "10",
"sessions": "504",
"sessions": "984",
"sga_max_size": "1610612736",
"sga_min_size": "0",
"sga_target": "1610612736",
"shadow_core_dump": "partial",
"shared_memory_address": "0",
"shared_pool_reserved_size": "19293798",
"shared_pool_size": "0",
"shared_pool_reserved_size": "5872025",
"shared_pool_size": "16777216",
"shared_servers": "1",
"shrd_dupl_table_refresh_rate": "60",
"skip_unusable_indexes": "TRUE",
@@ -309,7 +310,7 @@
"standby_file_management": "MANUAL",
"star_transformation_enabled": "FALSE",
"statistics_level": "TYPICAL",
"streams_pool_size": "0",
"streams_pool_size": "117440512",
"tape_asynch_io": "TRUE",
"target_pdbs": "3",
"temp_undo_enabled": "FALSE",
@@ -318,7 +319,7 @@
"timed_os_statistics": "0",
"timed_statistics": "TRUE",
"trace_enabled": "TRUE",
"transactions": "554",
"transactions": "1082",
"transactions_per_rollback_segment": "5",
"undo_management": "AUTO",
"undo_retention": "900",

View File

@@ -1,7 +1,7 @@
{
"start_time": 1572969216650,
"end_time": 1572969246165,
"observation_time": 29,
"start_time": 1563264802685,
"end_time": 1563265002918,
"observation_time": 200,
"database_type": "oracle",
"database_version": "19.0.0.0.0",
"workload_name": "tpcc"

View File

@@ -0,0 +1,318 @@
{
"global": {"global": {
"allow_global_dblinks": "FALSE",
"allow_group_access_to_sga": "FALSE",
"approx_for_aggregation": "FALSE",
"approx_for_count_distinct": "FALSE",
"approx_for_percentile": "none",
"aq_tm_processes": "1",
"archive_lag_target": "0",
"asm_io_processes": "20",
"asm_power_limit": "1",
"audit_file_dest": "/opt/oracle/admin/ORCLCDB/adump",
"audit_sys_operations": "FALSE",
"audit_trail": "NONE",
"autotask_max_active_pdbs": "2",
"awr_pdb_autoflush_enabled": "FALSE",
"awr_snapshot_time_offset": "0",
"background_core_dump": "partial",
"background_dump_dest": "/opt/oracle/product/12.2.0.1/dbhome_1/rdbms/log",
"backup_tape_io_slaves": "FALSE",
"bitmap_merge_area_size": "1048576",
"blank_trimming": "FALSE",
"cdb_cluster": "FALSE",
"cdb_cluster_name": "ORCLCDB",
"cell_offload_compaction": "ADAPTIVE",
"cell_offload_decryption": "TRUE",
"cell_offload_plan_display": "AUTO",
"cell_offload_processing": "TRUE",
"client_result_cache_lag": "3000",
"client_result_cache_size": "0",
"clonedb": "FALSE",
"cluster_database": "FALSE",
"cluster_database_instances": "1",
"commit_point_strength": "1",
"common_user_prefix": "C##",
"compatible": "12.2.0",
"connection_brokers": "((TYPE=DEDICATED)(BROKERS=1)), ((TYPE=EMON)(BROKERS=1))",
"containers_parallel_degree": "65535",
"control_file_record_keep_time": "7",
"control_files": "/opt/oracle/oradata/ORCLCDB/control01.ctl",
"control_management_pack_access": "DIAGNOSTIC+TUNING",
"core_dump_dest": "/opt/oracle/diag/rdbms/orclcdb/ORCLCDB/cdump",
"cpu_count": "4",
"create_bitmap_area_size": "8388608",
"cursor_bind_capture_destination": "memory+disk",
"cursor_invalidation": "IMMEDIATE",
"cursor_sharing": "EXACT",
"cursor_space_for_time": "FALSE",
"data_guard_sync_latency": "0",
"data_transfer_cache_size": "0",
"db_16k_cache_size": "0",
"db_2k_cache_size": "0",
"db_32k_cache_size": "0",
"db_4k_cache_size": "0",
"db_8k_cache_size": "0",
"db_big_table_cache_percent_target": "0",
"db_block_buffers": "0",
"db_block_checking": "FALSE",
"db_block_checksum": "TYPICAL",
"db_block_size": "8192",
"db_cache_advice": "ON",
"db_cache_size": "0",
"db_file_multiblock_read_count": "128",
"db_files": "200",
"db_flash_cache_size": "0",
"db_flashback_retention_target": "1440",
"db_index_compression_inheritance": "NONE",
"db_keep_cache_size": "0",
"db_lost_write_protect": "NONE",
"db_name": "ORCLCDB",
"db_recovery_file_dest_size": "0",
"db_recycle_cache_size": "0",
"db_securefile": "PREFERRED",
"db_ultra_safe": "OFF",
"db_unique_name": "ORCLCDB",
"db_unrecoverable_scn_tracking": "TRUE",
"db_writer_processes": "1",
"dbfips_140": "FALSE",
"dbwr_io_slaves": "0",
"ddl_lock_timeout": "0",
"default_sharing": "metadata",
"deferred_segment_creation": "TRUE",
"dg_broker_config_file1": "/opt/oracle/product/12.2.0.1/dbhome_1/dbs/dr1ORCLCDB.dat",
"dg_broker_config_file2": "/opt/oracle/product/12.2.0.1/dbhome_1/dbs/dr2ORCLCDB.dat",
"dg_broker_start": "FALSE",
"diagnostic_dest": "/opt/oracle",
"disable_pdb_feature": "0",
"disk_asynch_io": "TRUE",
"dispatchers": "(PROTOCOL=TCP) (SERVICE=ORCLCDBXDB)",
"distributed_lock_timeout": "60",
"dml_locks": "2216",
"dnfs_batch_size": "4096",
"dst_upgrade_insert_conv": "TRUE",
"enable_automatic_maintenance_pdb": "TRUE",
"enable_ddl_logging": "FALSE",
"enable_dnfs_dispatcher": "FALSE",
"enable_goldengate_replication": "FALSE",
"enable_pluggable_database": "TRUE",
"enabled_pdbs_on_standby": "*",
"encrypt_new_tablespaces": "CLOUD_ONLY",
"exafusion_enabled": "1",
"fast_start_io_target": "0",
"fast_start_mttr_target": "0",
"fast_start_parallel_rollback": "LOW",
"file_mapping": "FALSE",
"filesystemio_options": "none",
"gcs_server_processes": "0",
"global_names": "FALSE",
"global_txn_processes": "1",
"hash_area_size": "131072",
"heat_map": "OFF",
"hi_shared_memory_address": "0",
"hs_autoregister": "TRUE",
"inmemory_adg_enabled": "TRUE",
"inmemory_expressions_usage": "ENABLE",
"inmemory_force": "DEFAULT",
"inmemory_max_populate_servers": "0",
"inmemory_query": "ENABLE",
"inmemory_size": "0",
"inmemory_trickle_repopulate_servers_percent": "1",
"inmemory_virtual_columns": "MANUAL",
"instance_abort_delay_time": "0",
"instance_mode": "READ-WRITE",
"instance_name": "ORCLCDB",
"instance_number": "0",
"instance_type": "RDBMS",
"instant_restore": "FALSE",
"java_jit_enabled": "TRUE",
"java_max_sessionspace_size": "0",
"java_pool_size": "0",
"java_restrict": "none",
"java_soft_sessionspace_limit": "0",
"job_queue_processes": "4000",
"large_pool_size": "0",
"ldap_directory_access": "NONE",
"ldap_directory_sysauth": "no",
"license_max_sessions": "0",
"license_max_users": "0",
"license_sessions_warning": "0",
"lock_sga": "FALSE",
"log_archive_dest_state_1": "enable",
"log_archive_dest_state_10": "enable",
"log_archive_dest_state_11": "enable",
"log_archive_dest_state_12": "enable",
"log_archive_dest_state_13": "enable",
"log_archive_dest_state_14": "enable",
"log_archive_dest_state_15": "enable",
"log_archive_dest_state_16": "enable",
"log_archive_dest_state_17": "enable",
"log_archive_dest_state_18": "enable",
"log_archive_dest_state_19": "enable",
"log_archive_dest_state_2": "enable",
"log_archive_dest_state_20": "enable",
"log_archive_dest_state_21": "enable",
"log_archive_dest_state_22": "enable",
"log_archive_dest_state_23": "enable",
"log_archive_dest_state_24": "enable",
"log_archive_dest_state_25": "enable",
"log_archive_dest_state_26": "enable",
"log_archive_dest_state_27": "enable",
"log_archive_dest_state_28": "enable",
"log_archive_dest_state_29": "enable",
"log_archive_dest_state_3": "enable",
"log_archive_dest_state_30": "enable",
"log_archive_dest_state_31": "enable",
"log_archive_dest_state_4": "enable",
"log_archive_dest_state_5": "enable",
"log_archive_dest_state_6": "enable",
"log_archive_dest_state_7": "enable",
"log_archive_dest_state_8": "enable",
"log_archive_dest_state_9": "enable",
"log_archive_format": "%t_%s_%r.dbf",
"log_archive_max_processes": "4",
"log_archive_min_succeed_dest": "1",
"log_archive_start": "FALSE",
"log_archive_trace": "0",
"log_buffer": "7634944",
"log_checkpoint_interval": "0",
"log_checkpoint_timeout": "1800",
"log_checkpoints_to_alert": "FALSE",
"long_module_action": "TRUE",
"max_datapump_jobs_per_pdb": "100",
"max_dump_file_size": "unlimited",
"max_idle_time": "0",
"max_iops": "0",
"max_mbps": "0",
"max_pdbs": "4098",
"max_string_size": "STANDARD",
"memory_max_target": "0",
"memory_target": "0",
"nls_comp": "BINARY",
"nls_language": "AMERICAN",
"nls_length_semantics": "BYTE",
"nls_nchar_conv_excp": "FALSE",
"nls_territory": "AMERICA",
"noncdb_compatible": "FALSE",
"o7_dictionary_accessibility": "FALSE",
"object_cache_max_size_percent": "10",
"object_cache_optimal_size": "10240000",
"ofs_threads": "4",
"olap_page_pool_size": "0",
"one_step_plugin_for_pdb_with_tde": "FALSE",
"open_cursors": "300",
"open_links": "4",
"open_links_per_instance": "4",
"optimizer_adaptive_plans": "TRUE",
"optimizer_adaptive_reporting_only": "FALSE",
"optimizer_adaptive_statistics": "FALSE",
"optimizer_capture_sql_plan_baselines": "FALSE",
"optimizer_dynamic_sampling": "2",
"optimizer_features_enable": "12.2.0.1",
"optimizer_index_caching": "0",
"optimizer_index_cost_adj": "100",
"optimizer_inmemory_aware": "TRUE",
"optimizer_mode": "ALL_ROWS",
"optimizer_secure_view_merging": "TRUE",
"optimizer_use_invisible_indexes": "FALSE",
"optimizer_use_pending_statistics": "FALSE",
"optimizer_use_sql_plan_baselines": "TRUE",
"os_authent_prefix": "ops$",
"os_roles": "FALSE",
"outbound_dblink_protocols": "ALL",
"parallel_adaptive_multi_user": "FALSE",
"parallel_degree_limit": "CPU",
"parallel_degree_policy": "MANUAL",
"parallel_execution_message_size": "16384",
"parallel_force_local": "FALSE",
"parallel_max_servers": "160",
"parallel_min_percent": "0",
"parallel_min_servers": "16",
"parallel_min_time_threshold": "AUTO",
"parallel_servers_target": "64",
"parallel_threads_per_cpu": "2",
"permit_92_wrap_format": "TRUE",
"pga_aggregate_limit": "2147483648",
"pga_aggregate_target": "536870912",
"plscope_settings": "IDENTIFIERS:NONE",
"plsql_code_type": "INTERPRETED",
"plsql_debug": "FALSE",
"plsql_optimize_level": "2",
"plsql_v2_compatibility": "FALSE",
"plsql_warnings": "DISABLE:ALL",
"pre_page_sga": "TRUE",
"processes": "320",
"query_rewrite_enabled": "TRUE",
"query_rewrite_integrity": "enforced",
"read_only_open_delayed": "FALSE",
"recovery_parallelism": "0",
"recyclebin": "on",
"remote_dependencies_mode": "TIMESTAMP",
"remote_login_passwordfile": "EXCLUSIVE",
"remote_os_authent": "FALSE",
"remote_os_roles": "FALSE",
"replication_dependency_tracking": "TRUE",
"resource_limit": "TRUE",
"resource_manage_goldengate": "FALSE",
"resource_manager_cpu_allocation": "4",
"result_cache_max_result": "5",
"result_cache_max_size": "8060928",
"result_cache_mode": "MANUAL",
"result_cache_remote_expiration": "0",
"resumable_timeout": "0",
"sec_case_sensitive_logon": "TRUE",
"sec_max_failed_login_attempts": "3",
"sec_protocol_error_further_action": "(DROP,3)",
"sec_protocol_error_trace_action": "TRACE",
"sec_return_server_release_banner": "FALSE",
"serial_reuse": "disable",
"service_names": "ORCLCDB",
"session_cached_cursors": "50",
"session_max_open_files": "10",
"sessions": "504",
"sga_max_size": "1610612736",
"sga_min_size": "0",
"sga_target": "1610612736",
"shadow_core_dump": "partial",
"shared_memory_address": "0",
"shared_pool_reserved_size": "16777216",
"shared_pool_size": "0",
"shared_servers": "1",
"shrd_dupl_table_refresh_rate": "60",
"skip_unusable_indexes": "TRUE",
"sort_area_retained_size": "0",
"sort_area_size": "65536",
"spatial_vector_acceleration": "FALSE",
"spfile": "/opt/oracle/product/12.2.0.1/dbhome_1/dbs/spfileORCLCDB.ora",
"sql92_security": "TRUE",
"sql_trace": "FALSE",
"sqltune_category": "DEFAULT",
"standby_archive_dest": "?#/dbs/arch",
"standby_db_preserve_states": "NONE",
"standby_file_management": "MANUAL",
"star_transformation_enabled": "FALSE",
"statistics_level": "TYPICAL",
"streams_pool_size": "0",
"tape_asynch_io": "TRUE",
"target_pdbs": "3",
"temp_undo_enabled": "FALSE",
"thread": "0",
"threaded_execution": "FALSE",
"timed_os_statistics": "0",
"timed_statistics": "TRUE",
"trace_enabled": "TRUE",
"transactions": "554",
"transactions_per_rollback_segment": "5",
"undo_management": "AUTO",
"undo_retention": "900",
"undo_tablespace": "UNDOTBS1",
"unified_audit_sga_queue_size": "1048576",
"uniform_log_timestamp_format": "TRUE",
"use_dedicated_broker": "FALSE",
"use_large_pages": "TRUE",
"user_dump_dest": "/opt/oracle/product/12.2.0.1/dbhome_1/rdbms/log",
"workarea_size_policy": "AUTO",
"xml_db_events": "enable"
}},
"local": null
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,9 @@
{
"start_time": 1572999607609,
"end_time": 1572999638053,
"observation_time": 30,
"database_type": "oracle",
"database_version": "19.0.0.0.0",
"workload_name": "tpcc",
"real_database_version": "12.2.0.1.0"
}

View File

@@ -23,58 +23,23 @@ import requests
from fabric.api import env, lcd, local, settings, show, task
from fabric.state import output as fabric_output
from utils import file_exists, get, load_driver_conf, parse_bool, put, run, sudo
from utils import (file_exists, get, load_driver_conf, parse_bool,
put, run, run_sql_script, sudo, FabricException)
# Loads the driver config file (defaults to driver_config.py)
dconf = load_driver_conf()
# Fabric settings
fabric_output.update({
'running': True,
'stdout': True,
})
env.abort_exception = FabricException
env.hosts = [dconf.LOGIN]
# Loads the driver config file (default: driver_config.py)
dconf = load_driver_conf()
def _setup():
global LOGIN
# Determine correct login for the type of host connection
if dconf.HOST_CONN == 'local':
LOGIN = 'localhost'
elif dconf.HOST_CONN == 'remote':
if not dconf.LOGIN_HOST:
raise ValueError("LOGIN_HOST must be set if HOST_CONN=remote")
LOGIN = dconf.LOGIN_HOST
if dconf.LOGIN_NAME:
LOGIN = '{}@{}'.format(dconf.LOGIN_NAME, LOGIN)
if dconf.LOGIN_PORT:
LOGIN += ':{}'.format(dconf.LOGIN_PORT)
elif dconf.HOST_CONN == 'docker':
if not dconf.CONTAINER_NAME:
raise ValueError("CONTAINER_NAME must be set if HOST_CONN=docker")
LOGIN = 'localhost'
else:
raise ValueError(("Invalid HOST_CONN: {}. Valid values are "
"'local', 'remote', or 'docker'.").format(dconf.HOST_CONN))
# Update Fabric's host list
env.hosts = [LOGIN]
# Create local directories
for d in (dconf.RESULT_DIR, dconf.LOG_DIR, dconf.TEMP_DIR):
os.makedirs(d, exist_ok=True)
# Copy Oracle scripts
if dconf.DB_TYPE == 'oracle':
put('./oracleScripts', '/home/oracle')
sudo('chown -R oracle:oinstall /home/oracle/oracleScripts')
_setup()
# Create local directories
for _d in (dconf.RESULT_DIR, dconf.LOG_DIR, dconf.TEMP_DIR):
os.makedirs(_d, exist_ok=True)
# Configure logging
@@ -145,7 +110,7 @@ def restart_database():
else:
sudo('pg_ctl -D {} -w -t 600 restart -m fast'.format(dconf.PG_DATADIR), user=dconf.DB_USER)
elif dconf.DB_TYPE == 'oracle':
run('sh oracleScripts/shutdownOracle.sh && sh oracleScripts/startupOracle.sh')
run_sql_script('restartOracle.sh')
else:
raise Exception("Database Type {} Not Implemented !".format(dconf.DB_TYPE))
@@ -175,7 +140,7 @@ def create_user():
run("PGPASSWORD={} psql -c \\\"{}\\\" -U postgres -h {}".format(
dconf.DB_PASSWORD, sql, dconf.DB_USER, dconf.DB_HOST))
elif dconf.DB_TYPE == 'oracle':
run('sh oracleScripts/createUser.sh {} {}'.format(dconf.DB_USER, dconf.DB_PASSWORD))
run_sql_script('createUser.sh', dconf.DB_USER, dconf.DB_PASSWORD)
else:
raise Exception("Database Type {} Not Implemented !".format(dconf.DB_TYPE))
@@ -187,7 +152,7 @@ def drop_user():
run("PGPASSWORD={} psql -c \\\"{}\\\" -U postgres -h {}".format(
dconf.DB_PASSWORD, sql, dconf.DB_HOST))
elif dconf.DB_TYPE == 'oracle':
run('sh oracleScripts/dropUser.sh {}'.format(dconf.DB_USER))
run_sql_script('dropUser.sh', dconf.DB_USER)
else:
raise Exception("Database Type {} Not Implemented !".format(dconf.DB_TYPE))
@@ -456,16 +421,15 @@ def dump_database():
LOG.info('Dump database %s to %s', dconf.DB_NAME, dumpfile)
if dconf.DB_TYPE == 'oracle':
cmd = 'sh oracleScripts/dumpOracle.sh {} {} {} {}'.format(
dconf.DB_USER, dconf.DB_PASSWORD, dconf.DB_NAME, dconf.DB_DUMP_DIR)
run_sql_script('dumpOracle.sh', dconf.DB_USER, dconf.DB_PASSWORD,
dconf.DB_NAME, dconf.DB_DUMP_DIR)
elif dconf.DB_TYPE == 'postgres':
cmd = 'PGPASSWORD={} pg_dump -U {} -h {} -F c -d {} > {}'.format(
run('PGPASSWORD={} pg_dump -U {} -h {} -F c -d {} > {}'.format(
dconf.DB_PASSWORD, dconf.DB_USER, dconf.DB_HOST, dconf.DB_NAME,
dumpfile)
dumpfile))
else:
raise Exception("Database Type {} Not Implemented !".format(dconf.DB_TYPE))
run(cmd)
return True
@@ -475,23 +439,20 @@ def restore_database():
if not file_exists(dumpfile):
raise FileNotFoundError("Database dumpfile '{}' does not exist!".format(dumpfile))
LOG.info('Start restoring database')
if dconf.DB_TYPE == 'oracle':
# You must create a directory named dpdata through sqlplus in your Oracle database
# The following script assumes such directory exists.
drop_user()
create_user()
cmd = 'sh oracleScripts/restoreOracle.sh {} {}'.format(dconf.DB_USER, dconf.DB_NAME)
run_sql_script('restoreOracle.sh', dconf.DB_USER, dconf.DB_NAME)
elif dconf.DB_TYPE == 'postgres':
drop_database()
create_database()
cmd = 'PGPASSWORD={} pg_restore -U {} -h {} -n public -j 8 -F c -d {} {}'.format(
dconf.DB_PASSWORD, dconf.DB_USER, dconf.DB_HOST, dconf.DB_NAME, dumpfile)
run('PGPASSWORD={} pg_restore -U {} -h {} -n public -j 8 -F c -d {} {}'.format(
dconf.DB_PASSWORD, dconf.DB_USER, dconf.DB_HOST, dconf.DB_NAME, dumpfile))
else:
raise Exception("Database Type {} Not Implemented !".format(dconf.DB_TYPE))
LOG.info('Start restoring database')
run(cmd)
LOG.info('Finish restoring database')

View File

@@ -0,0 +1,8 @@
#!/bin/sh
sqlplus / as sysdba <<EOF
shutdown immediate
startup
quit
EOF

View File

@@ -8,14 +8,43 @@ dconf = None
def load_driver_conf():
driver_conf = os.environ.get('DRIVER_CONFIG', 'driver_config')
if driver_conf.endswith('.py'):
driver_conf = driver_conf[:-len('.py')]
dmod = importlib.import_module(driver_conf)
# The default config file is 'driver_config.py' but you can use
# set the env 'DRIVER_CONFIG' to the path of a different config
# file to override it.
global dconf
if not dconf:
dconf = dmod
return dmod
driver_conf = os.environ.get('DRIVER_CONFIG', 'driver_config')
if driver_conf.endswith('.py'):
driver_conf = driver_conf[:-len('.py')]
mod = importlib.import_module(driver_conf)
dconf = mod
# Generate the login string of the host connection
if dconf.HOST_CONN == 'local':
login_str = 'localhost'
elif dconf.HOST_CONN == 'remote':
if not dconf.LOGIN_HOST:
raise ValueError("LOGIN_HOST must be set if HOST_CONN=remote")
login_str = dconf.LOGIN_HOST
if dconf.LOGIN_NAME:
login_str = '{}@{}'.format(dconf.LOGIN_NAME, login_str)
if dconf.LOGIN_PORT:
login_str += ':{}'.format(dconf.LOGIN_PORT)
elif dconf.HOST_CONN == 'docker':
if not dconf.CONTAINER_NAME:
raise ValueError("CONTAINER_NAME must be set if HOST_CONN=docker")
login_str = 'localhost'
else:
raise ValueError(("Invalid HOST_CONN: {}. Valid values are "
"'local', 'remote', or 'docker'.").format(dconf.HOST_CONN))
dconf.LOGIN = login_str
return dconf
def parse_bool(value):
@@ -103,8 +132,35 @@ def put(local_path, remote_path, use_sudo=False):
return res
@task
def run_sql_script(scriptfile, *args):
if dconf.DB_TYPE == 'oracle':
if dconf.HOST_CONN != 'local':
scriptdir = '/home/oracle/oracleScripts'
remote_path = os.path.join(scriptdir, scriptfile)
if not file_exists(remote_path):
run('mkdir -p {}'.format(scriptdir))
put(os.path.join('./oracleScripts', scriptfile), remote_path)
sudo('chown -R oracle:oinstall /home/oracle/oracleScripts')
res = run('sh {} {}'.format(remote_path, ' '.join(args)))
else:
raise Exception("Database Type {} Not Implemented !".format(dconf.DB_TYPE))
return res
@task
def file_exists(filename):
with settings(warn_only=True), hide('warnings'):
res = run('[ -f {} ]'.format(filename))
return res.return_code == 0
@task
def dir_exists(dirname):
with settings(warn_only=True), hide('warnings'):
res = run('[ -d {} ]'.format(dirname))
return res.return_code == 0
class FabricException(Exception):
pass