Anda di halaman 1dari 9

CREATE PROFILE DW_test LIMIT

SESSIONS_PER_USER UNLIMITED
CPU_PER_SESSION UNLIMITED
CPU_PER_CALL UNLIMITED
CONNECT_TIME 5
IDLE_TIME 10
LOGICAL_READS_PER_SESSION DEFAULT
LOGICAL_READS_PER_CALL DEFAULT
COMPOSITE_LIMIT DEFAULT
PRIVATE_SGA DEFAULT
FAILED_LOGIN_ATTEMPTS DEFAULT
PASSWORD_LIFE_TIME DEFAULT
PASSWORD_REUSE_TIME DEFAULT
PASSWORD_REUSE_MAX DEFAULT
PASSWORD_LOCK_TIME DEFAULT
PASSWORD_GRACE_TIME DEFAULT
PASSWORD_VERIFY_FUNCTION DEFAUL

CREATE PROFILE DW_TEST LIMIT


SESSIONS_PER_USER UNLIMITED
CPU_PER_SESSION UNLIMITED
CPU_PER_CALL UNLIMITED
CONNECT_TIME 5
IDLE_TIME 10
LOGICAL_READS_PER_SESSION UNLIMITED
LOGICAL_READS_PER_CALL UNLIMITED
COMPOSITE_LIMIT UNLIMITED
PRIVATE_SGA UNLIMITED
FAILED_LOGIN_ATTEMPTS 10
PASSWORD_LIFE_TIME 180
PASSWORD_REUSE_TIME DEFAULT
PASSWORD_REUSE_MAX DEFAULT
PASSWORD_LOCK_TIME DEFAULT
PASSWORD_GRACE_TIME DEFAULT
PASSWORD_VERIFY_FUNCTION DEFAULT;

CREATE USER test_valid123


IDENTIFIED BY testvalid123
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP
PROFILE DW_test
ACCOUNT UNLOCK;

grant connect to test_valid

SELECT s.sid, s.serial#, s.username, s.osuser, p.spid, s.machine, p.terminal,


s.program
FROM Gv$session s, Gv$process p
WHERE s.paddr = p.addr and s.username='TEST_VALID123';
#!/bin/sh
tmpfile=/tmp/tmp.$$
sqlplus system/manager <<EOF
spool $tmpfile
select p.spid from Gv\$process p,Gv\$session s
where s.paddr=p.addr
and s.status=�SNIPED�;
spool off
EOF
for x in `cat $tmpfile | grep �^[0123456789]�`
do
kill -9 $x
done
rm $tmpfile

alias rtxtest_env='. /home/oracle/rtxtest_env'

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

Final Script

#!/bin/sh
tmpfile=/tmp/tmp.$$
raid_dw_env
sqlplus / as sysdba<<EOF
spool $tmpfile
select p.spid from v\$process p,v\$session s
where s.paddr=p.addr
and s.status='SNIPED'
spool off
EOF
for x in `cat $tmpfile | grep "^[0123456789]"`
do
kill -9 $x
done
rm $tmpfile

cat TSfile.txt|awk '{print $1}'|grep -v FILE|grep -v "\-\-"|cut -f1 -d/|grep -v no

#!/bin/bash
echo "Enter a value"
read num
case $num in
1) echo "one" ;;
2) echo "Two" ;;
esac

#!/bin/bash

if [ -t 0 ]
then
ORACLE_SID=""
while [ -z "${ORACLE_SID}" ]
do
tput clear; tput rev
echo "Valid Oracle SIDs are :"
tput rmso
for SID in `cat /etc/oratab|grep -v "^#"|cut -f1 -d: -s`
do
echo " ${SID}"
done
DEFAULT=`cat /etc/oratab|grep -v "^#"|cut -d: -f1 -s|head -1`
echo "\nEnter the Oracle SID you require (def: $DEFAULT): \c"
read ANSWER
[ "${ANSWER}" = "" ] && ANSWER=$DEFAULT
export ORACLE_SID=`grep "^${ANSWER}:" /etc/oratab|cut -d: -f1 -s`
export ORACLE_HOME=`grep "^${ANSWER}:" /etc/oratab|cut -d: -f2 -s`
if [ "${ORACLE_SID}" = "" ]
then
echo "\n\n ${ANS}: Invalid Oracle SID \c"
sleep 2
fi
done
else # Set to first entry in oratab
export ORACLE_SID=`cat /etc/oratab|grep -v "^#"|cut -d: -f1 -s|head -1`
export ORACLE_HOME=`cat /etc/oratab|grep -v "^#"|cut -d: -f2 -s|head -1`
fi

