11g静默安装

文章详细描述了在Linux服务器上进行路径设置、防火墙和SELinux配置,设置主机名和IP,创建用户组和用户,管理Oracle数据库环境(包括安装所需的包、系统配置、响应文件操作、监听器和tnsnames配置),以及使用dbca工具创建数据库的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. path部署

#!/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}'`
a=`hostname`
echo "${ip} ${a}" >> /etc/hosts



###create group&user
ora_user=oracle
ora_group=('oinstall' 'dba' 'oper')
for i in ${ora_group[@]}
do
a=`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}" ];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}" ];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}" ];then
cat << EOF >> /home/${ora_user}/.bash_profile
export ORACLE_SID=${ORACLE_SID}
export ORACLE_BASE=${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 [ $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 "${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 ${zfile} ];then
echo "You input location not found zip file."
else
export zfile=${zfile}
unzip ${zfile} -d /${ora_dir} && chown -R ${ora_user}:${ora_group[0]} /${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=${ORACLE_BASE}/data
recovery_dir=${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" ${db_response_file}
sed -i "s!ORACLE_HOSTNAME=!ORACLE_HOSTNAME=${hostname}!g" ${db_response_file}
sed -i "s!UNIX_GROUP_NAME=!UNIX_GROUP_NAME=${ora_group[0]}!g" ${db_response_file}
sed -i "s!INVENTORY_LOCATION=!INVENTORY_LOCATION=${ORACLE_BASE}/oraInventory!g" ${db_response_file}
sed -i "s!SELECTED_LANGUAGES=en!SELECTED_LANGUAGES=en,zh_CN!g" ${db_response_file}
sed -i "s!ORACLE_HOME=!ORACLE_HOME=${ORACLE_HOME}!g" ${db_response_file}
sed -i "s!ORACLE_BASE=!ORACLE_BASE=${ORACLE_BASE}!g" ${db_response_file}
sed -i "s!oracle.install.db.InstallEdition=!oracle.install.db.InstallEdition=EE!g" ${db_response_file}
sed -i "s!oracle.install.db.DBA_GROUP=!oracle.install.db.DBA_GROUP=${ora_group[1]}!g" ${db_response_file}
sed -i "s!oracle.install.db.OPER_GROUP=!oracle.install.db.OPER_GROUP=${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" ${db_response_file}
sed -i "s!oracle.install.db.config.starterdb.globalDBName=!oracle.install.db.config.starterdb.globalDBName=${ORACLE_SID}!g" ${db_response_file}
sed -i "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" ${db_response_file}
sed -i "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" ${db_response_file}
sed -i "s!oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=!oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=${data_dir}!g" ${db_response_file}
sed -i "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" ${db_response_file}
su - oracle -c "${install_dir}/runInstaller -silent -ignoreDiskWarning -ignoreSysPrereqs -ignorePrereq -responseFile ${db_response_file}"

#Confiture oracle listener&dbca

2. dbca建库

#!/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 ${ORACLE_BASE}/data
export DATAFILE=${ORACLE_BASE}/oradata
else
export DATAFILE=${ORACLE_BASE}/oradata
fi
temp=`ls ${ORACLE_BASE}|grep 'area'`
if [ ! -n ${temp} ];then
mkdir ${ORACLE_BASE}/flash_recovery_area
export RECOVERY=${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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

韶博雅

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

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

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

打赏作者

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

抵扣说明:

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

余额充值