Script previo antes de instalar Oracle en Fedora | Linuxadmin

Antes de instalar Oracle tenemos que hacer un montón de pasos en Linux y cualquiera se los aprende. Bien, pues me encontré en un  foro un script muy bueno que he modificado un par de cosas para adaptarlo a hoy:

#!/bin/sh # Made by “Unlimited_Eng@hotmail.com” # for techincal feedback please contanct me at this mail “”AhmedShabana2000@gmail.com””

# it is under GPL

# WIDE SCRIBT PARAMETER “EXIT STATUS” E_NOTROOT=11 # you are not a root E_NPAC_SOURCE=12 # you have no valid package source

E_INIT_BEFORE=13 # this scribt runs in this system before

# ” ” ” “VARIABLES”
YUM_REPO_SERVER=”” # may be added in the future %%%%

# FUNCTION INCLUSION

########################### common_packages() { (xterm -geometry 96×25-0+0 -bg “#000000″ -fg “#99CCFF” -title “DOWNLOADING AND INSTALLING PACKAGES” -e ” yum -y install binutils-2.* > /root/Desktop/OracleSysInit.log 2> /root/Desktop/OraError.log ; yum -y install elfutils-libelf-0.* 2>> /root/Desktop/OraError.log ; yum -y install glibc-2.* 2>> /root/Desktop/OraError.log; yum -y install glibc-common-2.* 2>> /root/Desktop/OraError.log; yum -y install libgcc-4.* 2>> /root/Desktop/OraError.log ; yum -y install libstdc++-4.* 2>> /root/Desktop/OraError.log; yum -y install make-3.* 2>> /root/Desktop/OraError.log; yum -y install elfutils-libelf-devel-0.* 2>> /root/Desktop/OraError.log; yum -y install glibc-devel-2.* 2>> /root/Desktop/OraError.log; yum -y install gcc-4.* 2>> /root/Desktop/OraError.log; yum -y install gcc-c++-4.* 2>> /root/Desktop/OraError.log; yum -y install libstdc++-devel-4.* 2>> /root/Desktop/OraError.log; yum -y install unixODBC-2.* 2>> /root/Desktop/OraError.log; sleep 3 “) | zenity –progress –pulsate –percentage=25 –auto-close –title “Oracle System Initialzation scribt” –text “essential packages installing ….”

}

packages_install() { case $CONNECTION in “internet”) common_packages xterm -geometry 96×25-0+0 -bg “#000000″ -fg “#ee1635″ -title “DOWNLOADING AND INSTALLING PACKAGES” -e ” yum -y install libaio libaio-devel 2>> /root/Desktop/OraError.log; yum -y install unixODBC-devel 2>> /root/Desktop/OraError.log; yum -y install sysstat 2>> /root/Desktop/OraError.log; yum -y install compat-libstdc++ 2>> /root/Desktop/OraError.log ” break ;; “local”) common_packages zenity –info –title “Oracle System Initialization Scribt” –text “You must install your self those packages ”ibaio libaio-devel unixODBC-devel sysstat compat-libstdc++ ”” break ;; *) echo “Unkown” ;; esac

}

yum_config_local_repo() { # Check if this step has been configured before if [ -f /etc/yum.repos.d/OracleClass.repo] ;then exit $E_INIT_BEFORE fi # Configure ftp server to hold the packages and export it for the local machine ISO_File=$(zenity –title=”Please Select the FC9 DVD iso file ” –file-selection)

echo $ISO_File | grep ‘.iso$’ >> /dev/null || (zenity –info –text “Error Invalid ISO image” –title “Oracle System Initialization scribt” && yum_config_local_repo )

mount -o loop $ISO_File /mnt cd /mnt/Packages rpm -ivh vsftpd* && chkconfig vsftpd on service vsftpd start mkdir /var/ftp/pub/local ln -s * /var/ftp/pub/local # Create local yum repo file cat /etc/yum.repos.d/OracleClass.repo [ local-repo ] name=”This for Oracle 11g server use” baseurl=ftp://localhost/pub/local enable=1 gpgcheck=0 EOF /etc/init.d/iptables stop

}

test_network() {

ping -c 1 www.google.com > /dev/null 2>/dev/null

if [ $? -eq 0 ] then CONNECTION=”internet” else ping -c 1 $YUM_REPO_SERVER > /dev/null 2> /dev/null if [ $? -eq 0 ] then CONNECTION=”lan” fi else zenity –question –title “oracle 11g system initializer” –text “Do you have The FC9 .iso source and at least 1G free space in /var directory” if [ $? -eq 1 ] zenity –info –title “oracle 11g system initializer” –text “SORRY , program will exit ”Error can not find packages installation source ”” exit $E_NPAC_SOURCE

fi

enity –question –title “oracle 11g system initializer” –text “In case that you has FC9 DVD iso image and free space in /var Do you want to create local yum repository ?” if [ $? -eq 0] ; then yum_config_local_repo fi

}

