RMAN Backup Script

SET ORACLE_HOME=d:\app\database
SET ORACLE_SID=ERKSDB1
cd D:\backup
%ORACLE_HOME%\bin\rman target / @D::\backup\full_backup_local.rman log=D:\backup\full_backup_local.log}

rman target / @/dbexport/rman/full_backup.rman log=dbexport/rman/full_backup.log

run
{
ALLOCATE CHANNEL C01 TYPE FORMAT DISK ‘/dbexport/rman/backup/DF_CH01_%U’;
ALLOCATE CHANNEL C02 TYPE FORMAT DISK ‘/dbexport/rman/backup/DF_CH02_%U’;
ALLOCATE CHANNEL C03 TYPE FORMAT ‘/dbexport/rman/backup/DF_CH03_%U’;
ALLOCATE CHANNEL C04 TYPE FORMAT ‘/dbexport/rman/backup/DF_CH04_%U’;
SQL ‘ALTER SYSTEM ARCHIVE LOG CURRENT’;
BACKUP DATABASE;
SQL ‘ALTER SYSTEM ARCHIVE LOG CURRENT’;
BACKUP AS COMPRESSED BACKUPSET ARCHIVELOG ALL;
BACKUP CURRENT CONTROLFILE FORMAT ‘/dbexport/rman/backup/controlfile_%d_%t_%s’;
BACKUP SPFILE FORMAT ‘/dbexport/rman/backup/spfile_%d’;
RELEASE CHANNEL C01;
RELEASE CHANNEL C02;
RELEASE CHANNEL C03;
RELEASE CHANNEL C04;
}

RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE disk;
ALLOCATE CHANNEL c2 DEVICE TYPE disk;
ALLOCATE CHANNEL c3 DEVICE TYPE disk;
ALLOCATE CHANNEL c4 DEVICE TYPE disk;
sql ‘alter system archive log current’;
backup AS COMPRESSED BACKUPSET full database tag GPIS_FULL format ‘/dbexport/rman/backup/%d_%T_%s_%p_FULL’ ;
sql ‘alter system archive log current’;
backup AS COMPRESSED BACKUPSET archivelog all delete all input tag GPIS_ARCHIVE format ‘/dbexport/rman/backup/%d_%T_%s_%p_ARCHIVE’;
backup tag GPIS_CONTROL current controlfile format ‘/dbexport/rman/backup/%d_%T_%s_%p_CONTROL’;
BACKUP tag GPIS_SPFILE FORMAT ‘/dbexport/rman/backup/spfile_%d’;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}

MultiPath Link

https://support.purestorage.com/Solutions/Linux/Linux_Reference/Linux_Recommended_Settings

https://www.dell.com/community/PowerPath/PowerPath-and-Linux-LVM/td-p/6599773

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_device_mapper_multipath/modifying-the-dm-multipath-configuration-file_configuring-device-mapper-multipath

https://www.casesup.com/category/knowledgebase/howtos/how-to-configure-device-mapper-multipath-for-emc

https://infohub.delltechnologies.com/l/solution-guide-storage-configuration-best-practices-for-sap-hana-tdi-on-unity-storage-systems/enabling-native-linux-multipathing-dm-mpio-5

https://flashdba.com/2015/03/30/implementing-linux-native-multipathing-or-dm-mpio-together-with-emc-powerpath/

https://library.netapp.com/ecmdocs/ECMLP2748974/html/GUID-95A6E76F-C268-48A7-8E1C-D5B534355D6D.html

http://blog.chinaunix.net/uid-11676504-id-5823648.html

https://www.thegeeksearch.com/veritas-dynamic-multipathing-vxdmp-command-line-reference-cheat-sheet/

https://infohub.delltechnologies.com/l/dell-powermax-and-vmax-non-disruptive-and-minimally-disruptive-migration-best-practices-and-operational-guide/veritas-dynamic-multipathing-3

https://infohub.delltechnologies.com/l/dell-emc-powermax-and-vmax-all-flash-srdf-metro-overview-and-best-practices-1/veritas-dynamic-multipathing

