《非Oracle Linux下安装Oracle 19c》我们安装了non-cdb的19c数据库,通过这个脚本,还可以搭建cdb的数据库。
1. 修改安装脚本
cp /etc/init.d/oracledb_ORCLCDB-19c /etc/init.d/oracledb_pdbisal-19c
其中要改几处,ORACLE_SID改成新的,LISTENER_NAME改成新的,CREATE_AS_CDB之前我写的false,要改为true,
vi oracledb_bisal-pdb19c
export ORACLE_VERSION=19c
export ORACLE_SID=PDBISAL
export TEMPLATE_NAME=General_Purpose.dbc
export CHARSET=AL32UTF8
export PDB_NAME=BISALPDB1
export LISTENER_NAME=PDBLISTENER
export NUMBER_OF_PDBS=1
export CREATE_AS_CDB=true
# General exports and vars
export PATH=$ORACLE_HOME/bin:$PATH
LSNR=$ORACLE_HOME/bin/lsnrctl
SQLPLUS=$ORACLE_HOME/bin/sqlplus
DBCA=$ORACLE_HOME/bin/dbca
NETCA=$ORACLE_HOME/bin/netca
ORACLE_OWNER=oracle
RETVAL=0
CONFIG_NAME="oracledb_$ORACLE_SID-$ORACLE_VERSION.conf"
CONFIGURATION="/etc/sysconfig/$CONFIG_NAME"
...
需要关注的就是,脚本执行的时候,会读取配置文件,文件名是拼接出来的,“oracledb_ORACLE_SID-ORACLE_VERSION.conf”,因此接下来,需要创建对应的配置文件。
2. 创建配置文件
配置文件的名称,要和(1)引用的相同,
cp /etc/sysconfig/oracledb_BISAL-19c.conf /etc/sysconfig/oracledb_PDBISAL-19c.conf
其中要改三处,端口号改为1522(因为我是同机装),数据文件的路径,可以指定不同的,EM端口(默认5500)可以改为5600,
vi oracledb_PDBISAL-19c.conf
#This is a configuration file to setup the Oracle Database.
#It is used when running '/etc/init.d/oracledb_ORCLCDB configure'.
#Please use this file to modify the default listener port and the
#Oracle data location.
# LISTENER_PORT: Database listener
LISTENER_PORT=1522
# ORACLE_DATA_LOCATION: Database oradata location
ORACLE_DATA_LOCATION=/opt/oracle/pdboradata
# EM_EXPRESS_PORT: Oracle EM Express listener
EM_EXPRESS_PORT=5600
3. 执行安装
root执行,大约几十分钟,
[root@bisal init.d]# ./oracledb_bisal-pdb19c configure
Configuring Oracle Database PDBISAL.
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
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
/opt/oracle/cfgtoollogs/dbca/PDBISAL.
Database Information:
Global Database Name:PDBISAL
System Identifier(SID):PDBISAL
Look at the log file "/opt/oracle/cfgtoollogs/dbca/PDBISAL/PDBISAL.log" for further details.
Database configuration completed successfully. The passwords were auto generated, you must change them by connecting to the database using 'sqlplus / as sysdba' as the oracle user.
此时创建了CDB的数据库,
SQL> select cdb from v$database;
CDB
---
YES
除了种子PDB(只读),另外有个PDB名称是BISALPDB1,
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 BISALPDB1 READ WRITE NO
我们看下数据文件的结构,
BISALPDB1的目录结构,
pdbseed的目录结构,
但是有个疑问,从oracledb_bisal-pdb19c脚本中能看到他用的dbca静默方式创建的数据库,如果我需要改system表空间数据文件的初始化大小,应该改什么文件?
$SU -s /bin/bash $ORACLE_OWNER -c "$DBCA -silent -createDatabase -gdbName $ORACLE_SID -templateName $TEMPLATE_NAME
-characterSet $CHARSET -createAsContainerDatabase $CREATE_AS_CDB -numberOfPDBs $NUMBER_OF_PDBS -pdbName $PDB_NAME
-createListener $LISTENER_NAME:$LISTENER_PORT -datafileDestination $ORACLE_DATA_LOCATION -sid $ORACLE_SID
-autoGeneratePasswords -emConfiguration DBEXPRESS -emExpressPort $EM_EXPRESS_PORT"
从脚本中,看到他引用了这个文件,
export TEMPLATE_NAME=General_Purpose.dbc
-templateName $TEMPLATE_NAME
搜索一下,
[root@bisal /]# find . -name General_Purpose.dbc
./opt/oracle/product/19c/dbhome_1/assistants/dbca/templates/General_Purpose.dbc
原来这个文件中,定义了数据文件相关的信息,如果改了红框内标记的数据表空间信息,执行安装的时候,就可以改数据文件的大小了,
初次尝试cdb、pdb,有待继续摸索。