Oracle19c_pdb数据库自动安装脚本
项目地址:https://github.com/domdanrtsey/Oracle19c_pdb_autoinstall
请注意:本脚本是自动安装部署pdb容器数据库的脚本,不适用于cdb数据库
oracle19c(12.2.0.3)版本在linux系统环境的使用说明:
The following Linux x86-64 kernels are supported:
1、Oracle Linux 7.4 with the Unbreakable Enterprise Kernel 4: 4.1.12-112.16.7.el7uek.x86_64 or later
2、Oracle Linux 7.4 with the Unbreakable Enterprise Kernel 5: 4.14.35-1818.1.6.el7uek.x86_64 or later
3、Oracle Linux 7.4 with the Red Hat Compatible kernel: 3.10.0-693.5.2.0.1.el7.x86_64 or later
4、Red Hat Enterprise Linux 7.4: 3.10.0-693.5.2.0.1.el7.x86_64 or later
5、SUSE Linux Enterprise Server 12 SP3: 4.4.103-92.56-default or later
以下为脚本所有内容,请参阅!
#!/bin/bash
#script_name: oracle19c_pdb_install.sh
#Author: Danrtsey.Shun
#Email:mydefiniteaim@126.com
#auto_install_oracle19c version=12.2.0.3
#################### Steup 1 Install oracle software ####################
# attentions1:
# 1.上传19c软件安装包至随意路径下,脚本提示路径是 /opt
#
# LINUX.X64_193000_db_home.zip
#
# 2.预设oracle用户的密码为 Danrtsey.com 请根据需要修改
#####################################
#ORACLE_OS_PWD= #
#if [ "$ORACLE_OS_PWD" = "" ]; then #
# ORACLE_OS_PWD="Danrtsey.com" #
#fi #
#####################################
# 3.选择数据库字符集与国家字符集
# CharacterSet: ZHS16GBK or AL32UTF8
# NationalCharacterSet: AL16UTF16 or UTF8
# 4.执行
# chmod + oracle19c_pdb_install.sh
# sh -x oracle19c_pdb_install.sh
#
#################### Steup 2 Install oracle listener & dbca ####################
# attentions2:
########################################
# 1.according to the different environment to set the processes && sessions value
# alter system set processes=1000 scope=spfile;
# alter system set sessions=1522 scope=spfile;
########################################
export PATH=$PATH
#Source function library.
. /etc/init.d/functions
#Require root to run this script.
uid=`id | cut -d\( -f1 | cut -d= -f2`
if [ $uid -ne 0 ];then
action "Please run this script as root." /bin/false
exit 1
fi
##set oracle password
ORACLE_OS_PWD=
if [ "$ORACLE_OS_PWD" = "" ]; then
ORACLE_OS_PWD="Danrtsey.com"
fi
###install require packages
echo -e "\033[34mInstallNotice >>\033[0m \033[32moracle install dependency \033[05m...\033[0m"
yum -y install epel-release
cp /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.bak
cp /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.bak
sed -e 's!^metalink=!#metalink=!g' \
-e 's!^#baseurl=!baseurl=!g' \
-e 's!//download\.fedoraproject\.org/pub!//mirrors.tuna.tsinghua.edu.cn!g' \
-e 's!http://mirrors\.tuna!https://mirrors.tuna!g' \
-i /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo
yum makecache fast
yum -y install gcc gcc-c++ make binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-common \
glibc-devel libaio libaio-devel libgcc libstdc++ libstdc++-devel unixODBC unixODBC-devel elfutils-libelf-devel-static \
numactl-devel sysstat pcre-devel readline compat-libcap1 libXi libXtst libxcb ksh \
zip unzip tree vim lrzsz net-tools wget ntpdate ntp
if [[ $? == 0 ]];then
echo -e "\033[34mInstallNotice >>\033[0m \033[32myum install dependency successed\033[0m"
else
echo -e "\033[34mInstallNotice >>\033[0m \033[32myum install dependency faild, pls check your network\033[0m"
exit
fi
###set firewalld & optimize the os system & set selinux
echo "################# Optimize system parameters ##########################"
firewall_status=`systemctl status firewalld | grep Active |awk '{print $3}'`
if [ ${firewall_status} == "(running)" ];then
firewall-cmd --permanent --zone=public --add-port=1521/tcp && firewall-cmd --reload
else
systemctl start firewalld
firewall-cmd --permanent --zone=public --add-port=1521/tcp && firewall-cmd --reload
fi
SELINUX=`cat /etc/selinux/config |grep ^SELINUX=|awk -F '=' '{print $2}'`
if [ ${SELINUX} == "enforcing" ];then
sed -i "s@SELINUX=enforcing@SELINUX=disabled@g" /etc/selinux/config
else
if [ ${SELINUX} == "permissive" ];then
sed -i "s@SELINUX=permissive@SELINUX=disabled@g" /etc/selinux/config
fi
fi
setenforce 0
echo "================更改为中文字符集================="
\cp /etc/locale.conf /etc/locale.conf.$(date +%F)
cat >>/etc/locale.conf<<EOF
LANG="zh_CN.UTF-8"
#LANG="en_US.UTF-8"
EOF
source /etc/locale.conf
grep LANG /etc/locale.conf
action "更改字符集zh_CN.UTF-8完成" /bin/true
echo "================================================="
echo ""
###set the ip in hosts
echo "############################ Ip&Hosts Configuration #######################################"
hostname=`hostname`
HostIP=`ip a|grep 'inet '|grep -v '127.0.0.1'|awk '{print $2}'|awk -F '/' '{print $1}'`
for i in ${HostIP}
do
A=`grep "${i}" /etc/hosts`
if [ ! -n "${A}" ];then
echo "${i} ${hostname}" >> /etc/hosts
else
break
fi
done
###create group&user
echo "############################ Create Group&User #######################################"
ora_user=oracle
ora_group=('oinstall' 'dba' 'oper')
for i in ${ora_group[@]}
do
B=`grep '${i}' /etc/group`
if [ ! -n ${B} ];then
groupdel ${i} && groupadd ${i}
else
groupadd ${i}
fi
done
C=`grep 'oracle' /etc/passwd`
if [ ! -n ${C} ];then
userdel -r ${ora_user} && useradd -u 501 -g ${ora_group[0]} -G ${ora_group[1]},${ora_group[2]} ${ora_user}
else
useradd -u 501 -g ${ora_group[0]} -G ${ora_group[1]},${ora_group[2]} ${ora_user}
fi
echo "${ORACLE_OS_PWD}" | passwd --stdin ${ora_user}
###create directory and grant priv
echo "############################ Create DIR & set privileges & set OracleSid ##################"
echo "############################ Create OracleBaseDi #######################################"
echo "############################ Create OracleHomeDir #######################################"
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(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:/u01/oracle):" S1
read -p "Please input the ORACLE_BASE again(/u01/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:/u01/oracle/product/19c/dbhome_1):" S1
read -p "Please input the ORACLE_HOME again(/u01/oracle/product/19c/dbhome_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} ];
