среда, 27 марта 2013 г.

Rollback PSU 11.2.0.3.5

Patch  14727347 - 11.2.0.3.5 GI Patch Set Update (Includes Database PSU 11.2.0.3.5)


1. Stop the CRS managed resources running from DB homes.

# su - oraagent

$ emctl stop agent

# su - oradb

$ /u01/app/oradb/product/11.2.0.3/dbhome_1/bin/srvctl stop home -o /u01/app/oradb/product/11.2.0.3/dbhome_1 -s /export/home/oradb/state_file.oradb



2. Run the pre root script.

$su -

# /u01/app/11.2.0.3/grid/crs/install/roothas.pl -unlock



3. Unzipping

# su - oragrid

$cd /tmp

$unzip  p14727347_112030_SOLARIS64.zip

$ls -l
total 552336
drwxrwxr-x 4 oragrid oinstall 307 Jul 18 09:21 15876003
drwxr-xr-x 5 oragrid oinstall 302 Jul 18 09:21 14727310



4. Rollback the CRS patch using.


    $ /u01/app/11.2.0.3/grid/OPatch/opatch rollback -local -id 15876003 -oh /u01/app/11.2.0.3/grid
    $ /u01/app/11.2.0.3/grid/OPatch/opatch rollback -local -id 14727310 -oh /u01/app/11.2.0.3/grid




5. Run the pre script for DB component of the patch.

# su - oradb

    $ /tmp/15876003/custom/server/15876003/custom/scripts/prepatch.sh -dbhome /u01/app/oradb/product/11.2.0.3/dbhome_1



6. Rollback the DB patch.


    $ /u01/app/oradb/product/11.2.0.3/dbhome_1/OPatch/opatch rollback -local -id 15876003 -oh /u01/app/oradb/product/11.2.0.3/dbhome_1
    $ /u01/app/oradb/product/11.2.0.3/dbhome_1/OPatch/opatch rollback -local -id 14727310 -oh /u01/app/oradb/product/11.2.0.3/dbhome_1



7. Run the post script for DB component of the patch.

    $ /tmp/15876003/custom/server/15876003/custom/scripts/postpatch.sh -dbhome /u01/app/oradb/product/11.2.0.3/dbhome_1


8. Run the post script.

$su -

Run the post script.

# /u01/app/11.2.0.3/grid/rdbms/install/rootadd_rdbms.sh
# /u01/app/11.2.0.3/grid/crs/install/roothas.pl -patch


9. Start the CRS managed resources that were earlier running from DB homes.

# su - oradb

$ /u01/app/oradb/product/11.2.0.3/dbhome_1/bin/srvctl start home -o /u01/app/oradb/product/11.2.0.3/dbhome_1 -s /export/home/oradb/state_file.oradb


Проверяем:

$/u01/app/oradb/product/11.2.0.3/dbhome_1/OPatch/opatch lsinventory

$su - oragrid

$/u01/app/11.2.0.3/grid/OPatch/opatch lsinventory


четверг, 21 марта 2013 г.

Clone database

su - oragrid

$more listener.ora
# listener.ora Network Configuration File: /u01/app/11.2.0.3/grid/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = testdbt1.sun.com)
      (ORACLE_HOME = /u01/app/oradb/product/11.2.0.3/dbhome_1)
      (SID_NAME = testdbt1)
    )

  )


LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = test.sun.com)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oragrid

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent

$


su - oradb

$more tnsnames.ora

TESTDBT1.SUN.COM =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = testdbt1.sun.com)
    )
  )


$



# Rman CloneDB_asm:
#00 22 * * * ${HOME}/bin/pkg/clonedb_asm/_run.sh   testdbt1      > /dev/null 2>> /tmp/crontab_oracle.err




$more _run.sh
#!/bin/bash


#
# Package Name:
#

tmp_string="`dirname $0`"
pkg_name="`basename ${tmp_string}`"

if [ "${pkg_name}" = "." ]; then
  tmp_string="`pwd`"
  pkg_name="`basename ${tmp_string}`"
fi

# Check Parameters:
if [ $1 ]
then
  oracle_sid=`echo ${1} | tr "[A-Z]" "[a-z]"`
else
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: Error! (Parameter=1). Call `basename $0` " >&2
  exit 2
fi

#
# Setup Environment:
#

