签到成功

知道了

CNDBA社区CNDBA社区

Linux 平台 静默安装 Oracle 19c 软件、监听 和 CDB实例

2025-07-02 00:55 21 0 原创 Oracle 19c
作者: dave

在之前的博客中我们已经了解了11g中通过命令行的方式手工安装软件,创建监听,已经创建实例,如下:http://www.cndba.cn/cndba/dave/article/131671http://www.cndba.cn/cndba/dave/article/131671

Oracle 11g 静默安装软件 创建监听 手册
https://www.cndba.cn/dave/article/1604http://www.cndba.cn/cndba/dave/article/131671

Oracle 11g 单实例 中手工建库 示例
http://www.cndba.cn/dave/article/209

Linux 7.4 平台下 Oracle 19.3 单实例安装手册
https://www.cndba.cn/dave/article/3427

其实通过图形GUI部署是最省事的,但还是在一些情况下,无法直接调用图形界面,比如通过堡垒机连接或者一些云上的环境,所以本篇记录下19.3 静默部署的操作过程。

1 准备工作

1.1 系统准备工作

1.1.1 配置本地yum源

[root@dave yum.repos.d]# cat cndba.repo 
[www.cndba.cn]
name=CNDBA.CN YUM Server
baseurl=file:///mnt
gpgcheck=0
enabled=1

1.1.2 挂载镜像

[root@dave yum.repos.d]# mount /dev/cdrom /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@dave yum.repos.d]# yum clean all
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Cleaning repos: www.cndba.cn
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
[root@dave yum.repos.d]#

1.1.3 配置/etc/hosts

[root@dave ~]# vim /etc/hosts
192.168.1.51 cndba

1.1.4 安装操作系统必备的软件包

yum install binutils gcc gcc-c++  compat-libstdc++-33 glibc  glibc.i686  glibc-devel  ksh libgcc.i686   libstdc++-devel  libaio  libaio.i686  libaio-devel  libaio-devel.i686  libXtst  libXtst.i686  libX11  libX11.i686 libXau  libXau.i686  libxcb  libxcb.i686  libXi  libXi.i686  make  sysstat  compat-libcap1 -y

RedHat7.*的镜像文件中没有compat-libstdc包,需要手动安装http://www.cndba.cn/cndba/dave/article/131671

http://www.cndba.cn/cndba/dave/article/131671

[root@dave software]# rpm -ivh compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm 
warning: compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:compat-libstdc++-33-3.2.3-72.el7 ################################# [100%]

1.1.5 配置Linux的系统参数

1)配置Linux的内核参数

[root@dave ~]# vim /etc/sysctl.conf 
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4294967295
kernel.shmmni = 4096
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 = 1048576

用root用户执行sysctl -p 使修改生效。

[root@cndba ~]# sysctl -p
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4294967295
kernel.shmmni = 4096
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 = 1048576

2)设置 Oracle 用户的 Shell 限制

[root@dave ~]# vim /etc/security/limits.conf
oracle  soft  nproc  2047
oracle  hard  nproc  16384
oracle  soft  nofile  1024
oracle  hard  nofile  65536
oracle  soft  stack  10240
oracle  hard  stack  32768
oracle soft memlock unlimited
oracle hard memlock unlimited

3)设置PAM

在 /etc/pam.d/login 文件中添加以下行:

[root@dave ~]# vim /etc/pam.d/login
session required pam_limits.so

4)关闭防火墙/SELINUX

关闭防火墙

[root@dave ~]# systemctl stop firewalld
[root@dave ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

关闭SELINUX

[root@dave ~]# vi /etc/selinux/config
[root@dave ~]# cat /etc/selinux/config 

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

1.2 创建用户和组

[root@dave ~]# /usr/sbin/groupadd -g 54321 oinstall
[root@dave ~]# /usr/sbin/groupadd -g 54322 dba
[root@dave ~]# /usr/sbin/groupadd -g 54323 oper
[root@dave ~]# /usr/sbin/useradd -u 54321 -g oinstall -G dba,oper oracle
[root@dave software]# passwd oracle
验证Oracle安装所有者是否将Oracle Inventory组作为其主要组:
[oracle@cndba ~]$ id oracle
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper)

1.3 创建目录

[root@dave ~]# mkdir -p /u03/app/oracle/product/19.3.0/dbhome_1
[root@dave ~]# chown -R oracle:oinstall /u03
[root@dave ~]# chmod -R 775 /u03/

1.4 设置环境变量

切换到oracle用户下执行vim .bash_profile编辑.bash_profile文件添加以下内容:

