OraMatt: YABAOracle

Yet Another Blog About Oracle

, , , , , ,

Script to set the db parameters for OEM 12c

#!/bin/bash
   #===================================================================================
   #
   #         FILE: OEM_DB_Setup.sh
   #
   #        USAGE: Run it...
   #
   #  DESCRIPTION: Script to set the db parameters for OEM 12c
   #      OPTIONS:  
   # REQUIREMENTS: 
   #       AUTHOR: Matt Dee
   #      CREATED: May 2, 2012
   #      VERSION: 1.0
   #
   #
   #
   #
   #
   #
   #===================================================================================


clear screen

function start_up()
{
	clear screen
	echo "#########################################################"
	echo "# This will setup your Oracle Database for OEM 12c       #"
	echo "#########################################################"

	echo
	echo

	echo "################################################"
	echo "#                                              #"
	echo "#    What would you like to do ?               #"
	echo "#                                              #"
	echo "#          1 ==   Change Database Settings     #"
	echo "#                                              #"
	echo "#          2 ==   Rollback Database Settings   #"
	echo "#                                              #"
	echo "#          3 ==   QUIT                         #"
	echo "#                                              #"
	echo "################################################"
	echo 
	echo "Please enter in your choice:> "
	read whatwhat
}

function oracle_home_set()
{
	# Test for Oracle Home setting
	if test "${ORACLE_HOME+set}" != set ; then
 		echo "ORACLE_HOME is not set"
 		echo "Please set your ORACLE_HOME and rerun"
	else
 		echo "$ORACLE_HOME is set"
	fi
}


function change_db()
{
	oracle_home_set
	
	echo "What is the SID of the Oracle database"
	echo "Currently runnging Databases"
	ps -ef | grep -v grep | grep pmon | cut -d _ -f3
	echo "Enter the SID: "
	read ORASID
	
	export ORACLE_SID=${ORASID}

	sqlplus '/ AS SYSDBA' <<EOF

	create pfile='/tmp/init_backup.ora' from spfile;

	ALTER SYSTEM SET processes=300 SCOPE=SPFILE;
	ALTER SYSTEM SET session_cached_cursors=200 SCOPE=SPFILE;
	ALTER SYSTEM SET sga_target=2G SCOPE=SPFILE;
	ALTER SYSTEM SET shared_pool_size=600M SCOPE=SPFILE;
	ALTER SYSTEM SET pga_aggregate_target=1G SCOPE=SPFILE;
	ALTER SYSTEM SET job_queue_processes=20 SCOPE=SPFILE;
	ALTER SYSTEM SET open_cursors=300 SCOPE=SPFILE;
	-- Restart the instance.
	SHUTDOWN ABORT
	STARTUP
	exit
EOF
}

function rollback_changes()
{
	oracle_home_set
	
if test ! -f /tmp/init_backup.ora
	then 	
		echo "No /tmp/init_backup.ora exists"
		echo "Exiting"
		exit 1
	else
		echo "What is the SID of the Oracle database"
		echo "Currently runnging Databases"
		ps -ef | grep -v grep | grep pmon | cut -d _ -f3
		echo "Enter the SID: "
		read ORASID

	export ORACLE_SID=${ORASID}
	
	sqlplus '/ AS SYSDBA' <<EOF
	shutdown abort
	startup pfile='/tmp/init_backup.ora'
	create spfile from pfile='/tmp/init_backup.ora'
	shutdown abort
	startup
	exit
EOF
fi	
}

function do_nothing()
{
	echo "################################################"
	echo "You don't want to do nothing...lazy..."
	echo "So...you want to quit...yes? "
	echo "Enter yes or no"
	echo "################################################"
	read DOWHAT
	if [[ $DOWHAT = yes ]]; then
		echo "Yes"
		exit 1
	else
		echo "No"
		work_time
	fi
	
}

function work_time()
{
start_up
case $whatwhat in
	1)
		change_db
		;;
	2)
		rollback_changes
		;;
	3) 
		do_nothing
		;;
esac
}


# Work time!!!
work_time

Leave a comment

Navigation

About

I’m Matt and I do Oracle things.