Wednesday, 19 May 2021

R12.2 start and stop scripts without weblogic password prompt

-----------------------------------------------------------------------------------------------

 startapps.sh 

. /u01/app/EBS/EBSapps.env run

adstrtal.sh apps/apps<<EOF

Welcome_1

EOF

-----------------------------------------------------------------------------------------------

 stopapps.sh 

. /u01/app/EBS/EBSapps.env run

adstpall.sh apps/apps<<EOF

Welcome_1

EOF



Monday, 17 May 2021

rman backup script

#!/bin/bash
#backup location:
# Begin ###################################
export ORACLE_HOME=/u01/app/oracle/11.2.0/ebs
export ORACLE_SID=EBSDB
unset PERLBIN
unset PERL5LIB
# End   ###################################
BKPLOC=/BKP/DailyBKP
#Number Of Channels:
CHS=24
#Number of Days to keep Archives:
ARCHDAYS=2
#Number Of Bakcups to Keep:
BKPDAYS=2
##############################################################
##############################################################
##############################################################
##############################################################

LOC=$BKPLOC/$(date +%d_%h_%Y-%a)/$(date +%H.%M)
RMANCONF=$LOC/rman.conf
RMANOLDCONF=$LOC/rmanold.conf
RMANLOG=$LOC/rman.log
CTL=$LOC/controlfile$ORACLE_SID.ctl
CTLAUTO=$LOC/%F
#configure controlfile autobackup format for device type disk to '$CTLAUTO';
CTLTRC=$LOC/control$ORACLE_SID.txt
PARFILE=$LOC/init$ORACLE_SID.ora
###############################################
set -e
#####open log in new terminal
log=$1
if [[ -n "$log" ]]; then
gnome-terminal  -e  "tail -1000f $RMANLOG" &
fi
#######################
#check if backup dir is exist or no
[[ -d $LOC ]] || mkdir -p $LOC
touch $RMANLOG
####################
#delete old backup
if [ "$(ls -tdR $BKPLOC/*/* |wc -l)" -gt "$BKPDAYS" ]; then
ls -tdR $BKPLOC/*/* | awk "NR>$BKPDAYS" | xargs rm -rf &
rmdir $BKPLOC/* 2> /dev/null &
fi
############################
/u01/app/oracle/11.2.0/ebs/bin/rman target / <<EOF >> ${RMANLOG}  2>&1 &
run {
CONFIGURE COMPRESSION ALGORITHM 'MEDIUM';
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT ='$LOC/%d_full_%s_%p';
CONFIGURE DEVICE TYPE DISK PARALLELISM $CHS BACKUP TYPE TO compressed backupset;
CONFIGURE RETENTION POLICY TO REDUNDANCY $BKPDAYS;
delete noprompt  ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-$ARCHDAYS';
#delete noprompt force ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-$ARCHDAYS';
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt expired backup;
delete noprompt expired backupset;
delete noprompt obsolete;
sql "alter database backup controlfile to trace as ''$CTLTRC'' ";
sql "create pfile=''$PARFILE''from spfile";
sql 'alter system switch logfile';
backup current controlfile;
backup full database plus archivelog;
sql 'alter system archive log current';
CONFIGURE CHANNEL DEVICE TYPE DISK CLEAR;
CONFIGURE DEVICE TYPE DISK CLEAR;
CONFIGURE COMPRESSION ALGORITHM CLEAR;
CONFIGURE RETENTION POLICY CLEAR;
CONFIGURE CONTROLFILE AUTOBACKUP clear;
host 'echo -e "\e[1;31mRMAN Script Completed..\e[0m"';
}
EOF
/usr/local/bin/sendEmail -f mtalmasri@gmail.com -s 10.100.75.123 -t mtalmasri@gmail.com  -u "EBS Daily Backup" -o tls=no -o  message-file=$RMANLOG
##########

Friday, 14 May 2021

Rebuild Physical Standby using RMAN full backup



Primary:

rman target / 

run

{

backup AS COMPRESSED BACKUPSET  database tag="FORSTDBY" format '/u02/backup/RMANBKP_klfcdb/standby/FORSTDBY_%U';

}


rman> backup current controlfile for standby format '/u02/backup/RMANBKP_klfcdb/standby/stby_ctl';


Copy pieces to standby: 




Standdy server:

 

sqlplus> shutdown abort;

sqlplus> startup nomount;


rman> restore standby controlfile from '/u02/backup/RMANBKP_klfcdb/standby/stby_ctl';


sqlplus> alter database mount;


rman> catalog start with '/u02/backup/RMANBKP_klfcdb/standby/';


rman> restore database;


sqlplus> shutdown immediate;

sqlplus> startup mount;


alter system set standby_file_management=manual;

alter database recover managed standby database cancel;



select GROUP#  from  v$logfile where type='STANDBY';

select 'alter database clear logfile group '||GROUP# ||';' from  v$logfile where type='STANDBY';

alter database clear logfile group 8;

alter database clear logfile group 9;

alter database clear logfile group 10;

alter database clear logfile group 11;

alter database clear logfile group 4;

alter database clear logfile group 5;

alter database clear logfile group 6;

alter database clear logfile group 7;



select 'alter database drop standby logfile group '||GROUP# ||';' from  v$logfile where type='STANDBY';

alter database drop standby logfile group 8;

alter database drop standby logfile group 9;

alter database drop standby logfile group 10;

alter database drop standby logfile group 11;

alter database drop standby logfile group 4;

alter database drop standby logfile group 5;

alter database drop standby logfile group 6;

alter database drop standby logfile group 7;




rm -rf /u01/app/oracle/oradata/KLFCDB/klfcdb_srl0.f

rm -rf /u01/app/oracle/oradata/KLFCDB/klfcdb_srl1.f

rm -rf /u01/app/oracle/oradata/KLFCDB/klfcdb_srl2.f

rm -rf /u01/app/oracle/oradata/KLFCDB/klfcdb_srl3.f

rm -rf /u01/app/oracle/oradata/KLFCDB/stb_redo1.log

rm -rf /u01/app/oracle/oradata/KLFCDB/stb_redo2.log

rm -rf /u01/app/oracle/oradata/KLFCDB/stb_redo3.log

rm -rf /u01/app/oracle/oradata/KLFCDB/stb_redo4.log



select 'ALTER DATABASE ADD STANDBY LOGFILE group '||GROUP# ||'('''||member||''') SIZE 200M;' from  v$logfile where type='STANDBY';


ALTER DATABASE ADD STANDBY LOGFILE group 8('/u01/app/oracle/oradata/KLFCDB/klfcdb_srl0.f') SIZE 200M;

ALTER DATABASE ADD STANDBY LOGFILE group 9('/u01/app/oracle/oradata/KLFCDB/klfcdb_srl1.f') SIZE 200M;

ALTER DATABASE ADD STANDBY LOGFILE group 10('/u01/app/oracle/oradata/KLFCDB/klfcdb_srl2.f') SIZE 200M;

ALTER DATABASE ADD STANDBY LOGFILE group 11('/u01/app/oracle/oradata/KLFCDB/klfcdb_srl3.f') SIZE 200M;

ALTER DATABASE ADD STANDBY LOGFILE group 4('/u01/app/oracle/oradata/KLFCDB/stb_redo1.log') SIZE 200M;

ALTER DATABASE ADD STANDBY LOGFILE group 5('/u01/app/oracle/oradata/KLFCDB/stb_redo2.log') SIZE 200M;

ALTER DATABASE ADD STANDBY LOGFILE group 6('/u01/app/oracle/oradata/KLFCDB/stb_redo3.log') SIZE 200M;

ALTER DATABASE ADD STANDBY LOGFILE group 7('/u01/app/oracle/oradata/KLFCDB/stb_redo4.log') SIZE 200M;


alter system set standby_file_management=auto;

alter database recover managed standby database disconnect;

 


 

 


UNIX: Copy file to multiple hosts without password

In bash shell script:


for HOST in company-xxx-prm-db company-xxx-stb-db company-klf-prm-db company-klf-stb-db company-seha-prm-db company-seha-stb-db; do

    sshpass -p "oracle" scp maillist.txt $HOST:/home/oracle/scripts/

done

Monday, 10 May 2021

Attach oracle home to existing inventory

You might get below error:

LsInventorySession failed: RawInventory gets null OracleHomeInfo


Error running opatch. Error code : 73

Cannot confirm bugfixes applied to the Database ORACLE_HOME.



Solution:

 Set ORACLE_HOME environment to point to correct oracle home and then execute the following command:

<ORACLE_HOME>/oui/bin/attachHome.sh



Number of Visitors