[oracle@cndba ~]$ vim .bash_profile
ORACLE_SID=cndba;export ORACLE_SID  
ORACLE_UNQNAME=cndba;export ORACLE_UNQNAME
JAVA_HOME=/usr/local/java; export JAVA_HOME
ORACLE_BASE=/u03/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/19.3.0/dbhome_1; export ORACLE_HOME
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT="YYYY:MM:DDHH24:MI:SS"; export NLS_DATE_FORMAT
#NLS_LANG=american_america.ZHS16GBK; export NLS_LANG
export NLS_LANG=AMERICAN_AMERICA.UTF8
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11
PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin:$ORA_CRS_HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export CLASSPATH
THREADS_FLAG=native; export THREADS_FLAG
export TEMP=/tmp
export TMPDIR=/tmp
umask 022

使设置的环境变量生效
[oracle@cndba ~]$ source .bash_profile

2 安装DB 软件

2.1 解压文件

从Oracle 18c开始,数据库软件直接采用解压缩的方式进行,需要直接解压缩到$ORACLE_HOME目录下。

[dave@cndba.cn ~]$ cd $ORACLE_HOME
[dave@cndba.cn dbhome_1]$ pwd
/u03/app/oracle/product/19.3.0/dbhome_1
[dave@cndba.cn dbhome_1]$ ll
total 2988000
-rw-r--r--. 1 ora19c oinstall 3059705302 Jul  1 23:12 LINUX.X64_193000_db_home.zip
[dave@cndba.cn dbhome_1]$ unzip LINUX.X64_193000_db_home.zip

2.2 编辑db_install.rsp响应文件

静默安装需要响应文件,默认在$ORACLE_HOME/install/response目录下:

[dave@cndba.cn dbhome_1]$ cd $ORACLE_HOME/install/response
[dave@cndba.cn response]$ ls
db_install.rsp
[dave@cndba.cn response]$

这个是模板文件,里面内容比较多,我们这里创建一个简单点的:http://www.cndba.cn/cndba/dave/article/131671

[dave@cndba.cn response]$ mv db_install.rsp db_install.rsp.bak
[dave@cndba.cn response]$ touch db_install.rsp
[dave@cndba.cn response]$ cat db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v19.0.0
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u03/app/oraInventory
ORACLE_HOME=/u03/app/oracle/product/19.3.0/dbhome_1
ORACLE_BASE=/u03/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_GROUP=dba
oracle.install.db.OSOPER_GROUP=oper
oracle.install.db.OSBACKUPDBA_GROUP=dba
oracle.install.db.OSKMDBA_GROUP=dba
oracle.install.db.OSRACDBA_GROUP=dba
oracle.install.db.OSDGDBA_GROUP=dba
[dave@cndba.cn response]$

2.3 安装DB 软件

[dave@cndba.cn response]$ cd $ORACLE_HOME
[dave@cndba.cn dbhome_1]$ ./runInstaller -silent -noconfig -responseFile /u03/app/oracle/product/19.3.0/dbhome_1/install/response/db_install.rsp
……
As a root user, execute the following script(s):
        1. /u03/app/oracle/product/19.3.0/dbhome_1/root.sh

Execute /u03/app/oracle/product/19.3.0/dbhome_1/root.sh on the following nodes: 
[ora11g]
Successfully Setup Software with warning(s).
[dave@cndba.cn dbhome_1]$ 

执行root.sh 脚本:
[root@ora11g dbhome_1]# ssh /u03/app/oracle/product/19.3.0/dbhome_1/root.sh

3 创建监听

图形界面是用netca,我们这里还是直接静默。http://www.cndba.cn/cndba/dave/article/131671

3.1 查看响应文件

监听的响应文件模板在/u03/app/oracle/product/19.3.0/dbhome_1/assistants/netca目录下,里面的内容不需要修改,可以直接使用。

http://www.cndba.cn/cndba/dave/article/131671

[dave@cndba.cn netca]$ grep -v '^#' netca.rsp |grep -v '^$'
[GENERAL]
RESPONSEFILE_VERSION="19.0"
CREATE_TYPE="CUSTOM"
[oracle.net.ca]
INSTALLED_COMPONENTS={"server","net8","javavm"}
INSTALL_TYPE=""typical""
LISTENER_NUMBER=1
LISTENER_NAMES={"LISTENER"}
LISTENER_PROTOCOLS={"TCP;1521"}
LISTENER_START=""LISTENER""
NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}
NSN_NUMBER=1
NSN_NAMES={"EXTPROC_CONNECTION_DATA"}
NSN_SERVICE={"PLSExtProc"}
NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}
[dave@cndba.cn netca]$

