OraMatt: YABAOracle

Yet Another Blog About Oracle

, , ,

Oracle Install Linux Quickstart Script — updated May 2, 2012


#!/bin/bash 
   #===================================================================================
   #
   #         FILE: linux_install_quickstart
   #
   #        USAGE: select an option or do all
   #
   #  DESCRIPTION:
   #      OPTIONS:  
   # REQUIREMENTS: 
   #       AUTHOR: Matt Dee
   #      CREATED: March 8, 2012
   #      UPDATED: May 2, 2012
   #      VERSION: 2.0
   #
   #
   #
   #
   #
   #
   #===================================================================================



# Functions for various stuff
function start_up()
{
	clear screen
	echo "#########################################################"
	echo "# This will setup your linux system for Oracle Database #"
	echo "#########################################################"

	echo
	echo
	echo 

	echo "################################################"
	echo "#                                              #"
	echo "#    What would you like to do ?               #"
	echo "#                                              #"
	echo "#          1 ==   Create Oracle user & Groups  #"
	echo "#                                              #"
	echo "#          2 ==   Change kernel settings       #"
	echo "#                                              #"
	echo "#          3 ==   Change security settings     #"
	echo "#                                              #"
	echo "#          4 ==   Set up YUM                   #"
	echo "#                                              #"
	echo "#          5 ==   Update YUM                   #"
	echo "#                                              #"
	echo "#          6 ==   Install required packages    #"
	echo "#                                              #"
	echo "#          7 ==   Do EVERYTHING                #"
	echo "#                                              #"
	echo "#          8 ==   Do NOTHING                   #"
	echo "#                                              #"
	echo "################################################"
	echo 
	echo "Please enter in your choice:> "
	read whatwhat

#	if [ $whatwhat -gt 9 ]
#		then
#		echo "Please enter a valid choice"
#		sleep 3
#		start_up
#	fi
	
}

function oracle_user_groups()
{
	echo "################################################"
	echo "Set up Oracle user & Groups"
	echo "Would you like to continue? "
	echo "Enter yes or no"
	echo "################################################"
	read DOWHAT
	if [[ $DOWHAT = yes ]]; then
		echo "Yes"
		# Create oracle groups
		/usr/sbin/groupadd oinstall
		/usr/sbin/groupadd  dba

		# Create oracle user
		/usr/sbin/useradd oracle -g oinstall -G dba
		/usr/sbin/usermod -g oinstall -G dba oracle

		# Change oracle passwd
		#export ORAPASS=oracle
		#passwd oracle $ORAPASS

		# Create directory for oracle stuff
		mkdir /u01
		chown -Rv oracle.oinstall /u01
		#start_up
	else
		echo "No"
		work_time
	fi
	
}


function kernel_settings()
{
	echo "################################################"
	echo "Set up kernel for Oracle"
	echo "Would you like to continue? "
	echo "Enter yes or no"
	echo "################################################"
	read DOWHAT
	if [[ $DOWHAT = yes ]]; then
		echo "Yes"
		echo kernel.shmmax=2147483648 >>/etc/sysctl.conf
		echo kernel.sem=250 32000 100 128 >>/etc/sysctl.conf
		echo fs.file-max=65536 >>/etc/sysctl.conf
		echo net.ipv4.ip_local_port_range=1024 65000 >>/etc/sysctl.conf
		echo fs.aio-max-nr = 1048576 >>/etc/sysctl.conf
		echo fs.file-max = 6815744 >>/etc/sysctl.conf
		echo kernel.shmall = 2097152 >>/etc/sysctl.conf
		echo kernel.shmmax = 536870912 >>/etc/sysctl.conf
		echo kernel.shmmni = 4096 >>/etc/sysctl.conf
		echo kernel.sem = 250 32000 100 128 >>/etc/sysctl.conf
		echo net.ipv4.ip_local_port_range = 1024 65500 >>/etc/sysctl.conf
		echo net.core.rmem_default = 262144 >>/etc/sysctl.conf
		echo net.core.rmem_max = 4194304 >>/etc/sysctl.conf
		echo net.core.wmem_default = 262144 >>/etc/sysctl.conf
		echo net.core.wmem_max = 1048586 >>/etc/sysctl.conf

		/sbin/sysctl -p
		#start_up
		
	else
		echo "No"
		work_time
	fi
	
}