tune_kernel() { RAM=$(free | sed -n ‘2p’ | awk ‘{print $2}’)

SWAP=$(echo $[ $RAM/2 ])

echo ” kernel.shmall = 2097152 kernel.shmmni = 4096 # semaphores: semmsl, semmns, semopm, semmni kernel.sem = 250 32000 100 128 fs.file-max = 65536 # 512 * PROCESSES net.ipv4.ip_local_port_range = 1024 65000 net.core.rmem_default=4194304 net.core.rmem_max=4194304 net.core.wmem_default=262144 net.core.wmem_max=262144 kernel.shmmax = 2147483648″ >> /etc/sysctl.conf # Smallest of -> (Half the size of the physical memory) or (4GB – 1 byte) # echo “kernel.shmmax = $SWAP ” >> /etc/sysctl.conf /sbin/sysctl -p

}

set_security_limitations(){ echo ” oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024

oracle hard nofile 65536 ” >> /etc/security/limits.conf

echo ” session required /lib/security/pam_limits.so

session required pam_limits.so ” >> /etc/pam.d/login

# ADDITIONAL SECURIY STRATIGIES DISAPLING #FIREWALL OFF chkconfig iptables off

service iptables stop

#SECURITY ENHANCED LINUX DISAPLING setenforce permissive

}

user_group_create() { groupadd oinstall groupadd dba groupadd oper

groupadd asmadmin

useradd -g oinstall -G dba,oper,asmadmin –home /home/oracle oracle
echo “oracle” | passwd –stdin oracle

}

set_bash_profile() { echo ” TMP=/tmp; export TMP

TMPDIR=$TMP; export TMPDIR

ORACLE_HOSTNAME=f9.localdomain; export ORACLE_HOSTNAME ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1; export ORACLE_HOME ORACLE_SID=DB11G; export ORACLE_SID ORACLE_TERM=xterm; export ORACLE_TERM PATH=/usr/sbin:$PATH; export PATH

PATH=$ORACLE_HOME/bin:$PATH; export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

if [ $USER = “oracle” ]; then if [ $SHELL = “/bin/ksh” ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi fi ” >> /home/oracle/.bash_profile } ###########################

# end of special local function

# CHECKING ROOT ACCOUNT if [ ! $(whoami | grep root ) ] ;then

zenity –info –text “Please Mr/Mrs $(logname) must run this scribt as a root user you can access the root account with this command ”#su -” ”

exit $E_NOTROOT fi # Start interactive execution from here SELECT=$(zenity –title “Oracle System Initialization scrint” –text “Select the what you want to install by default it will perform full installation” –list –radiolist –column “Select” –column “Options” TRUE “Full installation” FALSE “Configure local yum repository ” FALSE “Set kernel tuning parameter” FALSE “Set security limitation” FALSE “Set the Environment variables of the Oracle user”) case $SELECT in “Configure local yum repository”) yum_config_local_repo ;; break “Set kernel tuning parameter”) tune_kernel ;; break “Set security limitation”) set_security_limitations ;; break “Set the Environment variables of the Oracle user”) set_bash_profile

*)

# CHICKING IF THIS SCRBIT HAS BEEN RUN BEFORE IN THIS SYSTEM grep ‘^#### ORACLE SYSTEM INITIALIZATION SCRIBT RUN IN THIS SYSTEM’ /etc/rc.local ) if [ $? -eq 0 ] ;then zenity –question –text “This scribt has been run in this system before click OK to install missing packages” if [ $? -eq 1 ];then exit $E_INIT_BEFORE ;fi test_network packages_install exit $E_INIT_BEFORE fi

echo “#### ORACLE SYSTEM INITIALIZATION SCRIBT RUN IN THIS SYSTEM” >> /etc/rc.local

# USER INPUT STAGE IPADDR=$(zenity –entry –title “oracle 11g system initializer” –text “please Enter your ip address”) SERVER_NAME=$(zenity –entry –title “oracle 11g system intializer” –text “Please insert name to assigned to this server”)

echo ” $IPADDR $SERVER_NAME ” >> /etc/hosts

# YUM CONFIGURATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% test_network # KERNEL PARAMETER TUNNING STAGE

tune_kernel

# BASH SECURITY LIMITATION CONFIGURATION STAGE
set_security_limitations

# PACKAGE INSTALLATION
packages_install

# ORACLE USERs AND GROUPs CREATION user_group_create

# INSTALLATION DIRECTORY CREATION WITH ADAPTIVE PERMISSIONs

mkdir -p /u01/app/oracle/product/11.1.0/db_1 chown -R oracle:oinstall /u01

chmod -R 775 /u01

# CHANGING THE RELEASE TO RUN PROPERLY “WITHOUR ERROR MESSAGEs”
echo “redhat release 5″ > /etc/redhat-release

# SETTING THE ENVIRONMENTAL VARIABLES FOR THE ORACLE
set_bash_profile

zenity –info –text “You now has two log files in your desktop OracleSysInit.log and OraError.log” zenity –info –text “Please access the installer location and then run ./runInstaller”

# SYSTEM PREPERATION ENDs HERE

;; break
exit 0