Oracle静默安装

1.安装前准备

1.1.关闭防火墙和SELINUX

systemctl stop firewalld
systemctl disable firewalld
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

1.2.修改主机名

vi /etc/hostname

1.3.添加hosts解析

vi /etc/hosts
#----------------------------------------------------------
192.168.3.100   oracletest
#----------------------------------------------------------

1.4.关闭透明大页

cd /etc/default/
cp grub grub.bak
vi grub
#----------------------------------------------------------
GRUB_CMDLINE_LINUX="spectre_v2=retpoline rhgb quiet"
# 修改为
GRUB_CMDLINE_LINUX="spectre_v2=retpoline rhgb quiet transparent_hugepage=never"
#----------------------------------------------------------
# On BIOS-based machines(安装系统时使用传统 BIOS的改法):
grub2-mkconfig -o /boot/grub2/grub.cfg
# On UEFI-based machines(安装系统时使用UEFI-BIOS时的改法):
grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

1.5.修改内核参数

cp /etc/sysctl.conf /etc/sysctl.conf.bak
echo "#oracle" >> /etc/sysctl.conf
echo "kernel.shmmni = 4096" >> /etc/sysctl.conf
echo "fs.aio-max-nr = 1048576" >> /etc/sysctl.conf
echo "fs.file-max = 6815744" >> /etc/sysctl.conf
echo "kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf
echo "net.ipv4.ip_local_port_range = 9000 65500" >> /etc/sysctl.conf
echo "net.core.rmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.rmem_max = 4194304" >> /etc/sysctl.conf
echo "net.core.wmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.wmem_max = 1048586" >> /etc/sysctl.conf
echo "vm.swappiness = 10" >> /etc/sysctl.conf
echo "kernel.shmmax= $(free|grep Mem |awk '{print int($2*1024*0.66)}')" >> /etc/sysctl.conf
echo "kernel.shmall = $(free|grep Mem |awk '{print int(($2*1024*0.67)/4096)}')" >> /etc/sysctl.conf
echo "vm.nr_hugepages = $(free -m|grep Mem |awk '{print int(($2*0.65)/2)}')" >> /etc/sysctl.conf
free -m
sysctl -p

1.6.修改用户限制

echo "#oracle" >> /etc/security/limits.conf
echo "oracle soft nproc 2047" >> /etc/security/limits.conf
echo "oracle hard nproc 16384" >> /etc/security/limits.conf
echo "oracle soft nofile 1024" >> /etc/security/limits.conf
echo "oracle hard nofile 65536" >> /etc/security/limits.conf
echo "* soft memlock $(free |grep Mem|awk '{print int($2*0.67)}')" >> /etc/security/limits.conf
echo "* hard memlock $(free |grep Mem|awk '{print int($2*0.67)}')" >> /etc/security/limits.conf

1.7.添加oracle profile

cat >> /etc/profile <<EOF
if [ \$USER = "oracle" ]; then
    if [ \$SHELL = "/bin/ksh" ]; then
       ulimit -u 16384
       ulimit -n 65536
    else
       ulimit -u 16384 -n 65536
    fi
fi
EOF

1.8.创建用户

#create user
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/useradd -g oinstall -G dba oracle
echo "oracle" | passwd --stdin oracle

1.9.配置yum源

# lsblk查看挂在到服务器的系统镜像
lsblk
# 挂载
mount /dev/sr0 /mnt
cd /etc/yum.repos.d/
vi local.repo
#-------------------------------------------------
[base]
name = local
baseurl = file:///mnt
gpgcheck=0
enable = 1
#-------------------------------------------------

1.10.重启主机

reboot

2.安装

2.1.上传软件包

cd /data
mkdir soft
chmod 777 soft
# 以oracle用户的身份把安装文件上传到soft中

2.2.创建oracle_base,oracle_home

mkdir -p /oracle/11204
chown -R oracle.oinstall /oracle
chown -R oracle.oinstall /oradata

2.3.安装依赖包

compat-libstdc++包在系统镜像中不存在,无法使用yum安装,可以去这里下载,之后上传到服务器安装。pdksh不是必须的,可以忽略。

cd /data/soft/
yum install compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
yum install -y unzip gcc libaio libaio-devel elfutils-libelf-devel glibc-devel glibc-headers gcc-c++ libstdc++-devel sysstat pdksh

