oracle 11g 静默安装脚本

11.2.0.4安装包:

链接:https://pan.baidu.com/s/1EdKgyaI893exQz5o9MBLaQ
提取码:p8s3
该软件只用于个人测试学习,如需商业使用,请按规范操作

简介

ora_create_path.sh : 环境创建脚本
ora_dbca.sh : db创建脚本
此脚本绝对可用,使用前可简单阅读脚本,其中的ORACLE_HOME,ORACLE_BASE,ORACLE_SID等以变量的方式带入
需要手动输入对应路径

ora_create_path.sh
#!/bin/bash
export PATH=$PATH

###set firewalld&selinux
os=cat /etc/redhat-release|awk '{print $4}'|awk -F'.' '{print $1}'
if [ ${os} == “7” ];then
systemctl disable firewalld && systemctl stop firewalld
systemctl disable abrt-ccpp
systemctl disable abrtd
systemctl disable atd
systemctl disable auditd
systemctl disable cpuspeed
systemctl disable cups
systemctl disable dnsmasq
systemctl disable firstboot
systemctl disable lvm2-monitor
systemctl disable netconsole
systemctl disable netfs
systemctl disable ntpd
systemctl disable ntpdate
systemctl disable portreserve
systemctl disable postfix
systemctl disable rdisc
systemctl disable restorecond
systemctl disable saslauthd
systemctl disable wdaemon
systemctl disable wpa_supplicant
systemctl disable NetworkManager
systemctl disable blk-availability
systemctl disable cpuspeed
systemctl disable lvm2-monitor
systemctl disable restorecond
systemctl disable netconsole
if [ getenforce == “Enforcing” ];then
setenforce 0
sed -i “s!SELINUX=enforcing!SELINUX=disabled!g” /etc/selinux/config
elif [ getenforce == “Permissive” ];then
sed -i “s!SELINUX=enforcing!SELINUX=disabled!g” /etc/selinux/config
else
continue
fi
else
chkconfig iptables off && chkconfig ip6tables off && service iptables stop && service ip6tables stop
chkconfig abrt-ccpp off
chkconfig abrtd off
chkconfig atd off
chkconfig auditd off
chkconfig cpuspeed off
chkconfig cups off
chkconfig dnsmasq off
chkconfig firstboot off
chkconfig lvm2-monitor off
chkconfig netconsole off
chkconfig netfs off
chkconfig ntpd off
chkconfig ntpdate off
chkconfig portreserve off
chkconfig postfix off
chkconfig rdisc off
chkconfig restorecond off
chkconfig saslauthd off
chkconfig wdaemon off
chkconfig wpa_supplicant off
chkconfig NetworkManager off
chkconfig blk-availability off
chkconfig cpuspeed off
chkconfig lvm2-monitor off
chkconfig restorecond off
chkconfig netconsole off
if [ getenforce == “Enforcing” ];then
setenforce 0
sed -i “s!SELINUX=enforcing!SELINUX=disabled!g” /etc/selinux/config
elif [ getenforce == “Permissive” ];then
sed -i “s!SELINUX=enforcing!SELINUX=disabled!g” /etc/selinux/config
else
continue
fi
fi