https://www.dell.com/community/VNX/VNX-Oracle-Linux-6-multipath-conf-settings-in-latest-July/td-p/6979183

VNX multipath.conf

defaults {
user_friendly_names no
polling interval 5
fast_io_fail_tmo 5
dev_loss_tmo 120
checker_timeout 15
}
devices {
device {
vendor “DGC"
product “.*"
product_blacklist “LUNZ"
features “0″
hardware_handler “1 emc"
path_selector “round-robin 0″
path_grouping_policy group_by_prio
failback immediate
rr_weight uniform
no_path_retry 5
rr_min_io 1000
path_checker emc_clariion
prio emc
flush_on_last_del yes
}
}

RAC archive log missing

run {
allocate channel c1 type disk;
backup archivelog from sequence 461797 until sequence 461798 thread 1 format ‘/backup/archivelog/arch_%U’;
backup archivelog from sequence 459596 until sequence 459597 thread 2 format ‘/backup/archivelog/arch_%U’;
}

run
{
catalog start with ‘/home/oracle/archivelog’;
allocate channel c1 type disk ;
restore archivelog from sequence 461797 until sequence 461798 thread 1;
restore archivelog from sequence 459596 until sequence 459597 thread 2;
}

PowerPath to Linux Native (LVM)

1.) Contact the SAN administrator and make sure s/he knows how to present LUNs for Linux dm-multipath (may require different options at the SAN side than PowerPath; have him/her check the appropriate documentation from the SAN manufacturer)

2.) Unmount the data disks, shutdown any raw databases, and deactivate the VGs (vgchange -a n ).

umount /test
vgchange -a n testvg

3.) Remove and un-install PowerPath

Before you remove PowerPath, ensure the following:
Steps
● Ensure that no PowerPath devices are in use. Unmount all file systems from pseudo devices and ensure that none of the
logical volumes on volumes groups from pseudo devices are in use.
● Run the lsof command and ensure that none of the storage devices that are managed by the PowerPath are listed. If the
lsof command lists the processes along with opened PowerPath managed storage devices, then close such applications/
processes and ensure that PowerPath managed storage devices are not in use.
● Manually remove references to PowerPath pseudo devices from system configuration files. For example, /etc/fstab.
● If the LVM filter had previously been updated to PowerPath recommended filter when PowerPath was initially installed
and configured, restore the filter back to the default configuration. Pseudo devices are not available after PowerPath is
uninstalled.

rpm -qa | grep EMCpower.LINUX

rpm -ev EMCPower.LINUX-_

NOTE: In rare instances, if the PowerPath uninstall program displays a message saying that it could not unload the
emcp module, run the lsmod | grep emcp command to determine if any PowerPath modules are loaded on the host.
If so, restart the host after the uninstallation completes to unload the modules.

4.) Configure device-mapper-multipath and make the appropriate changes to the LVM configuration: with PowerPath, your LVM should be configured to use only PowerPath devices/prefer them over anything else. Now LVM should be configured to use dm-multipath devices instead.

Yes, filtering and/or the “preferred_names" setting in lvm.conf, if your Linux distribution has it.

# By default we accept every block device:
filter = [ “a/.*/" ]
#filter = [ “a|/dev/mapper/mpath.*|", “r|.*|" ]

5.) Run “multipath -v2″ to initialize the multipath configuration, then make sure the multipathd daemon is running and configured to start at boot time.

multipath -v2

pvscan (is this reqd?)

6.) Run “vgscan". It should automatically figure out that your VGs are now accessible through dm-multipath devices. Verify with commands like “pvs", “vgs". Make sure LVM uses dm-multipath devices, not /dev/sd* devices.

vgscan -vvvv

7.) Activate your VGs again (vgchange -a y). Mount filesystems; etc.

vgchange -a y testvg

mount /dev/testvg/testvol /test

8.) Remember to re-create your initrd, to remove the last traces of PowerPath & to include your new LVM and dm-multipath configurations. You might want to reboot to make sure the system can boot without issues.