2.3.配置环境变量

cat >> /home/oracle/.bash_profile <<EOF
export TMP=/tmp
export LANG=en_US
export TMPDIR=$TMP
export ORACLE_UNQNAME=oracle
export ORACLE_SID=orcl
export ORACLE_BASE=/oracle
export ORACLE_HOME=/oracle/11204
export ORACLE_TERM=xterm
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export PATH=\$PATH:\$ORACLE_HOME/bin:\$ORACLE_HOME/OPatch
export THREADS_FLAG=native
umask=022
EOF
source .bash_profile

2.4.安装软件

2.4.1.自定义db_install.rsp
# 解压安装介质
unzip p13390677_112040_Linux-x86-64_1of7.zip
unzip p13390677_112040_Linux-x86-64_2of7.zip
cd database/response
# 下面的dbca.rsp  db_install.rsp  netca.rsp就是静默安装的模板文件
# 自定义的db_install.rsp文件
cat >> db_install.rsp <<EOF
#软件版本信息
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
#安装选项-仅安装数据库软件
oracle.install.option=INSTALL_DB_SWONLY
#主机名称
ORACLE_HOSTNAME=oracle
#oracle用户用于安装软件的组名
UNIX_GROUP_NAME=oinstall
#oracle产品清单目录
INVENTORY_LOCATION=/oracle/oraInventory
#oracle运行语言环境
SELECTED_LANGUAGES=en
#oracle家目录
ORACLE_HOME=/oracle/11204
#oracle基础目录
ORACLE_BASE=/oracle
#安装版本类型:企业版
oracle.install.db.InstallEdition=EE
#不手动指定企业安装组件
oracle.install.db.EEOptionsSelection=false
#当EEOptionsSelection=false时,该参数不用填写
oracle.install.db.optionalComponents=
#指定拥有DBA组
oracle.install.db.DBA_GROUP=dba
#指定oper用户组
oracle.install.db.OPER_GROUP=oinstall
#不配置安全更新
DECLINE_SECURITY_UPDATES=true
#跳过更新
oracle.installer.autoupdates.option=SKIP_UPDATES
EOF
2.4.2.静默安装
cd /data/soft/database/
# 注意db_install.rsp不能是相对路径,noconfig意思是不配置数据库,ignoreprereq忽略oracle安装要求检查
./runInstaller -silent -noconfig -ignorePrereq -responseFile /data/soft/db_install.rsp

image-20240610165756119

# root用户执行
sh /oracle/oraInventory/orainstRoot.sh
sh /oracle/11204/root.sh

image-20240610165905048

2.4.3.卸载
# oracle用户执行
cd $ORACLE_HOME/deinstall/
./deinstall
# root用户执行
rm -f /usr/local/bin/dbhome
rm -f /usr/local/bin/oraenv
rm -f /usr/local/bin/coraenv

2.5.静默配置监听

cp /data/soft/database/response/netca.rsp /data/soft/
netca -silent -responsefile /data/soft/netca.rsp

2.6.创建数据库

2.6.1.自定义dbca.rsp
cat >> dbca.rsp <<EOF
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"

[CREATEDATABASE]
GDBNAME = "orcl"
SID = "orcl"
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "monkey"
SYSTEMPASSWORD = "monkey"
EMCONFIGURATION = "NONE"
DATAFILEDESTINATION = "/oradata"
CHARACTERSET = "AL32UTF8"
INITPARAMS = "processes=500,audit_trail=none"
AUTOMATICMEMORYMANAGEMENT = "false"
EOF

如果上面的选项无法完全满足要求,可以修改$ORACLE_HOME/assistants/dbca/templates下的General_Purpose.dbc。

2.6.2.静默安装
dbca -silent -responseFile /data/soft/dbca.rsp

image-20240610170847599

2.6.3.调整参数文件

根据需要调整参数文件,例如db_files,control_files,sga_target,pga_aggregate_target等

2.6.4.静默删除数据库
$ORACLE_HOME/bin/dbca -silent -deleteDatabase -sourceDB orcl

3.图形化生成文件

3.1.软件安装rsp

3.2.数据库生成模板文件


会在$ORACLE_HOME/assistants/dbca/templates目录下生成mydbca.dbc模板文件

posted @ 2024-06-10 18:31  monkey6  阅读(203)  评论(0编辑  收藏  举报