linux_db_script ---014

tom_xieym發表於2011-08-03

DT2PRDB$cat shutdown_db.sh

#!/bin/bash

#shutdown_db.sh

ORACLE_HOME=/u01/product/oracle;export ORACLE_HOME
ORACLE_SID=umlaut; export ORACLE_SID

/u01/product/oracle/bin/sqlplus /nolog <connect / as sysdba
alter system switch logfile;
alter system switch logfile;
alter system switch logfile;
shutdown immediate;
exit
EOF

/u01/product/oracle/bin/lsnrctl <stop
exit
EOF


DT2PRDB$cat startup_db.sh
#!/bin/bash

#startup_db.sh

ORACLE_HOME=/u01/product/oracle;export ORACLE_HOME
ORACLE_SID=umlaut; export ORACLE_SID

/u01/product/oracle/bin/sqlplus /nolog <connect / as sysdba
startup
exit
EOF

/u01/product/oracle/bin/lsnrctl <start
exit
EOF


cat /etc/rc.local
#set oracle environment

ORACLE_HOME=/u01/product/oracle;export ORACLE_HOME
ORACLE_SID=nbewind; export ORACLE_SID=nbewind

su oracle -c "/u01/product/oracle/bin/sqlplus /nolog <connect / as sysdba
startup
exit
EOF"

su oracle -c "/u01/product/oracle/bin/lsnrctl <start
exit
EOF"


DT2PRDB$cat autocheckumlaut
#!/bin/sh
# autocheck

export ORACLE_SID=umlaut

sqlplus "/as sysdba" @/data/run/tbs.sql

exit


DT2PRDB$cat tbs.sql
set linesize 131
col object format a40
col type format a10
col tsname format a10
select a.owner||'.'||a.segment_name object,
         a.segment_type  type            ,
         a.bytes/1024/1024    NG         ,
         a.next_extent/1024/1024 Next ,
         a.tablespace_name ts_name
    from sys.dba_segments a
where a. next_extent * &num > (
                           select max(b.bytes)
                             from dba_free_space b
                            where a.tablespace_name = b.tablespace_name)
order by 3 desc
/

DT2PRDB$cat showsession
ps -ef |grep delll10 |wc

#!/bin/sh
# autochecksession

export ORACLE_SID=umlaut

sqlplus "/as sysdba" @/data/run/session.sql

exit


DT2PRDB$cat session.sql
set wrap off
set linesize 80
col resource_name for a15
select count(*) session_all from gv$resource_limit where resource_name = 'sessions';
select * from gv$resource_limit where resource_name = 'sessions';
col owner for a15
col object_name for a20
select count(*) invalid_object from dba_objects where status='INVALID' and object_type <> 'SYNONYM';
select owner,object_name,created,last_ddl_time,status from dba_objects where status='INVALID' and object_type <> 'SYNONYM';
select round(sum(a.bytes_alloc)/1024/1024/1024,2) "Tablespace_all_size(G)",
       round(   (sum(a.bytes_alloc)-sum(nvl(b.bytes_free, 0)))/1024/1024/1024,3)  "Tablespace_used_size(G)"
from  ( select  f.tablespace_name,
               sum(f.bytes) bytes_alloc
             from dba_data_files f
        group by tablespace_name) a,
      ( select  f.tablespace_name,
               sum(f.bytes)  bytes_free
         from dba_free_space f
        group by tablespace_name) b
where a.tablespace_name = b.tablespace_name (+) ;

col job for 99
col schema_user for a15
select job,schema_user,last_date,next_date,failures,what from dba_jobs order by schema_user;
exit


DT2PRDBDG$cat autoreco
#!/bin/sh

ORACLE_HOME=/u01/product/oracle;export ORACLE_HOME
ORACLE_SID=umlaut;export ORACLE_SID

/u01/product/oracle/bin/sqlplus /nolog <connect / as sysdba;
set autorecovery on;
recover standby database;
EOF


DT2PRDBDG$cat copyarchumlaut
#!/bin/bash


pid=`/sbin/pidof rsync |wc | awk '{print $1}' `
#echo $pid
if [ "$pid" -gt "1" ]
then
    echo "Rsync is already running...."
else
    echo "Starting rsync `date`"
    rsync -e ssh -avoracle@10.153.32.80:/data/umlaut/arch//data/umlaut/arch/
    echo "Completed rsync `date`"
fi


exit 0

 

DT2PRDBDG$cat del_arch
#!/bin/sh

find /data/umlaut/arch/1_*.arc  -mmin  +4320 -exec rm -f {} \;
DT2PRDBDG$cat del_trace
#!/bin/sh

#oracle_sid=delll6
find /u01/product/admin/umlaut/adump/ora_*.aud -mmin  +1440 -exec rm -f {} \;
find /u01/product/admin/umlaut/bdump/umlaut_*.trc -mmin  +1440 -exec rm -f {} \;
find /u01/product/admin/umlaut/udump/umlaut_ora_*.trc  -mmin  +1440 -exec rm -f {} \;

 

DT2PRDBDG$cat shutdown_db.sh
#!/bin/bash
#shutdown_db.sh

ORACLE_HOME=/u01/product/oracle;export ORACLE_HOME
ORACLE_SID=umlaut; export ORACLE_SID

/u01/product/oracle/bin/sqlplus /nolog <connect / as sysdba
shutdown immediate
exit
EOF

/u01/product/oracle/bin/lsnrctl <stop
exit
EOF
DT2PRDBDG$cat startup_db.sh
#!/bin/bash

#startup_dg.sh

ORACLE_HOME=/u01/product/oracle;export ORACLE_HOME
ORACLE_SID=umlaut; export ORACLE_SID

/u01/product/oracle/bin/sqlplus /nolog <connect / as sysdba
startup nomount;
alter database mount standby database;
exit
EOF

/u01/product/oracle/bin/lsnrctl <start
exit
EOF


cat /etc/rc.local

#set oracle environment

ORACLE_HOME=/u01/product/oracle;export ORACLE_HOME
ORACLE_SID=nbewind; export ORACLE_SID=nbewind

su oracle -c "/u01/product/oracle/bin/sqlplus /nolog <connect / as sysdba
startup nomunt
alter database mount standby database
recover managed standby database disconnect from session
exit
EOF"

su oracle -c "/u01/product/oracle/bin/lsnrctl <start
exit
EOF"

 

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25850100/viewspace-703912/,如需轉載,請註明出處,否則將追究法律責任。

相關文章