export ORACLE_SID=$ORACLE_SID
export ORACLE_HOME=$ORACLE_HOME
export PATH=${PATH}:${ORACLE_HOME}/bin
#ORAENV_ASK=NO
#. ${ORACLE_HOME}/bin/oraenv
#ORAENV_ASK=
echo
echo Oracle SID is now `tput rev`$ORACLE_SID`tput rmso`, Oracle Home is `tput
rev`$ORACLE_HOME`tput rmso`
echo

+ASM
bscstest
rtxtest
[oracle@flvprdbscsbd01 ~]$

#!/bin/bash

echo "Valid Oracle SIDs are :"


for SID in `cat /etc/oratab|grep -v "^#"|cut -f1 -d: -s`
do
echo "${SID}"
done
echo "\nEnter the Oracle SID you want to swithc"
read ANSWER
case $ANSWER in
"+ASM") Echo "ASM is yet to come ";;
"bscstest") /home/oracle/bscstest
echo "$ORACLE_SID " echo " $ORACLE_HOME " ;;
"rtxtest") /home/oracle/rtxtest
echo "$ORACLE_SID " echo " $ORACLE_HOME " ;;

*) echo "Sorry, I can not get a valid Input "


esac

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

#!/usr/bin/ksh
#
# Sample 10g CRS resource status query script
#
# Description:
# - Returns formatted version of crs_stat -t, in tabular
# format, with the complete rsc names and filtering keywords
# - The argument, $RSC_KEY, is optional and if passed to the script, will
# limit the output to HA resources whose names match $RSC_KEY.
# Requirements:
# - $ORA_CRS_HOME should be set in your environment

RSC_KEY=$1
QSTAT=-u
AWK=/bin/awk # if not available use /usr/bin/awk

# Table header:echo ""


$AWK \
'BEGIN {printf "%-45s %-10s %-18s\n", "HA Resource", "Target", "State";
printf "%-45s %-10s %-18s\n", "-----------", "------", "-----";}'

# Table body:
$ORACLE_HOME/bin/crsctl status resource | $AWK \
'
function ltrim(s) { sub(/^[ \t]+/, "", s); return s }
function rtrim(s) { sub(/[ \t]+$/, "", s); return s }
function trim(s) { return rtrim(ltrim(s)); }

BEGIN { FS="="; state = 0; }


$1~/NAME/ && $2~/'$RSC_KEY'/ {appname = $2; state=1};
state == 0 {next;}
$1~/TARGET/ && state == 1 {apptarget = $2; split(apptarget, atarget, ",");
state=2;}
$1~/STATE/ && state == 2 {appstate = $2; split(appstate, astate, ","); state=3;}
state == 3 { split(appname, a, ",");
for (i = 1; i <= length(atarget); i++) {
printf "%-45s %-10s %-18s\n", appname, trim(atarget[i]),
trim(astate[i])
};
state=0;}'

[grid@lsbqasrac03n01 ~]$ ./display.sh|grep -i ARCH.dg


ora.ARCH.dg ONLINE ONLINE on lsbqasrac03n01
ora.ARCH.dg ONLINE ONLINE on lsbqasrac03n02
ora.SIRESTP_ARCH.dg ONLINE ONLINE on lsbqasrac03n01
ora.SIRESTP_ARCH.dg ONLINE ONLINE on lsbqasrac03n02
[grid@lsbqasrac03n01 ~]$ ./display.sh|grep -i ARCH.dg|grep -v SIRESTP
ora.ARCH.dg ONLINE ONLINE on lsbqasrac03n01
ora.ARCH.dg ONLINE ONLINE on lsbqasrac03n02
[grid@lsbqasrac03n01 ~]$ ./display.sh|grep -i ARCH.dg|grep -v SIRESTP |grep
rac03n01
ora.ARCH.dg ONLINE ONLINE on lsbqasrac03n01
[grid@lsbqasrac03n01 ~]$

sed -n "/^$(date --date='20 minutes ago' '+%b %d %H:')\\|^$(date --date='0 minutes


ago' '+%b %d %H:')/p"

sed -n "/^$(date --date='3 minutes ago' '+%b %d %H:')\\|^$(date --date='0 minutes


ago' '+%b %d %H:')/p"

awk "/^$(date --date="-30 min" "+%b %_d %H:%M")/{p++} p"

awk -v bt=$(date "+%s" -d "30 minutes ago") '$1 > bt {printf("%s|%s|%s\n",


strftime("%F %T",$1), $3, $7)} '

grep "^$(date -d -4hour +'%Y-%m-%d %H')"