mv /boot/initrd-2.6.18-194.17.1.el5.img /boot/initrd-2.6.18-194.17.1.el5.img.old

mkinitrd -v /boot/initrd-2.6.18-194.17.1.el5.img 2.6.18-194.17.1.el5

Restore RAC to no-RAC

http://appsdbaworkshop.blogspot.com/2012/10/rac-to-non-rac-database-clone-11gr2.html

  1. Change the pfile
  2. Restore Controlfile
  3. Report Schema
  4. Restore and Recover database
  5. Rename logfile
  6. Open resetlog

https://sites.google.com/site/oraclerac009/f-rac-cloning/cloning/rac-to-non-rac-cloning

http://sandeepmagdum.blogspot.com/p/rac-to-nonrac-clonning.html

Restore the RMAN backup of a Oracle 12c RAC to a non ASM Single Instance database

Good!

--For Datafiles
SELECT    'set newname for datafile '
       || file#
       || ' to ''/your_new_datafile_location/'
       || SUBSTR (name, 17, LENGTH (name) - 16)
       || ''';'
  FROM v$datafile;

--For Tempfiles
SELECT    'set newname for datafile '
       || file#
       || ' to ''/your_new_tempfile_location/'
       || SUBSTR (name, 17, LENGTH (name) - 16)
       || ''';'
  FROM v$tempfile;

--For Redologs
SELECT    'sql "alter database rename file '''''
       || MEMBER
       || ''''' to '
       || '''''/u01/app/oracle/oradata/logfile_'
       || ROWNUM
       || ''''' ";'
  FROM v$logfile

Converting RAC DB to Non-RAC on Normal File System

RMAN Database Restore RAC – RAC

Steps to rename the listener log file in Oracle

Steps to rename the listener log file in Oracle

Following are the steps to rename the listener log file in Oracle:

1. Open the command prompt or terminal, Set the Oracle home and PATH:

-- Windows
set oracle_home=E:\oracle\18.0.0\dbhome_1
set path=%oracle_home%\bin;%oracle_home%\opatch;%path%

--Linux
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/18.0.0
export PATH=$ORACLE_HOME/bin:$PATH

2. Open the listener command prompt with command “lsnrctl”.

C:\windows\system32>lsnrctl
LSNRCTL for 64-bit Windows: Version 18.0.0.0.0 - Production on 26-NOV-2020 20:40:20
Copyright (c) 1991, 2018, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL>

3. Stop the listener log with command “set log_status off”

LSNRCTL> set log_status off
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=WINORACLE.ORCL.com)(PORT=1521)))
LISTENER parameter "log_status" set to OFF
The command completed successfully

4. Manually rename the listener log file by Operating system commands

Go to location of listener.log file:
mv listener.log listener_old.log

Note: If you donot know the location of listener log file then use command “status”

LSNRCTL> status
-- In status you will find the following line but it will point to xml.
Listener Log File C:\Oracle\dbhomeXE\diag\tnslsnr\WINORACLE\listener\alert\log.xml

--You will change the path of last folder instead of "alert" to "trace".
C:\Oracle\dbhomeXE\diag\tnslsnr\WINORACLE\listener\trace\listener.log

5. Start the listener log with command “set log_status on”

LSNRCTL> set log_status on
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=WINORACLE.ORCL.com)(PORT=1521)))
LISTENER parameter "log_status" set to ON
The command completed successfully

ADRCI tool useful commands in Oracle

For login to ADRCI utility

1. Just get the session of the server.

2. Set the oracle_home and oracle_sid parameter for database.

3. Execute the adrci utility command.

#adrci
oracle@localhost/u01/app/oracle# adrci
ADRCI: Release 11.2.0.2.0 - Production on Tue Jul 23 15:25:00 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
ADR base = "/u01/app/oracle"
adrci>

4. Check the present homes on the server with following commands.

#show homes
adrci> show homes
ADR Homes:
diag/rdbms/darvel/11
diag/tnslsnr/darvel/listener_11

