废话不多说,直接上脚本:
--增加18c,19c RU补丁安装选项。
--增加linux7安装11g,自动替换 $(MK_EMAGENT_NMECTL) -lnnz11。
--增加卸载db选项。
--增加建库后crontab自动配置删归档和增量备份脚本。
--增加oracle数据库参数优化配置。
--增加swap空间判断,自动挂载缺少的swap空间。
touch AllOracleSilent.sh(:set fileformat=unix)
-
#!/bin/bash
-
echo
"####################################################################################"
-
echo
"##Author : LuciferLiu"
-
echo
"##Blog : https://blog.csdn.net/m0_50546016"
-
echo
"##Version : 2.0"
-
echo
"##Function: Oracle 11g/12c/18c/19c install on Linux 6/7"
-
echo
"####################################################################################"
-
echo
"#执行脚本前:"
-
echo
"# 1. 把脚本放入软件目录,例如:/soft"
-
echo
"# 2. 挂载ISO"
-
echo
"# 3. 把需要本地安装的rpm和software上传到软件目录"
-
echo
"# 4. 设置好主机IP"
-
echo
"####################################################################################"
-
####################################################################################
-
# Parameters For Install
-
####################################################################################
-
PUBLICIP=
-
HOSTNAME=orcl
-
ORACLE_SID=orcl
-
ISCDB=FALSE
-
PDBNAME=pdb01
-
SOFTWAREDIR=$(
pwd)
-
DAYTIME=$(date +%Y%m%d)
-
DB_VERSION=
-
RELS=$(more /etc/system-release)
-
OS_VER_PRI=$(
echo
${RELS#*release} | awk
'{print $1}' | cut -f 1 -d
'.')
-
memTotal=$(grep MemTotal /proc/meminfo | awk
'{print $2}')
-
swapTotal=$(grep -i
'swaptotal' /proc/meminfo | awk
'{print $2}')
-
ORAPASSWD=oracle
-
ENV_BASE_DIR=/u01/app
-
ORADATADIR=/oradata
-
ARCHIVEDIR=/archivelog
-
BACKUPDIR=/backup
-
SCRIPTSDIR=/home/oracle/scripts
-
CHARACTERSET=AL32UTF8
-
ONLYCONFIGOS=N
-
ONLYINSTALLSOFTWARE=N
-
REMOVEINSTANCE=
-
REMOVEDBSOFTWARE=
-
RU=
-
####################################################################################
-
####################################################################################
-
##The following is a custom function:
-
####################################################################################
-
#Add colors to fonts through variables
-
#Define a c1() function here, if you want to change the font color later, you can call it directly
-
c1() {
-
RED_COLOR=
'\E[1;31m'
-
GREEN_COLOR=
'\E[1;32m'
-
YELLOW_COLOR=
'\E[1;33m'
-
BLUE_COLOR=
'\E[1;34m'
-
PINK_COLOR=
'\E[1;35m'
-
WHITE_BLUE=
'\E[47;34m'
-
DOWN_BLUE=
'\E[4;36m'
-
FLASH_RED=
'\E[5;31m'
-
RES=
'\E[0m'
-
-
#Here it is judged whether the incoming parameters are not equal to 2, if not equal to 2, prompt and exit
-
if [
$# -ne 2 ];
then
-
echo
"Usage $0 content {red|yellow|blue|green|pink|wb|db|fr}"
-
exit
-
fi
-
-
case
"$2"
in
-
red | RED)
-
echo -e
"${RED_COLOR}$1${RES}"
-
;;
-
yellow | YELLOW)
-
echo -e
"${YELLOW_COLOR}$1${RES}"
-
;;
-
green | GREEN)
-
echo -e
"${GREEN_COLOR}$1${RES}"
-
;;
-
blue | BLUE)
-
echo -e
"${BLUE_COLOR}$1${RES}"
-
;;
-
pink | PINK)
-
echo -e
"${PINK_COLOR}$1${RES}"
-
;;
-
wb | WB)
-
echo -e
"${WHITE_BLUE}$1${RES}"
-
;;
-
db | DB)
-
echo -e
"${DOWN_BLUE}$1${RES}"
-
;;
-
fr | FR)
-
echo -e
"${FLASH_RED}$1${RES}"
-
;;
-
*)
-
echo -e
"Please enter the specified color code:{red|yellow|blue|green|pink|wb|db|fr}"
-
;;
-
esac
-
}
-
-
##Example
-
##c1 "Program installation error!" red
-
##c1 "The program is successfully installed!" green
-
##c1 "Output related annotation information" blue
-
-
help() {
-
c1
"Desc: For ALL Oracle Silent Install" green
-
echo
-
c1
"Usage: AllOracleSilent [OPTIONS] OBJECT { COMMAND | help }" green
-
echo
-
c1
"Excute: " green
-
c1
"1.chmod 777 AllOracleSilent.sh" green
-
echo
-
c1
"2.How to Excute the script:" green
-
c1
"./AllOracleSilent.sh -i 192.168.56.120 -d 11g" blue
-
c1
"or" green
-
c1
"./AllOracleSilent.sh -i 192.168.56.120 -n orcl -o orcl -c TRUE -pb pdb01 -d 12c -p oracle -b /u01/app -s AL32UTF8 -m N -w N" blue
-
echo
-
c1
"3.How to Remove Instance:" green
-
c1
"./AllOracleSilent.sh -ri orcl" blue
-
echo
-
c1
"4.How to Remove Database Software:" green
-
c1
"./AllOracleSilent.sh -rd /u01/app/oracle/product/19.0.0/db" blue
-
echo
-
c1
"OPTIONS: " green
-
c1
"-i, --PUBLICIP PUBLICIP NETWORK ADDRESS" green
-
c1
"-n, --HOSTNAME HOSTNAME(orcl)" green
-
c1
"-o, --ORACLE_SID ORACLE_SID(orcl)" green
-
c1
"-c, --ISCDB IS CDB OR NOT(TRUE|FALSE)" green
-
c1
"-pb, --PDBNAME PDBNAME(pdb01)" green
-
c1
"-d, --DB_VERSION ORALCE DATABASE VERSION(11g|12c|18c|19c)" green
-
c1
"-p, --ORAPASSWD ORACLE USER PASSWORD(oracle)" green
-
c1
"-b, --ENV_BASE_DIR ORACLE BASE DIR(/u01/app)" green
-
c1
"-s, --CHARACTERSET ORACLE CHARACTERSET(ZHS16GBK|AL32UTF8)" green
-
c1
"-m, --ONLYCONFIGOS ONLY CONFIG SYSTEM PARAMETER(Y|N)" green
-
c1
"-w, --ONLYINSTALLSOFTWARE ONLY INSTALL ORACLE SOFTWARE(Y|N)" green
-
c1
"-ri, --REMOVEINSTANCE REMOVE ORACLE INSTANCE(orcl)" green
-
c1
"-rd, --REMOVEDBSOFTWARE REMOVE ORACLE SOFTWARE(/u01/app/oracle/product/11.2.0/db)" green
-
c1
"-ru, --RELEASE UPDATE DATABASE RELEASE UPDATE(32072711)" green
-
exit 0
-
}
-
-
echo
-
while [ -n
"$1" ];
do
#Here by judging whether $1 exists
-
case
$1
in
-
-i | --PUBLICIP)
-
PUBLICIP=
$2
#$2 Is the parameter we want to output
-
shift 2
-
;;
# Move the parameter back by 2 and enter the judgment of the next parameter
-
-n | --HOSTNAME)
-
HOSTNAME=
$2
-
shift 2
-
;;
-
-o | --ORACLE_SID)
-
ORACLE_SID=
$2
-
shift 2
-
;;
-
-c | --ISCDB)
-
ISCDB=
$2
-
shift 2
-
;;
-
-pb | --PDBNAME)
-
PDBNAME=
$2
-
shift 2
-
;;
-
-d | --DB_VERSION)
-
DB_VERSION=
$2
-
shift 2
-
;;
-
-p | --ORAPASSWD)
-
ORAPASSWD=
$2
-
shift 2
-
;;
-
-b | --ENV_BASE_DIR)
-
ENV_BASE_DIR=
$2
-
shift 2
-
;;
-
-s | --CHARACTERSET)
-
CHARACTERSET=
$2
-
shift 2
-
;;
-
-m | --ONLYCONFIGOS)
-
ONLYCONFIGOS=
$2
-
shift 2
-
;;
-
-w | --ONLYINSTALLSOFTWARE)
-
ONLYINSTALLSOFTWARE=
$2
-
shift 2
-
;;
-
-ri | --REMOVEINSTANCE)
-
REMOVEINSTANCE=
$2
-
shift 2
-
;;
-
-rd | --REMOVEDBSOFTWARE)
-
REMOVEDBSOFTWARE=
$2
-
shift 2
-
;;
-
-ru | --RU)
-
RU=
$2
-
shift 2
-
;;
-
-h | --
help)
help ;;
# function help is called
-
--)
-
shift
-
break
-
;;
# end of options
-
-*)
-
echo
"Error: Option '$1' is unknown, try './AllOracleSilent.sh --help'."
-
exit 1
-
;;
-
*)
break ;;
-
esac
-
done
-
-
##check Swap
-
COUNT=
-
if [
$memTotal -ge 1048576 ] && [
$memTotal -le 2097152 ];
then
-
swapNeed=$(expr
$memTotal \* 1.5)
-
if [
$swapNeed -gt
$swapTotal ];
then
-
COUNT=$(expr
$swapNeed -
$swapTotal)
-
fi
-
elif [
$memTotal -gt 2097152 ] && [
$memTotal -le 16777216 ];
then
-
swapNeed=
$memTotal
-
if [
$swapNeed -gt
$swapTotal ];
then
-
COUNT=$(expr
$swapNeed -
$swapTotal)
-
fi
-
elif [
$memTotal -gt 16777216 ];
then
-
swapNeed=16777216
-
if [
$swapNeed -gt
$swapTotal ];
then
-
COUNT=$(expr
$swapNeed -
$swapTotal)
-
fi
-
else
-
echo
-
c1
"At least 1 GB RAM for Oracle Database installations. 2 GB RAM recommended." red
-
exit 99
-
fi
-
-
##set swap space
-
if [ -n
${COUNT} ] && [ ! -f /swapfile ] && [
${COUNT} > 40 ];
then
-
dd
if=/dev/zero of=/swapfile bs=1K count=
${COUNT}
-
mkswap /swapfile
-
swapon /swapfile
-
echo
"/swapfile swap swap defaults 0 0" >>/etc/fstab
-
fi
-
-
##Judge whether user is root, if it is not, exit
-
if [
$USER !=
"root" ];
then
-
echo
-
c1
"The user must be root,and now you user is $USER,please su to root." red
-
exit 1
-
fi
-
-
##Judge whether ip or dbversion is empty, if it is empty, exit
-
if [ -z
"${REMOVEINSTANCE}" ] && [ -z
"${REMOVEDBSOFTWARE}" ];
then
-
if [ -z
"${PUBLICIP}" ] || [ -z
"${DB_VERSION}" ];
then
-
echo
-
c1
"PUBLICIP and DB_VERSION is a required parameter, try'./AllOracleSilent.sh --help' to execute the script" red
-
echo
-
exit
-
fi
-
####################################################################################
-
# ORACLE SID
-
####################################################################################
-
if [ -f /home/oracle/.bash_profile ] && [ $(egrep
"#OraConfBegin" /home/oracle/.bash_profile | wc -l) -ne 0 ];
then
-
oracleSid=$(grep
"ORACLE_SID=" /home/oracle/.bash_profile | awk
'{print $2}')
-
oracleSid=$(
echo
${oracleSid#*=})
-
oracleHostname=$(grep
"ORACLE_HOSTNAME=" /home/oracle/.bash_profile | awk
'{print $2}')
-
oracleHostname=$(
echo
${oracleHostname#*=})
-
oracleBase=$(grep
"ORACLE_BASE=" /home/oracle/.bash_profile | awk
'{print $2}')
-
oracleBase=$(
echo
${oracleBase#*=})
-
oracleHome=$(grep
"ORACLE_HOME=" /home/oracle/.bash_profile | awk
'{print $2}')
-
oracleHome=$(
echo
${oracleHome#*=})
-
fi
-
-
if [ -f /etc/oratab ] && [ $(egrep
"${ORACLE_SID}" /etc/oratab | wc -l) -ne 0 ];
then
-
if [
"${oracleSid}" =
"${ORACLE_SID}" ];
then
-
echo
-
c1
"ORACLE_SID:${oracleSid}" blue
-
echo
-
c1
"Specified SID Name (${oracleSid}) already exists, Specify a different SID Name that does not already exist OR :" red
-
echo
-
c1
"./AllOracleSilent -ri ${oracleSid} to remove it" blue
-
echo
-
exit 99
-
fi
-
fi
-
-
fi
-
-
####################################################################################
-
## Remove Instance && database
-
####################################################################################
-
##Judge whether OracleSID is empty, if it is empty ,exit
-
REMOVEINSTANCE() {
-
su - oracle -c
"dbca -silent -deleteDatabase -sourceDB ${REMOVEINSTANCE}"
-
if [ $? -ne 0 ];
then
-
c1
"You need to install Oracle Database Software First." red
-
oracleHOme=$(grep
"ORACLE_HOME=" /home/oracle/.bash_profile | awk
'{print $2}')
-
oracleHOme=$(
echo
${oracleHOme#*=})
-
rm -rf
${oracleHOme}
-
exit 99
-
fi
-
exit 99
-
}
-
-
##Judge whether OracleHome is empty, if it is empty ,exit
-
REMOVEDBSOFTWARE() {
-
if [ ! -d
"${REMOVEDBSOFTWARE}" ];
then
-
c1
"What You Input OracleHome (${REMOVEDBSOFTWARE}) is not exist, exit" red
-
exit 99
-
else
-
su - oracle -c
"${REMOVEDBSOFTWARE}/deinstall/deinstall -local -o ${REMOVEDBSOFTWARE}"
-
if [ $? -ne 0 ];
then
-
c1
"You need to install Oracle Database Software First." red
-
rm -rf
${REMOVEDBSOFTWARE}
-
fi
-
rm -rf /etc/oraInst.loc
-
rm -rf /opt/ORCLfmap
-
rm -rf /etc/oratab
-
exit 99
-
fi
-
}
-
-
####################################################################################
-
## Log Write
-
####################################################################################
-
rm -rf
${SOFTWAREDIR}/oracleAllSilent_*.
log
-
-
oracl19clog=
${SOFTWAREDIR}/oracleAllSilent_$(date +
"20%y%m%d%H%M%S").
log
-
-
logwrite() {
-
echo $(c1
"####################################################################################" green) >>
${oracl19clog}
-
echo $(
echo) >>
${oracl19clog}
-
echo $(c1
"# $1" blue) >>
${oracl19clog}
-
echo $(
echo) >>
${oracl19clog}
-
echo $(c1
"####################################################################################" green) >>
${oracl19clog}
-
echo $(
echo) >>
${oracl19clog}
-
echo
"$1 :" >>
${oracl19clog}
-
echo $(
echo) >>
${oracl19clog}
-
echo
"$2" >
${SOFTWAREDIR}/ex.sh
-
chmod +x
${SOFTWAREDIR}/ex.sh
-
echo
"$(${SOFTWAREDIR}/ex.sh)" >>
${oracl19clog}
-
rm -rf
${SOFTWAREDIR}/ex.sh
-
echo $(
echo) >>
${oracl19clog}
-
}
-
-
##Example
-
##logwrite "HostName" "hostname"
-
##logwrite "Firewalld" "systemctl status firewalld"
-
-
echo $(c1
"####################################################################################" green) >>
${oracl19clog}
-
echo $(
echo) >>
${oracl19clog}
-
echo $(c1
"# Installation Logging" wb) >>
${oracl19clog}
-
echo $(
echo) >>
${oracl19clog}
-
echo $(c1
"####################################################################################" green) >>
${oracl19clog}
-
echo $(
echo) >>
${oracl19clog}
-
echo $(
echo) >>
${oracl19clog}
-
-
####################################################################################
-
# OS Version
-
####################################################################################
-
if [
$OS_VER_PRI -eq 7 ];
then
-
OS_VERSION=linux7
-
elif [
$OS_VER_PRI -eq 6 ];
then
-
OS_VERSION=linux6
-
else
-
c1
"sorry, this operating system is not supported!!!" red
-
exit
-
fi
-
-
logwrite
"OS Version"
"more /etc/system-release"
-
-
####################################################################################
-
# Choice DB Version
-
####################################################################################
-
if [[ -z
"${DB_VERSION}" ]] || [[
"${DB_VERSION}" =
"19c" ]] || [[
"${DB_VERSION}" =
"19C" ]] || [[
"${DB_VERSION}" =
"19" ]];
then
-
DB_VERSION=19.3.0.0
-
elif [[
"${DB_VERSION}" =
"18c" ]] || [[
"${DB_VERSION}" =
"18C" ]] || [[
"${DB_VERSION}" =
"18" ]];
then
-
DB_VERSION=18.0.0.0
-
elif [[
"${DB_VERSION}" =
"12c" ]] || [[
"${DB_VERSION}" =
"12C" ]] || [[
"${DB_VERSION}" =
"12" ]];
then
-
DB_VERSION=12.2.0.1
-
elif [[
"${DB_VERSION}" =
"11g" ]] || [[
"${DB_VERSION}" =
"11G" ]] || [[
"${DB_VERSION}" =
"11" ]];
then
-
DB_VERSION=11.2.0.4
-
else
-
c1
"DB version is a required parameter!!! Try'./AllOracleSilent.sh --help' to execute the script" red
-
exit
-
fi
-
-
logwrite
"DB Version"
"echo ${DB_VERSION}"
-
-
####################################################################################
-
# Choice DB HOME
-
####################################################################################
-
ENV_ORACLE_BASE=
$ENV_BASE_DIR/oracle
-
ENV_ORACLE_INVEN=
$ENV_BASE_DIR/oraInventory
-
if [
"${DB_VERSION}" =
"11.2.0.4" ];
then
-
ENV_ORACLE_HOME=
$ENV_ORACLE_BASE/product/11.2.0/db
-
elif [
"${DB_VERSION}" =
"12.2.0.1" ];
then
-
ENV_ORACLE_HOME=
$ENV_ORACLE_BASE/product/12.2.0/db
-
elif [
"${DB_VERSION}" =
"18.0.0.0" ];
then
-
ENV_ORACLE_HOME=
$ENV_ORACLE_BASE/product/18.0.0/db
-
elif [
"${DB_VERSION}" =
"19.3.0.0" ];
then
-
ENV_ORACLE_HOME=
$ENV_ORACLE_BASE/product/19.3.0/db
-
else
-
c1
"Error database version! please check again!" red
-
exit
-
fi
-
-
if [ -z
"${REMOVEINSTANCE}" ] && [ -z
"${REMOVEDBSOFTWARE}" ];
then
-
if [[ -d
${ENV_ORACLE_HOME} ]] && [[
"$(ls -A ${ENV_ORACLE_HOME})" !=
"" ]];
then
-
c1
"ORACLE_HOME is not empty.Try ./AllOracleSilent -rd ${ENV_ORACLE_HOME} to remove it" red
-
exit 99
-
fi
-
fi
-
logwrite
"DB HOME"
"echo ${ENV_ORACLE_HOME}"
-
-
####################################################################################
-
# Configure hostname
-
####################################################################################
-
SetHostName() {
-
if [
"${OS_VERSION}" =
"linux6" ];
then
-
hostname=$(egrep
"HOSTNAME=" /etc/sysconfig/network)
-
if [[ $(egrep
"${HOSTNAME}" /etc/sysconfig/network) !=
"${HOSTNAME}" ]];
then
-
/bin/hostname
$HOSTNAME
-
sed -i
"s/${hostname}/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/network
-
fi
-
elif [
"${OS_VERSION}" =
"linux7" ];
then
-
if [[ $(egrep
"${HOSTNAME}" /etc/hostname) !=
"${HOSTNAME}" ]];
then
-
/usr/bin/hostnamectl
set-hostname
$HOSTNAME
-
fi
-
fi
-
}
-
-
logwrite
"HOSTNAME"
"echo ${HOSTNAME}"
-
-
####################################################################################
-
# Configure /etc/hosts
-
####################################################################################
-
SetHosts() {
-
if [[ $(egrep
"${HOSTNAME}" /etc/hosts) !=
"${HOSTNAME}" ]] || [[ $(egrep
"${PUBLICIP}" /etc/hosts) !=
"${PUBLICIP}" ]];
then
-
[ ! -f /etc/hosts.
${DAYTIME} ] && cp /etc/hosts /etc/hosts.
${DAYTIME}
-
cat <<EOF >/etc/hosts
-
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
-
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
-
-
#Public IP
-
$PUBLICIP
$HOSTNAME
-
EOF
-
fi
-
}
-
-
logwrite
"/etc/hosts"
"su -c \"cat /etc/hosts\""
-
-
####################################################################################
-
#install rpm that oracle is necessary for installing
-
####################################################################################
-
InstallRPM() {
-
####################################################################################
-
# Judge ISO file mount status
-
####################################################################################
-
mountPatch=$(mount | egrep
"iso|ISO" | awk
'{print $3}')
-
if [ !
"${mountPatch}" ];
then
-
echo
-
c1
"The ISO file is not mounted on system." red
-
exit 99
-
else
-
if [ $(egrep
"#OraConfBegin" /etc/yum.repos.d/local.repo | wc -l) -eq 0 ];
then
-
[ ! -f /etc/yum.repos.d/local.repo.
${DAYTIME} ] && cp /etc/yum.repos.d/local.repo /etc/yum.repos.d/local.repo.
${DAYTIME}
-
echo
"#OraConfBegin" >>/etc/yum.repos.d/local.repo
-
echo
"[server]" >>/etc/yum.repos.d/local.repo
-
echo
"name=server" >>/etc/yum.repos.d/local.repo
-
echo
"baseurl=file://"
${mountPatch} >>/etc/yum.repos.d/local.repo
-
echo
"enabled=1" >>/etc/yum.repos.d/local.repo
-
echo
"gpgcheck=1" >>/etc/yum.repos.d/local.repo
-
rpm --import
${mountPatch}/RPM-GPG-KEY-redhat-release
-
fi
-
if [
"${OS_VERSION}" =
"linux6" ];
then
-
if [ $(rpm -q bc binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ elfutils-libelf elfutils-libelf-devel glibc glibc-devel libaio libaio-devel libgcc libstdc++ libstdc++-devel libxcb libX11 libXau libXi libXrender make net-tools smartmontools sysstat e2fsprogs e2fsprogs-libs expect unzip openssh-clients readline psmisc --qf
'%{name}.%{arch}\n' | grep
"not installed" | wc -l) -gt 0 ];
then
-
yum install -y bc binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ elfutils-libelf elfutils-libelf-devel glibc glibc-devel libaio libaio-devel libgcc libstdc++ libstdc++-devel libxcb libX11 libXau libXi libXrender make net-tools smartmontools sysstat e2fsprogs e2fsprogs-libs expect unzip openssh-clients readline* psmisc
-
fi
-
elif [
"${OS_VERSION}" =
"linux7" ];
then
-
if [ $(rpm -q bc binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ elfutils-libelf elfutils-libelf-devel glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libxcb libX11 libXau libXi libXtst libXrender libXrender-devel make net-tools nfs-utils smartmontools sysstat e2fsprogs e2fsprogs-libs fontconfig-devel expect unzip openssh-clients readline psmisc --qf
'%{name}.%{arch}\n' | grep
"not installed" | wc -l) -gt 0 ];
then
-
yum install -y bc binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ elfutils-libelf elfutils-libelf-devel glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libxcb libX11 libXau libXi libXtst libXrender libXrender-devel make net-tools nfs-utils smartmontools sysstat e2fsprogs e2fsprogs-libs fontconfig-devel expect unzip openssh-clients readline* psmisc
-
fi
-
fi
-
-
fi
-
-
if [
"${OS_VERSION}" =
"linux6" ];
then
-
logwrite
"RPM Check"
"rpm -q bc binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ elfutils-libelf elfutils-libelf-devel glibc glibc-devel libaio libaio-devel libgcc libstdc++ libstdc++-devel libxcb libX11 libXau libXi libXrender make net-tools smartmontools sysstat e2fsprogs e2fsprogs-libs expect unzip openssh-clients readline"
-
elif [
"${OS_VERSION}" =
"linux7" ];
then
-
logwrite
"RPM Check"
"rpm -q bc binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ elfutils-libelf elfutils-libelf-devel glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libxcb libX11 libXau libXi libXtst libXrender libXrender-devel make net-tools nfs-utils smartmontools sysstat e2fsprogs e2fsprogs-libs fontconfig-devel expect unzip openssh-clients readline"
-
fi
-
}
-
-
####################################################################################
-
# create user and groups
-
####################################################################################
-
CreateUsersAndDirs() {
-
####################################################################################
-
# create user and groups
-
####################################################################################
-
if [ $(egrep
"oinstall" /etc/group | wc -l) -eq 0 ];
then
-
/usr/sbin/groupadd -g 54321 oinstall
-
fi
-
if [ $(egrep
"dba" /etc/group | wc -l) -eq 0 ];
then
-
/usr/sbin/groupadd -g 54322 dba
-
fi
-
if [ $(egrep
"oper" /etc/group | wc -l) -eq 0 ];
then
-
/usr/sbin/groupadd -g 54323 oper
-
fi
-
if [[
"${DB_VERSION}" =
"19.3.0.0" ]] || [[
"${DB_VERSION}" =
"18.0.0.0" ]] || [[
"${DB_VERSION}" =
"12.2.0.1" ]];
then
-
if [ $(egrep
"backupdba" /etc/group | wc -l) -eq 0 ];
then
-
/usr/sbin/groupadd -g 54324 backupdba
-
fi
-
if [ $(egrep
"dgdba" /etc/group | wc -l) -eq 0 ];
then
-
/usr/sbin/groupadd -g 54325 dgdba
-
fi
-
if [ $(egrep
"kmdba" /etc/group | wc -l) -eq 0 ];
then
-
/usr/sbin/groupadd -g 54326 kmdba
-
fi
-
if [ $(egrep
"racdba" /etc/group | wc -l) -eq 0 ];
then
-
/usr/sbin/groupadd -g 54330 racdba
-
fi
-
fi
-
-
##Create user
-
if [ $(egrep
"oracle" /etc/passwd | wc -l) -eq 0 ];
then
-
if [[
"${DB_VERSION}" =
"19.3.0.0" ]] || [[
"${DB_VERSION}" =
"18.0.0.0" ]] || [[
"${DB_VERSION}" =
"12.2.0.1" ]];
then
-
/usr/sbin/useradd -u 54321 -g oinstall -G dba,backupdba,dgdba,kmdba,racdba,oper oracle
-
elif [
"${DB_VERSION}" =
"11.2.0.4" ];
then
-
/usr/sbin/useradd -u 54321 -g oinstall -G dba,oper oracle
-
fi
-
if [ $? -ne 0 ];
then
-
echo
"Command failed to adding user --oracle."
-
exit 93
-
fi
-
else
-
if [[
"${DB_VERSION}" =
"19.3.0.0" ]] || [[
"${DB_VERSION}" =
"18.0.0.0" ]] || [[
"${DB_VERSION}" =
"12.2.0.1" ]];
then
-
/usr/sbin/usermod -g oinstall -G dba,backupdba,dgdba,kmdba,racdba,oper oracle
-
elif [
"${DB_VERSION}" =
"11.2.0.4" ];
then
-
/usr/sbin/usermod -g oinstall -G dba,oper oracle
-
fi
-
fi
-
-
##Set user oracle's password
-
echo
"${ORAPASSWD}" | passwd --stdin oracle
-
if [ $? -ne 0 ];
then
-
c1
"User oracle is not existing." red
-
exit 92
-
fi
-
-
####################################################################################
-
#make directory
-
####################################################################################
-
[ ! -d
"${ENV_ORACLE_HOME}" ] && mkdir -p
${ENV_ORACLE_HOME}
-
[ ! -d
"${ENV_ORACLE_INVEN}" ] && mkdir -p
${ENV_ORACLE_INVEN}
-
[ ! -d
${ORADATADIR} ] && mkdir -p
${ORADATADIR}
-
[ ! -d
${ARCHIVEDIR} ] && mkdir -p
${ARCHIVEDIR}
-
[ ! -d
${BACKUPDIR} ] && mkdir -p
${BACKUPDIR}
-
[ ! -d
${SCRIPTSDIR} ] && mkdir -p
${SCRIPTSDIR}
-
chown -R oracle:oinstall
${SCRIPTSDIR}
-
chown -R oracle:oinstall
${ORADATADIR}
-
chown -R oracle:oinstall
${ARCHIVEDIR}
-
chown -R oracle:oinstall
${BACKUPDIR}
-
chown -R oracle:oinstall
${ENV_BASE_DIR}
-
chmod -R 775
${ENV_BASE_DIR}
-
-
if [
"${DB_VERSION}" =
"12.2.0.1" ];
then
-
touch /etc/oraInst.loc
-
echo
"inventory_loc=${ENV_ORACLE_INVEN}" >>/etc/oraInst.loc
-
echo
"inst_group=oinstall" >>/etc/oraInst.loc
-
fi
-
-
logwrite
"Create user and groups"
"id oracle"
-
}
-
-
####################################################################################
-
#Time dependent Settings
-
####################################################################################
-
TimeDepSet() {
-
if [
"${OS_VERSION}" =
"linux6" ];
then
-
if [ $(egrep
"Asia/Shanghai" /etc/sysconfig/clock | wc -l) -eq 0 ];
then
-
[ ! -f /etc/sysconfig/clock.
${DAYTIME} ] && cp /etc/sysconfig/clock /etc/sysconfig/clock.
${DAYTIME}
-
cat <<EOF >/etc/sysconfig/clock
-
ZONE=
"Asia/Shanghai"
-
EOF
-
fi
-
if [ $(chkconfig --list | grep ntpd | grep on | wc -l) -gt 0 ];
then
-
service ntpd stop
-
chkconfig ntpd off
-
fi
-
logwrite
"ntpd"
"service ntpd status"
-
[ -f /etc/ntp.conf ] && mv /etc/ntp.conf /etc/ntp.conf.orig
-
elif [
"${OS_VERSION}" =
"linux7" ];
then
-
timedatectl
set-timezone Asia/Shanghai
-
if [ $(systemctl status chronyd | grep running | wc -l) -gt 0 ];
then
-
systemctl stop chronyd.service
-
systemctl
disable chronyd.service
-
fi
-
logwrite
"chronyd"
"systemctl status chronyd"
-
fi
-
logwrite
"Time dependent"
"date"
-
-
}
-
-
####################################################################################
-
#Stop avahi deamon
-
####################################################################################
-
Disableavahi() {
-
if [
"${OS_VERSION}" =
"linux6" ];
then
-
if [ $(chkconfig --list | grep avahi-daemon | grep
'3:on' | wc -l) -gt 0 ];
then
-
service avahi-daemon stop
-
chkconfig avahi-daemon off
-
fi
-
logwrite
"avahi-daemon"
"service avahi-daemon status"
-
-
elif [
"${OS_VERSION}" =
"linux7" ];
then
-
if [ $(systemctl status avahi-daemon | grep running | wc -l) -gt 0 ];
then
-
systemctl stop avahi-daemon.socket
-
systemctl
disable avahi-daemon.socket
-
systemctl stop avahi-daemon.service
-
systemctl
disable avahi-daemon.service
-
ps -ef | grep avahi-daemon | egrep -v
"grep" | awk
'{print "kill -9 "$2}'
-
fi
-
logwrite
"avahi-daemon"
"systemctl status avahi-daemon"
-
fi
-
}
-
-
####################################################################################
-
# Stop firefall
-
####################################################################################
-
DisableFirewall() {
-
if [
"${OS_VERSION}" =
"linux6" ];
then
-
if [ $(chkconfig --list | grep tables | grep on | wc -l) -gt 0 ];
then
-
service iptables stop
-
chkconfig iptables off
-
service ip6tables stop
-
chkconfig ip6tables off
-
fi
-
logwrite
"Iptables"
"service iptables status"
-
elif [
"${OS_VERSION}" =
"linux7" ];
then
-
if [ $(systemctl status firewalld.service | grep running | wc -l) -gt 0 ];
then
-
systemctl stop firewalld.service
-
systemctl
disable firewalld.service
-
fi
-
logwrite
"Firewalld"
"systemctl status firewalld"
-
fi
-
}
-
-
####################################################################################
-
# Disable Selinux
-
####################################################################################
-
DisableSelinux() {
-
if [
"$(/usr/sbin/getenforce)" !=
"Disabled" ];
then
-
/usr/sbin/setenforce 0
-
fi
-
if [ ! -z $(grep
"SELINUX=enforcing" /etc/selinux/config) ];
then
-
[ ! -f /etc/selinux/config.
${DAYTIME} ] && cp /etc/selinux/config /etc/selinux/config.
${DAYTIME}
-
sed -i
's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
-
fi
-
-
logwrite
"SELINUX"
"getenforce"
-
}
-
-
####################################################################################
-
# Disable transparent_hugepages&&numa
-
####################################################################################
-
DisableTHPAndNUMA() {
-
if [
"${OS_VERSION}" =
"linux6" ];
then
-
if [ $(egrep
"/sys/kernel/mm/transparent_hugepage/enabled" /etc/rc.d/rc.local | wc -l) -eq 0 ];
then
-
cat >>/etc/rc.d/rc.local <<EOF
-
if
test -f /sys/kernel/mm/transparent_hugepage/enabled;
then
-
echo never > /sys/kernel/mm/transparent_hugepage/enabled
-
fi
-
if
test -f /sys/kernel/mm/transparent_hugepage/defrag;
then
-
echo never > /sys/kernel/mm/transparent_hugepage/defrag
-
fi
-
EOF
-
fi
-
if [ $(egrep
"numa=off" /boot/grub/grub.conf | wc -l) -eq 0 ];
then
-
[ ! -f /boot/grub/grub.conf.
${DAYTIME} ] && cp /boot/grub/grub.conf /boot/grub/grub.conf.
${DAYTIME}
-
sed -i
's/quiet/quiet numa=off/' /boot/grub/grub.conf
-
fi
-
logwrite
"/boot/grub/grub.conf"
"cat /boot/grub/grub.conf"
-
elif [
"${OS_VERSION}" =
"linux7" ];
then
-
if [ $(egrep
"transparent_hugepage=never numa=off" /etc/default/grub | wc -l) -eq 0 ];
then
-
[ ! -f /etc/default/grub.
${DAYTIME} ] && cp /etc/default/grub /etc/default/grub.
${DAYTIME}
-
sed -i
's/quiet/quiet transparent_hugepage=never numa=off/' /etc/default/grub
-
grub2-mkconfig -o /boot/grub2/grub.cfg
-
fi
-
-
logwrite
"/etc/default/grub"
"cat /etc/default/grub"
-
fi
-
-
logwrite
"Transparent_hugepages"
"cat /sys/kernel/mm/transparent_hugepage/enabled"
-
logwrite
"NUMA"
"cat /proc/cmdline"
-
}
-
-
####################################################################################
-
# Disable NetworkManager
-
####################################################################################
-
DisableNetworkManager() {
-
if [
"${OS_VERSION}" =
"linux6" ];
then
-
if [ $(chkconfig --list | grep NetworkManager | grep on | wc -l) -gt 0 ];
then
-
service NetworkManager stop
-
chkconfig NetworkManager off
-
service NetworkManager off
-
fi
-
logwrite
"NetworkManager"
"service NetworkManager status"
-
elif [
"${OS_VERSION}" =
"linux7" ];
then
-
#Turn off the NetworkManager(Linux 7)
-
if [ $(systemctl status NetworkManager.service | grep running | wc -l) -gt 0 ];
then
-
systemctl stop NetworkManager.service
-
systemctl
disable NetworkManager.service
-
fi
-
logwrite
"NetworkManager"
"systemctl status NetworkManager"
-
fi
-
}
-
-
EditParaFiles() {
-
####################################################################################
-
# Edit sysctl.conf
-
####################################################################################
-
##shmmal's Calculation formula: physical memory 8G:(8*1024*1024*1024)/4096=2097152
-
##shmmax's Calculation formula: physical memory 8G:(8/2)*1024*1024*1024 -1=4294967295
-
-
totalMemory=$(expr
$memTotal / 2048)
-
shmall=$(expr
$memTotal / 4)
-
if [
$shmall -lt 2097152 ];
then
-
shmall=2097152
-
fi
-
shmmax=$(expr
$memTotal \* 1024 - 1)
-
if [
$shmmax -lt 4294967295 ];
then
-
shmmax=4294967295
-
fi
-
if [
"${OS_VERSION}" =
"linux6" ];
then
-
if [ $(egrep
"#OraConfBegin" /etc/sysctl.conf | wc -l) -eq 0 ];
then
-
[ ! -f /etc/sysctl.conf.
${DAYTIME} ] && cp /etc/sysctl.conf /etc/sysctl.conf.
${DAYTIME}
-
cat <<EOF >>/etc/sysctl.conf
-
#OraConfBegin
-
##shmmal's Calculation formula: physical memory 8G:(8*1024*1024*1024)/4096=2097152
-
##shmmax's Calculation formula: physical memory 8G:(8/2)*1024*1024*1024 -1=4294967295
-
fs.aio-max-nr = 1048576
-
fs.file-max = 6815744
-
kernel.shmall =
$shmall
-
kernel.shmmax =
$shmmax
-
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
-
#OraConfEnd
-
EOF
-
-
sysctl -p
-
logwrite
"/etc/sysctl.conf"
"sysctl -p"
-
fi
-
elif [
"${OS_VERSION}" =
"linux7" ];
then
-
if [ ! -f /etc/sysctl.d/97-oracledatabase-sysctl.conf ];
then
-
echo
"##For oracle" >>/etc/sysctl.d/97-oracledatabase-sysctl.conf
-
fi
-
if [ $(egrep
"#OraConfBegin" /etc/sysctl.d/97-oracledatabase-sysctl.conf | wc -l) -eq 0 ];
then
-
[ ! -f /etc/sysctl.d/97-oracledatabase-sysctl.conf.
${DAYTIME} ] && cp /etc/sysctl.d/97-oracledatabase-sysctl.conf /etc/sysctl.d/97-oracledatabase-sysctl.conf.
${DAYTIME}
-
cat <<EOF >>/etc/sysctl.d/97-oracledatabase-sysctl.conf
-
#OraConfBegin
-
##shmmal's Calculation formula: physical memory 8G:(8*1024*1024*1024)/4096=2097152
-
##shmmax's Calculation formula: physical memory 8G:(8/2)*1024*1024*1024 -1=4294967295
-
fs.aio-max-nr = 1048576
-
fs.file-max = 6815744
-
kernel.shmall =
$shmall
-
kernel.shmmax =
$shmmax
-
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
-
#OraConfEnd
-
EOF
-
/sbin/sysctl --system
-
logwrite
"/etc/sysctl.d/97-oracledatabase-sysctl.conf"
"/sbin/sysctl --system"
-
fi
-
fi
-
-
####################################################################################
-
# Edit nsysctl.conf
-
####################################################################################
-
if [ $(egrep
"#OraConfBegin" /etc/sysconfig/network | wc -l) -eq 0 ];
then
-
[ ! -f /etc/sysconfig/network.
${DAYTIME} ] && cp /etc/sysconfig/network /etc/sysconfig/network.
${DAYTIME}
-
echo
"#OraConfBegin" >>/etc/sysconfig/network
-
echo
"NOZEROCONF=yes" >>/etc/sysconfig/network
-
echo
"#OraConfEnd" >>/etc/sysconfig/network
-
fi
-
-
logwrite
"NOZEROCONF"
"cat /etc/sysconfig/network"
-
-
####################################################################################
-
# Edit limits.conf
-
####################################################################################
-
if [
"${OS_VERSION}" =
"linux7" ];
then
-
sed -i
's/* soft nproc 4096/* - nproc 16384/g' /etc/security/limits.d/20-nproc.conf
-
logwrite
"/etc/security/limits.d/20-nproc.conf"
"cat /etc/security/limits.d/20-nproc.conf"
-
fi
-
if [ $(egrep
"#OraConfBegin" /etc/security/limits.conf | wc -l) -eq 0 ];
then
-
[ ! -f /etc/security/limits.conf.
${DAYTIME} ] && cp /etc/security/limits.conf /etc/security/limits.conf.
${DAYTIME}
-
cat <<EOF >>/etc/security/limits.conf
-
#OraConfBegin
-
oracle soft nofile 1024
-
oracle hard nofile 65536
-
oracle soft stack 10240
-
oracle hard stack 32768
-
oracle soft nproc 2047
-
oracle hard nproc 16384
-
oracle hard memlock 134217728
-
oracle soft memlock 134217728
-
#OraConfEnd
-
EOF
-
fi
-
-
logwrite
"/etc/security/limits.conf"
"cat /etc/security/limits.conf"
-
-
##Configure pam.d
-
if [ $(egrep
"#OraConfBegin" /etc/pam.d/login | wc -l) -eq 0 ];
then
-
cat <<EOF >>/etc/pam.d/login
-
#OraConfBegin
-
session required pam_limits.so
-
session required /lib64/security/pam_limits.so
-
#OraConfEnd
-
EOF
-
fi
-
-
logwrite
"/etc/pam.d/login"
"cat /etc/pam.d/login"
-
-
####################################################################################
-
# Configure /dev/shm
-
####################################################################################
-
if [ $(egrep
"/dev/shm" /etc/fstab | wc -l) -eq 0 ];
then
-
[ ! -f /etc/fstab.
${DAYTIME} ] && cp /etc/fstab /etc/fstab.
${DAYTIME}
-
cat <<EOF >>/etc/fstab
-
tmpfs /dev/shm tmpfs size=4G 0 0
-
EOF
-
mount -o remount /dev/shm
-
fi
-
-
logwrite
"/dev/shm"
"cat /etc/fstab"
-
logwrite
"df -hP"
"df -hP"
-
-
####################################################################################
-
# Edit bash_profile
-
####################################################################################
-
##ORALCE:
-
if [ $(egrep
"#OraConfBegin" /home/oracle/.bash_profile | wc -l) -eq 0 ];
then
-
[ ! -f /home/oracle/.bash_profile
${daytime}.bak ] && su - oracle -c
"cp /home/oracle/.bash_profile /home/oracle/.bash_profile${daytime}.bak"
-
[ -f home/oracle/.bash_profile ] && su - oracle -c
"sed -i '/^#OraConfBegin/,/^#OraConfEnd/d' /home/oracle/.bash_profile"
-
cat <<EOF >>/home/oracle/.bash_profile
-
################OraConfBegin#########################
-
umask 022
-
export TMP=/tmp
-
export TMPDIR=\
$TMP
-
export NLS_LANG=AMERICAN_AMERICA.
${CHARACTERSET}
#AL32UTF8,ZHS16GBK
-
export ORACLE_BASE=
${ENV_ORACLE_BASE}
-
export ORACLE_HOME=
${ENV_ORACLE_HOME}
-
export ORACLE_HOSTNAME=
${HOSTNAME}
-
export ORACLE_TERM=xterm
-
export TNS_ADMIN=\
$ORACLE_HOME/network/admin
-
export LD_LIBRARY_PATH=\
$ORACLE_HOME/lib:/lib:/usr/lib
-
export ORACLE_SID=
${ORACLE_SID}
-
export PATH=/usr/sbin:\
$PATH
-
export PATH=\
$ORACLE_HOME/bin:\
$ORACLE_HOME/OPatch:\
$PATH
-
alias sqlplus=
'rlwrap sqlplus'
-
alias rman=
'rlwrap rman'
-
alias lsnrctl=
'rlwrap lsnrctl'
-
alias asmcmd=
'rlwrap asmcmd'
-
alias adrci=
'rlwrap adrci'
-
alias sas=
'sqlplus / as sysdba'
-
alias ggsci=
'rlwrap ggsci'
-
alias alert=
'tail -500f \$ORACLE_BASE/diag/rdbms/\$ORACLE_SID/\$ORACLE_SID/trace/alert_\$ORACLE_SID.log|more'
-
export PS1=
"[\`whoami\`@\`hostname\`:"
'\$PWD]\$ '
-
################OraConfEnd###########################
-
EOF
-
else
-
if [
"${oracleSid}" !=
"${ORACLE_SID}" ];
then
-
sed -i
"s/ORACLE_SID=${oracleSid}/ORACLE_SID=${ORACLE_SID}/" /home/oracle/.bash_profile
-
fi
-
if [
"${oracleHostname}" !=
"${HOSTNAME}" ];
then
-
sed -i
"s/ORACLE_HOSTNAME=${oracleHostname}/ORACLE_HOSTNAME=${HOSTNAME}/" /home/oracle/.bash_profile
-
fi
-
if [
"${oracleBase}" !=
"${ENV_ORACLE_BASE}" ];
then
-
sed -i
"s#ORACLE_BASE=${oracleBase}#ORACLE_BASE=${ENV_ORACLE_BASE}#" /home/oracle/.bash_profile
-
fi
-
if [
"${oracleHome}" !=
"${ENV_ORACLE_HOME}" ];
then
-
sed -i
"s#ORACLE_HOME=${oracleHome}#ORACLE_HOME=${ENV_ORACLE_HOME}#" /home/oracle/.bash_profile
-
fi
-
fi
-
logwrite
"Oracle Profile"
"cat /home/oracle/.bash_profile"
-
}
-
-
####################################################################################
-
# Install rlwrap
-
####################################################################################
-
InstallRlwrap() {
-
if [ $(ls -l
${SOFTWAREDIR}/rlwrap-*gz | wc -l) -gt 0 ];
then
-
rlwrap -v
-
if [ $? -ne 0 ];
then
-
tar -zxvf
${SOFTWAREDIR}/rlwrap* -C
${SOFTWAREDIR}
-
cd
${SOFTWAREDIR}/rlwrap-*/
-
./configure
-
make
-
make install
-
fi
-
logwrite
"rlwrap"
"rlwrap -v"
-
fi
-
-
}
-
-
####################################################################################
-
# Unzip DB Software
-
####################################################################################
-
UnzipDBSoft() {
-
if [
"${DB_VERSION}" =
"11.2.0.4" ];
then
-
if [ $(ls -l
${SOFTWAREDIR}/p13390677_112040_Linux-x86-64_*of7.zip | wc -l) -gt 0 ];
then
-
rm -rf
${SOFTWAREDIR}/database
-
unzip -o
${SOFTWAREDIR}/p13390677_112040_Linux-x86-64_1of7.zip -d
${SOFTWAREDIR}
-
unzip -o
${SOFTWAREDIR}/p13390677_112040_Linux-x86-64_2of7.zip -d
${SOFTWAREDIR}
-
else
-
c1
"Make sure the database installation package is in the ${SOFTWAREDIR} directory:" red
-
c1
"p13390677_112040_Linux-x86-64_1of7.zip" blue
-
c1
"p13390677_112040_Linux-x86-64_2of7.zip" blue
-
exit 99
-
fi
-
elif [
"${DB_VERSION}" =
"12.2.0.1" ];
then
-
if [ $(ls -l
${SOFTWAREDIR}/LINUX.X64_122010_db_home.zip | wc -l) -gt 0 ];
then
-
rm -rf
${SOFTWAREDIR}/database
-
unzip -o
${SOFTWAREDIR}/LINUX.X64_122010_db_home.zip -d
${SOFTWAREDIR}
-
else
-
c1
"Make sure the database installation package is in the ${SOFTWAREDIR} directory:" red
-
c1
"LINUX.X64_122010_db_home.zip" blue
-
exit 99
-
fi
-
elif [
"${DB_VERSION}" =
"18.0.0.0" ];
then
-
if [ $(ls -l
${SOFTWAREDIR}/LINUX.X64_180000_db_home.zip | wc -l) -gt 0 ];
then
-
unzip -o
${SOFTWAREDIR}/LINUX.X64_180000_db_home.zip -d
${ENV_ORACLE_HOME}
-
chown -R oracle:oinstall
${ENV_ORACLE_HOME}
-
else
-
c1
"Make sure the database installation package is in the ${SOFTWAREDIR} directory:" red
-
c1
"LINUX.X64_180000_db_home.zip" blue
-
exit 99
-
fi
-
elif [
"${DB_VERSION}" =
"19.3.0.0" ];
then
-
if [ $(ls -l
${SOFTWAREDIR}/LINUX.X64_193000_db_home.zip | wc -l) -gt 0 ];
then
-
unzip -o
${SOFTWAREDIR}/LINUX.X64_193000_db_home.zip -d
${ENV_ORACLE_HOME}
-
chown -R oracle:oinstall
${ENV_ORACLE_HOME}
-
else
-
c1
"Make sure the database installation package is in the ${SOFTWAREDIR} directory:" red
-
c1
"LINUX.X64_193000_db_home.zip" blue
-
exit 99
-
fi
-
else
-
c1
"Error database version! please check again!" red
-
exit
-
fi
-
}
-
-
####################################################################################
-
# Unzip DB Software
-
####################################################################################
-
InstallDBsoftware() {
-
-
####################################################################################
-
# Unzip oracle OPATCH&&RU
-
####################################################################################
-
if [ -n
"${RU}" ];
then
-
if [
"${DB_VERSION}" =
"18.0.0.0" ] || [[
"${DB_VERSION}" =
"19.3.0.0" ]];
then
-
if [
"${DB_VERSION}" =
"18.0.0.0" ];
then
-
su - oracle -c
"unzip -o ${SOFTWAREDIR}/p6880880_180000_Linux-x86-64.zip -d ${ENV_ORACLE_HOME}"
-
if [ $? -ne 0 ];
then
-
c1
"Make sure the Patch 6880880 is in the ${SOFTWAREDIR} directory:" red
-
c1
"p6880880_180000_Linux-x86-64.zip" blue
-
exit 92
-
fi
-
elif [
"${DB_VERSION}" =
"19.3.0.0" ];
then
-
su - oracle -c
"unzip -o ${SOFTWAREDIR}/p6880880_190000_Linux-x86-64.zip -d ${ENV_ORACLE_HOME}"
-
if [ $? -ne 0 ];
then
-
c1
"Make sure the Patch 6880880 is in the ${SOFTWAREDIR} directory:" red
-
c1
"p6880880_190000_Linux-x86-64.zip" blue
-
exit 92
-
fi
-
fi
-
-
if [ ! -d
${SOFTWAREDIR}/
${RU} ];
then
-
chown -R oracle:oinstall
${SOFTWAREDIR}
-
if [ $? -ne 0 ];
then
-
su - oracle -c
"unzip -o ${SOFTWAREDIR}/*p${RU}* -d ${SOFTWAREDIR}"
-
c1
"Make sure the database release update ${RU} is in the ${SOFTWAREDIR} directory:" red
-
c1
"p${RU}.......zip" blue
-
exit 99
-
fi
-
fi
-
fi
-
fi
-
-
if [
"${DB_VERSION}" =
"18.0.0.0" ] || [[
"${DB_VERSION}" =
"19.3.0.0" ]];
then
-
logwrite
"OPatch Version"
"su - oracle -c \"opatch version\""
-
fi
-
#Create db.rsp
-
rm -rf
${SOFTWAREDIR}/db.rsp
-
if [
${DB_VERSION} = 11.2.0.4 ];
then
-
cat <<EOF >>
${SOFTWAREDIR}/db.rsp
-
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
-
oracle.install.option=INSTALL_DB_SWONLY
-
ORACLE_HOSTNAME=
${HOSTNAME}
-
UNIX_GROUP_NAME=oinstall
-
INVENTORY_LOCATION=
${ENV_BASE_DIR}/oraInventory
-
SELECTED_LANGUAGES=en,zh_CN
-
ORACLE_HOME=
${ENV_ORACLE_HOME}
-
ORACLE_BASE=
${ENV_ORACLE_BASE}
-
oracle.install.db.InstallEdition=EE
-
oracle.install.db.DBA_GROUP=dba
-
oracle.install.db.OPER_GROUP=oinstall
-
DECLINE_SECURITY_UPDATES=
true
-
oracle.installer.autoupdates.option=SKIP_UPDATES
-
EOF
-
elif [
"${DB_VERSION}" =
"12.2.0.1" ];
then
-
cat <<EOF >>
${SOFTWAREDIR}/db.rsp
-
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.2.0
-
oracle.install.option=INSTALL_DB_SWONLY
-
UNIX_GROUP_NAME=oinstall
-
ORACLE_HOME=
${ENV_ORACLE_HOME}
-
INVENTORY_LOCATION=
${ENV_ORACLE_INVEN}
-
ORACLE_BASE=
${ENV_ORACLE_BASE}
-
SELECTED_LANGUAGES=en,zh_CN
-
ORACLE_HOME=
$ENV_ORACLE_HOME
-
ORACLE_BASE=
$ENV_ORACLE_BASE
-
oracle.install.db.InstallEdition=EE
-
oracle.install.db.OSDBA_GROUP=dba
-
oracle.install.db.OSOPER_GROUP=oper
-
oracle.install.db.OSBACKUPDBA_GROUP=backupdba
-
oracle.install.db.OSDGDBA_GROUP=dgdba
-
oracle.install.db.OSKMDBA_GROUP=kmdba
-
oracle.install.db.OSRACDBA_GROUP=racdba
-
DECLINE_SECURITY_UPDATES=
true
-
EOF
-
elif [
"${DB_VERSION}" =
"18.0.0.0" ];
then
-
cat <<EOF >>
${SOFTWAREDIR}/db.rsp
-
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v18.0.0
-
oracle.install.option=INSTALL_DB_SWONLY
-
UNIX_GROUP_NAME=oinstall
-
ORACLE_HOSTNAME=
${HOSTNAME}
-
ORACLE_HOME=
${ENV_ORACLE_HOME}
-
INVENTORY_LOCATION=
${ENV_ORACLE_INVEN}
-
ORACLE_BASE=
${ENV_ORACLE_BASE}
-
oracle.install.db.InstallEdition=EE
-
oracle.install.db.OSDBA_GROUP=dba
-
oracle.install.db.OSOPER_GROUP=oper
-
oracle.install.db.OSBACKUPDBA_GROUP=backupdba
-
oracle.install.db.OSDGDBA_GROUP=dgdba
-
oracle.install.db.OSKMDBA_GROUP=kmdba
-
oracle.install.db.OSRACDBA_GROUP=racdba
-
EOF
-
elif [
"${DB_VERSION}" =
"19.3.0.0" ];
then
-
cat <<EOF >>
${SOFTWAREDIR}/db.rsp
-
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v19.0.0
-
oracle.install.option=INSTALL_DB_SWONLY
-
UNIX_GROUP_NAME=oinstall
-
INVENTORY_LOCATION=
${ENV_ORACLE_INVEN}
-
ORACLE_BASE=
${ENV_ORACLE_BASE}
-
oracle.install.db.InstallEdition=EE
-
oracle.install.db.OSDBA_GROUP=dba
-
oracle.install.db.OSOPER_GROUP=oper
-
oracle.install.db.OSBACKUPDBA_GROUP=backupdba
-
oracle.install.db.OSDGDBA_GROUP=dgdba
-
oracle.install.db.OSKMDBA_GROUP=kmdba
-
oracle.install.db.OSRACDBA_GROUP=racdba
-
oracle.install.db.rootconfig.executeRootScript=
false
-
oracle.install.db.rootconfig.configMethod=
-
EOF
-
fi
-
-
logwrite
"${SOFTWAREDIR}/db.rsp"
"cat ${SOFTWAREDIR}/db.rsp"
-
-
#Install Database software
-
chown oracle.oinstall
${SOFTWAREDIR}/db.rsp
-
-
##Juge whether ${ENV_ORACLE_INVEN}/ContentsXML/inventory.xml contains ${ENV_ORACLE_HOME},if exists ,delete it
-
if [ -f
"${ENV_ORACLE_INVEN}/ContentsXML/inventory.xml" ] && [ $(egrep
"${ENV_ORACLE_HOME}"
${ENV_ORACLE_INVEN}/ContentsXML/inventory.xml | wc -l) -gt 0 ];
then
-
line=$(grep -n
"${ENV_ORACLE_HOME}"
${ENV_ORACLE_INVEN}/ContentsXML/inventory.xml | awk -F
":"
'{print $1}')
-
sed -i
"${line} d"
${ENV_ORACLE_INVEN}/ContentsXML/inventory.xml
-
fi
-
-
if [[
"${DB_VERSION}" =
"12.2.0.1" ]] || [[
"${DB_VERSION}" =
"11.2.0.4" ]];
then
-
su - oracle -c
"${SOFTWAREDIR}/database/runInstaller -silent -force -ignoreSysPrereqs -responseFile ${SOFTWAREDIR}/db.rsp -ignorePrereq" | tee
${SOFTWAREDIR}/setupDatabase.out
-
rm -rf
${SOFTWAREDIR}/setupDatabase.out
-
elif [
"${DB_VERSION}" =
"18.0.0.0" ] || [[
"${DB_VERSION}" =
"19.3.0.0" ]];
then
-
if [ -n
"${RU}" ];
then
-
su - oracle <<EOF
-
cd
${ENV_ORACLE_HOME};
-
./runInstaller -silent -force -responseFile
${SOFTWAREDIR}/db.rsp -ignorePrereqFailure -waitForCompletion -applyRU
${SOFTWAREDIR}/
${RU}
-
EOF
-
else
-
su - oracle <<EOF
-
cd
${ENV_ORACLE_HOME};
-
./runInstaller -silent -force -responseFile
${SOFTWAREDIR}/db.rsp -ignorePrereqFailure -waitForCompletion
-
EOF
-
fi
-
fi
-
-
if [ -f
${ENV_ORACLE_INVEN}/orainstRoot.sh ] || [ -f
${ENV_ORACLE_HOME}/root.sh ];
then
-
if [ -f
${ENV_ORACLE_INVEN}/orainstRoot.sh ];
then
-
${ENV_ORACLE_INVEN}/orainstRoot.sh
-
fi
-
if [ -f
${ENV_ORACLE_HOME}/root.sh ];
then
-
${ENV_ORACLE_HOME}/root.sh
-
fi
-
else
-
echo
-
c1
"Oracle software installation failed, please check the log." red
-
exit 99
-
fi
-
-
##LINUX7 INSTALL 11G,NEED TO SET -lnnz11
-
if [
"${DB_VERSION}" =
"11.2.0.4" ];
then
-
sed -i
's/^\(\s*\$(MK_EMAGENT_NMECTL)\)\s*$/\1 -lnnz11/g'
${ENV_ORACLE_HOME}/sysman/lib/ins_emagent.mk
-
fi
-
-
logwrite
"Oracle RDBMS"
"su - oracle -c \"sqlplus -V\""
-
logwrite
"OPatch lspatches"
"su - oracle -c \"opatch lspatches\""
-
-
}
-
-
####################################################################################
-
# Create netca.rsp
-
####################################################################################
-
creareNetca() {
-
rm -rf
${SOFTWAREDIR}/netca.rsp
-
if [
"${DB_VERSION}" =
"11.2.0.4" ];
then
-
RESPONSEFILE_VERSION=11.2
-
elif [
"${DB_VERSION}" =
"12.2.0.1" ];
then
-
RESPONSEFILE_VERSION=12.2
-
elif [
"${DB_VERSION}" =
"18.0.0.0" ];
then
-
RESPONSEFILE_VERSION=18.0
-
elif [
"${DB_VERSION}" =
"19.3.0.0" ];
then
-
RESPONSEFILE_VERSION=19.3
-
fi
-
-
cat <<EOF >>
${SOFTWAREDIR}/netca.rsp
-
[GENERAL]
-
RESPONSEFILE_VERSION=
"${RESPONSEFILE_VERSION}"
-
CREATE_TYPE=
"CUSTOM"
-
[oracle.net.ca]
-
INSTALLED_COMPONENTS={
"server",
"net8",
"javavm"}
-
INSTALL_TYPE=
""typical
""
-
LISTENER_NUMBER=1
-
LISTENER_NAMES={
"LISTENER"}
-
LISTENER_PROTOCOLS={
"TCP;1521"}
-
LISTENER_START=
""LISTENER
""
-
NAMING_METHODS={
"TNSNAMES",
"ONAMES",
"HOSTNAME"}
-
NSN_NUMBER=1
-
NSN_NAMES={
"EXTPROC_CONNECTION_DATA"}
-
NSN_SERVICE={
"PLSExtProc"}
-
NSN_PROTOCOLS={
"TCP;HOSTNAME;1521"}
-
EOF
-
-
logwrite
"${SOFTWAREDIR}/netca.rsp"
"cat ${SOFTWAREDIR}/netca.rsp"
-
-
su - oracle -c
"netca -silent -responsefile ${SOFTWAREDIR}/netca.rsp"
-
-
logwrite
"ORACLE LISTENER"
"su - oracle -c \"lsnrctl status\""
-
}
-
-
####################################################################################
-
## Create database
-
####################################################################################
-
createDB() {
-
if [
"${DB_VERSION}" =
"11.2.0.4" ];
then
-
su - oracle -c
"dbca -silent -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE -gdbname ${ORACLE_SID} -sid ${ORACLE_SID} -sysPassword oracle -systemPassword oracle -redoLogFileSize 120 -storageType FS -datafileDestination ${ORADATADIR} -sampleSchema true -characterSet ${CHARACTERSET} -nationalCharacterSet AL16UTF16 -emConfiguration NONE -automaticMemoryManagement false -totalMemory ${totalMemory} -databaseType OLTP"
-
elif [
"${DB_VERSION}" =
"12.2.0.1" ] || [
"${DB_VERSION}" =
"18.0.0.0" ] || [[
"${DB_VERSION}" =
"19.3.0.0" ]];
then
-
su - oracle -c
"dbca -silent -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE -gdbName ${ORACLE_SID} -sid ${ORACLE_SID} -sysPassword oracle -systemPassword oracle -redoLogFileSize 120 -storageType FS -datafileDestination ${ORADATADIR} -enableArchive true -archiveLogDest ${ARCHIVEDIR} -sampleSchema true -characterset ${CHARACTERSET} -nationalCharacterSet AL16UTF16 -emConfiguration NONE -automaticMemoryManagement false -totalMemory ${totalMemory} -databaseType OLTP -createAsContainerDatabase ${ISCDB} "
-
fi
-
-
logwrite
"ORACLE Instance"
"su - oracle -c \"lsnrctl status\""
-
}
-
-
####################################################################################
-
# Configure DBParaSet
-
####################################################################################
-
DBParaSet() {
-
cat <<EOF >/home/oracle/oracleParaset.sql
-
--
set db_create_file_dest
-
ALTER SYSTEM SET DB_CREATE_FILE_DEST=
'${ORADATADIR}';
-
ALTER SYSTEM SET LOG_ARCHIVE_DEST_1=
'LOCATION=${ARCHIVEDIR}';
-
exit;
-
EOF
-
-
su - oracle -c
"sqlplus / as sysdba @/home/oracle/oracleParaset.sql"
-
-
####################################################################################
-
# Create PDB and Set pdb autostart with cdb
-
####################################################################################
-
if [
"${ISCDB}" =
"TRUE" ];
then
-
if [ ! -f /home/oracle/pdbs_save_state.sql ];
then
-
cat <<EOF >>/home/oracle/pdbs_save_state.sql
-
--create pluggable database
-
create pluggable database
${PDBNAME} admin user admin identified by oracle;
-
--open pluggable database
-
alter pluggable database all open;
-
--
set pdb autostart with cdb
-
alter pluggable database all save state;
-
exit
-
EOF
-
fi
-
su - oracle -c
"sqlplus / as sysdba @/home/oracle/pdbs_save_state.sql"
-
####################################################################################
-
# Add pdb TNS
-
####################################################################################
-
if [ $(egrep
"#OraConfBegin"
${ENV_ORACLE_HOME}/network/admin/tnsnames.ora | wc -l) -eq 0 ];
then
-
[ ! -f
${ENV_ORACLE_HOME}/network/admin/tnsnames.ora.
${DAYTIME} ] && cp
${ENV_ORACLE_HOME}/network/admin/tnsnames.ora
${ENV_ORACLE_HOME}/network/admin/tnsnames.ora.
${DAYTIME}
-
su - oracle -c
"cat <<EOF >>${ENV_ORACLE_HOME}/network/admin/tnsnames.ora
-
#OraConfBegin
-
${PDBNAME} =
-
(DESCRIPTION =
-
(ADDRESS = (PROTOCOL = TCP)(HOST = ${HOSTNAME})(PORT = 1521))
-
(CONNECT_DATA =
-
(SERVER = DEDICATED)
-
(SERVICE_NAME = ${PDBNAME})
-
)
-
)
-
#OraConfEnd
-
EOF
-
"
-
fi
-
fi
-
-
####################################################################################
-
# Configure instances autostart with OS start
-
####################################################################################
-
if [ $(egrep
"#OraConfBegin" /etc/oratab | wc -l) -eq 0 ];
then
-
[ ! -f /etc/oratab.
${DAYTIME} ] && cp /etc/oratab /etc/oratab.
${DAYTIME}
-
sed -i
's/db:N/db:Y/' /etc/oratab
-
sed -i
's/ORACLE_HOME_LISTNER=$1/ORACLE_HOME_LISTNER=$ORACLE_HOME/'
${ENV_ORACLE_HOME}/bin/dbstart
-
cat <<EOF >>/etc/rc.d/rc.local
-
#OraConfBegin
-
su oracle -lc
"${ENV_ORACLE_HOME}/bin/lsnrctl start"
-
su oracle -lc
${ENV_ORACLE_HOME}/bin/dbstart
-
#OraConfEnd
-
EOF
-
-
chmod +x /etc/rc.d/rc.local
-
fi
-
-
####################################################################################
-
# Configure del_arch.sh to crontab
-
####################################################################################
-
##create del_arch.sh
-
if [ ! -f
${SCRIPTSDIR}/del_arch.sh ];
then
-
echo
'#!/bin/bash' >>
${SCRIPTSDIR}/del_arch.sh
-
echo
'source ~/.bash_profile' >>
${SCRIPTSDIR}/del_arch.sh
-
echo
'deltime=`date +"20%y%m%d%H%M%S"`' >>
${SCRIPTSDIR}/del_arch.sh
-
echo
"rman target / nocatalog msglog ${SCRIPTSDIR}/del_arch_\${deltime}.log<<EOF" >>
${SCRIPTSDIR}/del_arch.sh
-
echo
'crosscheck archivelog all;' >>
${SCRIPTSDIR}/del_arch.sh
-
echo
"delete noprompt archivelog until time 'sysdate-7';" >>
${SCRIPTSDIR}/del_arch.sh
-
echo
"delete noprompt force archivelog until time 'SYSDATE-10';" >>
${SCRIPTSDIR}/del_arch.sh
-
echo
'EOF' >>
${SCRIPTSDIR}/del_arch.sh
-
fi
-
-
##create dbbackup_lv0.sh
-
if [ ! -f
${SCRIPTSDIR}/dbbackup_lv0.sh ];
then
-
echo
'#!/bin/sh' >>
${SCRIPTSDIR}/dbbackup_lv0.sh
-
echo
'source ~/.bash_profile' >>
${SCRIPTSDIR}/dbbackup_lv0.sh
-
echo
'backtime=`date +"20%y%m%d%H%M%S"`' >>
${SCRIPTSDIR}/dbbackup_lv0.sh
-
echo
"rman target / log=${backupDir}/level0_backup_\${backtime}.log<<EOF" >>
${SCRIPTSDIR}/dbbackup_lv0.sh
-
echo
'run {' >>
${SCRIPTSDIR}/dbbackup_lv0.sh
-
echo
'allocate channel c1 device type disk;' >>
${SCRIPTSDIR}/dbbackup_lv0.sh
-
echo
'allocate channel c2 device type disk;' >>
${SCRIPTSDIR}/dbbackup_lv0.sh
-
echo
'crosscheck backup;' >>
${SCRIPTSDIR}/dbbackup_lv0.sh
-
echo
'crosscheck archivelog all; ' >>
${SCRIPTSDIR}/dbbackup_lv0.sh
-
echo
'alter system switch logfile;' >>
${SCRIPTSDIR}/dbbackup_lv0.sh
-
echo
'delete noprompt expired backup;' >>
${SCRIPTSDIR}/dbbackup_lv0.sh
-
echo
'delete noprompt obsolete device type disk;' >>
${SCRIPTSDIR}/dbbackup_lv0.sh
-
echo
"backup incremental level 0 database include current controlfile format '${backupDir}/backlv0_%d_%T_%t_%s_%p';" >>
${SCRIPTSDIR}/dbbackup_lv0.sh
-
echo
'backup archivelog all DELETE INPUT;' >>
${SCRIPTSDIR}/dbbackup_lv0.sh
-
echo
'release channel c1;' >>
${SCRIPTSDIR}/dbbackup_lv0.sh
-
echo
'release channel c2;' >>
${SCRIPTSDIR}/dbbackup_lv0.sh
-
echo
'}' >>
${SCRIPTSDIR}/dbbackup_lv0.sh
-
echo
'EOF' >>
${SCRIPTSDIR}/dbbackup_lv0.sh
-
fi
-
-
##create dbbackup_lv1.sh
-
if [ ! -f
${SCRIPTSDIR}/dbbackup_lv1.sh ];
then
-
echo
'#!/bin/sh' >>
${SCRIPTSDIR}/dbbackup_lv1.sh
-
echo
'source ~/.bash_profile' >>
${SCRIPTSDIR}/dbbackup_lv1.sh
-
echo
'backtime=`date +"20%y%m%d%H%M%S"`' >>
${SCRIPTSDIR}/dbbackup_lv1.sh
-
echo
"rman target / log=${backupDir}/level1_backup_\${backtime}.log<<EOF" >>
${SCRIPTSDIR}/dbbackup_lv1.sh
-
echo
'run {' >>
${SCRIPTSDIR}/dbbackup_lv1.sh
-
echo
'allocate channel c1 device type disk;' >>
${SCRIPTSDIR}/dbbackup_lv1.sh
-
echo
'allocate channel c2 device type disk;' >>
${SCRIPTSDIR}/dbbackup_lv1.sh
-
echo
'crosscheck backup;' >>
${SCRIPTSDIR}/dbbackup_lv1.sh
-
echo
'crosscheck archivelog all; ' >>
${SCRIPTSDIR}/dbbackup_lv1.sh
-
echo
'alter system switch logfile;' >>
${SCRIPTSDIR}/dbbackup_lv1.sh
-
echo
'delete noprompt expired backup;' >>
${SCRIPTSDIR}/dbbackup_lv1.sh
-
echo
'delete noprompt obsolete device type disk;' >>
${SCRIPTSDIR}/dbbackup_lv1.sh
-
echo
"backup incremental level 1 database include current controlfile format '${backupDir}/backlv1_%d_%T_%t_%s_%p';" >>
${SCRIPTSDIR}/dbbackup_lv1.sh
-
echo
'backup archivelog all DELETE INPUT;' >>
${SCRIPTSDIR}/dbbackup_lv1.sh
-
echo
'release channel c1;' >>
${SCRIPTSDIR}/dbbackup_lv1.sh
-
echo
'release channel c2;' >>
${SCRIPTSDIR}/dbbackup_lv1.sh
-
echo
'}' >>
${SCRIPTSDIR}/dbbackup_lv1.sh
-
echo
'EOF' >>
${SCRIPTSDIR}/dbbackup_lv1.sh
-
fi
-
-
##create dbbackup_lv2.sh
-
if [ ! -f
${SCRIPTSDIR}/dbbackup_lv2.sh ];
then
-
echo
'#!/bin/sh' >>
${SCRIPTSDIR}/dbbackup_lv2.sh
-
echo
'source ~/.bash_profile' >>
${SCRIPTSDIR}/dbbackup_lv2.sh
-
echo
'backtime=`date +"20%y%m%d%H%M%S"`' >>
${SCRIPTSDIR}/dbbackup_lv2.sh
-
echo
"rman target / log=${backupDir}/level2_backup_\${backtime}.log<<EOF" >>
${SCRIPTSDIR}/dbbackup_lv2.sh
-
echo
'run {' >>
${SCRIPTSDIR}/dbbackup_lv2.sh
-
echo
'allocate channel c2 device type disk;' >>
${SCRIPTSDIR}/dbbackup_lv2.sh
-
echo
'allocate channel c2 device type disk;' >>
${SCRIPTSDIR}/dbbackup_lv2.sh
-
echo
'crosscheck backup;' >>
${SCRIPTSDIR}/dbbackup_lv2.sh
-
echo
'crosscheck archivelog all; ' >>
${SCRIPTSDIR}/dbbackup_lv2.sh
-
echo
'alter system switch logfile;' >>
${SCRIPTSDIR}/dbbackup_lv2.sh
-
echo
'delete noprompt expired backup;' >>
${SCRIPTSDIR}/dbbackup_lv2.sh
-
echo
'delete noprompt obsolete device type disk;' >>
${SCRIPTSDIR}/dbbackup_lv2.sh
-
echo
"backup incremental level 2 database include current controlfile format '${backupDir}/backlv2_%d_%T_%t_%s_%p';" >>
${SCRIPTSDIR}/dbbackup_lv2.sh
-
echo
'backup archivelog all DELETE INPUT;' >>
${SCRIPTSDIR}/dbbackup_lv2.sh
-
echo
'release channel c2;' >>
${SCRIPTSDIR}/dbbackup_lv2.sh
-
echo
'release channel c2;' >>
${SCRIPTSDIR}/dbbackup_lv2.sh
-
echo
'}' >>
${SCRIPTSDIR}/dbbackup_lv2.sh
-
echo
'EOF' >>
${SCRIPTSDIR}/dbbackup_lv2.sh
-
fi
-
-
####################################################################################
-
# Configure scripts to crontab
-
####################################################################################
-
##Set to oracle crontab
-
if [ ! -f /var/spool/cron/oracle ];
then
-
echo
"##For oracle" >>/var/spool/cron/oracle
-
fi
-
if [ $(egrep
"#OraConfBegin" /var/spool/cron/oracle | wc -l) -eq 0 ];
then
-
[ ! -f /var/spool/cron/oracle.
${daytime} ] && cp /var/spool/cron/oracle /var/spool/cron/oracle.
${daytime} >/dev/null 2>&1
-
chown -R oracle:oinstall
${SCRIPTSDIR}/d*
-
chmod +x
${SCRIPTSDIR}/d*
-
echo
"#OraConfBegin" >>/var/spool/cron/oracle
-
echo
"#12 00 * * * ${SCRIPTSDIR}/del_arch.sh" >>/var/spool/cron/oracle
-
echo
"#00 00 * * 0 ${SCRIPTSDIR}/dbbackup_lv0.sh" >>/var/spool/cron/oracle
-
echo
"#00 00 * * 1,2,4,5 ${SCRIPTSDIR}/dbbackup_lv1.sh" >>/var/spool/cron/oracle
-
echo
"#00 00 * * 3,6 ${SCRIPTSDIR}/dbbackup_lv2.sh" >>/var/spool/cron/oracle
-
echo
"#OraConfEnd" >>/var/spool/cron/oracle
-
fi
-
-
####################################################################################
-
# Configure PASSWORD_LIFE_TIME UNLIMITED
-
####################################################################################
-
if [
"${ISCDB}" =
"TRUE" ];
then
-
cat <<EOF >/home/oracle/password_unlimt.sql
-
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
-
ALTER SYSTEM SET AUDIT_TRAIL=NONE SCOPE=SPFILE;
-
ALTER SYSTEM SET DEFERRED_SEGMENT_CREATION=FALSE;
-
ALTER SYSTEM SET
"_OPTIMIZER_CARTESIAN_ENABLED"=FALSE;
-
ALTER SYSTEM SET
"_USE_SINGLE_LOG_WRITER"=FALSE SCOPE=SPFILE;
-
ALTER SYSTEM SET RESULT_CACHE_MAX_SIZE= 0;
-
ALTER SYSTEM SET event=
'10949 trace name context forever:28401 trace name context forever,level 1:10849 trace name context forever, level 1:19823 trace name context forever, level 90' scope=spfile;
-
ALTER SESSION SET CONTAINER=
${PDBNAME};
-
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
-
GRANT DBA TO ADMIN;
-
exit;
-
EOF
-
else
-
cat <<EOF >/home/oracle/password_unlimt.sql
-
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
-
ALTER SYSTEM SET AUDIT_TRAIL=NONE SCOPE=SPFILE;
-
ALTER SYSTEM SET DEFERRED_SEGMENT_CREATION=FALSE;
-
ALTER SYSTEM SET
"_OPTIMIZER_CARTESIAN_ENABLED"=FALSE;
-
--ALTER SYSTEM SET
"_USE_SINGLE_LOG_WRITER"=FALSE SCOPE=SPFILE;
-
ALTER SYSTEM SET RESULT_CACHE_MAX_SIZE= 0;
-
ALTER SYSTEM SET event=
'10949 trace name context forever:28401 trace name context forever,level 1:10849 trace name context forever, level 1:19823 trace name context forever, level 90' scope=spfile;
-
exit;
-
EOF
-
fi
-
-
su - oracle -c
"sqlplus / as sysdba @/home/oracle/password_unlimt.sql"
-
-
cat <<EOF >/home/oracle/Impliedparameters.sql
-
col name
for a40
-
col VALUE
for a10
-
col DESCRIB
for a60
-
set lines 200
-
SHOW PARAMETER AUDIT_TRAIL
-
SHOW PARAMETER DEFERRED_SEGMENT_CREATION
-
SHOW PARAMETER RESULT_CACHE_MAX_SIZE
-
SELECT x.ksppinm NAME, y.ksppstvl VALUE, x.ksppdesc describ
-
FROM SYS.x\
$ksppi x, SYS.x\
$ksppcv y
-
WHERE x.inst_id = USERENV (
'Instance')
-
AND y.inst_id = USERENV (
'Instance')
-
AND x.indx = y.indx
-
and x.ksppinm
in (
'_optimizer_cartesian_enabled',
'_use_single_log_writer',
'_use_adaptive_log_file_sync');
-
exit;
-
EOF
-
logwrite
"Oracle Implied parameters"
"su - oracle -c \"sqlplus / as sysdba @/home/oracle/Impliedparameters.sql\""
-
-
####################################################################################
-
# Sqlnet.ora Configure lower Oracle client to connect
-
####################################################################################
-
if [ $(egrep
"#OraConfBegin"
${ENV_ORACLE_HOME}/network/admin/sqlnet.ora | wc -l) -eq 0 ];
then
-
[ ! -f
${ENV_ORACLE_HOME}/network/admin/sqlnet.ora.
${DAYTIME} ] && cp
${ENV_ORACLE_HOME}/network/admin/sqlnet.ora
${ENV_ORACLE_HOME}/network/admin/sqlnet.ora.
${DAYTIME}
-
su - oracle -c
"cat <<EOF >>${ENV_ORACLE_HOME}/network/admin/sqlnet.ora
-
#OraConfBegin
-
SQLNET.ALLOWED_LOGON_VERSION_CLIENT=8
-
SQLNET.ALLOWED_LOGON_VERSION_SERVER=8
-
#OraConfEnd
-
EOF
-
"
-
fi
-
-
}
-
-
##remove instance
-
if [ -n
"${REMOVEINSTANCE}" ];
then
-
REMOVEINSTANCE
-
fi
-
-
##remove rdbms
-
if [ -n
"${REMOVEDBSOFTWARE}" ];
then
-
REMOVEDBSOFTWARE
-
fi
-
-
##For OS CONFIG
-
SetHostName
-
SetHosts
-
InstallRPM
-
CreateUsersAndDirs
-
TimeDepSet
-
Disableavahi
-
DisableFirewall
-
DisableSelinux
-
DisableTHPAndNUMA
-
DisableNetworkManager
-
EditParaFiles
-
InstallRlwrap
-
-
##If ONLY INSTALL ORACLE SOFTWARE
-
if [
"${ONLYCONFIGOS}" =
'N' ];
then
-
UnzipDBSoft
-
InstallDBsoftware
-
if [
"${ONLYINSTALLSOFTWARE}" =
'N' ];
then
-
creareNetca
-
createDB
-
DBParaSet
-
fi
-
fi
转载:https://blog.csdn.net/m0_50546016/article/details/115491761
查看评论