Oracle 21C安装包下载地址
https://www.oracle.com/database/technologies/oracle-database-software-downloads.html
Oracle 21C文档位置
https://docs.oracle.com/en/database/oracle/oracle-database/index.html
Database Installation Guide for Linux
https://docs.oracle.com/en/database/oracle/oracle-database/21/ladbi/database-installation-guide-linux.pdf
准备安装环境:
操作系统版本:Redhat 7.6
cd /home/oracle
touch install_db01.sh
chmod a+x install_db01.sh
vim install_db01.sh
#!/bin/bash
SPATH=/soft
DATAPATH=/oradata
FS_TYPE=ext4
ORABASE=/oracle/product
FNAME=LINUX.X64_213000_db_home.zip
MT_PT=/oracle
ORAlnven=/oracle
TPATH=/home/oracle
ORAHOME=/oracle/product/21.3/db
mem=$(free -g | grep Mem | awk {'print $2'})
shm=$((mem*1024*1024*819))
mall=$((shm/4096))
sga=$((mem*512))M
pga=$((mem*153))M
cpu=$(cat proc/cpuinfo | grep process|wc -l)
install_database_log=$TPATH/install_database.log
install_database_rsp_file=$TPATH/install_database.rsp
#
##############################################################
## Step 2: create oracle path
##############################################################
env_info(){
echo "Os:" `cat etc/system-release`
echo `grep MemTotal proc/meminfo`
grep SwapTotal proc/meminfo
df -h tmp
free -g
df -h dev/shm
echo "Processor architecture: " `uname -m`
}
mk_path(){
mkdir -p "$MT_PT"
mkdir -p "$DATAPATH"
}
##############################################################
## Step 3: Change os properties
##############################################################
change_os(){
if [[ -f usr/lib/systemd/system/ctrl-alt-del.target ]]; then
rm -f usr/lib/systemd/system/ctrl-alt-del.target
init q
systemctl stop firewalld
systemctl stop avahi-daemon
systemctl stop bluetooth
systemctl disable firewalld
systemctl disable avahi-daemon
systemctl disable bluetooth
echo "OS has been changed"
else
echo "OS has been changed!!!!"
fi
}
add_user(){
id oracle
if [[ $? == 0 ]]; then
echo "Oracle user has been add!!!!!!"
else
#user and group
groupadd -g 301 oinstall
groupadd -g 300 dba
groupadd -g 303 oper
groupadd -g 307 backupdba
groupadd -g 308 dgdba
groupadd -g 309 kmdba
useradd -m -d /home/oracle -u 500 -g oinstall -G dba,oper,backupdba,dgdba,kmdba oracle
mkdir -p $ORAHOME
chown -R oracle:oinstall /oracle
echo 'oracle' | passwd oracle --stdin
cp /etc/profile /etc/profile_org
cat /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
export HISTTIMEFORMAT="%F %T "
export HISTSIZE=10000
eof
cat /home/oracle/.bash_profile
export ORACLE_BASE=/oracle/product
export ORACLE_HOME=$ORAHOME
export PATH=\$PATH:\$ORACLE_HOME/bin:\$ORACLE_HOME/OPatch:\$ORACLE_HOME/suptools/oratop
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:\$LD_LIBRARY_PATH
export ORACLE_SID=$DBNAME
alias cdo='cd \$ORACLE_HOME'
alias cdb='cd \$ORACLE_HOME/dbs'
alias cdn='cd \$ORACLE_HOME/network/admin'
alias cdal='cd \$ORACLE_BASE/diag/rdbms/*/$DBNAME/trace'
alias sqp='sqlplus / as sysdba'
eof
echo "User has been changed"
fi
}
change_param(){
if [[ $(cat /etc/sysctl.conf | grep 'oracle parameter' |wc -l) == 1 ]]; then
echo "Parameter has been changed!!!!!!"
else
cp /etc/sysctl.conf /etc/sysctl.conf_orig
cat /etc/sysctl.conf
##oracle parameter
kernel.shmmni = 4096
kernel.shmall = $mall
kernel.shmmax = $shm
fs.aio-max-nr = 1048576
fs.file-max = 6815744
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 = 1048586
net.ipv4.ipfrag_high_thresh = 16777216
net.ipv4.ipfrag_low_thresh = 15728640
kernel.panic_on_oops = 1
kernel.randomize_va_space = 0
vm.min_free_kbytes= 524288
vm.swappiness =10
eof
sysctl -p
cat /etc/security/limits.conf
##oracle parameter
* - memlock unlimited
* soft memlock unlimited
* hard memlock unlimited
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft nofile 65536
oracle hard nofile 65536
oracle soft stack 10240
eof
sed -i -e "s/4096/16384/g" /etc/security/limits.d/20-nproc.conf
cp /etc/pam.d/login /etc/pam.d/login_orig
echo "session required pam_limits.so" >> /etc/pam.d/login
echo "RemoveIPC=no" >> /etc/systemd/logind.conf
systemctl daemon-reload
systemctl restart systemd-logind
echo "Parameter has been changed"
fi
}
disable_thp(){
if [[ $(cat /etc/default/grub | grep 'transparent_hugepage=never' |wc -l) == 1 ]]; then
echo "THP has been disabled !!!!!!!"
else
cp /etc/default/grub /etc/default/grub_orig
cat /etc/default/grub
sed -i 's#rhgb quiet#rhgb quiet transparent_hugepage=never NUMA=off#' /etc/default/grub
#普通启动方式
grub2-mkconfig -o /boot/grub2/grub.cfg
#efi模式
# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
if [[ $? != 0 ]]; then
echo "THP change failed, Please manual change!"
else
echo "THP has been disabled!!!"
fi
fi
}
unzip_soft(){
chown oracle:oinstall $SPATH/$FNAME
echo "Begin unzip......"
su - oracle -c "unzip -qo $SPATH/$FNAME -d $ORAHOME"
}
env_info
mk_path
change_os
add_user
change_param
unzip_soft
nohup ./install_db01.sh > 01.log &
开始安装数据库:
su - oracle
[oracle@cjc db]$ pwd
/oracle/product/21.3/db
[oracle@cjc db]$ ./runInstaller
[oracle@cjc db]$ source /home/oracle/.bash_profile
[oracle@cjc db]$ sqlplus -v
SQL*Plus: Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
[oracle@cjc db]$ netca
[oracle@cjc db]$ dbca
EM:
https://CJC:5500/em
#####chenjuchao 2021-08-27 18:00#####