###set the ip in hosts
hostname=hostname
ip=ifconfig enp0s8 | grep -w 'inet' | awk '{print $2}'
for i in i p d o a = ‘ g r e p " {ip} do a=`grep " ipdoa=grep"{i}" /etc/hosts`
if [ ! -n “ a " ] ; t h e n e c h o " {a}" ];then echo " a"];thenecho"{i} ${hostname}” >> /etc/hosts
else
break
fi
done

###create group&user
ora_user=oracle
ora_group=(‘oinstall’ ‘dba’ ‘oper’)
for i in o r a g r o u p [ @ ] d o a = ‘ g r e p ′ {ora_group[@]} do a=`grep ' oragroup[@]doa=grep{i}’ /etc/group if [ ! -n ${a} ];then groupdel ${i} && groupadd ${i} else groupadd ${i} fi done a=grep ‘oracle’ /etc/passwd if [ ! -n ${a} ];then userdel -r ${ora_user} && useradd ${ora_user} -g ${ora_group[0]} -G ${ora_group[1]},${ora_group[2]} ${ora_user} else useradd -g ${ora_group[0]} -G ${ora_group[1]},${ora_group[2]} ${ora_user} fi echo "oracle" | passwd --stdin ${ora_user} ###create directory and grant priv count=0 while [ $count -lt 3 ] do read -p "Please input the ORACLE_SID(e.g:orcl):" S1 read -p "Please input the ORACLE_SID again(e.g:orcl):" S2 if [ "${S1}" == "${S2}" ];then export ORACLE_SID=${S1} break else echo "You input ORACLE_SID not same." count=$[${count}+1] fi done count=0 while [ $count -lt 3 ] do read -p "Please input the ORACLE_BASE(e.g:/data/app/oracle):" S1 read -p "Please input the ORACLE_BASE again(e.g:/data/app/oracle):" S2 if [ "${S1}" == "${S2}" ];then export ORACLE_BASE=${S1} break else echo "You input ORACLE_BASE not same." count=$[${count}+1] fi done count=0 while [ $count -lt 3 ] do read -p "Please input the ORACLE_HOME(e.g:/data/app/oracle/product/11.2.0/db_1):" S1 read -p "Please input the ORACLE_HOME again(e.g:/data/app/oracle/product/11.2.0/db_1):" S2 if [ "${S1}" == "${S2}" ];then export ORACLE_HOME=${S1} break else echo "You input ORACLE_HOME not same." count=$[${count}+1] fi done if [ ! -d ${ORACLE_HOME} ];then mkdir -p ${ORACLE_HOME} else continue fi if [ ! -d ${ORACLE_BASE}/oradata ];then mkdir -p ${ORACLE_BASE}/oradata else continue fi if [ ! -d ${ORACLE_BASE}/recovery ];then mkdir -p ${ORACLE_BASE}/recovery else continue fi ora_dir=echo ${ORACLE_HOME}|awk -F ‘/’ ‘{print $2}’ last_dir=echo ${ORACLE_HOME}|awk -F ‘/’ ‘{print $NF}’`

###install require packages
yum -y install elfutils-libelf-devel binutils compat-libcap1 compat-libstdc+±33 gcc gcc-c++ glibc glibc-devel libaio libaio-devel libgcc libstdc++ libstdc+±devel libXi libXtst make sysstat unixODBC unixODBC-devel zip unzip tree