crsctl status res |grep -v "^$"|awk -F "=" 'BEGIN {print " "} {printf("%s",NR%4 ?
$2"|" : $2"\n")}'|sed -e 's/ *, /,/g' -e 's/, /,/g'|\
awk -F "|" 'BEGIN { printf "%-40s%-35s%-20s%-50s\n","Resource Name","Resource
Type","Target ","State" }{ split ($3,trg,",") split ($4,st,",")}{for (i in trg)
{printf "%-40s%-35s%-20s%-50s\n",$1,$2,trg[i],st[i]}}'

crsctl status res |grep -v "^$"|awk -F "=" 'BEGIN {print " "} {printf("%s",NR%4 ?
$2"|" : $2"\n")}'|sed -e 's/ *, /,/g' -e 's/, /,/g'|\
awk -F "|" 'BEGIN { printf "%-40s%-20s%-50s\n","Resource Name","Target ","State" }{
split ($3,trg,",") split ($4,st,",")}{for (i in trg) {printf "%-40s%-20s%-50s\n",
$1,$2,trg[i],st[i]}}'|awk '{$3=" "; print $0}'

crsctl check cluster -all | grep -i CRS-463||echo 'OFFLINE's

[grid@lsbqasrac03n01 ~]$ crsctl check has


CRS-4638: Oracle High Availability Services is online
[grid@lsbqasrac03n01 ~]$ crsctl check has|awk '{print $1}'
CRS-4638:
[grid@lsbqasrac03n01 ~]$

[grid@lsbqasrac03n01 ~]$ crsctl check crs|awk '{print $1}'


CRS-4638:
CRS-4537:
CRS-4529:
CRS-4533:

[grid@lsbqasrac03n01 ~]$ srvctl status listener -n lsbqasrac03n01


Listener LISTENER is enabled on node(s): lsbqasrac03n01
Listener LISTENER is running on node(s): lsbqasrac03n01
[grid@lsbqasrac03n01 ~]$

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

$ pwd
/u01/app/11.2.0.3/grid/bin
$
$
$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.DATA.dg ora....up.type ONLINE ONLINE isdo...p001
ora.FRA.dg ora....up.type ONLINE ONLINE isdo...p001
ora....ER.lsnr ora....er.type ONLINE ONLINE isdo...p001
ora....N1.lsnr ora....er.type ONLINE ONLINE isdo...p004
ora....N2.lsnr ora....er.type ONLINE ONLINE isdo...p001
ora....N3.lsnr ora....er.type ONLINE ONLINE isdo...p002
ora.OCRVOTE.dg ora....up.type ONLINE ONLINE isdo...p001
ora.asm ora.asm.type ONLINE ONLINE isdo...p001
ora.cvu ora.cvu.type ONLINE ONLINE isdo...p001
ora.gcprod.db ora....se.type ONLINE ONLINE isdo...p001
ora....kup.svc ora....ce.type ONLINE ONLINE isdo...p002
ora....com.svc ora....ce.type ONLINE ONLINE isdo...p003
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....SM1.asm application ONLINE ONLINE isdo...p001
ora....01.lsnr application ONLINE ONLINE isdo...p001
ora....001.gsd application OFFLINE OFFLINE
ora....001.ons application ONLINE ONLINE isdo...p001
ora....001.vip ora....t1.type ONLINE ONLINE isdo...p001
ora....SM2.asm application ONLINE ONLINE isdo...p002
ora....02.lsnr application ONLINE ONLINE isdo...p002
ora....002.gsd application OFFLINE OFFLINE
ora....002.ons application ONLINE ONLINE isdo...p002
ora....002.vip ora....t1.type ONLINE ONLINE isdo...p002
ora....SM3.asm application ONLINE ONLINE isdo...p003
ora....03.lsnr application ONLINE ONLINE isdo...p003
ora....003.gsd application OFFLINE OFFLINE
ora....003.ons application ONLINE ONLINE isdo...p003
ora....003.vip ora....t1.type ONLINE ONLINE isdo...p003
ora....SM4.asm application ONLINE ONLINE isdo...p004
ora....04.lsnr application ONLINE ONLINE isdo...p004
ora....004.gsd application OFFLINE OFFLINE
ora....004.ons application ONLINE ONLINE isdo...p004
ora....004.vip ora....t1.type ONLINE ONLINE isdo...p004
ora....network ora....rk.type ONLINE ONLINE isdo...p001
ora.oc4j ora.oc4j.type ONLINE ONLINE isdo...p004
ora.ons ora.ons.type ONLINE ONLINE isdo...p001
ora....ry.acfs ora....fs.type ONLINE ONLINE isdo...p001
ora.scan1.vip ora....ip.type ONLINE ONLINE isdo...p004
ora.scan2.vip ora....ip.type ONLINE ONLINE isdo...p001
ora.scan3.vip ora....ip.type ONLINE ONLINE isdo...p002
$ hostname
isdoroemhp001
$
$
$ srvctl status listener -n isdoroemhp001
Listener LISTENER is enabled on node(s): isdoroemhp001
Listener LISTENER is running on node(s): isdoroemhp001
$ srvctl status asm -n isdoroemhp001
ASM is running on isdoroemhp001
$ srvctl STATUS instance -d GCPROD -i gcprod1
Instance gcprod1 is running on node isdoroemhp001
$

