Oracle安装脚本

前端之家收集整理的这篇文章主要介绍了Oracle安装脚本前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Oracle脚本,便于快速部署。现在用的是11G,可以针对不同版本加以调整,主要涉及以下几块内容
1. vnc安装
2. 安装涉及到的内核参数设置
3. 数据库dbca配置
4. netca设置
5. sqlplus设置

#!/bin/bash
#oralce install for 11.2.0.1
#usage:./oracle_installer.sh dp_ip db_hostname db_name



#modified time 2017-8-28 13:02:54 
#modified content
#add db_files variabe(install zipname)
#
#
#

#read -p "db_ip:" db_ip
#read -p "db_hostname:" db_hostname
#read -p "db_name:" db_name
#export db_name



db_ip=$1
db_hostname=$2
db_name=$3
db_files1=linux.x64_11gR2_database_1of2.zip
db_files2=linux.x64_11gR2_database_2of2.zip


echo -e "------------------db_ip=$1-------------\n"
echo -e "------------------db_hostname=$2-------\n"
echo -e "------------------db_name=$3-------------\n\n"
echo -e "------------------db_files=linux.x64_11gR2_database_1of2.zip------------\n"


echo -e "------------------uninstall last installation-------------\n\n"
rm -rf /u01
rm -rf /usr/local/bin/*
rm -rf /etc/oratab
rm -rf /etc/oraInst.loc
rm -rf /opt/ORCLfmap
rm -rf /home/oracle/oracle_install.sh
rm -rf /home/oracle/tmp.rsp

echo -e "---------------add group and member----------------\n\n"
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle



echo -e  "\n\n------------mount and cfg yum---------------------\n\n"

mount /dev/cdrom  /media


#add local source
grep  "local-source" /etc/yum.repos.d/rhel-source.repo > /dev/null
if [ $? -eq 0 ]; then
    echo "local-source found!"
else
    echo "local-source is configuring"
    echo -e  "\n\n[local-source]\nname=yum server\nbaseurl=file:///media\nenabled=1\ngpgcheck=0\n">>/etc/yum.repos.d/rhel-source.repo
fi

echo -e "\n\n--------------about vnc---------------------------\n\n"

yum install tigervnc-server.x86_64 -y


#iptables stop
service iptables stop



grep "${db_ip} ${db_hostname}" /etc/hosts  > /dev/null
if [ $? -eq 0 ]; then
   echo "hostname found"
else
   echo "hostname is configuring"
   echo -e "\n"${db_ip} ${db_hostname}"\n" >> /etc/hosts
fi


#configure vnc
vncserver
su - oracle -c "vncserver"


sed  -i  's/^twm/#twm/g'  /home/oracle/.vnc/xstartup
grep "gnome-session &" /home/oracle/.vnc/xstartup  > /dev/null

if [ $? -eq 0 ];then
   echo "ora gnome-session & found"
else
   echo "ora gnome-session & is configuring"
   echo "gnome-session &" >> /home/oracle/.vnc/xstartup
fi


sed  -i  's/^twm/#twm/g'  /root/.vnc/xstartup
grep "gnome-session &" /root/.vnc/xstartup > /dev/null

if [ $? -eq 0 ];then
   echo "gnome-session & found"
else
   echo "gnome-session & is configuring"
   echo "gnome-session &" >> /root/.vnc/xstartup
fi



grep "1:root 2:oracle" /etc/sysconfig/vncservers > /dev/null

if [ $? -eq 0 ];then
   echo "VNCSERVERS found"
else
   echo "VNCSERVERS is configuring"
   echo -e "\nVNCSERVERS=\"1:root 2:oracle\"\nVNCSERVERARGS[1]=\"-geometry 1024x768\"\nVNCSERVERARGS[2]=\"-geometry 1024x768\"" >> /etc/sysconfig/vncservers
fi


echo -e "\n\n---------------make oracle directories----------------------\n\n"


usermod -g oinstall -G dba oracle
mkdir -p /u01/app/oracle
mkdir -p /u01/app/oradata
mkdir -p /u01/app/oracle/product
chown -R oracle:oinstall /u01
chmod -R 775 /u01


echo -e "\n\n---------------about oracle configure------------------\n\n"


grep "oracle configure" /etc/sysctl.conf  > /dev/null
if [ $? -eq 0 ];then
  echo "#oracle configure found"
else
  echo "#oracle configure is configuring"
  echo -e \
"#oracle configure\n\ fs.file-max = 6815744\n\ fs.aio-max-nr = 1048576\n\ fs.aio-max-nr = 1048576\n\ kernel.shmall = 2097152\n\ kernel.shmmax = 2147483648\n\ kernel.shmmni = 4096\n\ kernel.sem = 250 32000 100 128\n\ net.ipv4.ip_local_port_range = 9000 65500\n\ net.core.rmem_default = 4194304\n\ net.core.rmem_max = 4194304\n\ net.core.wmem_default = 262144\n\ net.core.wmem_max = 1048576\n"\
>> /etc/sysctl.conf

fi


sysctl -p



grep "oracle shell limits" /etc/security/limits.conf > /dev/null
if [ $? -eq 0 ];then
 echo "oracle shell limits found"
else
 echo "oracle shell limits is configuring"
 echo -e \
"#oracle shell limits\n\ oracle soft nproc 2047\n\ oracle hard nproc 16384\n\ oracle soft nofile 1024\n\ oracle hard nofile 65536\n"\
>> /etc/security/limits.conf


fi


grep "#oracle pam configuring" /etc/pam.d/login > /dev/null
if [ $? -eq 0 ];then
 echo "oracle pam found"
else
 echo "oracle pam is configuring"
 echo -e \
"#oracle pam configuring\n\ session required pam_limits.so\n\ session required /lib/security/pam_limits.so\n"\
>> /etc/pam.d/login

fi



grep "#oracle profile configuring" /etc/profile > /dev/null
if [ $? -eq 0 ];then
 echo "oracle profile found"
else
"#oracle profile configuring\n\ if [ $USER = "oracle" ]; then\n\ if [ $SHELL = "/bin/ksh" ]; then\n\ ulimit -p 16384\n\ ulimit -n 65536\n\ else\n\ ulimit -u 16384 -n 65536\n\ fi\n\ fi\n"\
>> /etc/profile

fi



grep "#oracle csh configuring" /etc/csh.login > /dev/null
if [ $? -eq 0 ];then
 echo "oracle csh found"
else
 echo "oracle csh is configuring"
 echo -e \
"#oracle csh configuring\n\ if ( \$USER == \"oracle\" ) then\n\ limit maxproc 16384\n\ limit descriptors 65536\n\ endif\n"\
>> /etc/csh.login

fi

echo -e "\n\n------------------about selinux-------------------\n\n"

sed -r 's/(SELINUX=)*/\1disabled/' /etc/selinux/config  > /dev/null