pkg_env="${HOME}/bin/_conf/.env"
if [ ! -r "${pkg_env}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Not Found Environment file: ${pkg_env}" >&2
  exit 2
fi

if [ -s "${pkg_env}" ]; then
  . ${pkg_env}
else
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment file is empty: ${pkg_env}" >&2
  exit 2
fi


#
# Check Environment:
#


# Check ORA_USER:
if [ -z "${ORA_USER}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable ORA_USER not defined" >&2
  exit 2
else
  ora_user=${ORA_USER}
fi


# Check ORACLE_BASE:
if [ -z "${ORACLE_BASE}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable ORACLE_BASE not defined" >&2
  exit 2
elif [ ! -d "${ORACLE_BASE}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Directory ORACLE_BASE not found (${ORACLE_BASE})" >&2
  exit 2
fi


# Check ORACLE_HOME:
if [ -z "${ORACLE_HOME}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable ORACLE_HOME not defined" >&2
  exit 2
elif [ ! -d "${ORACLE_HOME}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Directory ORACLE_HOME not found (${ORACLE_HOME})" >&2
  exit 2
fi


# Check TMP_DIR:
if [ -z "${TMP_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable TMP_DIR not defined" >&2
  exit 2
elif [ ! -d "${TMP_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Directory TMP_DIR not found (${TMP_DIR})" >&2
  exit 2
elif [ ! -w "${TMP_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Directory TMP_DIR not writeable (${TMP_DIR})" >&2
  exit 2
fi


# Check BIN_DIR:
if [ -z "${BIN_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable BIN_DIR not defined" >&2
  exit 2
elif [ ! -d "${BIN_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Directory BIN_DIR not found (${BIN_DIR})" >&2
  exit 2
fi


# Check COMPANY_NAME:
if [ -z "${COMPANY_NAME}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable COMPANY_NAME not defined" >&2
  exit 2
fi


# Check HOST_NAME:
if [ -z "${HOST_NAME}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable HOST_NAME not defined" >&2
  exit 2
fi


# Check MAIL_RECIPIENTS:
if [ -z "${MAIL_DBA}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable MAIL_RECIPIENTS not defined" >&2
  exit 2
fi


# Check UTL_SEND:
if [ -z "${UTL_SEND}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable UTL_SEND not defined" >&2
  exit 2
elif [ ! -f "${UTL_SEND}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. File UTL_SEND not found (${UTL_SEND})" >&2
  exit 2
elif [ ! -x "${UTL_SEND}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. File UTL_SEND not executable (${UTL_SEND})" >&2
  exit 2
fi


# Check UTL_SQLPLUS:
if [ -z "${UTL_SQLPLUS}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable UTL_SQLPLUS not defined" >&2
  exit 2
elif [ ! -f "${UTL_SQLPLUS}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. File UTL_SQLPLUS not found (${UTL_SQLPLUS})" >&2
  exit 2
elif [ ! -x "${UTL_SQLPLUS}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. File UTL_SQLPLUS not executable (${UTL_SQLPLUS})" >&2
  exit 2
fi


# Check UTL_ORAPWD:
if [ -z "${UTL_ORAPWD}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable UTL_ORAPWD not defined" >&2
  exit 2
elif [ ! -f "${UTL_ORAPWD}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. File UTL_ORAPWD not found (${UTL_ORAPWD})" >&2
  exit 2
elif [ ! -x "${UTL_ORAPWD}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. File UTL_ORAPWD not executable (${UTL_ORAPWD})" >&2
  exit 2
fi


# Check UTL_RMAN:
if [ -z "${UTL_RMAN}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable UTL_RMAN not defined" >&2
  exit 2
elif [ ! -f "${UTL_RMAN}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. File UTL_RMAN not found (${UTL_RMAN})" >&2
  exit 2
elif [ ! -x "${UTL_RMAN}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. File UTL_RMAN not executable (${UTL_RMAN})" >&2
  exit 2
fi


# Initialize Package:

pkg_flag="`basename $0 .sh`"
run_in_progress=${TMP_DIR}/${pkg_name}_${oracle_sid}.lock
log_file=${TMP_DIR}/${pkg_name}_${oracle_sid}.log
prefix="${COMPANY_NAME}#${HOST_NAME}(${oracle_sid}) ${pkg_name}"
mess_theme="${prefix}: Error! Another process running (${run_in_progress})"

mail_recipients="$MAIL_DBA"
echo $mail_recipients

# Check Another process for running:
if [ -f ${run_in_progress} ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: Error! Another process running. Remove a file ${run_in_progress}" >&2
  echo "Remove a file ${run_in_progress}" | ${BIN_DIR}/_lib/utl_send.sh "${mess_theme}" "${mail_recipients}"
  exit 2
fi

# Prevent Parallel Execution:
touch ${run_in_progress}


# Run Implementation:
${BIN_DIR}/pkg/${pkg_name}/body.sh "${pkg_flag}" "${oracle_sid}" | tee ${log_file}

# Cleanup Stop Flag:
test -r ${run_in_progress} && rm ${run_in_progress}

$




$more body.sh
#!/bin/bash


#
# Check Parameters:
#

# Package Name:
tmp_string="`dirname $0`"
pkg_name="`basename ${tmp_string}`"

if [ "${pkg_name}" = "." ]; then
  tmp_string="`pwd`"
  pkg_name="`basename ${tmp_string}`"
fi

# Check for internal call:
if [ ! $1 = '_run' ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: Error! (Parameter=1) Call `basename $0` from ./_run.sh" >&2
  exit 2
fi

# Check For :
if [ $2 ]
then
  ##echo " 2=${2} (ORACLE_SID)"
  ORACLE_SID=`echo ${2} | tr "[A-Z]" "[a-z]"`; export ORACLE_SID
else
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: Error! (Parameter=2) Call `basename $0` With 2-d parameter" >&2
  exit 2
fi


#
# Define local variables:
#

# Variables:

prefix="${COMPANY_NAME}#${HOST_NAME}(${ORACLE_SID}) ${pkg_name}"
mess_theme="${prefix}:Duplicate database"
log_file=${TMP_DIR}/${pkg_name}_${ORACLE_SID}.log
after_recreate_sql=/export/home/oradb/bin/_sql/testdb_after_recreate_${ORACLE_SID}.sql
after_recreate_log=/export/home/oradb/bin/_sql/testdb_after_recreate_${ORACLE_SID}.log

mail_recipients="$MAIL_DBA"

orapwd_filename="${ORACLE_HOME}/dbs/orapw${ORACLE_SID}"
orapwd_temp_passwd='oracle'
tnsnames_name="${ORACLE_SID}"
initfile_ora="${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora"
spfile_ora="${ORACLE_HOME}/dbs/spfile${ORACLE_SID}.ora"
rman_cmdfile="${BIN_DIR}/_sql/make_${ORACLE_SID}.rman"


echo "Start RMAN Duplicate Database: `date +%Y.%m.%d" "%H:%M:%S`"
echo ''

echo "ORACLE_HOME=${ORACLE_HOME}"
echo "UTL_SQLPLUS=${UTL_SQLPLUS}"
echo "UTL_ORAPWD=${UTL_ORAPWD}"
echo "UTL_RMAN=${UTL_RMAN}"
echo "ORACLE_SID=${ORACLE_SID}"
echo "orapwd_filename=${orapwd_filename}"
echo "orapwd_temp_passwd=${orapwd_temp_passwd}"
echo "tnsnames_name=${tnsnames_name}"
echo "initfile_ora=${initfile_ora}"
echo "spfile_ora=${spfile_ora}"
echo "rman_cmdfile=${rman_cmdfile}"
echo ''
echo ''


#
# Task 0: Drop Database
# (2DO: First time - DB does`t not exist!!!)
#
echo "`date +%Y.%m.%d" "%H:%M:%S` Task 0: DROP DATABASE - Start"

${UTL_SQLPLUS} -s '/ as sysdba' << EOF
shutdown abort;
STARTUP MOUNT RESTRICT;
DROP DATABASE;
EOF

echo "`date +%Y.%m.%d" "%H:%M:%S` Task 0: DROP DATABASE - Finish"
echo ''
echo ''


#
# Step 0.A: Trying shutdown Instance
#
echo " Trying shutdown Instance: ${ORACLE_SID} - Start"

${UTL_SQLPLUS} /nolog << EOF
connect / as sysdba
shutdown abort;
EOF

echo " Trying shutdown Instance: ${ORACLE_SID} - Finish"
echo ''
echo ''


#
# Step 0.B: Trying to remove spfile
#
echo -n " Trying to remove spfile: ${spfile_ora}"

if [ -r ${spfile_ora} ]; then
    rm ${spfile_ora}
    echo " - Done."
else
    echo " - Skipped. File not exist."
fi

echo ''
echo ''


#
# Task 1: Create an Oracle Password File for the Auxiliary Instance
#
echo "`date +%Y.%m.%d" "%H:%M:%S` Task 1: Create an Oracle Password File for the Auxiliary Instance - Start"

${UTL_ORAPWD} force=y file=${orapwd_filename} password=${orapwd_temp_passwd}

echo "`date +%Y.%m.%d" "%H:%M:%S` Task 1: Create an Oracle Password File for the Auxiliary Instance - Finish"
echo ''
echo ''


#
# Task 3: Create an Initialization Parameter File for the Auxiliary Instance
#
echo "`date +%Y.%m.%d" "%H:%M:%S` Task 3: Establish Oracle Net Connectivity to the Auxiliary Instance - Start"

rm -f ${initfile_ora}

echo  "db_name=${ORACLE_SID}" >  ${initfile_ora}
echo  "shared_pool_size=1g" >>  ${initfile_ora}


echo "`date +%Y.%m.%d" "%H:%M:%S` Task 3: Establish Oracle Net Connectivity to the Auxiliary Instance - Finish"
echo ''
echo ''


#
# Task 4: Start the Auxiliary Instance
#
echo "`date +%Y.%m.%d" "%H:%M:%S` Task 4: Start the Auxiliary Instance - Start"

${UTL_SQLPLUS}  -s '/ as sysdba' << EOF
startup force nomount;
EOF

echo "`date +%Y.%m.%d" "%H:%M:%S` Task 4: Start the Auxiliary Instance - Finish"
echo ''
echo ''


#
# Task 5: Start DUPLICATE
#
echo "`date +%Y.%m.%d" "%H:%M:%S` Task 5: - Start"

${UTL_RMAN} cmdfile ${rman_cmdfile}
rm -f ${initfile_ora}

echo "`date +%Y.%m.%d" "%H:%M:%S` Task 5: - Finish"
echo ''
echo ''


#
# Task 6: Apply After Recreate Script
#
echo -n " Trying apply commands from file: ${after_recreate_sql}"

if [ -r ${after_recreate_sql} ]; then
    export ORACLE_SID=${ORACLE_SID}
    sqlplus /nolog @${after_recreate_sql} ${ORACLE_SID} > ${after_recreate_log}
    echo " - Done."
else
    echo " - Skipped. File not exist."
fi


echo "End RMAN Duplicate Database: `date +%Y.%m.%d" "%H:%M:%S`"

cat ${log_file} | ${UTL_SEND} "${mess_theme}" "${mail_recipients}"
$




$more make_testdbt1.rman
connect auxiliary sys/oracle@TESTDBT1.SUN.COM;
run {
duplicate target database to 'testdbt1'
SPFILE
    SET CONTROL_FILES '+TEST','+TEST'
    set db_create_file_dest='+TEST'
    SET CLUSTER_DATABASE 'false'
    set sga_max_size '10g'
    set db_cache_size '5g'
    set pga_aggregate_target '2g'
    set shared_pool_size '2g'
    set dispatchers '(PROTOCOL=TCP) (SERVICE=testdbt1XDB)'
    reset audit_file_dest
    reset dg_broker_start
    reset fal_server
    reset fal_client
    reset log_archive_config
    reset log_archive_dest_state_2
    reset log_archive_dest_2
    BACKUP LOCATION '/mnt/primary_backup/backups/oradb/rman/testdb/'
    NOFILENAMECHECK
;
}

exit 0



$more testdb_after_recreate_testdbt1.sql
connect / as sysdba

alter system reset "__db_cache_size"        scope=spfile sid='testdb';
alter system reset "__java_pool_size"       scope=spfile sid='testdb';
alter system reset "__large_pool_size"      scope=spfile sid='testdb';
alter system reset "__oracle_base"          scope=spfile sid='testdb';
alter system reset "__pga_aggregate_target" scope=spfile sid='testdb';
alter system reset "__sga_target"           scope=spfile sid='testdb';
alter system reset "__shared_io_pool_size"  scope=spfile sid='testdb';
alter system reset "__shared_pool_size"     scope=spfile sid='testdb';
alter system reset "__streams_pool_size"    scope=spfile sid='testdb';
alter system reset "log_archive_format"     scope=spfile sid='testdb';
alter system reset "log_archive_trace"      scope=spfile sid='testdb';


-- Call procedure... :
begin
  null;
end;
/

exit
$



Make dataguard

на primary:

#su - oragrid

$more listener.ora
# listener.ora Network Configuration File: /u01/app/11.2.0.3/grid/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC=
      (SID_NAME = testdb)
      (GLOBAL_DBNAME=testdb_p_DGMGRL.sun.com)
      (ORACLE_HOME=/u01/app/oradb/product/11.2.0.3/dbhome_1)
    )
  )


LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = primary.sun.com)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oragrid

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent
$


#su - oradb

$more tnsnames.ora
#
# TESTDB:
#

TESTDB_P.SUN.COM =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = m5k3.sun.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (UR = A)
      (SERVICE_NAME = testdb_p_DGMGRL.sun.com)
    )
  )

TESTDB_S.SUN.COM =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = m5k4.sun.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (UR = A)
      (SERVICE_NAME = testdb_s_DGMGRL.sun.com)
    )
  )

TESTDB.SUN.COM =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = m5k3.sun.com)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = m5k4.sun.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = testdb_app.sun.com)
      (SERVER = DEDICATED)
      (FAILOVER_MODE =
        (TYPE = SESSION)
        (METHOD = BASIC)
        (RETRIES = 180)
        (DELAY = 1)
      )
    )
  )


$



alter system set DB_UNIQUE_NAME='testdb_p' SCOPE=SPFILE;

alter system set log_archive_format='%t_%s_%r.arc' SCOPE=SPFILE;
             

archive log list

shutdown immediate
startup mount
alter database archivelog;
alter database open;
archive log list


alter database force logging;
alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(testdb_p, testdb_s1)';
alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES, ALL_ROLES)';
alter system set LOG_ARCHIVE_DEST_2='SERVICE=testdb_s1.sun.com LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=testdb_s1';
alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE;
alter system set LOG_ARCHIVE_DEST_STATE_2=ENABLE;
alter system set remote_login_passwordfile='EXCLUSIVE' scope=spfile;
alter system set FAL_SERVER=testdb_s1;
alter system set FAL_CLIENT=testdb_p;

SELECT a.group#, a.member, b.bytes FROM v$logfile a, v$log b WHERE a.group# = b.group#;

ALTER DATABASE ADD STANDBY LOGFILE GROUP  7 SIZE 314572800;
ALTER DATABASE ADD STANDBY LOGFILE GROUP  8 SIZE 314572800;
ALTER DATABASE ADD STANDBY LOGFILE GROUP  9 SIZE 314572800;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 10 SIZE 314572800;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 11 SIZE 314572800;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 12 SIZE 314572800;

select status, type, member, group# from v$logfile;
select * from v$standby_log;




на standby:
#su - oragrid

$more listener.ora
# listener.ora Network Configuration File: /u01/app/11.2.0.3/grid/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC=
      (SID_NAME = testdb)
      (GLOBAL_DBNAME=testdb_s1_DGMGRL.sun.com)
      (ORACLE_HOME=/u01/app/oradb/product/11.2.0.3/dbhome_1)
    )
  )


LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = standby.sun.com)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oragrid

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent

$

#su - oradb
$more tnsnames.ora

#
# TESTDB:
#

TESTDB_P.SUN.COM =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = m5k3.sun.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (UR = A)
      (SERVICE_NAME = testdb_p_DGMGRL.sun.com)
    )
  )

TESTDB_S.SUN.COM =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = m5k4.sun.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (UR = A)
      (SERVICE_NAME = testdb_s_DGMGRL.sun.com)
    )
  )

TESTDB.SUN.COM =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = m5k3.sun.com)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = m5k4.sun.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = testdb_app.sun.com)
      (SERVER = DEDICATED)
      (FAILOVER_MODE =
        (TYPE = SESSION)
        (METHOD = BASIC)
        (RETRIES = 180)
        (DELAY = 1)
      )
    )
  )



$



# Make dataguard:
00 23 * * * ${HOME}/bin/pkg/make_dataguard/_run.sh   testdb     > /dev/null 2>> /tmp/crontab_oracle.err



$more _run.sh
#!/bin/bash


#
# Package Name:
#

tmp_string="`dirname $0`"
pkg_name="`basename ${tmp_string}`"

if [ "${pkg_name}" = "." ]; then
  tmp_string="`pwd`"
  pkg_name="`basename ${tmp_string}`"
fi

# Check Parameters:
if [ $1 ]
then
  oracle_sid=`echo ${1} | tr "[A-Z]" "[a-z]"`
else
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: Error! (Parameter=1). Call `basename $0` " >&2
  exit 2
fi

#
# Setup Environment:
#

pkg_env="${HOME}/bin/_conf/.env"
if [ ! -r "${pkg_env}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Not Found Environment file: ${pkg_env}" >&2
  exit 2
fi

if [ -s "${pkg_env}" ]; then
  . ${pkg_env}
else
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment file is empty: ${pkg_env}" >&2
  exit 2
fi


#
# Check Environment:
#


# Check ORACLE_USER:
if [ -z "${ORA_USER}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable ORA_USER not defined" >&2
  exit 2
else
  ora_user=${ORA_USER}
fi


# Check ORACLE_HOME:
if [ -z "${ORACLE_HOME}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable ORACLE_HOME not defined" >&2
  exit 2
elif [ ! -d "${ORACLE_HOME}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Directory ORACLE_HOME not found (${ORACLE_HOME})" >&2
  exit 2
fi


# Check TMP_DIR:
if [ -z "${TMP_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable TMP_DIR not defined" >&2
  exit 2
elif [ ! -d "${TMP_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Directory TMP_DIR not found (${TMP_DIR})" >&2
  exit 2
elif [ ! -w "${TMP_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Directory TMP_DIR not writeable (${TMP_DIR})" >&2
  exit 2
fi


# Check BIN_DIR:
if [ -z "${BIN_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable BIN_DIR not defined" >&2
  exit 2
elif [ ! -d "${BIN_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Directory BIN_DIR not found (${BIN_DIR})" >&2
  exit 2
fi


# Check COMPANY_NAME:
if [ -z "${COMPANY_NAME}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable COMPANY_NAME not defined" >&2
  exit 2
fi


# Check HOST_NAME:
if [ -z "${HOST_NAME}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable HOST_NAME not defined" >&2
  exit 2
fi


# Check MAIL_RECIPIENTS:
if [ -z "${MAIL_DBA}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable MAIL_RECIPIENTS not defined" >&2
  exit 2
fi


# Check UTL_SEND:
if [ -z "${UTL_SEND}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable UTL_SEND not defined" >&2
  exit 2
elif [ ! -f "${UTL_SEND}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. File UTL_SEND not found (${UTL_SEND})" >&2
  exit 2
elif [ ! -x "${UTL_SEND}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. File UTL_SEND not executable (${UTL_SEND})" >&2
  exit 2
fi

# Initialize Package:

pkg_flag="`basename $0 .sh`"
run_in_progress=${TMP_DIR}/${pkg_name}_${oracle_sid}.lock
log_file=${TMP_DIR}/${pkg_name}_${oracle_sid}.log
prefix="${COMPANY_NAME}#${HOST_NAME}(${oracle_sid}) ${pkg_name}"
mess_theme="${prefix}: Error! Another process running (${run_in_progress})"

mail_recipients="$MAIL_DBA"
echo $mail_recipients

# Check Another process for running:
if [ -f ${run_in_progress} ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: Error! Another process running. Remove a file ${run_in_progress}" >&2
  echo "Remove a file ${run_in_progress}" | ${BIN_DIR}/_lib/utl_send.sh "${mess_theme}" "${mail_recipients}"
  exit 2
fi

# Prevent Parallel Execution:
touch ${run_in_progress}


# Run Implementation:
${BIN_DIR}/pkg/${pkg_name}/body.sh "${pkg_flag}" "${oracle_sid}" | tee ${log_file}

# Cleanup Stop Flag:
test -r ${run_in_progress} && rm ${run_in_progress}

$


$more body.sh
#!/bin/bash


###################
# Check Parameters:
###################

# Package Name:
tmp_string="`dirname $0`"
pkg_name="`basename ${tmp_string}`"

if [ "${pkg_name}" = "." ]; then
  tmp_string="`pwd`"
  pkg_name="`basename ${tmp_string}`"
fi

# Check for internal call:
if [ ! $1 = '_run' ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: Error! (Parameter=1) Call `basename $0` from ./_run.sh" >&2
  exit 2
fi

# Check For :
if [ $2 ]
then
  ##echo " 2=${2} (ORACLE_SID)"
  ORACLE_SID=`echo ${2} | tr "[A-Z]" "[a-z]"`; export ORACLE_SID
else
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: Error! (Parameter=2) Call `basename $0` With 2-d parameter" >&2
  exit 2
fi


#########################
# Define local variables:
#########################

# Variables:

prefix="${COMPANY_NAME}#${HOST_NAME}(${ORACLE_SID}) ${pkg_name}"
mess_theme="${prefix}:Make dataguard"
log_file=${TMP_DIR}/${pkg_name}_${ORACLE_SID}.log

after_recreate_sql=/export/home/oradb/bin/_sql/dataguard_after_recreate_${ORACLE_SID}.sql
after_recreate_log=/export/home/oradb/bin/_sql/dataguard_after_recreate_${ORACLE_SID}.log

mail_recipients="$MAIL_DBA"

orapwd_filename="${ORACLE_HOME}/dbs/orapw${ORACLE_SID}"
orapwd_temp_passwd='oracle'
tnsnames_name="${ORACLE_SID}"
initfile_ora="${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora"
spfile_ora="${ORACLE_HOME}/dbs/spfile${ORACLE_SID}.ora"
rman_cmdfile="${BIN_DIR}/_sql/make_physical_standby_${ORACLE_SID}.rman"

echo "Start RMAN Make Dataguard: `date +%Y.%m.%d" "%H:%M:%S`"
echo ''

echo "MASTER_HOST=${MASTER_HOST}"
echo "ORACLE_SID=${ORACLE_SID}"
echo "ORACLE_HOME=${ORACLE_HOME}"
echo "UTL_SQLPLUS=${UTL_SQLPLUS}"
echo "UTL_ORAPWD=${UTL_ORAPWD}"
echo "UTL_RMAN=${UTL_RMAN}"
echo "orapwd_filename=${orapwd_filename}"
echo "orapwd_temp_passwd=${orapwd_temp_passwd}"
echo "tnsnames_name=${tnsnames_name}"
echo "initfile_ora=${initfile_ora}"
echo "spfile_ora=${spfile_ora}"
echo "rman_cmdfile=${rman_cmdfile}"
echo ''
echo ''


##############################################
# Task 0: Drop Database
##############################################
echo "`date +%Y.%m.%d" "%H:%M:%S` Task 0: DROP DATABASE - Start"

${UTL_SQLPLUS} -s '/ as sysdba' << EOF
shutdown abort;
STARTUP MOUNT RESTRICT;
DROP DATABASE;
EOF

echo "`date +%Y.%m.%d" "%H:%M:%S` Task 0: DROP DATABASE - Finish"
echo ''
echo ''


#####################################
# Task 1: Trying shutdown Instance
#####################################
echo " Trying shutdown Instance: ${ORACLE_SID} - Start"

${UTL_SQLPLUS} /nolog << EOF
connect / as sysdba
shutdown abort;
EOF

echo " Trying shutdown Instance: ${ORACLE_SID} - Finish"
echo ''
echo ''


############################################################################
# Task 2: Create an Initialization Parameter File for the Auxiliary Instance
############################################################################
echo "`date +%Y.%m.%d" "%H:%M:%S` Task 2: Create an Initialization Parameter File for the Auxiliary Instance"

echo -n " Trying to remove spfile: ${initfile_ora}"

if [ -r ${initfile_ora} ]; then
    rm -f ${initfile_ora}
    echo " - Done."
else
    echo " - Skipped. File not exist."
fi

echo  "db_name=${ORACLE_SID}" >  ${initfile_ora}


echo "`date +%Y.%m.%d" "%H:%M:%S` Task 2: Create an Initialization Parameter File for the Auxiliary Instance"
echo ''
echo ''


############################################################################
# Task 3: Remove SPFILE  for the Auxiliary Instance
############################################################################
echo "`date +%Y.%m.%d" "%H:%M:%S` Task 3: Remove SPFILE  for the Auxiliary Instance"

echo -n " Trying to remove spfile: ${spfile_ora}"

if [ -r ${spfile_ora} ]; then
    rm -f ${spfile_ora}
    echo " - Done."
else
    echo " - Skipped. File not exist."
fi

echo "`date +%Y.%m.%d" "%H:%M:%S` Task 3: Remove SPFILE  for the Auxiliary Instance"
echo ''
echo ''



###################################################################
# Task 4: Create an Oracle Password File for the Auxiliary Instance
###################################################################
echo "`date +%Y.%m.%d" "%H:%M:%S` Task 4: Create an Oracle Password File for the Auxiliary Instance - Start"

echo -n " Trying to remove spfile: ${orapwd_filename}"

if [ -r ${orapwd_filename} ]; then
    rm -f ${orapwd_filename}
    echo " - Done."
else
    echo " - Skipped. File not exist."
fi

${UTL_ORAPWD} force=y file=${orapwd_filename} password=${orapwd_temp_passwd}

echo "`date +%Y.%m.%d" "%H:%M:%S` Task 4: Create an Oracle Password File for the Auxiliary Instance - Finish"
echo ''
echo ''



######################################
# Task 5: Start the Auxiliary Instance
######################################
echo "`date +%Y.%m.%d" "%H:%M:%S` Task 5: Start the Auxiliary Instance - Start"

# Start up the auxiliary instance nomount
${UTL_SQLPLUS}  -s '/ as sysdba' << EOF
startup force nomount;
EOF

echo "`date +%Y.%m.%d" "%H:%M:%S` Task 5: Start the Auxiliary Instance - Finish"
echo ''
echo ''


######################################
# Task 6: Start Make Dataguard script
######################################
echo "`date +%Y.%m.%d" "%H:%M:%S` Task 6: Start Make Dataguard script"

${UTL_RMAN} cmdfile ${rman_cmdfile}

echo "`date +%Y.%m.%d" "%H:%M:%S` Task 6: Start Make Dataguard script"
echo ''
echo ''


############################################################################
# Task 7: Remove an Initialization Parameter File for the Auxiliary Instance
############################################################################
echo "`date +%Y.%m.%d" "%H:%M:%S` Task 7: Remove an Initialization Parameter File for the Auxiliary Instance"

echo -n " Trying to remove spfile: ${initfile_ora}"

if [ -r ${initfile_ora} ]; then
    rm -f ${initfile_ora}
    echo " - Done."
else
    echo " - Skipped. File not exist."
fi

echo "`date +%Y.%m.%d" "%H:%M:%S` Task 7: Remove an Initialization Parameter File for the Auxiliary Instance"
echo ''
echo ''


#######################################################
# Task 8: Copy PRYMARY Password File to STANDBY server
#######################################################
echo "`date +%Y.%m.%d" "%H:%M:%S` Task 8: Copy PRYMARY Password File to STANDBY server"

echo -n " Trying to remove spfile: ${orapwd_filename}"

if [ -r ${orapwd_filename} ]; then
    rm -f ${orapwd_filename}
    echo " - Done."
else
    echo " - Skipped. File not exist."
fi

scp -pr ${MASTER_HOST}:${orapwd_filename} ${orapwd_filename}

echo "`date +%Y.%m.%d" "%H:%M:%S` Task 8: Copy PRYMARY Password File to STANDBY server"
echo ''
echo ''


echo "End make Dataguard: `date +%Y.%m.%d" "%H:%M:%S`"

cat  ${log_file}  | ${BIN_DIR}/_lib/utl_send.sh "${mess_theme}" "${mail_recipients}"
$




$more make_physical_standby_testdb.rman
connect auxiliary sys/oracle@TESTDB_S1.SUN.COM;
run {
DUPLICATE TARGET DATABASE
   FOR STANDBY
   BACKUP LOCATION '/mnt/primary_backup/backups/oradb/rman/testdb/'
    spfile
     set control_files='+DATA','+DATA','+DATA'
     set db_unique_name='testdb_s1'
     set fal_client='testdb_s1'
     set fal_server='testdb_p'
     set standby_file_management='AUTO'
     set log_archive_config='DG_CONFIG=(testdb_p, testdb_s1)'
     set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES, ALL_ROLES)'
     set log_archive_dest_2='SERVICE=testdb_p.sun.com LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=testdb_p'
     set log_archive_dest_state_1='ENABLE'
     nofilenamecheck
;
}

exit 0

$


на primary:

SQL> show parameter DG_BROKER_START
SQL> alter system set DG_BROKER_START=true scope=both;
SQL> show parameter DG_BROKER_START

на standby:

SQL> show parameter DG_BROKER_START
SQL> alter system set DG_BROKER_START=true scope=both;
SQL> show parameter DG_BROKER_START


на primary:

DGMGRL> connect sys/pwd@testdb_p.sun.com;

create configuration 'testdb_bdg' as primary database is testdb_p connect identifier is testdb_p.sun.com;

add database testdb_s1 as connect identifier is testdb_s1.sun.com maintained as physical;

show configuration

enable configuration;


на standby:

#On the standby database, start the MRP process.
$alter database recover managed standby database disconnect from session;
$alter database recover managed standby database cancel;


среда, 20 марта 2013 г.

Clean system audit

# Clean system audit
06 04 * * * ${HOME}/bin/pkg/clean_sys_audit/_run.sh 1 > /dev/null 2>> /tmp/crontab_oracle.err



$more _run.sh
#!/bin/bash


#
# Package Name:
#

tmp_string="`dirname $0`"
pkg_name="`basename ${tmp_string}`"

if [ "${pkg_name}" = "." ]; then
  tmp_string="`pwd`"
  pkg_name="`basename ${tmp_string}`"
fi



# Check Parameters:
if [ $1 ]; then
  retention_period=$1
else
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: Error! (Parameter=2). Call `basename $0` " >&2
  exit 2
fi


#
# Setup Environment:
#

pkg_env="${HOME}/bin/_conf/.env"
if [ ! -r "${pkg_env}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Not Found Environment file: ${pkg_env}" >&2
  exit 2
fi

if [ -s "${pkg_env}" ]; then
  . ${pkg_env}
else
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment file is empty: ${pkg_env}" >&2
  exit 2
fi


#
# Check Environment:
#

# Check ORACLE_USER:
if [ -z "${ORA_USER}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable ORA_USER not defined" >&2
  exit 2
else
  ora_user=${ORA_USER}
fi


# Check ORACLE_BASE:
if [ -z "${ORACLE_BASE}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable ORACLE_BASE not defined" >&2
  exit 2
else
  oracle_base=${ORACLE_BASE}
fi


# Check ORACLE_HOME:
if [ -z "${ORACLE_HOME}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable ORACLE_HOME not defined" >&2
  exit 2
elif [ ! -d "${ORACLE_HOME}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Directory ORACLE_HOME not found (${ORACLE_HOME})" >&2
  exit 2
fi


# Check TMP_DIR:
if [ -z "${TMP_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable TMP_DIR not defined" >&2
  exit 2
elif [ ! -d "${TMP_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Directory TMP_DIR not found (${TMP_DIR})" >&2
  exit 2
elif [ ! -w "${TMP_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Directory TMP_DIR not writeable (${TMP_DIR})" >&2
  exit 2
fi


# Check BIN_DIR:
if [ -z "${BIN_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable BIN_DIR not defined" >&2
  exit 2
elif [ ! -d "${BIN_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Directory BIN_DIR not found (${BIN_DIR})" >&2
  exit 2
fi


# Check COMPANY_NAME:
if [ -z "${COMPANY_NAME}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable COMPANY_NAME not defined" >&2
  exit 2
fi


# Check HOST_NAME:
if [ -z "${HOST_NAME}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable HOST_NAME not defined" >&2
  exit 2
fi


# Check MAIL_RECIPIENTS:
if [ -z "${MAIL_DBA}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable MAIL_RECIPIENTS not defined" >&2
  exit 2
fi


# Check UTL_SEND:
if [ -z "${UTL_SEND}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable UTL_SEND not defined" >&2
  exit 2
elif [ ! -f "${UTL_SEND}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. File UTL_SEND not found (${UTL_SEND})" >&2
  exit 2
elif [ ! -x "${UTL_SEND}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. File UTL_SEND not executable (${UTL_SEND})" >&2
  exit 2
fi



# Initialize Package:

pkg_flag="`basename $0 .sh`"
run_in_progress=${TMP_DIR}/${pkg_name}_${oracle_sid}.lock
log_file=${TMP_DIR}/${pkg_name}_${oracle_sid}.log
prefix="${COMPANY_NAME}#${HOST_NAME} ${pkg_name}"
mess_theme="${prefix}: Error! Another process running (${run_in_progress})"

mail_recipients="$MAIL_DBA"
echo $mail_recipients


# Check Another process for running:
if [ -f ${run_in_progress} ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: Error! Another process running. Remove a file ${run_in_progress}" >&2
  echo "Remove a file ${run_in_progress}" | ${BIN_DIR}/_lib/utl_send.sh "${mess_theme}" "${mail_recipients}"
  exit 2
fi


# Prevent Parallel Execution:
touch ${run_in_progress}


# Run Implementation:
${BIN_DIR}/pkg/${pkg_name}/body.sh "${pkg_flag}" "${retention_period}" | tee ${log_file}


# Send E-Mail:
# mess_theme="${host_name}(${oracle_sid}): ${mess_header}"
# cat ${log_file} | ${BIN_DIR}/_lib/utl_send.sh "${mess_theme}" "${mail_recipients}"


# Cleanup Stop Flag:
test -r ${run_in_progress} && rm ${run_in_progress}




$more body.sh
#!/bin/bash

#
# Check Parameters:
#

# Package Name:
tmp_string="`dirname $0`"
pkg_name="`basename ${tmp_string}`"

if [ "${pkg_name}" = "." ]; then
  tmp_string="`pwd`"
  pkg_name="`basename ${tmp_string}`"
fi

# Check for internal call:
if [ ! $1 = '_run' ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: Error! (Parameter=1) Call `basename $0` from ./_run.sh" >&2
  exit 2
fi


# Check For :
if [ $2 ]; then
  retention_period=$2
else
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: Error! (Parameter=3) Call `basename $0` With 3-d parameter" >&2
  exit 2
fi


#
# Define local variables:
#

# Variables:


host_name=${HOST_NAME}
oracle_sid=${ORACLE_SID}
mail_recipients="$MAIL_DBA"

sys_audit_dir=${ORACLE_HOME}/rdbms/audit/

echo "`date +%T` Check directory for system audit: (${sys_audit_dir})"

if [ -r ${sys_audit_dir} ]; then
  echo "system audit dir done."
  ${FIND_UTL} /u01/app/oradb/product/11.2.0.3/dbhome_1/rdbms/audit/ -type f -name "*_ora\_*\_*.aud" -mtime +${retention_period} -print -exec ls -l {} \;
  ${FIND_UTL} /u01/app/oradb/product/11.2.0.3/dbhome_1/rdbms/audit/ -type f -name "*_ora\_*\_*.aud" -mtime +${retention_period} -print -exec rm {} \;
else
  loc_mess_theme="${host_name}(${oracle_sid})-${pkg_name}: Error! Not Found Directory for Clean system audit"
  loc_mess_body="Not exist directory: ${sys_audit_dir}"
  echo "${loc_mess_body}" | ${BIN_DIR}/_lib/utl_send.sh "${loc_mess_theme}" "${mail_recipients}"
  echo " - Error!"
  exit
fi

$



Для  очистки аудита экземпляра ASM все также, только  пути будут другие
и запускать нужно crontab  из под пользователя oragrid:

#
# Define local variables:
#

# Variables:


host_name=${HOST_NAME}
oracle_sid=${ORACLE_SID}
mail_recipients="$MAIL_DBA"

asm_audit_dir=${ORACLE_HOME}/rdbms/audit/

echo "`date +%T` Check directory for asm audit: (${asm_audit_dir})"

if [ -r ${asm_audit_dir} ]; then
  echo "asm audit ASM dir done."
  ${FIND_UTL} /u01/app/11.2.0.3/grid/rdbms/audit/ -type f -name "*_ora\_*\_*.aud" -mtime +${retention_period} -print -exec ls -l {}
\;
  ${FIND_UTL} /u01/app/11.2.0.3/grid/rdbms/audit/ -type f -name "*_ora\_*\_*.aud" -mtime +${retention_period} -print -exec rm -f {}
\;
else
  loc_mess_theme="${host_name}(${oracle_sid})-${pkg_name}: Error! Not Found Directory for Clean asm audit"
  loc_mess_body="Not exist directory: ${asm_audit_dir}"
  echo "${loc_mess_body}" | ${BIN_DIR}/_lib/utl_send.sh "${loc_mess_theme}" "${mail_recipients}"
  echo " - Error!"
  exit
fi
 

ADRCI purge

# ADRCI purge
30 06 * * 0 ${HOME}/bin/pkg/adrci_purge/_run.sh  > /dev/null 2>> /tmp/crontab_oracle.err


$more _run.sh
#!/bin/bash

#
# Package Name:
#

tmp_string="`dirname $0`"
pkg_name="`basename ${tmp_string}`"

if [ "${pkg_name}" = "." ]; then
  tmp_string="`pwd`"
  pkg_name="`basename ${tmp_string}`"
fi


#
# Setup Environment:
#

pkg_env="${HOME}/bin/_conf/.env"
if [ ! -r "${pkg_env}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Not Found Environment file: ${pkg_env}" >&2
  exit 2
fi

if [ -s "${pkg_env}" ]; then
  . ${pkg_env}
else
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment file is empty: ${pkg_env}" >&2
  exit 2
fi



#
# Check Environment:
#


# Check TMP_DIR:
if [ -z "${TMP_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable TMP_DIR not defined" >&2
  exit 2
elif [ ! -d "${TMP_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Directory TMP_DIR not found (${TMP_DIR})" >&2
  exit 2
elif [ ! -w "${TMP_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Directory TMP_DIR not writeable (${TMP_DIR})" >&2
  exit 2
fi


# Check BIN_DIR:
if [ -z "${BIN_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable BIN_DIR not defined" >&2
  exit 2
elif [ ! -d "${BIN_DIR}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Directory BIN_DIR not found (${BIN_DIR})" >&2
  exit 2
fi


# Check COMPANY_NAME:
if [ -z "${COMPANY_NAME}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable COMPANY_NAME not defined" >&2
  exit 2
fi


# Check HOST_NAME:
if [ -z "${HOST_NAME}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable HOST_NAME not defined" >&2
  exit 2
fi


# Check MAIL_SYSDBA:
if [ -z "${MAIL_DBA}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable MAIL_RECIPIENTS not defined" >&2
  exit 2
fi


# Check UTL_SEND:
if [ -z "${UTL_SEND}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. Environment variable UTL_SEND not defined" >&2
  exit 2
elif [ ! -f "${UTL_SEND}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. File UTL_SEND not found (${UTL_SEND})" >&2
  exit 2
elif [ ! -x "${UTL_SEND}" ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: ERROR!!! Execution Aborted. File UTL_SEND not executable (${UTL_SEND})" >&2
  exit 2
fi


# Initialize Package:

pkg_flag="`basename $0 .sh`"
run_in_progress="${TMP_DIR}/${pkg_name}_${mess}.lock"
log_file="${TMP_DIR}/${pkg_name}_${mess}.log"
prefix="${COMPANY_NAME}#${HOST_NAME} ${pkg_name}"
mess_theme="${prefix}: Error! Another process running (${run_in_progress})"

mail_recipients="$MAIL_DBA"
echo $mail_recipients

# Check Another process for running:

if [ -f ${run_in_progress} ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: Error! Another process running. Remove a file ${run_in_progress}" >&2
  echo "Remove a file ${run_in_progress}" | ${BIN_DIR}/_lib/utl_send.sh "${mess_theme}" "${mail_recipients}"
  exit 2
fi



# Prevent Parallel Execution:
touch ${run_in_progress}


# Run Implementation:
${BIN_DIR}/pkg/${pkg_name}/body.sh | tee ${log_file}



# Cleanup Stop Flag:
test -r ${run_in_progress} && rm ${run_in_progress}
$




$more body.sh
#!/bin/bash


#
# Check Parameters:
#

# Package Name:
tmp_string="`dirname $0`"
pkg_name="`basename ${tmp_string}`"

if [ "${pkg_name}" = "." ]; then
  tmp_string="`pwd`"
  pkg_name="`basename ${tmp_string}`"
fi

# Check for internal call:
if [ ! $1 = '_run' ]; then
  echo "`date +%Y.%m.%d" "%H:%M:%S` - ${pkg_name}: Error! (Parameter=1) Call `basename $0` from ./_run.sh" >&2
  exit 2
fi



#
# Define local Variables:
#

# Variables:

prefix="${COMPANY_NAME}#${HOST_NAME} ${pkg_name}"
mess_theme="${prefix}: Purge trace and dump files"
temp_file=${TMP_DIR}/${pkg_name}.tmp
mess_limit="The limit ${limit_per_free}% is exceeded"

mail_recipients="$MAIL_DBA"
echo $mail_recipients

#
# Body Section:
#

${BIN_DIR}/_lib/adrci_purge.sh  > ${temp_file}

cat ${temp_file} | ${BIN_DIR}/_lib/utl_send.sh "${mess_theme}" "${mail_recipients}"



$more adrci_purge.sh
#!/bin/sh

for ADRHOME in `adrci exec="show home"`
do
    if [ $ADRHOME = "ADR" -o $ADRHOME = "Homes:" ]
    then
        continue;
    fi
    echo $ADRHOME
    adrci << EOF
         set home $ADRHOME
         echo $ADRHOME
         set control (SHORTP_POLICY = 168)
         set control (LONGP_POLICY = 720)

         # purge all tracefiles older than 2 days (2880 minutes):
         purge -age   2880 -type trace

         # purging ALERT older than 30 days
         purge -age 43200 -type ALERT

         # purging INCIDENT older than 14 days
         purge -age  20160 -type INCIDENT

         # purging TRACE older than 14 days
         purge -age  20160 -type TRACE

         # purging CDUMP older than 14 days
         purge -age  20160 -type CDUMP

         # purging HM older than 14 days
         purge -age  20160 -type HM

         show tracefile -rt
         purge
    exit
EOF
done




$more utl_send.sh
#!/bin/bash
# UNIX


# Setup Environment:
. ${HOME}/bin/_conf/.env


# Check for Message Theme:
if [ "$1" ]; then
  priv_mess_theme="$1"
else
  priv_mess_theme="No Theme"
fi



# Check For Message Recipients:
if [ "$2" ]; then
  priv_mail_recipients="$2"
else
  priv_mail_recipients=${MAIL_DEFAULT}
fi


# :
cat - | mailx -s "${priv_mess_theme}" "${priv_mail_recipients}"


четверг, 14 марта 2013 г.

AUTO TASK

Oracle 11g включает три задачи автоматического обслуживания базы данных:

Автоматическая сборка статистики оптимизатора - собирает устаревшие или отсутствующие статистические данные для всех объектов схемы.
Имя задачи - это 'auto optimizer stats collection'

Автоматический советник по сегментам - определяет сегменты, которые могут быть реорганизованы для экономии места.
Имя задачи - 'auto space advisor'.

Автоматический советник по настройке SQL - определяет и пытается настроить SQL с высокой нагрузкой.
Имя задачи - 'sql tuning advisor'

Эти задачи выполняются во время окон обслуживания, которые планируется открыть за ночь.

auto optimizer stats collection
auto space advisor
sql tuning advisor



select operation_name, status from dba_autotask_operation;

OPERATION_NAME              STATUS  
------------------------------------------------
auto optimizer stats job        ENABLED   
auto space advisor job          ENABLED  
automatic sql tuning task      ENABLED   

 

select window_name,
       window_active,
       autotask_status,
       to_char(window_next_time,'dd/mm/yyyy hh24:mi:ss') next_time
  from DBA_AUTOTASK_WINDOW_CLIENTS
 order by window_next_time;


WINDOW_NAME        WINDOW_ACTIVE   AUTOTASK_STATUS   NEXT_TIME 
---------------------------------------------------------------------------------------------------------        
MONDAY_WINDOW          FALSE           DISABLED          01/10/2018 22:00:00  
TUESDAY_WINDOW         FALSE           DISABLED          02/10/2018 22:00:00  
WEDNESDAY_WINDOW   FALSE           DISABLED          03/10/2018 22:00:00  
THURSDAY_WINDOW      FALSE           DISABLED          04/10/2018 22:00:00  
FRIDAY_WINDOW             FALSE           DISABLED          05/10/2018 22:00:00  
SATURDAY_WINDOW       FALSE           DISABLED          06/10/2018 06:00:00  
SUNDAY_WINDOW            FALSE           DISABLED          07/10/2018 06:00:00  

 
                                 
Отключить или включить отдельные автоматические задачи из всех окон обслуживания:

BEGIN
  DBMS_AUTO_TASK_ADMIN.disable(
    client_name => 'auto space advisor',
    operation   => NULL,
    window_name => NULL);
END;
/

select operation_name, status from dba_autotask_operation;

BEGIN
  DBMS_AUTO_TASK_ADMIN.enable(
    client_name => 'auto space advisor',
    operation   => NULL,
    window_name => NULL);
END;
/

select operation_name, status from dba_autotask_operation;


Изменение приоритетов.

BEGIN
  DBMS_AUTO_TASK_ADMIN.override_priority(
    client_name => 'auto optimizer stats collection',
    priority => dbms_auto_task_admin.priority_high);
END;
/


select client_name, priority_override from dba_autotask_client;

begin
   dbms_auto_task_admin.override_priority(
      client_name => 'auto space advisor',
      priority => dbms_auto_task_admin.priority_urgent);
end;
/


begin
   dbms_auto_task_admin.override_priority(
      client_name => 'auto space advisor',
      priority => dbms_auto_task_admin.priority_medium);
end;
/

select client_name, priority_override from dba_autotask_client;



Настроим так:


BEGIN
  DBMS_AUTO_TASK_ADMIN.disable(
    client_name => 'sql tuning advisor',
    operation   => NULL,
    window_name => NULL);
END;
/

BEGIN
  DBMS_AUTO_TASK_ADMIN.disable(
    client_name => 'auto space advisor',
    operation   => NULL,
    window_name => NULL);
END;
/

BEGIN
  DBMS_AUTO_TASK_ADMIN.enable(
    client_name => 'auto optimizer stats collection',
    operation   => 'auto optimizer stats job',
    window_name => NULL);
END;
/


Просмотр журнала сбора статистики:

select client_name,
       job_status,
       job_start_time,
       job_duration,
       job_info
  from dba_autotask_job_history
where client_name like '%stats%'
order by job_start_time;



Удалять или добавлять задачи в отдельные окна обслуживания:

BEGIN
  DBMS_AUTO_TASK_ADMIN.disable(
    client_name => 'auto optimizer stats collection',
    operation   => NULL,
    window_name => 'MONDAY_WINDOW');

  DBMS_AUTO_TASK_ADMIN.disable(
    client_name => 'auto space advisor',
    operation   => NULL,
    window_name => 'MONDAY_WINDOW');

  DBMS_AUTO_TASK_ADMIN.disable(
    client_name => 'sql tuning advisor',
    operation => NULL,
    window_name => 'MONDAY_WINDOW');
END;
/




Глобальные параметры сбора статистики могут быть изменены с помощью процедуры
SET_GLOBAL_PREFS в пакете DBMS_STATS:



EXEC DBMS_STATS.alter_stats_history_retention(90);
EXEC DBMS_STATS.set_global_prefs('estimate_percent', '5');


Включить инкрементальный сбор статистики:

BEGIN
 DBMS_STATS.SET_GLOBAL_PREFS('INCREMENTAL', 'TRUE');
END;
/

Включить сбор статистики только по системному словарю:

BEGIN
 DBMS_STATS.SET_GLOBAL_PREFS('AUTOSTATS_TARGET','ORACLE');
END;
/

Автоматический режим сбора статистики:

BEGIN
 DBMS_STATS.SET_GLOBAL_PREFS('AUTOSTATS_TARGET','AUTO');
END;
/


Проверить в каком режиме идет сбор статистики:

select DBMS_STATS.GET_PREFS ('AUTOSTATS_TARGET') as AUTOSTATS_TARGET from dual;


Глобальные настройки режима сбора статистики:



select 'CASCADE = '||dbms_stats.GET_PREFS('CASCADE') as global_stats from dual
union all
select 'DEGREE = '||dbms_stats.GET_PREFS('DEGREE') from dual
union all
select 'ESTIMATE_PERCENT = '||dbms_stats.GET_PREFS('ESTIMATE_PERCENT') from dual
union all
select 'METHOD_OPT = '||dbms_stats.GET_PREFS('METHOD_OPT') from dual
union all
select 'NO_INVALIDATE = '||dbms_stats.GET_PREFS('NO_INVALIDATE') from dual
union all
select 'GRANULARITY = '||dbms_stats.GET_PREFS('GRANULARITY') from dual
union all
select 'PUBLISH = '||dbms_stats.GET_PREFS('PUBLISH') from dual
union all
select 'INCREMENTAL = '||dbms_stats.GET_PREFS('INCREMENTAL') from dual
union all
select 'STALE_PERCENT = '||dbms_stats.GET_PREFS('STALE_PERCENT') from dual
union all
select 'AUTOSTATS_TARGET = '||DBMS_STATS.GET_PREFS ('AUTOSTATS_TARGET') as AUTOSTATS_TARGET from dual;

GLOBAL_STATS                                    
-----------------------------------------------
CASCADE = DBMS_STATS.AUTO_CASCADE               
DEGREE = NULL                                   
ESTIMATE_PERCENT = DBMS_STATS.AUTO_SAMPLE_SIZE  
METHOD_OPT = FOR ALL COLUMNS SIZE AUTO          
NO_INVALIDATE = DBMS_STATS.AUTO_INVALIDATE      
GRANULARITY = AUTO                              
PUBLISH = TRUE                                  
INCREMENTAL = FALSE                             
STALE_PERCENT = 10                              
AUTOSTATS_TARGET = AUTO                         




Параметры sql tuning advisor могут быть изменены с помощью процедуры SET_TUNING_TASK_PARAMETER в пакете DBMS_SQLTUNE.

BEGIN
  DBMS_SQLTUNE.set_tuning_task_parameter('SYS_AUTO_SQL_TUNING_TASK', 'LOCAL_TIME_LIMIT', 1200);
  DBMS_SQLTUNE.set_tuning_task_parameter('SYS_AUTO_SQL_TUNING_TASK', 'ACCEPT_SQL_PROFILES', 'FALSE');
  DBMS_SQLTUNE.set_tuning_task_parameter('SYS_AUTO_SQL_TUNING_TASK', 'MAX_SQL_PROFILES_PER_EXEC', 20);
  DBMS_SQLTUNE.set_tuning_task_parameter('SYS_AUTO_SQL_TUNING_TASK', 'MAX_AUTO_SQL_PROFILES', 10000);
END;
/


Вся группа окон MAINTENANCE_WINDOW_GROUP может быть включена или отключена с помощью процедур ENABLE и DISABLE в пакете DBMS_SCHEDULER.

MAINTENANCE_WINDOW_GROUP

BEGIN
  DBMS_SCHEDULER.disable(
    name  => 'SYS.MAINTENANCE_WINDOW_GROUP',
    force => TRUE);

  DBMS_SCHEDULER.enable(
    name  => 'SYS.MAINTENANCE_WINDOW_GROUP');
END;
/


Изменить атрибуты окна можно с использованием процедуры SET_ATTRIBUTE пакета DBMS_SCHEDULER.

BEGIN
  DBMS_SCHEDULER.disable(name => 'SYS.MONDAY_WINDOW', force => TRUE);

  DBMS_SCHEDULER.set_attribute(
    name      => 'SYS.MONDAY_WINDOW',
    attribute => 'DURATION',
    value     => numtodsinterval(180, 'minute'));

  DBMS_SCHEDULER.enable(name=>'SYS.MONDAY_WINDOW');
END;
/


Если создали дополнительные окна обслуживания, назначьте их группе MAINTENANCE_WINDOW_GROUP,
и по умолчанию они будут назначены плану ресурсов DEFAULT_MAINTENANCE_PLAN.
При необходимости вы можете отредактировать этот план или создать новый план.



Если вы создаете новый план ресурсов, вы можете назначить его соответствующим окнам обслуживания с помощью пакета DBMS_SCHEDULER.

BEGIN
  DBMS_SCHEDULER.disable(name => 'SYS.MONDAY_WINDOW', force => TRUE);

  DBMS_SCHEDULER.set_attribute(
    name      => 'SYS.MONDAY_WINDOW',
    attribute => 'RESOURCE_PLAN',
    value     => 'MY_NEW_PLAN');

  DBMS_SCHEDULER.enable(name=>'SYS.MONDAY_WINDOW');
END;
/


Чтобы очистить план ресурса, выполните следующую команду. 

BEGIN
  DBMS_SCHEDULER.set_attribute(
    name      => 'SYS.MONDAY_WINDOW',
    attribute => 'RESOURCE_PLAN',
    value     => '');
END;
/


Следующие представления отображают информацию,
связанную с задачами автоматического обслуживания базы данных:



select * from dba_scheduler_wingroup_members;
select * from dba_scheduler_windows;
select * from dba_scheduler_window_groups;
select * from DBA_AUTOTASK_CLIENT;
select * from DBA_AUTOTASK_CLIENT_HISTORY;
select * from DBA_AUTOTASK_JOB_HISTORY;
select * from DBA_AUTOTASK_CLIENT_JOB;
select * from DBA_AUTOTASK_OPERATION;
select * from DBA_AUTOTASK_TASK;
select * from DBA_AUTOTASK_WINDOW_CLIENTS;
select * from DBA_AUTOTASK_WINDOW_HISTORY;
select * from DBA_AUTOTASK_SCHEDULE;


select * from dba_rsrc_plans;
select * from dba_rsrc_plan_directives;
select * from dba_rsrc_consumer_groups;
select * from dba_rsrc_consumer_group_privs;
select * from dba_rsrc_mapping_priority;
select * from dba_rsrc_group_mappings;
select * from dba_rsrc_manager_system_privs;
select initial_rsrc_consumer_group from dba_users;
select resource_consumer_group, current_queue_duration from v$session;
select * from v$rsrc_plan;
select * from v$rsrc_consumer_group;