$ crsctl check crs


CRS-4638: Oracle High Availability Services is online
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
$

=============================================================================

Steps to down services one node at a time(ex:isdoroemhp001):--


------------------------------------------------
/u01/app/11.2.0.3/grid/bin/srvctl STOP instance -d GCPROD -i gcprod1
/u01/app/11.2.0.3/grid/bin/srvctl stop asm -n isdoroemhp001-->if not down do
forcefully as below

/u01/app/11.2.0.3/grid/bin/srvctl stop asm -n isdoroembr001 -o immediate -f

/u01/app/11.2.0.3/grid/bin/srvctl stop listener -n isdoroemhp001

exit from node and apply :


/usr/local/bin/sudo /tech/oracle/crs/bin/crsctl disable crs
/usr/local/bin/sudo /tech/oracle/crs/bin/crsctl stop crs

step to up the services at a time:--


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

exit from node and apply :


/usr/local/bin/sudo /tech/oracle/crs/bin/crsctl start crs
/usr/local/bin/sudo /tech/oracle/crs/bin/crsctl enable crs

wait for some time and check the crs_stat -t from orcle id..

if online fine otherwise manually do the following:

/u01/app/11.2.0.3/grid/bin/srvctl start listener -n isdoroemhp001


/u01/app/11.2.0.3/grid/bin/srvctl start asm -n isdoroemhp001
/u01/app/11.2.0.3/grid/bin/srvctl STart instance -d GCPROD -i gcprod1

check crs
crs_stat -t-->node one related all shud be online

bring down and bring up nodes one by one by above steps ====

$ find alert_qasttk1.log -mtime -1 -exec cat {} \;

find ./ -type f -name "*.log*" -mmin -30 -exec wc -l {} \;

ORACLE_SID = < yoursid >


alertlogloc = < path to bdump directory >
alertlog= < alert_yoursid.log >
alertlog_bak=`echo $alertlog'_bak'`

diff $alertlogloc$alertlog $alertlogloc$alertlog_bak | grep 'ORA-' >


$alertlogloc/err_alertlog

errcnt=`wc -l $alertlogloc/err_alertlog awk '{print $1}'`

if [ $errcnt -ge 1 ]; then


cat $alertlogloc/err_alertlog | mailx -s "Alert: Errors found in $ORACLE_SID
alert log file" < Email >
echo date >> /home/oracle/log/alertlog__err_dates
fi

cp $alertlogloc$alertlog $alertlogloc$alertlog_bak
find . -mmin -60

!/usr/bin/ksh
cnt=find . -type f -name "*.log*" -mmin -30 |wc -l
if [cnt > 0]; then
Err=tail -200f alert_qasttk1.log|grep -i ORA-|awk '{print $1}'
echo $Err
Else
retrun 0
fi;

if (( $cnt == 0 )); then


echo "0"
else
Err=tail -200f alert_qasttk1.log|grep -i ORA-|awk '{print $1}'
echo "$Err"
fi

/u02/app/oracle/rbt/diag/rdbms/qasrbt/qasrbt1/trace/

final

[oracle@lsbqasrac03n01 trace]$ cat alertcheck.sh


#!/bin/bash
Zero=0
>error.txt
cnt=`find /u02/app/oracle/rbt/diag/rdbms/qasrbt/qasrbt1/trace -type f -name
"*.log*" -mmin -30 |wc -l`
if (( $cnt == 0 )); then
echo $cnt >>error.txt
else
tail -200 alert_qasrbt1.log|grep -i ora|awk '{print $1}' >>error.txt
fi
[oracle@lsbqasrac03n01 trace]$

SELECT tablespace_name,maxbytes,bytes INTO v_tbs_info FROM dba_data_files;

FOR tbs_inf IN v_tbs_info LOOP


IF tbs_inf.bytes/tbs_inf.maxbytes > 0.99
excecute immediate 'ALTER TABLESPACE '|| tbs_inf.tablespcae_name ||' ADD DATAFILE
SIZE 1M aUTOEXTEND ON NEXT 10M MAXSIZE 10G';
END LOOP;

Anda mungkin juga menyukai