加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Oracle安装脚本

发布时间:2020-12-12 14:22:14 所属栏目:百科 来源:网络整理
导读:Oracle脚本,便于快速部署。现在用的是11G,可以针对不同版本加以调整,主要涉及以下几块内容 1. vnc安装 2. 安装涉及到的内核参数设置 3. 数据库dbca配置 4. netca设置 5. sqlplus设置 #!/bin/bash #oralce install for 11.2.0.1 #usage:./oracle_installer

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-------------nn"
echo -e "------------------db_files=linux.x64_11gR2_database_1of2.zip------------n"


echo -e "------------------uninstall last installation-------------nn"
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----------------nn"
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle



echo -e  "nn------------mount and cfg yum---------------------nn"

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  "nn[local-source]nname=yum servernbaseurl=file:///medianenabled=1ngpgcheck=0n">>/etc/yum.repos.d/rhel-source.repo
fi

echo -e "nn--------------about vnc---------------------------nn"

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 "nn---------------make oracle directories----------------------nn"


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 "nn---------------about oracle configure------------------nn"


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 configuren fs.file-max = 6815744n fs.aio-max-nr = 1048576n fs.aio-max-nr = 1048576n kernel.shmall = 2097152n kernel.shmmax = 2147483648n kernel.shmmni = 4096n kernel.sem = 250 32000 100 128n net.ipv4.ip_local_port_range = 9000 65500n net.core.rmem_default = 4194304n net.core.rmem_max = 4194304n net.core.wmem_default = 262144n net.core.wmem_max = 1048576n"
>> /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 limitsn oracle soft nproc 2047n oracle hard nproc 16384n oracle soft nofile 1024n oracle hard nofile 65536n"
>> /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 configuringn session required pam_limits.son session required /lib/security/pam_limits.son"
>> /etc/pam.d/login

fi



grep "#oracle profile configuring" /etc/profile > /dev/null
if [ $? -eq 0 ];then
 echo "oracle profile found"
else
"#oracle profile configuringn if [ $USER = "oracle" ]; thenn if [ $SHELL = "/bin/ksh" ]; thenn ulimit -p 16384n ulimit -n 65536n elsen ulimit -u 16384 -n 65536n fin fin"
>> /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 configuringn if ( $USER == "oracle" ) thenn limit maxproc 16384n limit descriptors 65536n endifn"
>> /etc/csh.login

fi

echo -e "nn------------------about selinux-------------------nn"

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=disabledn" >> /etc/selinux/config
fi


echo -e "nn--------------install dependecies---------------------nn"
 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 "nn--------------------oracle env varibales-----------------------nn"
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_ENVn export ORACLE_BASE=/u01/app/oraclen export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1n export ORACLE_SID=${db_name}n export PATH=$PATH:$HOME/bin:/u01/app/oracle/product/11.2.0/db_1/binn export LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/db_1/lib:/usr/libn" >> ~/.bash_profile"
fi
su - oracle -c "source .bash_profile"


echo -e "nn----------------install oralce and create database-------------------------------nn"
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 "nn----------------create database-------------------------------nn"


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 "nn----------------netca-------------------------------nn"
su - oracle -c "netca /silent /responsefile /database/response/netca.rsp "



echo -e "nn----------------sqlplus-------------------------------nn"
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 SETn"
else
  echo -e "SQLPLUS ORACLE_INSTALL_CONFIG NOT SETn"
    echo -e 
    "--ORACLE_INSTALL_CONFIGn set linesize 160n set pagesize 100n set sqlprompt '_user@ _connect_identifier>'n define _editor=vin n"
>>/u01/app/oracle/product/11.2.0/db_1/sqlplus/admin/glogin.sql
fi


echo -e "nn----------------oralce installed successfully-------------------------------nn"


exit 0

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读