Skip to main content

Posts

Showing posts from October, 2016

run unix command on multiple servers using ssh in mobaxTerm

I get a request to check ldap.ora on all $ORACLE_HOME on 300 Unix servers. I do not want to logon to each server and check each oracle_home, I use the following method to check, it took a few hours to build this solution, and then I can run it again and again, and each time it only took a few minutes to complete! Step1: find out all the ORACLE_HOME registered in Grid Control. I use this query: with oraclehomevw as ( SELECT mgmt$target.host_name  , mgmt$target.target_name  , mgmt$target.target_type  , mgmt$target_properties.property_name  , mgmt$target_properties.property_value  FROM mgmt$target , mgmt$target_properties  WHERE ( mgmt$target.target_name = mgmt$target_properties.target_name )  AND ( mgmt$target.target_type = mgmt$target_properties.target_type )  and ( lower(mgmt$target_properties.property_name) like '%%home%')  and  mgmt$target_properties.property_value is not null and lower(mgmt$target_properties.property_name) not in ('domain_home','home_guid'

Unix Script to delete archivelog for RAC Dataguard database.

I use this script to delete archivelog for dataguard database running RAC. example: /path/this_script SID #!/bin/bash export PATH=/bin:/usr/bin:/usr/local/bin:/usr/sbin:.:/usr/ccs/bin:/usr/ucb:/usr/openwin/bin:/u01/oracle/dba #. $HOME/.profile ORACLE_SID=$1 export ORAENV_ASK=NO . /usr/local/bin/oraenv SCRIPT_HOME=/u01/dba/bin DATE=`date +%d%m%y_%H%M` LOG=${SCRIPT_HOME}/logs/archive_cleanup_${ORACLE_SID}.log rm -rf ${LOG} cd ${SCRIPT_HOME} touch ${LOG} echo $PATH >${LOG} $ORACLE_HOME/bin/sqlplus  -S / as sysdba <<EOF set pagesize 0 set feedback off spool ${SCRIPT_HOME}/$SID_tmp.lst select database_role from v\$database; spool off ; EOF DB_ROLE=`grep -i "PHYSICAL STANDBY" ${SCRIPT_HOME}/$SID_tmp.lst |wc -l` echo $DB_ROLE if [ "$DB_ROLE" -eq '1' ]; then $ORACLE_HOME/bin/sqlplus  -S / as sysdba <<EOF set pagesize 0 set feedback off spool ${SCRIPT_HOME}/$SID_tmp.lst select 'delete noprompt archivelog until sequence '||max(sequence#)||&#

RC script to start oracle process for server shutdown and start

This is for the Grid Control server. #!/bin/sh #for whatever reason, /bin/bash does not work, it does not even create the log file while server reboot # https://gruffdba.wordpress.com/2013/02/09/installing-oracle-enterprise-manager-12c-12-1-0-2-on-centos-6-3-on-vmware-workstation-8/#more-584 # Created on Oct 7th, 2016 by Jiulu Sun # This script is used on Oracle Grid Control OMS Server, it will start/stop oracle database, listener, OMS and agent when the box is reboot. # !!! I have to modify first line of $ORACLE_HOME/bin/dbstart and dbshut script to use ksh rather than sh, otherwise it run into error 'invalid identifier' using sh ORA_OWNER=orabcf #export ORAENV_ASK=NO #export ORACLE_SID=oem11g #. oraenv #export ORACLE_HOME=/u01/oracle/oem11g/product/11.2.0 #export OMS_HOME=/u01/oracle/grc/middleware/oms11g #export AGENT_HOME=/u01/oracle/grc/middleware/agent11g case "$1" in     start) echo "start">/u01/orabcf/dbstartup.log date>>