3.2 创建监听

[dave@cndba.cn ~]$ netca -silent -responsefile /u03/app/oracle/product/19.3.0/dbhome_1/assistants/netca/netca.rsp

Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /u03/app/oracle/product/19.3.0/dbhome_1/assistants/netca/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
    Running Listener Control: 
      /u03/app/oracle/product/19.3.0/dbhome_1/bin/lsnrctl start LISTENER
    Listener Control complete.
    Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0

[dave@cndba.cn ~]$ lsnrctl status

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 01-JUL-2025 23:57:57

Copyright (c) 1991, 2019, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora11g)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                01-JUL-2025 23:57:37
Uptime                    0 days 0 hr. 0 min. 20 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u03/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u03/app/oracle/diag/tnslsnr/ora11g/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora11g)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
[dave@cndba.cn ~]$

4 创建CDB实例

4.1 创建响应文件

相关的工具响应文件模板都在$ORACLE_HOME/assistants 目录下:http://www.cndba.cn/cndba/dave/article/131671

[dave@cndba.cn assistants]$ pwd
/u03/app/oracle/product/19.3.0/dbhome_1/assistants
[dave@cndba.cn assistants]$ cd dbca
[dave@cndba.cn dbca]$ ll
total 28
-rw-r-----. 1 ora19c oinstall 25502 Apr  6  2019 dbca.rsp
drwxr-xr-x. 2 ora19c oinstall   242 Apr 17  2019 doc
drwxr-xr-x. 2 ora19c oinstall    41 Apr 17  2019 jlib
drwxr-xr-x. 2 ora19c oinstall   171 Apr 17  2019 templates
[dave@cndba.cn dbca]$

需要填写的内容较多:

http://www.cndba.cn/cndba/dave/article/131671

[dave@cndba.cn dbca]$ mv dbca.rsp dbca.rsp.bak
[dave@cndba.cn dbca]$ ll
total 28
-rw-r-----. 1 ora19c oinstall 25502 Apr  6  2019 dbca.rsp.bak
drwxr-xr-x. 2 ora19c oinstall   242 Apr 17  2019 doc
drwxr-xr-x. 2 ora19c oinstall    41 Apr 17  2019 jlib
drwxr-xr-x. 2 ora19c oinstall   171 Apr 17  2019 templates
[dave@cndba.cn dbca]$ touch dbca.rsp
[dave@cndba.cn dbca]$ vim dbca.rsp
[dave@cndba.cn dbca]$ cat dbca.rsp
responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v19.0.0
templateName=General_Purpose.dbc
gdbName=cndba
sid=cndba
createAsContainerDatabase=TRUE
numberOfPDBs=1
pdbName=dave
pdbAdminPassword=oracle
sysPassword=oracle
systemPassword=oracle
datafileDestination=/u03/app/oracle/oradata
recoveryAreaDestination=/u03/app/oracle/flash_recovery_area
storageType=FS
characterSet=AL32UTF8
nationalCharacterSet=AL16UTF16
sampleSchema=true
totalMemory=2048
databaseType=OLTP
emConfiguration=NONE
[dave@cndba.cn dbca]$

我们这里创建包含一个PDB的CDB。

4.2 创建实例

[dave@cndba.cn dbca]$ dbca -silent -createDatabase -responseFile /u03/app/oracle/product/19.3.0/dbhome_1/assistants/dbca/dbca.rsp
……
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
43% complete
46% complete
Completing Database Creation
51% complete
53% complete
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
 /u03/app/oracle/cfgtoollogs/dbca/cndba.
Database Information:
Global Database Name:cndba
System Identifier(SID):cndba
Look at the log file "/u03/app/oracle/cfgtoollogs/dbca/cndba/cndba.log" for further details.
[dave@cndba.cn ~]$ 

[dave@cndba.cn ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jul 2 00:45:37 2025
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> show pdbs;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 DAVE                           READ WRITE NO
SQL>

版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
dave

dave

关注

人的一生应该是这样度过的:当他回首往事的时候,他不会因为虚度年华而悔恨,也不会因为碌碌无为而羞耻;这样,在临死的时候,他就能够说:“我的整个生命和全部精力,都已经献给世界上最壮丽的事业....."

  • 2279
    原创
  • 3
    翻译
  • 579
    转载
  • 196
    评论
  • 访问:8159723次
  • 积分:4413
  • 等级:核心会员
  • 排名:第1名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