快速开始
OracleShellInstall 是一款 Oracle 数据库一键自动化安装脚本,支持 Oracle 11gR2 至 26ai 全版本,覆盖 20+ Linux 发行版。脚本会自动完成操作系统参数配置、依赖包安装、用户创建、Oracle 软件安装及数据库创建全流程。
三步安装
- 上传软件包 - 将
OracleShellInstall.sh 脚本和 Oracle 安装介质上传至服务器 /soft 目录
- 配置参数 - 使用 命令生成器 或手动拼接安装参数
- 执行安装 - 在
/soft 目录下以 root 用户执行生成的命令
注意:脚本必须以 root 用户执行,且需要在软件包所在目录下运行。Bash 版本需 >= 4。
环境准备
目录结构
将以下文件放置在 /soft 目录下:
/soft/
OracleShellInstall.sh # 安装脚本
LINUX.X64_193000_db_home.zip # Oracle 安装介质 (以19c为例)
p35940989_190000.zip # PSU/RU 补丁 (可选)
p35926646_190000.zip # OJVM 补丁 (可选)
p6880880_190000.zip # OPatch (可选,补丁需要)
系统要求
- 支持的操作系统:CentOS 7/8、RHEL 7/8/9、OracleLinux、Rocky Linux、Anolis OS、openEuler、麒麟 Kylin、统信 UOS、Ubuntu、Debian 等
- Bash 版本 >= 4
- 建议内存 >= 2GB(生产环境建议 >= 8GB)
- 磁盘空间:Oracle 软件至少 15GB,数据文件根据业务需求规划
- 网络:确保 yum/dnf/apt 软件源可用,或使用本地源 (
-lrp Y)
- SELinux:脚本会自动关闭 SELinux,无需手动处理
- 防火墙:脚本会自动关闭防火墙,如需保留请安装后自行配置
不同 Oracle 版本需要的安装介质文件不同,请根据目标版本准备对应的安装包。脚本会自动识别 /soft 目录下的 ZIP 文件。
提示:19c 及以上版本安装包只需一个 ZIP 文件。11gR2 需要多个分卷文件。补丁文件(PSU/RU/OJVM)和 OPatch 工具放置在同一目录即可,脚本会自动识别。
工作原理
OracleShellInstall 脚本按照以下流程自动完成整个安装过程:
执行流程
- 参数校验 - 验证所有输入参数的合法性,检查必填项,校验密码格式
- 环境检测 - 识别操作系统类型和版本,检测 CPU 架构,检查磁盘空间
- OS 配置 - 配置主机名、hosts、内核参数、资源限制、关闭 SELinux/防火墙、配置 NTP 时间同步
- 依赖安装 - 根据 OS 类型自动配置软件源,安装 Oracle 所需的依赖包
- 用户创建 - 创建 oracle/grid 用户及 oinstall、dba、asmadmin 等用户组,配置环境变量
- 目录准备 - 创建 ORACLE_BASE、ORACLE_HOME 等目录结构并设置权限
- 磁盘配置 (ASM/RAC) - 通过 UDEV 规则或 multipath 配置 ASM 磁盘
- Grid 安装 (ASM/RAC) - 解压并安装 Grid Infrastructure,创建 ASM 磁盘组
- SSH 互信 (RAC) - 在所有节点间建立 root、oracle、grid 用户的 SSH 无密码登录
- 数据库软件安装 - 解压 Oracle 安装介质,静默安装数据库软件
- 补丁应用 (可选) - 应用 PSU/RU、OJVM 补丁
- 数据库创建 - 使用 DBCA 静默创建数据库实例,创建 PDB(如指定)
- 安装后配置 - 配置自动启动、优化参数(如指定)、配置大页内存(如指定)
日志文件
安装过程中会生成两个日志文件:
print_shell_install_*.log - 安装摘要日志,记录关键步骤的执行结果
shell_install_output_*.log - 详细输出日志,记录所有命令的标准输出和错误输出
日志位置:日志文件生成在脚本执行的当前目录(通常为 /soft),文件名包含时间戳,便于区分多次安装。
单机安装
单机模式基于文件系统存储,适用于开发测试及中小型业务场景。
最简安装
sh OracleShellInstall.sh \
-install_mode single `# 单机模式`\
-lf eth0 `# 公网网卡名称`
以上命令使用全部默认值安装:数据库名 orcl,字符集 AL32UTF8,安装目录 /u01,数据目录 /oradata。
自定义安装
sh OracleShellInstall.sh \
-install_mode single `# 单机模式`\
-lf eth0 `# 公网网卡名称`\
-n oracledb `# 主机名`\
-o prod `# 数据库名称`\
-dp 'Passw0rd#' `# 数据库密码`\
-ds ZHS16GBK `# 字符集`\
-pdb pdb01,pdb02 `# 创建多个 PDB`\
-opd Y `# 优化数据库参数`
单机 ASM 安装
单机 ASM 模式需要 Grid Infrastructure 和 ASM 磁盘。脚本会自动配置 UDEV 绑盘或 multipath。
sh OracleShellInstall.sh \
-install_mode standalone `# 单机 ASM 模式`\
-lf eth0 `# 公网网卡名称`\
-dd /dev/sdb,/dev/sdc `# DATA 磁盘`
提示:如果不使用 multipath,可设置 -mp N,脚本将使用 UDEV 直接绑盘。如果已自行配置好 ASM 磁盘,可设置 -adc N 并传入已配置好的磁盘路径。
自定义 ASM 安装
sh OracleShellInstall.sh \
-install_mode standalone `# 单机 ASM 模式`\
-lf eth0 `# 公网网卡名称`\
-o prod `# 数据库名称`\
-dp 'Passw0rd#' `# 数据库密码`\
-mp N `# 不使用 multipath`\
-dd /dev/sdb,/dev/sdc,/dev/sdd `# 3 块 DATA 磁盘`\
-dn DATADG `# 自定义磁盘组名`\
-dr NORMAL `# NORMAL 冗余`\
-gpa 35940989 `# Grid 补丁`\
-opa 35940989 `# Oracle 补丁`
注意:NORMAL 冗余至少需要 3 块磁盘,HIGH 冗余至少需要 5 块磁盘。EXTERNAL 冗余为外部冗余(不做镜像),仅需 1 块磁盘。
RAC 集群安装
RAC 模式需要在第一个节点上执行脚本,脚本会自动配置所有节点的 SSH 互信、Grid 安装、ASM 磁盘及数据库创建。
RAC 前置条件:
- 所有节点的 root 密码必须一致
- 所有节点需配置公网和心跳网络,且网络互通
- 共享磁盘需在所有节点上可见(SAN/iSCSI/共享 VMDK 等)
- 脚本仅需在第一个节点执行,会自动同步到其他节点
基础 2 节点 RAC
sh OracleShellInstall.sh \
-install_mode rac `# RAC 集群模式`\
-lf eth0 `# 公网网卡`\
-pf eth1,eth2 `# 心跳网卡`\
-n orcl `# 主机名前缀`\
-hn orcl01,orcl02 `# 所有节点主机名`\
-ri 10.0.0.101,10.0.0.102 `# 公网 IP`\
-vi 10.0.0.103,10.0.0.104 `# 虚拟 IP`\
-si 10.0.0.105 `# Scan IP`\
-rp 'rootPasswd' `# root 密码`\
-od /dev/sdb `# OCR 磁盘`\
-dd /dev/sdc `# DATA 磁盘`
生产环境 RAC(含 ARCH 磁盘组和补丁)
sh OracleShellInstall.sh \
-install_mode rac `# RAC 集群模式`\
-lf ens192 `# 公网网卡`\
-pf ens224,ens256 `# 双心跳网卡`\
-n dbprod `# 主机名前缀`\
-hn dbprod01,dbprod02 `# 节点主机名`\
-ri 192.168.1.101,192.168.1.102 `# 公网 IP`\
-vi 192.168.1.103,192.168.1.104 `# 虚拟 IP`\
-si 192.168.1.105 `# Scan IP`\
-rp 'R00t#2024' `# root 密码`\
-o proddb `# 数据库名称`\
-dp 'Oracle#2024' `# 数据库密码`\
-ds ZHS16GBK `# 中文字符集`\
-od /dev/sdb,/dev/sdc,/dev/sdd `# OCR 磁盘`\
-or NORMAL `# OCR NORMAL 冗余`\
-dd /dev/sde,/dev/sdf,/dev/sdg `# DATA 磁盘`\
-dr NORMAL `# DATA NORMAL 冗余`\
-ad /dev/sdh,/dev/sdi `# ARCH 归档磁盘`\
-ar EXTERNAL `# ARCH 冗余`\
-gpa 35940989 `# Grid 补丁`\
-opa 35940989 `# Oracle 补丁`\
-jpa 35926646 `# OJVM 补丁`\
-opd Y `# 优化数据库参数`\
-hf Y `# 配置大页内存`
提示:生产环境建议 OCR 磁盘组使用 NORMAL 冗余(至少 3 块磁盘),并配置独立的 ARCH 磁盘组用于归档日志。
高级用法
分步安装
在某些场景下,可能需要将安装过程拆分为多个步骤独立执行:
仅配置操作系统
sh OracleShellInstall.sh \
-install_mode single \
-lf eth0 \
-m Y `# 仅完成 OS 配置,不安装 Oracle`
适用于需要先检查 OS 配置是否正确,或需要在 OS 配置后做额外手动调整的场景。
安装到 DB 软件结束
sh OracleShellInstall.sh \
-install_mode single \
-lf eth0 \
-ud Y `# 安装到 DB 软件结束,不创建数据库`
适用于需要手动创建数据库(如使用自定义模板或特殊配置)的场景。
RAC 安装到 Grid 结束
sh OracleShellInstall.sh \
-install_mode rac \
-lf eth0 -pf eth1 \
-hn orcl01,orcl02 -ri 10.0.0.101,10.0.0.102 \
-vi 10.0.0.103,10.0.0.104 -si 10.0.0.105 \
-rp 'rootPasswd' -od /dev/sdb -dd /dev/sdc \
-ug Y `# 安装到 Grid 结束,不继续安装 DB`
一键打补丁
将补丁文件和 OPatch 工具放入 /soft 目录,通过参数指定补丁编号即可自动应用:
/soft/
OracleShellInstall.sh
LINUX.X64_193000_db_home.zip # Oracle 安装介质
p35940989_190000_Linux-x86-64.zip # PSU/RU 补丁
p35926646_190000_Linux-x86-64.zip # OJVM 补丁
p6880880_190000_Linux-x86-64.zip # OPatch 最新版
说明:OPatch 工具 (p6880880) 是应用补丁的前置条件。脚本会自动替换 ORACLE_HOME 下的旧版 OPatch。如果仅安装不打补丁,则无需 OPatch 文件。
多实例安装
通过 -o 参数传入多个数据库名(逗号分隔),可在同一主机上创建多个数据库实例:
sh OracleShellInstall.sh \
-install_mode single \
-lf eth0 \
-o proddb,testdb `# 创建两个数据库实例`
VirtualBox 环境
在 VirtualBox 虚拟机中安装 ASM/RAC 时,需要添加 -vbox Y 参数来修复 VirtualBox 的 SCSI 磁盘识别问题:
sh OracleShellInstall.sh \
-install_mode standalone \
-lf eth0 \
-dd /dev/sdb \
-vbox Y `# VirtualBox 环境修复`
安装验证
安装完成后,可通过以下方式验证安装是否成功:
单机/Standalone 验证
检查监听状态
su - oracle
lsnrctl status
应看到监听器处于 READY 状态,服务已注册。
检查数据库状态
sqlplus / as sysdba
SELECT instance_name, status FROM v$instance;
SELECT name, open_mode FROM v$database;
SELECT name, open_mode FROM v$pdbs; -- 如有 PDB
数据库状态应为 OPEN,PDB 状态应为 READ WRITE。
检查 ASM(Standalone/RAC)
su - grid
asmcmd lsdg
应显示所有磁盘组的状态为 MOUNTED,可用空间正常。
RAC 集群验证
检查集群状态
su - grid
crsctl stat res -t
所有资源应为 ONLINE 状态。
检查集群节点
olsnodes -n
crsctl check cluster -all
检查 Scan VIP
srvctl status scan
srvctl status scan_listener
srvctl status database -d proddb
提示:如果安装中使用了 -opd Y 优化参数,可通过 SHOW PARAMETER 确认 SGA/PGA 等参数已按预期配置。
通用参数
| 参数 | 说明 | 默认值 |
| -lf | 公网 IP 的网卡名称(必填) | - |
| -n | 主机名(单机为主机名,RAC 为主机名前缀) | orcl |
| -o | 数据库名称,支持多实例:orcl,oradb | orcl |
| -d | Oracle 软件安装根目录 | /u01 |
| -ou | 系统 oracle 用户名称 | oracle |
| -op | 系统 oracle 用户密码,特殊字符需单引号包裹 | oracle |
| -dp | 数据库 sys/system 密码,需字母开头,可含 _#$ | oracle |
| -ds | 数据库字符集 | AL32UTF8 |
| -ns | 数据库国家字符集 | AL16UTF16 |
| -dbs | 数据库块大小:2048/4096/8192/16384/32768 | 8192 |
| -redo | Redo 日志文件大小(MB) | 1024 |
| -er | 启用归档模式:true/false | true |
| -pdb | PDB 名称(设置后自动启用 CDB 架构),多个逗号分隔 | pdb01 |
| -ord | 数据文件目录(单机模式) | /oradata |
| -ard | 归档文件目录(单机模式) | /oradata/archivelog |
| -lrp | 配置本地软件源(Y/N) | Y |
| -nrp | 配置网络软件源(Y/N) | N |
| -gui | 安装系统图形界面(Y/N) | N |
| -opd | 优化数据库参数(Y/N) | N |
| -hf | 配置大页内存(Y/N) | N |
| -m | 仅配置操作系统(Y/N) | N |
| -ud | 安装到 DB 软件结束(Y/N) | N |
| -opa | Oracle PSU/RU 补丁编号 | - |
| -jpa | OJVM PSU/RU 补丁编号 | - |
ASM 相关参数
| 参数 | 说明 | 默认值 |
| -gu | 系统 grid 用户名称 | grid |
| -gp | 系统 grid 用户密码 | oracle |
| -adc | 是否由脚本配置 ASM 磁盘(Y/N) | Y |
| -mp | 配置 multipath 多路径(Y/N) | Y |
| -dd | DATA 磁盘组的磁盘列表(必填) | - |
| -dn | DATA 磁盘组名称 | DATA |
| -dr | DATA 磁盘组冗余度:EXTERNAL/NORMAL/HIGH | EXTERNAL |
| -gpa | Grid PSU/RU 补丁编号 | - |
| -vbox | VirtualBox 环境修复(Y/N) | N |
RAC 专属参数
| 参数 | 说明 | 默认值 |
| -pf | 心跳网卡名称,多组逗号分隔(必填) | - |
| -hn | 所有节点主机名,按顺序逗号分隔(必填) | - |
| -ri | 所有节点公网 IP(必填) | - |
| -vi | 所有节点虚拟 IP(必填) | - |
| -si | Scan IP 地址(必填) | - |
| -rp | root 用户密码,所有节点需一致(必填) | - |
| -cn | 集群名称(不超过15位) | 主机名前缀-cluster |
| -sn | Scan 名称 | 主机名前缀-scan |
| -od | OCR 磁盘组的磁盘列表(必填) | - |
| -ad | ARCH 磁盘组的磁盘列表 | - |
| -on/-or | OCR 磁盘组名称/冗余度 | OCR / EXTERNAL |
| -an/-ar | ARCH 磁盘组名称/冗余度 | ARCH / EXTERNAL |
| -tsi | CTSS 时间服务器 IP | - |
| -dns | 是否配置 DNS(多个 Scan IP 时需要) | N |
| -dnsn | DNS 服务器名称 | - |
| -dnsi | DNS 服务器 IP | - |
| -ug | 安装到 Grid 软件结束(Y/N) | N |
故障排查
安装失败的通用排查步骤
- 查看安装摘要日志:
cat /soft/print_shell_install_*.log
- 查看详细输出日志:
cat /soft/shell_install_output_*.log
- 定位失败的具体步骤和错误信息
- 修复问题后,使用
-m Y 跳过 OS 配置重新执行
常见错误及解决方案
依赖包安装失败
错误表现:提示 yum/dnf 无法安装某些 RPM 包。
解决方案:
- 检查是否配置了正确的软件源,或使用
-lrp Y 配置本地源
- 如需网络源,设置
-nrp Y,确保服务器可访问外网
- 对于国产系统(麒麟、统信),确保系统自带软件源完整
ASM 磁盘无法发现
错误表现:Grid 安装完成后 ASM 无法发现磁盘设备。
解决方案:
- 检查磁盘设备是否存在:
ls -l /dev/sd*
- 确认磁盘未被分区或挂载:
lsblk
- 检查 UDEV 规则是否生效:
ls -l /dev/oracleasm/
- 如使用 multipath,检查多路径配置:
multipath -ll
- VirtualBox 环境必须添加
-vbox Y 参数
RAC SSH 互信失败
错误表现:节点间无法建立 SSH 连接,提示 Permission denied。
解决方案:
- 确认所有节点 root 密码一致
- 检查
/etc/ssh/sshd_config 是否允许 root 登录和密码认证
- 确认所有节点间网络互通:
ping 测试公网和心跳 IP
内存不足导致 DBCA 失败
错误表现:创建数据库时提示内存不足或 ORA-00845 错误。
解决方案:
- 确保可用内存 >= 2GB
- 如启用了大页内存 (
-hf Y),确保 HugePages 配置正确
- 检查
/dev/shm 是否挂载且大小足够
OPatch 版本过低
错误表现:打补丁时提示 OPatch 版本不兼容。
解决方案:下载最新的 OPatch 工具 (p6880880) 放入 /soft 目录,脚本会自动替换旧版本。
常见问题
Q: 脚本支持哪些 Oracle 安装介质格式?
脚本自动识别 Oracle 安装介质的 ZIP 包。将 ZIP 文件放置在 /soft 目录下即可,无需手动解压。
Q: 安装过程中断了怎么办?
查看安装日志文件 print_shell_install_*.log 和 shell_install_output_*.log,定位失败原因。修复后可使用 -m Y 参数跳过已完成的 OS 配置步骤。
Q: RAC 安装时节点间需要什么网络条件?
需要公网和心跳网络互通,所有节点 root 密码需一致。脚本会自动建立 SSH 互信。
Q: 数据库密码有什么要求?
数据库密码(-dp)必须以字母开头,只能包含字母、数字及 _ # $ 三种特殊字符。包含特殊字符时需用单引号包裹。
Q: 如何过滤多路径磁盘?
使用 -fd 参数可以过滤多路径磁盘,去除重复路径获取唯一盘符。例如:-fd /dev/sda 排除系统盘。
Q: 是否支持离线安装?
支持。使用 -lrp Y 参数配置本地软件源(需要系统安装 ISO),脚本会自动挂载 ISO 并配置本地 yum/dnf 源,无需外网连接。
Q: 如何在已有 Oracle 环境上安装第二个数据库?
使用 -o 参数指定新的数据库名即可。脚本会检测现有环境,跳过已完成的配置步骤。也可以使用 -m Y 跳过 OS 配置只创建数据库。
Q: 脚本是否修改了操作系统的哪些配置?
脚本会修改以下系统配置:
- 主机名和
/etc/hosts
- 内核参数 (
/etc/sysctl.conf)
- 资源限制 (
/etc/security/limits.conf)
- 关闭 SELinux 和防火墙
- 创建 oracle/grid 用户及用户组
- 配置 NTP/Chrony 时间同步
- 配置用户环境变量 (
.bash_profile)
Q: 支持 ARM 架构服务器吗?
支持。脚本会自动检测 CPU 架构(x86_64/aarch64),并使用对应的安装介质和依赖包。需要确保使用对应架构的 Oracle 安装介质。
Q: 如何卸载由脚本安装的 Oracle?
脚本不提供卸载功能。手动卸载步骤:停止数据库和监听器 → 删除 Oracle 目录 → 删除用户和用户组 → 清理系统配置 → 清理 /etc/oraInst.loc 和 /etc/oratab。
更新日志
v5.0.0 (2024-08-22)
- 支持 Oracle 26ai 版本安装
- 新增 AFD (ASM Filter Driver) 配置支持
- 新增 GIMR 配置支持
- 新增更多国产操作系统支持:华为 openEuler、中科方德 NFS、中标麒麟 NeoKylin 等
- 优化安装日志输出和进度展示
- 增强参数校验逻辑
v4.2.0 (2024-03-15)
- 支持 Oracle 21c 安装
- 新增 Rocky Linux 9、AlmaLinux 9 支持
- 新增
-hf 参数支持大页内存自动配置
- 优化 ARM (aarch64) 架构兼容性
- 修复 Ubuntu 22.04 下依赖包安装问题
v4.0.0 (2023-09-10)
- 重构脚本架构,模块化设计
- 新增 Debian/Ubuntu 系列支持
- 新增
-opd 参数支持数据库参数优化
- 新增多实例安装支持(
-o orcl1,orcl2)
- 优化 multipath 和 UDEV 磁盘绑定逻辑
v3.5.0 (2023-04-20)
- 新增统信 UOS、麒麟 Kylin V10 支持
- 新增
-nrp 参数支持网络软件源配置
- 优化 RAC 安装的 SSH 互信逻辑
- 修复 CentOS 8 Stream 兼容性问题
v3.0.0 (2022-11-01)
- 支持 Oracle 19c RAC 安装
- 新增 ASM 磁盘自动配置功能 (
-adc)
- 新增 VirtualBox 环境兼容参数 (
-vbox)
- 完善安装日志输出机制
Quick Start
OracleShellInstall is a one-click automated Oracle Database installation script supporting Oracle 11gR2 through 26ai across 20+ Linux distributions. The script automatically handles OS parameter configuration, dependency installation, user creation, Oracle software installation, and database creation.
3-Step Install
- Upload packages - Upload
OracleShellInstall.sh and Oracle installation media to the /soft directory on your server
- Configure parameters - Use the Command Generator or manually compose install parameters
- Execute - Run the generated command as
root in the /soft directory
Note: The script must be run as root user in the directory containing the installation media. Bash version >= 4 is required.
Prerequisites
Directory Structure
Place the following files in the /soft directory:
/soft/
OracleShellInstall.sh # Install script
LINUX.X64_193000_db_home.zip # Oracle media (19c example)
p35940989_190000.zip # PSU/RU patch (optional)
p35926646_190000.zip # OJVM patch (optional)
p6880880_190000.zip # OPatch (optional, needed for patches)
System Requirements
- Supported OS: CentOS 7/8, RHEL 7/8/9, OracleLinux, Rocky Linux, Anolis OS, openEuler, Kylin, UOS, Ubuntu, Debian, etc.
- Bash version >= 4
- Recommended memory >= 2GB (production >= 8GB)
- Disk space: at least 15GB for Oracle software, data files as per business requirements
- Network: ensure yum/dnf/apt package sources are available, or use local repo (
-lrp Y)
- SELinux: the script automatically disables SELinux, no manual action needed
- Firewall: the script automatically disables the firewall; re-configure after installation if needed
Different Oracle versions require different installation media files. Prepare the corresponding packages for your target version. The script automatically identifies ZIP files in the /soft directory.
Tip: Oracle 19c and above only require a single ZIP file. 11gR2 requires multiple volume files. Patch files (PSU/RU/OJVM) and the OPatch tool should be placed in the same directory; the script identifies them automatically.
How It Works
The OracleShellInstall script follows this automated workflow:
Execution Flow
- Parameter Validation - Validates all input parameters, checks required fields, verifies password format
- Environment Detection - Identifies OS type and version, detects CPU architecture, checks disk space
- OS Configuration - Configures hostname, hosts, kernel parameters, resource limits, disables SELinux/firewall, configures NTP
- Dependency Installation - Automatically configures package sources and installs Oracle-required dependencies
- User Creation - Creates oracle/grid users and groups (oinstall, dba, asmadmin, etc.), sets environment variables
- Directory Setup - Creates ORACLE_BASE, ORACLE_HOME directory structure with proper permissions
- Disk Configuration (ASM/RAC) - Configures ASM disks via UDEV rules or multipath
- Grid Installation (ASM/RAC) - Extracts and installs Grid Infrastructure, creates ASM disk groups
- SSH Trust (RAC) - Establishes passwordless SSH between all nodes for root, oracle, and grid users
- Database Software Install - Extracts Oracle media and runs silent installation
- Patch Application (optional) - Applies PSU/RU and OJVM patches
- Database Creation - Creates database instance via DBCA silent mode, creates PDBs if specified
- Post-Install Config - Configures auto-start, optimizes parameters (if specified), configures HugePages (if specified)
Log Files
Two log files are generated during installation:
print_shell_install_*.log - Installation summary log with key step results
shell_install_output_*.log - Detailed output log with all command stdout and stderr
Log location: Log files are created in the script's working directory (typically /soft), with timestamps in the filename for easy identification.
Single Instance Install
Single instance mode uses file system storage, suitable for development, testing, and small-medium business scenarios.
Minimal Install
sh OracleShellInstall.sh \
-install_mode single `# Single instance`\
-lf eth0 `# Public NIC name`
This command uses all defaults: database name orcl, character set AL32UTF8, install directory /u01, data directory /oradata.
Custom Install
sh OracleShellInstall.sh \
-install_mode single `# Single instance`\
-lf eth0 `# Public NIC name`\
-n oracledb `# Hostname`\
-o prod `# Database name`\
-dp 'Passw0rd#' `# DB password`\
-ds ZHS16GBK `# Character set`\
-pdb pdb01,pdb02 `# Create multiple PDBs`\
-opd Y `# Optimize DB params`
Standalone ASM Install
Standalone ASM mode requires Grid Infrastructure and ASM disks. The script automatically configures UDEV disk binding or multipath.
sh OracleShellInstall.sh \
-install_mode standalone `# Standalone ASM`\
-lf eth0 `# Public NIC name`\
-dd /dev/sdb,/dev/sdc `# DATA disks`
Tip: To skip multipath, set -mp N and the script will use UDEV binding directly. If you've already configured ASM disks, set -adc N and provide the configured disk paths.
Custom ASM Install
sh OracleShellInstall.sh \
-install_mode standalone `# Standalone ASM`\
-lf eth0 `# Public NIC`\
-o prod `# Database name`\
-dp 'Passw0rd#' `# DB password`\
-mp N `# Skip multipath`\
-dd /dev/sdb,/dev/sdc,/dev/sdd `# 3 DATA disks`\
-dn DATADG `# Custom diskgroup name`\
-dr NORMAL `# NORMAL redundancy`\
-gpa 35940989 `# Grid patch`\
-opa 35940989 `# Oracle patch`
Note: NORMAL redundancy requires at least 3 disks, HIGH redundancy requires at least 5 disks. EXTERNAL redundancy (no mirroring) requires only 1 disk.
RAC Cluster Install
RAC mode runs on the first node. The script automatically configures SSH trust on all nodes, installs Grid, sets up ASM disks, and creates the database.
RAC Prerequisites:
- All nodes must have the same root password
- All nodes must have public and heartbeat networks configured and reachable
- Shared disks must be visible on all nodes (SAN/iSCSI/shared VMDK, etc.)
- Only run the script on the first node; it syncs to other nodes automatically
Basic 2-Node RAC
sh OracleShellInstall.sh \
-install_mode rac `# RAC cluster`\
-lf eth0 `# Public NIC`\
-pf eth1,eth2 `# Heartbeat NICs`\
-n orcl `# Hostname prefix`\
-hn orcl01,orcl02 `# All node hostnames`\
-ri 10.0.0.101,10.0.0.102 `# Public IPs`\
-vi 10.0.0.103,10.0.0.104 `# Virtual IPs`\
-si 10.0.0.105 `# Scan IP`\
-rp 'rootPasswd' `# root password`\
-od /dev/sdb `# OCR disks`\
-dd /dev/sdc `# DATA disks`
Production RAC (with ARCH Diskgroup and Patches)
sh OracleShellInstall.sh \
-install_mode rac `# RAC cluster`\
-lf ens192 `# Public NIC`\
-pf ens224,ens256 `# Dual heartbeat NICs`\
-n dbprod `# Hostname prefix`\
-hn dbprod01,dbprod02 `# Node hostnames`\
-ri 192.168.1.101,192.168.1.102 `# Public IPs`\
-vi 192.168.1.103,192.168.1.104 `# Virtual IPs`\
-si 192.168.1.105 `# Scan IP`\
-rp 'R00t#2024' `# root password`\
-o proddb `# Database name`\
-dp 'Oracle#2024' `# DB password`\
-ds ZHS16GBK `# Character set`\
-od /dev/sdb,/dev/sdc,/dev/sdd `# OCR disks`\
-or NORMAL `# OCR NORMAL redundancy`\
-dd /dev/sde,/dev/sdf,/dev/sdg `# DATA disks`\
-dr NORMAL `# DATA NORMAL redundancy`\
-ad /dev/sdh,/dev/sdi `# ARCH archive disks`\
-ar EXTERNAL `# ARCH redundancy`\
-gpa 35940989 `# Grid patch`\
-opa 35940989 `# Oracle patch`\
-jpa 35926646 `# OJVM patch`\
-opd Y `# Optimize DB params`\
-hf Y `# Configure HugePages`
Tip: For production environments, use NORMAL redundancy for the OCR diskgroup (at least 3 disks) and configure a separate ARCH diskgroup for archive logs.
Common Parameters
| Param | Description | Default |
| -lf | Public IP network interface name (required) | - |
| -n | Hostname (single) or hostname prefix (RAC) | orcl |
| -o | Database name, supports multiple: orcl,oradb | orcl |
| -d | Oracle software installation root directory | /u01 |
| -ou | System oracle username | oracle |
| -op | System oracle user password, wrap special chars in single quotes | oracle |
| -dp | Database sys/system password, must start with letter, may contain _#$ | oracle |
| -ds | Database character set | AL32UTF8 |
| -ns | National character set | AL16UTF16 |
| -dbs | Database block size: 2048/4096/8192/16384/32768 | 8192 |
| -redo | Redo log file size (MB) | 1024 |
| -er | Enable archive mode: true/false | true |
| -pdb | PDB name (enables CDB architecture), comma-separated for multiple | pdb01 |
| -ord | Data file directory (single instance mode) | /oradata |
| -ard | Archive file directory (single instance mode) | /oradata/archivelog |
| -lrp | Configure local software repository (Y/N) | Y |
| -nrp | Configure network software repository (Y/N) | N |
| -gui | Install system GUI (Y/N) | N |
| -opd | Optimize database parameters (Y/N) | N |
| -hf | Configure HugePages (Y/N) | N |
| -m | OS configuration only (Y/N) | N |
| -ud | Install to DB software only (Y/N) | N |
| -opa | Oracle PSU/RU patch ID | - |
| -jpa | OJVM PSU/RU patch ID | - |
ASM Parameters
| Param | Description | Default |
| -gu | System grid username | grid |
| -gp | System grid user password | oracle |
| -adc | Script configures ASM disks (Y/N) | Y |
| -mp | Configure multipath (Y/N) | Y |
| -dd | DATA diskgroup disk list (required) | - |
| -dn | DATA diskgroup name | DATA |
| -dr | DATA diskgroup redundancy: EXTERNAL/NORMAL/HIGH | EXTERNAL |
| -gpa | Grid PSU/RU patch ID | - |
| -vbox | VirtualBox environment fix (Y/N) | N |
RAC Parameters
| Param | Description | Default |
| -pf | Heartbeat NIC names, comma-separated (required) | - |
| -hn | All node hostnames, comma-separated in order (required) | - |
| -ri | All node public IPs (required) | - |
| -vi | All node virtual IPs (required) | - |
| -si | Scan IP address (required) | - |
| -rp | root password, must be same on all nodes (required) | - |
| -cn | Cluster name (max 15 characters) | hostname-prefix-cluster |
| -sn | Scan name | hostname-prefix-scan |
| -od | OCR diskgroup disk list (required) | - |
| -ad | ARCH diskgroup disk list | - |
| -on/-or | OCR diskgroup name/redundancy | OCR / EXTERNAL |
| -an/-ar | ARCH diskgroup name/redundancy | ARCH / EXTERNAL |
| -tsi | CTSS time server IP | - |
| -dns | Configure DNS (needed for multiple Scan IPs) | N |
| -dnsn | DNS server name | - |
| -dnsi | DNS server IP | - |
| -ug | Install to Grid software only (Y/N) | N |
Advanced Usage
Step-by-Step Installation
In some scenarios, you may need to split the installation into separate stages:
OS Configuration Only
sh OracleShellInstall.sh \
-install_mode single \
-lf eth0 \
-m Y `# Only configure OS, do not install Oracle`
Useful when you need to verify OS configuration first or make additional manual adjustments.
Install to DB Software Only
sh OracleShellInstall.sh \
-install_mode single \
-lf eth0 \
-ud Y `# Install to DB software only, no database creation`
Useful when you need to create the database manually (custom templates or special configuration).
RAC Install to Grid Only
sh OracleShellInstall.sh \
-install_mode rac \
-lf eth0 -pf eth1 \
-hn orcl01,orcl02 -ri 10.0.0.101,10.0.0.102 \
-vi 10.0.0.103,10.0.0.104 -si 10.0.0.105 \
-rp 'rootPasswd' -od /dev/sdb -dd /dev/sdc \
-ug Y `# Install to Grid only, no DB installation`
One-Click Patching
Place patch files and OPatch tool in the /soft directory and specify patch IDs via parameters:
/soft/
OracleShellInstall.sh
LINUX.X64_193000_db_home.zip # Oracle media
p35940989_190000_Linux-x86-64.zip # PSU/RU patch
p35926646_190000_Linux-x86-64.zip # OJVM patch
p6880880_190000_Linux-x86-64.zip # Latest OPatch
Note: OPatch tool (p6880880) is a prerequisite for applying patches. The script automatically replaces the old OPatch in ORACLE_HOME. If installing without patches, OPatch is not needed.
Multi-Instance Installation
Pass multiple database names (comma-separated) via the -o parameter to create multiple instances on the same host:
sh OracleShellInstall.sh \
-install_mode single \
-lf eth0 \
-o proddb,testdb `# Create two database instances`
VirtualBox Environment
When installing ASM/RAC in VirtualBox VMs, add the -vbox Y parameter to fix VirtualBox SCSI disk detection issues:
sh OracleShellInstall.sh \
-install_mode standalone \
-lf eth0 \
-dd /dev/sdb \
-vbox Y `# VirtualBox fix`
Post-Install Verification
After installation, verify success with the following checks:
Single/Standalone Verification
Check Listener Status
su - oracle
lsnrctl status
The listener should be in READY state with services registered.
Check Database Status
sqlplus / as sysdba
SELECT instance_name, status FROM v$instance;
SELECT name, open_mode FROM v$database;
SELECT name, open_mode FROM v$pdbs; -- if PDBs exist
Database status should be OPEN, PDB status should be READ WRITE.
Check ASM (Standalone/RAC)
su - grid
asmcmd lsdg
All disk groups should show MOUNTED status with expected free space.
RAC Cluster Verification
Check Cluster Status
su - grid
crsctl stat res -t
All resources should be ONLINE.
Check Cluster Nodes
olsnodes -n
crsctl check cluster -all
Check Scan VIP
srvctl status scan
srvctl status scan_listener
srvctl status database -d proddb
Tip: If you used -opd Y for parameter optimization, use SHOW PARAMETER to confirm SGA/PGA and other parameters are configured as expected.
Troubleshooting
General Troubleshooting Steps
- Check the summary log:
cat /soft/print_shell_install_*.log
- Check the detailed log:
cat /soft/shell_install_output_*.log
- Identify the specific failed step and error message
- After fixing the issue, re-run with
-m Y to skip OS configuration
Common Errors and Solutions
Dependency Package Installation Failure
Symptom: yum/dnf fails to install certain RPM packages.
Solution:
- Check that correct package sources are configured, or use
-lrp Y for local repo
- For network repo, set
-nrp Y and ensure internet access
- For domestic OS (Kylin, UOS), ensure built-in package sources are complete
ASM Disk Discovery Failure
Symptom: ASM cannot discover disk devices after Grid installation.
Solution:
- Verify disk devices exist:
ls -l /dev/sd*
- Confirm disks are not partitioned or mounted:
lsblk
- Check if UDEV rules are applied:
ls -l /dev/oracleasm/
- For multipath, check configuration:
multipath -ll
- VirtualBox environments must use
-vbox Y
RAC SSH Trust Failure
Symptom: Cannot establish SSH connection between nodes, "Permission denied" error.
Solution:
- Verify all nodes have the same root password
- Check
/etc/ssh/sshd_config allows root login and password authentication
- Confirm network connectivity between all nodes:
ping test public and heartbeat IPs
Insufficient Memory for DBCA
Symptom: Database creation fails with insufficient memory or ORA-00845 error.
Solution:
- Ensure available memory >= 2GB
- If HugePages enabled (
-hf Y), verify HugePages configuration is correct
- Check that
/dev/shm is mounted and adequately sized
OPatch Version Too Old
Symptom: Patching fails with OPatch version incompatibility error.
Solution: Download the latest OPatch tool (p6880880) and place it in the /soft directory. The script automatically replaces the old version.
FAQ
Q: What Oracle installation media formats are supported?
The script automatically recognizes Oracle installation media in ZIP format. Simply place the ZIP file in the /soft directory — no manual extraction needed.
Q: What if the installation is interrupted?
Check the log files print_shell_install_*.log and shell_install_output_*.log to identify the failure. After fixing the issue, use -m Y to skip completed OS configuration steps.
Q: What network requirements exist for RAC installation?
Public and heartbeat networks must be reachable between all nodes. The root password must be the same on all nodes. The script automatically establishes SSH trust.
Q: What are the database password requirements?
The database password (-dp) must start with a letter and can only contain letters, numbers, and the special characters _ # $. Wrap passwords containing special characters in single quotes.
Q: How to filter multipath disks?
Use the -fd parameter to filter multipath disks and get unique device names. For example: -fd /dev/sda excludes the system disk.
Q: Does it support offline installation?
Yes. Use -lrp Y to configure a local package source (requires the OS installation ISO). The script automatically mounts the ISO and configures local yum/dnf repos without internet access.
Q: How to install a second database on an existing Oracle environment?
Use the -o parameter to specify the new database name. The script detects the existing environment and skips completed configuration steps. You can also use -m Y to skip OS configuration entirely.
Q: What OS configurations does the script modify?
The script modifies the following system configurations:
- Hostname and
/etc/hosts
- Kernel parameters (
/etc/sysctl.conf)
- Resource limits (
/etc/security/limits.conf)
- Disables SELinux and firewall
- Creates oracle/grid users and groups
- Configures NTP/Chrony time synchronization
- Sets user environment variables (
.bash_profile)
Q: Does it support ARM architecture servers?
Yes. The script automatically detects CPU architecture (x86_64/aarch64) and uses the corresponding installation media and dependencies. Make sure to use the ARM version of Oracle media.
Q: How to uninstall Oracle installed by the script?
The script does not provide an uninstall function. Manual steps: Stop database and listener → Remove Oracle directories → Delete users and groups → Clean up system configurations → Remove /etc/oraInst.loc and /etc/oratab.
Changelog
v5.0.0 (2024-08-22)
- Added Oracle 26ai version support
- Added AFD (ASM Filter Driver) configuration support
- Added GIMR configuration support
- Added more domestic OS support: Huawei openEuler, CMCC NFS, NeoKylin, etc.
- Improved installation log output and progress display
- Enhanced parameter validation logic
v4.2.0 (2024-03-15)
- Added Oracle 21c installation support
- Added Rocky Linux 9, AlmaLinux 9 support
- Added
-hf parameter for automatic HugePages configuration
- Improved ARM (aarch64) architecture compatibility
- Fixed dependency installation issues on Ubuntu 22.04
v4.0.0 (2023-09-10)
- Major script architecture refactoring with modular design
- Added Debian/Ubuntu series support
- Added
-opd parameter for database parameter optimization
- Added multi-instance installation support (
-o orcl1,orcl2)
- Improved multipath and UDEV disk binding logic
v3.5.0 (2023-04-20)
- Added UOS and Kylin V10 support
- Added
-nrp parameter for network repository configuration
- Improved RAC SSH trust establishment logic
- Fixed CentOS 8 Stream compatibility issues
v3.0.0 (2022-11-01)
- Added Oracle 19c RAC installation support
- Added automatic ASM disk configuration feature (
-adc)
- Added VirtualBox compatibility parameter (
-vbox)
- Improved installation log output mechanism