Ubuntu 20.04 一键安装 Oracle 19C 单机
程小虎2025-12-31 14:39:18
✨ 前言
Oracle 一键安装脚本,演示 Ubuntu 20.04 一键安装 Oracle 19C 单机(19.24)过程(全程无需人工干预)。
本教程支持系统版本如下:
- Ubuntu 20.04 (包含所有小版本)
安装包下载:Oracle一键安装包
系统镜像下载:Ubuntu系统镜像
🔧 安装准备
- 系统组安装好操作系统(支持最小化安装)
- 网络组配置好主机网络,通常只需要一个公网 IP 地址
- DBA 创建软件目录:
mkdir /soft - DBA 上传 Oracle 安装介质(基础包,补丁包)到 /soft 目录下
- DBA 上传 Oracle 一键安装脚本到 /soft 目录下,授予脚本执行权限:
chmod +x OracleshellInstall - 根据脚本安装脚本以及实际情况,配置好脚本的安装参数,在 /soft 目录下执行一键安装即可。
需要上传的文件:
提示
- OracleShellInstall # Oracle 一键安装脚本
- LINUX.X64_193000_db_home.zip # 数据库安装包
- p6880880_190000_Linux-x86-64.zip # OPatch 补丁包
- p36414915_190000_Linux-x86-64.zip # OJVM PSU/RU 补丁包
- p36582781_190000_Linux-x86-64.zip # Oracle PSU/RU 补丁包
- rlwrap-0.44.tar.gz # rlwrap 工具
📄 环境信息
# 主机版本
root@Ubuntu20:~# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
# 网络信息
root@Ubuntu20:~# ip a
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:b2:0d:b2 brd ff:ff:ff:ff:ff:ff
inet 192.168.80.31/24 brd 192.168.80.255 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:feb2:db2/64 scope link
valid_lft forever preferred_lft forever
# 连接外网测试
root@Ubuntu20:~# ping www.baidu.com
PING www.a.shifen.com (183.2.172.177) 56(84) bytes of data.
64 bytes from 183.2.172.177 (183.2.172.177): icmp_seq=1 ttl=128 time=9.06 ms
64 bytes from 183.2.172.177 (183.2.172.177): icmp_seq=2 ttl=128 time=8.82 ms
64 bytes from 183.2.172.177 (183.2.172.177): icmp_seq=3 ttl=128 time=8.59 ms
64 bytes from 183.2.172.177 (183.2.172.177): icmp_seq=4 ttl=128 time=8.97 ms
64 bytes from 183.2.172.177 (183.2.172.177): icmp_seq=5 ttl=128 time=20.9 ms
64 bytes from 183.2.172.177 (183.2.172.177): icmp_seq=6 ttl=128 time=8.16 ms
# 安装包存放在 /soft 目录下
[root@Ubuntu20 soft]# ll
total 5081364
-rw-r--r-- 1 root root 3059705302 Jun 25 07:21 LINUX.X64_193000_db_home.zip
-rw-r--r-- 1 root root 245190 Jun 25 07:20 OracleShellInstall
-rw-r--r-- 1 root root 127588003 Jun 25 07:20 p36414915_190000_Linux-x86-64.zip
-rw-r--r-- 1 root root 1880954749 Jun 25 07:21 p36582781_190000_Linux-x86-64.zip
-rw-r--r-- 1 root root 134471443 Jun 25 07:20 p6880880_190000_Linux-x86-64.zip
-rw-r--r-- 1 root root 321590 Jun 25 07:20 rlwrap-0.44.tar.gz
确保安装环境准备完成后,即可执行一键安装。
🛠️ 安装命令
使用标准生产环境安装参数(安装过程若失败,脚本支持重复执行安装):
# 根据脚本 README 或者 -h 命令提示,编辑好一键安装命令,进入 /soft 目录执行安装:
chmod +x /soft/OracleShellInstall
/soft/OracleShellInstall \
-lf ens33 `# 主机网卡名称`\
-n oracle19c `# 主机名`\
-op oracle `# 主机 oracle 用户密码`\
-d /u01 `# Oracle 软件安装基础目录`\
-ord /oradata `# 数据库文件存放目录`\
-o orcl `# 数据库名称`\
-dp oracle123 `# sys/system 用户密码`\
-ds AL32UTF8 `# 数据库字符集`\
-ns AL16UTF16 `# 国家字符集`\
-opa 36582781 `# Oracle PSU/RU 补丁编号`\
-jpa 36414915 `# Oracle OJVM PSU/RU 补丁编号`\
-redo 100 `# 在线重做日志大小(M)`\
-opd Y `# 是否优化数据库`
🛠️ 安装过程
███████ ██ ████████ ██ ██ ██ ██ ██ ██ ██
██░░░░░██ ░██ ██░░░░░░ ░██ ░██ ░██░██ ░██ ░██ ░██
██ ░░██ ██████ ██████ █████ ░██ █████ ░██ ░██ █████ ░██ ░██░██ ███████ ██████ ██████ ██████ ░██ ░██
░██ ░██░░██░░█ ░░░░░░██ ██░░░██ ░██ ██░░░██░█████████░██████ ██░░░██ ░██ ░██░██░░██░░░██ ██░░░░ ░░░██░ ░░░░░░██ ░██ ░██
░██ ░██ ░██ ░ ███████ ░██ ░░ ░██░███████░░░░░░░░██░██░░░██░███████ ░██ ░██░██ ░██ ░██░░█████ ░██ ███████ ░██ ░██
░░██ ██ ░██ ██░░░░██ ░██ ██ ░██░██░░░░ ░██░██ ░██░██░░░░ ░██ ░██░██ ░██ ░██ ░░░░░██ ░██ ██░░░░██ ░██ ░██
░░███████ ░███ ░░████████░░█████ ███░░██████ ████████ ░██ ░██░░██████ ███ ███░██ ███ ░██ ██████ ░░██ ░░████████ ███ ███
░░░░░░░ ░░░ ░░░░░░░░ ░░░░░ ░░░ ░░░░░░ ░░░░░░░░ ░░ ░░ ░░░░░░ ░░░ ░░░ ░░ ░░░ ░░ ░░░░░░ ░░ ░░░░░░░░ ░░░ ░░░
注意:本脚本仅用于新服务器上实施部署数据库使用,严禁在已运行数据库的主机上执行,以免发生数据丢失或者损坏,造成不可挽回的损失!!!
请选择安装模式 [单机(si)/单机ASM(sa)/集群(rac)] : si
数据库安装模式: single
请选择数据库版本 [11|12|19|21|23] : 19
数据库版本: 19
!!! 免责声明:当前操作系统版本是 [ Ubuntu 20.04.6 LTS ] 不在 Oracle 官方支持列表,本脚本只负责安装,请确认是否继续安装 (Y/N): [Y]
OracleShellInstall 开始安装,详细安装过程可查看日志: tail -2000f /soft/print_shell_install_20250625073514.log
正在进行安装前检查,请稍等......
正在检测安装包 /soft/LINUX.X64_193000_db_home.zip 的 MD5 值是否正确,请稍等......
正在配置网络软件源......已完成 (耗时: 30 秒)
正在获取操作系统信息......已完成 (耗时: 1 秒)
正在安装依赖包......已完成 (耗时: 158 秒)
正在配置 Swap......已完成 (耗时: 8 秒)
正在禁用防火墙......已完成 (耗时: 1 秒)
正在配置主机名和 hosts 文件......已完成 (耗时: 1 秒)
正在创建用户和组......已完成 (耗时: 1 秒)
正在创建安装目录......已完成 (耗时: 1 秒)
正在配置透明大页 && NUMA && 磁盘 IO 调度器......已完成 (耗时: 4 秒)
正在配置操作系统参数 sysctl......已完成 (耗时: 1 秒)
正在配置 RemoveIPC......已完成 (耗时: 1 秒)
正在配置用户限制 limit......已完成 (耗时: 1 秒)
正在配置 shm 目录......已完成 (耗时: 1 秒)
正在配置用户环境变量......已完成 (耗时: 2 秒)
正在解压 Oracle 安装包以及补丁......已完成 (耗时: 75 秒)
正在安装 Oracle 软件以及补丁......已完成 (耗时: 420 秒)
正在创建监听......已完成 (耗时: 2 秒)
正在创建数据库......已完成 (耗时: 659 秒)
正在优化数据库......已完成 (耗时: 7 秒)
恭喜!Oracle 一键安装执行完成 (耗时: 1378 秒),现在是否重启主机:[Y/N] Y
正在重启当前节点主机......
✅ 连接测试
查看系统版本:
[root@oracle19c:/root]# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
查看 Oracle 版本以及补丁:
[oracle@oracle19c:/home/oracle]$ sqlplus -v
SQL*Plus: Release 19.0.0.0.0 - Production
Version 19.24.0.0.0
[oracle@oracle19c:/home/oracle]$ opatch lspatches
36414915;OJVM RELEASE UPDATE: 19.24.0.0.240716 (36414915)
36582781;Database Release Update : 19.24.0.0.240716 (36582781)
29585399;OCW RELEASE UPDATE 19.3.0.0.0 (29585399)
OPatch succeeded.
检查监听:
[oracle@oracle19c:/home/oracle]$ lsnrctl status
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 25-JUN-2025 11:29:53
Copyright (c) 1991, 2024, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle19c)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 25-JUN-2025 11:26:12
Uptime 0 days 0 hr. 3 min. 40 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/19.3.0/db/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/oracle19c/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle19c)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
连接数据库:
[oracle@oracle19c:/home/oracle]$ sas
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jun 25 08:00:43 2025
Version 19.24.0.0.0
Copyright (c) 1982, 2024, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.24.0.0.0
SYS@orcl SQL> show parameter name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cdb_cluster_name string
cell_offloadgroup_name string
db_file_name_convert string
db_name string orcl
db_unique_name string orcl
global_names boolean FALSE
instance_name string orcl
lock_name_space string
log_file_name_convert string
pdb_file_name_convert string
processor_group_name string
service_names string orcl
数据库连接正常。