###set the sysctl,limits and profile
a=grep 'fs.aio-max-nr' /etc/sysctl.conf
if [ ! -n “ a " ] ; t h e n c a t < < E O F > > / e t c / s y s c t l . c o n f f s . a i o − m a x − n r = 1048576 f s . f i l e − m a x = 6815744 k e r n e l . s h m a l l = 2097152 k e r n e l . s h m m a x = 4294967295 k e r n e l . s h m m n i = 4096 k e r n e l . s e m = 25032000100128 n e t . i p v 4. i p l o c a l p o r t r a n g e = 900065500 n e t . c o r e . r m e m d e f a u l t = 262144 n e t . c o r e . r m e m m a x = 4194304 n e t . c o r e . w m e m d e f a u l t = 262144 n e t . c o r e . w m e m m a x = 1048576 E O F e l s e c o n t i n u e f i a = ‘ g r e p ′ o r a c l e ′ / e t c / s e c u r i t y / l i m i t s . c o n f ‘ i f [ ! − n " {a}" ];then cat << EOF >> /etc/sysctl.conf fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = 2097152 kernel.shmmax = 4294967295 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.ipv4.ip_local_port_range = 9000 65500 net.core.rmem_default = 262144 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576 EOF else continue fi a=`grep 'oracle' /etc/security/limits.conf` if [ ! -n " a"];thencat<<EOF>>/etc/sysctl.conffs.aiomaxnr=1048576fs.filemax=6815744kernel.shmall=2097152kernel.shmmax=4294967295kernel.shmmni=4096kernel.sem=25032000100128net.ipv4.iplocalportrange=900065500net.core.rmemdefault=262144net.core.rmemmax=4194304net.core.wmemdefault=262144net.core.wmemmax=1048576EOFelsecontinuefia=greporacle/etc/security/limits.confif[!n"{a}” ];then
cat << EOF >> /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
EOF
else
continue
fi
a=grep 'ORACLE_SID' /home/${ora_user}/.bash_profile
if [ ! -n “ a " ] ; t h e n c a t < < E O F > > / h o m e / {a}" ];then cat << EOF >> /home/ a"];thencat<<EOF>>/home/{ora_user}/.bash_profile
export ORACLE_SID= O R A C L E S I D e x p o r t O R A C L E B A S E = {ORACLE_SID} export ORACLE_BASE= ORACLESIDexportORACLEBASE={ORACLE_BASE}
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export PATH=$PATH:$ORACLE_HOME/bin
EOF
else
continue
fi
a=grep 'oracle' /etc/profile
if [ ! -n “${a}” ];then
cat << EOF >> /etc/profile
if [ $USER = “oracle” ]; then
if [ S H E L L = " / b i n / k s h " ] ; t h e n u l i m i t − p 16384 u l i m i t − n 65536 e l s e u l i m i t − u 16384 − n 65536 f i f i E O F e l s e c o n t i n u e f i a = ‘ g r e p ′ p a m l i m i t s . s o ′ / e t c / p a m . d / l o g i n ‘ i f [ ! − n " SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi fi EOF else continue fi a=`grep 'pam_limits.so' /etc/pam.d/login` if [ ! -n " SHELL="/bin/ksh"];thenulimitp16384ulimitn65536elseulimitu16384n65536fifiEOFelsecontinuefia=greppamlimits.so/etc/pam.d/loginif[!n"{a}” ];then
cat << EOF >> /etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so
EOF
else
continue
fi
sysctl -p && source /home/${ora_user}/.bash_profile

###unzip the install package and set response file
count=0
while [ $count -lt 2 ]
do
read -p “Please input the zip file location(e.g:/oracle/db.zip):” zfile
if [ ! -f z f i l e ] ; t h e n e c h o " Y o u i n p u t l o c a t i o n n o t f o u n d z i p f i l e . " e l s e e x p o r t z f i l e = {zfile} ];then echo "You input location not found zip file." else export zfile= zfile];thenecho"Youinputlocationnotfoundzipfile."elseexportzfile={zfile}
unzip z f i l e − d / {zfile} -d / zfiled/{ora_dir} && chown -R o r a u s e r : {ora_user}: orauser:{ora_group[0]} /KaTeX parse error: Expected 'EOF', got '&' at position 11: {ora_dir} &̲& chmod -R 775 …{ora_dir}
fi
count= [ [ [{count}+1]
done

free_m=free -m | grep 'Mem:'|awk '{print $2}'
db_response_file=find / -type f -name db_install.rsp
data_dir= O R A C L E B A S E / d a t a r e c o v e r y d i r = {ORACLE_BASE}/data recovery_dir= ORACLEBASE/datarecoverydir={ORACLE_BASE}/recovery
cd find / -type f -name db_install.rsp | sed -n 's:/[^/]*$::p' && cd …/
install_dir=pwd
sed -i “s!oracle.install.option=!oracle.install.option=INSTALL_DB_SWONLY!g” d b r e s p o n s e f i l e s e d − i " s ! O R A C L E H O S T N A M E = ! O R A C L E H O S T N A M E = {db_response_file} sed -i "s!ORACLE_HOSTNAME=!ORACLE_HOSTNAME= dbresponsefilesedi"s!ORACLEHOSTNAME=!ORACLEHOSTNAME={hostname}!g" d b r e s p o n s e f i l e s e d − i " s ! U N I X G R O U P N A M E = ! U N I X G R O U P N A M E = {db_response_file} sed -i "s!UNIX_GROUP_NAME=!UNIX_GROUP_NAME= dbresponsefilesedi"s!UNIXGROUPNAME=!UNIXGROUPNAME={ora_group[0]}!g" d b r e s p o n s e f i l e s e d − i " s ! I N V E N T O R Y L O C A T I O N = ! I N V E N T O R Y L O C A T I O N = {db_response_file} sed -i "s!INVENTORY_LOCATION=!INVENTORY_LOCATION= dbresponsefilesedi"s!INVENTORYLOCATION=!INVENTORYLOCATION={ORACLE_BASE}/oraInventory!g" ${db_response_file}
sed -i “s!SELECTED_LANGUAGES=en!SELECTED_LANGUAGES=en,zh_CN!g” d b r e s p o n s e f i l e s e d − i " s ! O R A C L E H O M E = ! O R A C L E H O M E = {db_response_file} sed -i "s!ORACLE_HOME=!ORACLE_HOME= dbresponsefilesedi"s!ORACLEHOME=!ORACLEHOME={ORACLE_HOME}!g" d b r e s p o n s e f i l e s e d − i " s ! O R A C L E B A S E = ! O R A C L E B A S E = {db_response_file} sed -i "s!ORACLE_BASE=!ORACLE_BASE= dbresponsefilesedi"s!ORACLEBASE=!ORACLEBASE={ORACLE_BASE}!g" ${db_response_file}
sed -i “s!oracle.install.db.InstallEdition=!oracle.install.db.InstallEdition=EE!g” d b r e s p o n s e f i l e s e d − i " s ! o r a c l e . i n s t a l l . d b . D B A G R O U P = ! o r a c l e . i n s t a l l . d b . D B A G R O U P = {db_response_file} sed -i "s!oracle.install.db.DBA_GROUP=!oracle.install.db.DBA_GROUP= dbresponsefilesedi"s!oracle.install.db.DBAGROUP=!oracle.install.db.DBAGROUP={ora_group[1]}!g" d b r e s p o n s e f i l e s e d − i " s ! o r a c l e . i n s t a l l . d b . O P E R G R O U P = ! o r a c l e . i n s t a l l . d b . O P E R G R O U P = {db_response_file} sed -i "s!oracle.install.db.OPER_GROUP=!oracle.install.db.OPER_GROUP= dbresponsefilesedi"s!oracle.install.db.OPERGROUP=!oracle.install.db.OPERGROUP={ora_group[2]}!g" ${db_response_file}
sed -i “s!oracle.install.db.config.starterdb.type=!oracle.install.db.config.starterdb.type=GENERAL_PURPOSE!g” d b r e s p o n s e f i l e s e d − i " s ! o r a c l e . i n s t a l l . d b . c o n f i g . s t a r t e r d b . g l o b a l D B N a m e = ! o r a c l e . i n s t a l l . d b . c o n f i g . s t a r t e r d b . g l o b a l D B N a m e = {db_response_file} sed -i "s!oracle.install.db.config.starterdb.globalDBName=!oracle.install.db.config.starterdb.globalDBName= dbresponsefilesedi"s!oracle.install.db.config.starterdb.globalDBName=!oracle.install.db.config.starterdb.globalDBName={ORACLE_SID}!g" d b r e s p o n s e f i l e s e d − i " s ! o r a c l e . i n s t a l l . d b . c o n f i g . s t a r t e r d b . S I D = ! o r a c l e . i n s t a l l . d b . c o n f i g . s t a r t e r d b . S I D = {db_response_file} sed -i "s!oracle.install.db.config.starterdb.SID=!oracle.install.db.config.starterdb.SID= dbresponsefilesedi"s!oracle.install.db.config.starterdb.SID=!oracle.install.db.config.starterdb.SID={ORACLE_SID}!g" ${db_response_file}
sed -i “s!oracle.install.db.config.starterdb.characterSet=AL32UTF8!oracle.install.db.config.starterdb.characterSet=AL32UTF8!g” d b r e s p o n s e f i l e s e d − i " s ! o r a c l e . i n s t a l l . d b . c o n f i g . s t a r t e r d b . m e m o r y L i m i t = ! o r a c l e . i n s t a l l . d b . c o n f i g . s t a r t e r d b . m e m o r y L i m i t = {db_response_file} sed -i "s!oracle.install.db.config.starterdb.memoryLimit=!oracle.install.db.config.starterdb.memoryLimit= dbresponsefilesedi"s!oracle.install.db.config.starterdb.memoryLimit=!oracle.install.db.config.starterdb.memoryLimit=[free_m*8/10]!g" ${db_response_file}
sed -i “s!oracle.install.db.config.starterdb.password.ALL=!oracle.install.db.config.starterdb.password.ALL=wincenter!g” ${db_response_file}
sed -i “s!oracle.install.db.config.starterdb.storageType=!oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE!g” d b r e s p o n s e f i l e s e d − i " s ! o r a c l e . i n s t a l l . d b . c o n f i g . s t a r t e r d b . f i l e S y s t e m S t o r a g e . d a t a L o c a t i o n = ! o r a c l e . i n s t a l l . d b . c o n f i g . s t a r t e r d b . f i l e S y s t e m S t o r a g e . d a t a L o c a t i o n = {db_response_file} sed -i "s!oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=!oracle.install.db.config.starterdb.fileSystemStorage.dataLocation= dbresponsefilesedi"s!oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=!oracle.install.db.config.starterdb.fileSystemStorage.dataLocation={data_dir}!g" d b r e s p o n s e f i l e s e d − i " s ! o r a c l e . i n s t a l l . d b . c o n f i g . s t a r t e r d b . f i l e S y s t e m S t o r a g e . r e c o v e r y L o c a t i o n = ! o r a c l e . i n s t a l l . d b . c o n f i g . s t a r t e r d b . f i l e S y s t e m S t o r a g e . r e c o v e r y L o c a t i o n = {db_response_file} sed -i "s!oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=!oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation= dbresponsefilesedi"s!oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=!oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation={recovery_dir}!g" ${db_response_file}
sed -i “s!oracle.installer.autoupdates.option=!oracle.installer.autoupdates.option=SKIP_UPDATES!g” ${db_response_file}
sed -i “s!SECURITY_UPDATES=!SECURITY_UPDATES=true!g” d b r e s p o n s e f i l e s u − o r a c l e − c " {db_response_file} su - oracle -c " dbresponsefilesuoraclec"{install_dir}/runInstaller -silent -ignoreDiskWarning -ignoreSysPrereqs -ignorePrereq -responseFile ${db_response_file}"

==================================================================================================================================================================================================================
#Confiture oracle listener&dbca
ora_dbca.sh :
#!/bin/bash
export PATH=$PATH

PASSWORD=“oracle”
ORACLE_SID=su - oracle -c 'source ~/.bash_profile && echo $ORACLE_SID'
ORACLE_BASE=su - oracle -c 'source ~/.bash_profile && echo $ORACLE_BASE'
ORACLE_HOME=su - oracle -c 'source ~/.bash_profile && echo $ORACLE_HOME'

temp=ls ${ORACLE_BASE}|grep 'data'
if [ ! -n ${temp} ];then
mkdir O R A C L E B A S E / d a t a e x p o r t D A T A F I L E = {ORACLE_BASE}/data export DATAFILE= ORACLEBASE/dataexportDATAFILE={ORACLE_BASE}/oradata
else
export DATAFILE=${ORACLE_BASE}/oradata
fi
temp=ls ${ORACLE_BASE}|grep 'area'
if [ ! -n ${temp} ];then
mkdir O R A C L E B A S E / f l a s h r e c o v e r y a r e a e x p o r t R E C O V E R Y = {ORACLE_BASE}/flash_recovery_area export RECOVERY= ORACLEBASE/flashrecoveryareaexportRECOVERY={ORACLE_BASE}/flash_recovery_area
else
export RECOVERY=${ORACLE_BASE}/flash_recovery_area
fi
NETCA=find / -type f -name netca.rsp
sed -i “s!INSTALL_TYPE=”“typical”“!INSTALL_TYPE=”“custom”“!g” ${NETCA}
MEM=free -m|grep 'Mem:'|awk '{print $2}'
TOTAL=$[MEM*8/10]

###set listener&tnsnames
su - oracle << EOF
source ~/.bash_profile
${ORACLE_HOME}/bin/netca -silent -responsefile ${NETCA}
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname ${ORACLE_SID} -sid ${ORACLE_SID} -sysPassword ${PASSWORD} -systemPassword ${PASSWORD} -responseFile NO_VALUE -datafileDestination ${DATAFILE} -redoLogFileSize 1000 -recoveryAreaDestination ${RECOVERY} -storageType FS -characterSet ZHS16GBK -nationalCharacterSet AL16UTF16 -sampleSchema false -memoryPercentage 80 -totalMemory $TOTAL -databaseType OLTP -emConfiguration NONE
EOF

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

韶博雅

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值