function security_settings()
{
	echo "################################################"
	echo "Set up sercurity for Oracle"
	echo "Would you like to continue? "
	echo "Enter yes or no"
	echo "################################################"
	read DOWHAT
	if [[ $DOWHAT = yes ]]; then
		echo "Yes"
		echo oracle           soft    nproc   2047 >>/etc/security/limits.conf
		echo oracle           hard    nproc   16384 >>/etc/security/limits.conf
		echo oracle           soft    nofile  4096 >>/etc/security/limits.conf
		echo oracle           hard    nofile  65536 >>/etc/security/limits.conf
		# Set PAM
		# /etc/pam.d/login
		echo session    required     pam_limits.so >> /etc/pam.d/login
		#start_up
		
	else
		echo "No"
		work_time
	fi
	
}


function setup_yum()
{
	echo "################################################"
	echo "Add public-yum.oracle.com to YUM"
	echo "Would you like to continue? "
	echo "Enter yes or no"
	echo "################################################"
	read DOWHAT
	if [[ $DOWHAT = yes ]]; then
		echo "Yes"
		linux_release=`cat /etc/redhat-release | awk '{print $7}'`
		echo $linux_release
		case $linux_release in
		5*)
		cd /tmp
		rm -fv public-yum*
		wget http://public-yum.oracle.com/public-yum-el5.repo
		mv public-yum-el5.repo public-yum-el5.old
		cat public-yum-el5.old | sed "s/enabled=0/enabled=1/g" >public-yum-el5.repo
		cp public-yum-el5.repo /etc/yum.repos.d/
		;;
		6*)
		cd /tmp
		rm -fv public-yum*
		wget http://public-yum.oracle.com/public-yum-ol6.repo 
		mv public-yum-ol6.repo public-yum-ol6.old
		cat public-yum-ol6.old | sed "s/enabled=0/enabled=1/g" >public-yum-ol6.repo 
		cp public-yum-ol6.repo /etc/yum.repos.d/
		;;
		esac
		#start_up
		
	else
		echo "No"
		work_time
	fi
	
	
}

function update_yum()
{
	echo "################################################"
	echo "Update Yum...this can be a lengthly operation"
	echo "Would you like to continue? "
	echo "Enter yes or no"
	echo "################################################"
	read DOWHAT
	if [[ $DOWHAT = yes ]]; then
		echo "Yes"
		yum -y update 
		#start_up
		
	else
		echo "No"
		work_time
	fi
	
}


function install_stuff()
{
	echo "################################################"
	echo "Install required software for Oracle"
	echo "Would you like to continue? "
	echo "Enter yes or no"
	echo "################################################"
	read DOWHAT
	if [[ $DOWHAT = yes ]]; then
		echo "Yes"
		sudo yum -y install kernel-deve* binutils-* compat-libstdc++-* elfutils-libelf-* elfutils-libelf-devel-* elfutils-libelf-devel-static-* gcc-* gcc-c++-* glibc-* glibc-common-* glibc-devel-* glibc-headers-* kernel-headers-* ksh-* libaio-* libaio-devel-*  libgcc-* libgomp-* libstdc++-* libstdc++-devel-* make-* sysstat-* unixODBC-* unixODBC-devel-* oracleasm-`uname -r`
		#start_up
		
	else
		echo "No"
		work_time
	fi
	
}


function do_everything()
{
	echo "################################################"
	echo "Do it all...NOW "
	echo "Would you like to continue? "
	echo "Enter yes or no"
	echo "################################################"
	read DOWHAT
	if [[ $DOWHAT = yes ]]; then
		echo "Yes"
		oracle_user_groups
		kernel_settings
		security_settings
		setup_yum
		update_yum
		install_stuff
		#start_up
		
	else
		echo "No"
		work_time
	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) 
		oracle_user_groups
		;;
	2) 
		kernel_settings
		;;
	3)
		security_settings
		;;
	4) 
		setup_yum
		;;
	5)
		update_yum
		;;
	6)
	 	install_stuff
		;;
	7)
		do_everything
		;;
	8)
		do_nothing
		;;
esac
}



# Script must be run by root user
# Let's go to work

clear screen
if [[ `whoami` != "root" ]]
	then
		echo "This script must be run as the root user."
		exit 1
	else 
		work_time
fi



.

One response to “Oracle Install Linux Quickstart Script — updated May 2, 2012”

  1. […] Oracle Install Linux Quickstart Script — updated May 2, 2012 […]

Leave a comment

Navigation

About

I’m Matt and I do Oracle things.