5. You need to set the home which you want to check log file. In Oracle 11g, LISTENER and RDBMS home is at different location.

adrci> set homepath diag/tnslsnr/darvel/11

6. Check the alert log file error on the home location.

---For check the last lines of alert log
adrci> show alert –tail
--For checking last 200 line of alert log
adrci> show alert -tail 200
--For check the error message present in the alert log file
adrci> show alert -p "message_text like '%ORA-%' "
--For check the last 30 days error present in alert log file
adrci> show alert -p "message_text like '%ORA-%' and originating_timestamp > systimestamp-30"

7. For Purge diagnostic data that is over 1 day old (1440 minutes).

adrci> PURGE -age 1440 -type ALERT
--For purging incident data older than 1 day
adrci> purge -age 1440 -type incident
adrci> PURGE [[-i id1 | start_id end_id] | [-age mins [-type ALERT|INCIDENT|TRACE|CDUMP|HM|UTSCDMP]

8. Show all the incident happening in database.

adrci> show incident
adrci> show incident -p "incident_id = 40165 or incident_id = 145"
adrci> show incident -mode detail
adrci> show incident -mode detail -p "incident_id=33"
adrci> show incident -p "CREATE_TIME > '2011-09-18 21:35:25.012579 +00:00'"
adrci> show incident -p "problem_key='ORA 600 [ksmnfy2]'"
adrci> show incident -p "problem_key='ORA 700 [kfnReleaseASM1]'" -mode basic -last -all

9. Show the problem happening in database.

adrci> show problem
adrci> show problem -all
adrci> show problem -p "problem_id=44"
adrci> show problem -p "problem_key='ORA 600 [krfw_switch_4]'"

1. Go to command windows and used adrci command:

C:\Windows\System32\config\systemprofile>adrci
ADRCI: Release 12.1.0.2.0 - Production on Wed Mar 29 05:04:40 2017
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
ADR base = "E:\oracle"
adrci>

2. List the oracle home present by show home command:

adrci> show home
ADR Homes:home
diag\rdbms\ic\ic
diag\tnslsnr\IC\listener

3. Select the home with set homepath command:

adrci> set homepath diag\rdbms\ic\ic

4. For list all the problem going, please run show problem command:

adrci> show problem

ADR Home = E:\oracle\diag\rdbms\ic\ic:
************************************************************
PROBLEM_ID PROBLEM_KEY  LAST_INCIDENT LASTINC_TIME
---------- ------------ ------------- ---------------------------------
3          ORA 600[723] 246517        2017-03-10 21:14:18.539000 -05:00
2          ORA 445      243935        2017-03-11 06:06:54.406000 -05:00
1          ORA 4030     283042        2017-03-23 02:25:05.963000 -04:00


5. Show all incident and specific incident with following commands:

--Show all incident on at home:
ardci> show incident
--If you want for specific problem then enter define problem key:
adrci> show incident -p "problem_key='ORA 4030'"

ADR Home = E:\oracle\diag\rdbms\ic\ic:
*********************************************************
INCIDENT_ID PROBLEM_KEY CREATE_TIME
----------- ----------- -----------------------------
235513      ORA 4030    2017-03-02 22:00:05.502000 -05:00
235401      ORA 4030    2017-03-02 22:00:05.861000 -05:00
235402      ORA 4030    2017-03-02 22:00:11.002000 -05:00

6. Create package for specific incident id for upload on oracle support.
Note: specify the path and incident number for creating package.

adrci> ips pack incident 235402 in E:\patch_backup
Generated package 2 in file E:\patch_backup\ORA4030_20170329050754_COM_1.zip, mode complete

Script for monitoring with ADRCI utility in Oracle

Following is the script used for monitoring with help of ADRCI utility. It will generate or report error and incident coming in Listener.log and alert.log files.

Script:

#################################################

###### ALERT LOG CHECKING VIA ADRCI #############
#################################################
# To run for last 24 hours – ./check_alert.sh D
# To run for last hour – ./check_alert.sh
# Edit variables below for moving between servers
# Changes To the Script
#

export ORACLE_SID=+ASM1
export ORACLE_HOME=/u01/crs/oracle/product/11.2.0/grid/
export PATH=$PATH:$ORACLE_HOME/bin
DAILY_LOG=/home/oracle/bin/alert_log_check_daily.txt
HOURLY_LOG=/home/oracle/bin/alert_log_check_hourly.txt
MAIL_SUBJ="PRD:WARNING HOST: “
MAIL_RECIPIENT="your_dba_group@your_company.com"

HOST_NAME=`hostname -a`

if [ “$1″ = “D" ]
then

############################################
###############DAILY CHECKS ################
############DBMS AND ASM CHECK##############
############################################

adrci_homes=( $(adrci exec="show homes" | grep -e rdbms -e asm))

echo ‘####################################################’ > $DAILY_LOG
echo ‘####### ALERT LOG OUTPUT FOR LAST 24 HOURS #########’ >> $DAILY_LOG
echo ‘####################################################’ >> $DAILY_LOG
echo " >> $DAILY_LOG
echo " >> $DAILY_LOG
echo " >> $DAILY_LOG

for adrci_home in ${adrci_homes[@]}
do
echo $adrci_home’ Alert Log’ >> $DAILY_LOG
adrci exec="set home ${adrci_home};

show alert -p \\\"message_text like ‘%ORA-%’ and originating_timestamp > systimestamp-1\\\"" -term >> $DAILY_LOG
done

############################################
############## DAILY CHECKS ################
############# LISTENER CHECK###############
############################################

adrci_lsnr_homes=( $(adrci exec="show homes" | grep -e tnslsnr))

echo " >> $DAILY_LOG
echo " >> $DAILY_LOG
echo " >> $DAILY_LOG
echo ‘####################################################’ >> $DAILY_LOG
echo ‘###### LISTENER LOG OUTPUT FOR LAST 24 Hours #######’ >> $DAILY_LOG
echo ‘####################################################’ >> $DAILY_LOG
echo " >> $DAILY_LOG
echo " >> $DAILY_LOG
echo " >> $DAILY_LOG

for adrci_lsnr_home in ${adrci_lsnr_homes[@]}
do
echo $adrci_lsnr_home’ Listener Log’ >> $DAILY_LOG
adrci exec="set home ${adrci_lsnr_home}; show alert -p \\\"message_text like ‘%TNS-%’ and originating_timestamp > systimestamp-1\\\"" -term >> $DAILY_LOG
done

num_errors=`grep -c -e ‘TNS’ -e ‘ORA’ $DAILY_LOG`
if [ $num_errors != 0 ]
then
MAIL_SUBJ=$MAIL_SUBJ$HOST_NAME" Errors Found in Daily Alert Summary"
mailx -s “$MAIL_SUBJ" $MAIL_RECIPIENT $HOURLY_LOG
echo " >> $HOURLY_LOG
echo " >> $HOURLY_LOG
echo ‘####################################################’ >> $HOURLY_LOG
echo ‘######### ALERT LOG OUTPUT FOR LAST HOUR ###########’ >> $HOURLY_LOG
echo ‘####################################################’ >> $HOURLY_LOG
echo " >> $HOURLY_LOG
echo " >> $HOURLY_LOG
echo " >> $HOURLY_LOG

for adrci_home in ${adrci_homes[@]}
do
echo $adrci_home’ Alert Log’ >> $HOURLY_LOG
adrci exec="set home ${adrci_home}; show alert -p \\\"message_text like ‘%ORA-%’ and originating_timestamp > systimestamp-1/24\\\"" -term >> $HOURLY_LOG
done

num_errors=`grep -c -e ‘TNS’ -e ‘ORA’ $HOURLY_LOG`
if [ $num_errors != 0 ]
then
MAIL_SUBJ=$MAIL_SUBJ$HOST_NAME" Errors Found in Hourly Alert Summary"
mailx -s “$MAIL_SUBJ" $MAIL_RECIPIENT < $HOURLY_LOG
fi

fi