grep "SELINUX=disabled" /etc/selinux/config > /dev/null

if [ $? -eq 0 ]; then
 echo "SELINUX=disabled found"
else
 echo "SELINUX=disabled is configuring"
 echo -e "\nSELINUX=disabled\n" >> /etc/selinux/config
fi


echo -e "\n\n--------------install dependecies---------------------\n\n"
 yum -y install compat-libstdc++-33 elfutils-libelf-devel gcc gcc-c++ glibc-devel glibc-headers libaio-devel libstdc++-devel pdksh unixODBC unixODBC-devel  gcc* glibc* ksh
* libstdc* make* libXp*

echo -e "\n\n--------------------oracle env varibales-----------------------\n\n"
grep "ORACLE_ENV" /home/oracle/.bash_profile > /dev/null

if [ $? -eq 0 ]; then
  echo "ORACLE_ENV found"
else
  echo "ORACLE_ENV is configuring"
su - oracle -c \
"echo -e \ \"#ORACLE_ENV\n\ export ORACLE_BASE=/u01/app/oracle\n\ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1\n\ export ORACLE_SID=${db_name}\n\ export PATH=$PATH:$HOME/bin:/u01/app/oracle/product/11.2.0/db_1/bin\n\ export LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/db_1/lib:/usr/lib\n\"\ >> ~/.bash_profile"
fi
su - oracle -c "source .bash_profile"


echo -e "\n\n----------------install oralce and create database-------------------------------\n\n"
unzip /$db_files1 -d /
unzip /$db_files2 -d /

cp ./db_install.rsp ./tmp.rsp
sed -i "s/sky2/${db_name}/g" ./tmp.rsp
mv ./tmp.rsp /home/oracle/tmp.rsp


chown oracle:oinstall   /home/oracle/tmp.rsp
chown -R oracle:oinstall  /database



su - oracle -c "cd /database && ./runInstaller -waitforcompletion -silent -ignoreSysPrereqs -ignorePrereq -responseFile /home/oracle/tmp.rsp"


/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0/db_1/root.sh

echo -e "\n\n----------------create database-------------------------------\n\n"


export db_name
su - oracle -c "dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname $db_name -sid $db_name -responseFile NO_VALUE -characterSet AL32UTF8 \ -memoryPercentage 30 -emConfiguration LOCAL"







echo -e "\n\n----------------netca-------------------------------\n\n"
su - oracle -c "netca /silent /responsefile /database/response/netca.rsp "



echo -e "\n\n----------------sqlplus-------------------------------\n\n"
grep "ORACLE_INSTALL_CONFIG" /u01/app/oracle/product/11.2.0/db_1/sqlplus/admin/glogin.sql > /dev/null
if [ $? -eq 0 ]; then
    echo -e "sqlPLUS ORACLE_INSTALL_CONFIG SET\n"
else
  echo -e "sqlPLUS ORACLE_INSTALL_CONFIG NOT SET\n"
    echo -e \
    "--ORACLE_INSTALL_CONFIG\n\ set linesize 160\n\ set pagesize 100\n\ set sqlprompt '_user@ _connect_identifier>'\n\ define _editor=vi\n\ \n"\
>>/u01/app/oracle/product/11.2.0/db_1/sqlplus/admin/glogin.sql
fi


echo -e "\n\n----------------oralce installed successfully-------------------------------\n\n"


exit 0
原文链接:https://www.f2er.com/oracle/207366.html

猜你在找的Oracle相关文章