Multitenant : Rename Services During PDB Creation in Oracle Database 12c Release 2 (12.2)
In Oracle 12c Release 2 it is possible to rename PDB services during PDB creation to prevent clashes.
oracle 12cconfigurationintermediate
by OracleDba
13 views
In Oracle 12c Release 2 it is possible to rename PDB services during PDB creation to prevent clashes.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
CONN / AS SYSDBA
ALTER SESSION SET CONTAINER=pdb1;
BEGIN
DBMS_SERVICE.create_service('my_new_service_1','my_new_service_1');
DBMS_SERVICE.start_service('my_new_service_1');
DBMS_SERVICE.create_service('my_new_service_2','my_new_service_2');
DBMS_SERVICE.start_service('my_new_service_2');
END;
/
SELECT name
FROM dba_services
ORDER BY name;
NAME
----------------------------------------------------------------
PDB1
my_new_service_1
my_new_service_2
SQL>
CONN / AS SYSDBA
CREATE PLUGGABLE DATABASE pdb2 FROM pdb1;
ALTER PLUGGABLE DATABASE pdb2 OPEN;
ALTER SESSION SET CONTAINER=pdb2;
SELECT name
FROM dba_services
ORDER BY name;
NAME
----------------------------------------------------------------
PDB2
my_new_service_1
my_new_service_2
SQL>
CONN sys/SysPassword1@//localhost:1521/my_new_service_1 AS SYSDBA
SHOW CON_NAME
CON_NAME
------------------------------
PDB1
SQL>
CONN sys/SysPassword1@//localhost:1521/my_new_service_2 AS SYSDBA
SHOW CON_NAME
CON_NAME
------------------------------
PDB1
SQL>
ALTER SESSION SET CONTAINER=pdb2 SERVICE=my_new_service_1;
ERROR:
ORA-44787: Service cannot be switched into.
SQL>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
CONN / AS SYSDBA
-- Remove the PDB.
ALTER PLUGGABLE DATABASE pdb2 CLOSE;
DROP PLUGGABLE DATABASE pdb2 INCLUDING DATAFILES;
-- Create the PDB, renaming the services.
CREATE PLUGGABLE DATABASE pdb2 FROM pdb1
SERVICE_NAME_CONVERT=('my_new_service_1','my_new_service_1b','my_new_service_2','my_new_service_2b')
;
ALTER PLUGGABLE DATABASE pdb2 OPEN;
-- Check the services.
ALTER SESSION SET CONTAINER=pdb2;
SELECT name
FROM dba_services
ORDER BY name;
NAME
----------------------------------------------------------------
PDB2
my_new_service_1b
my_new_service_2b
SQL>
-- Start the services.
BEGIN
DBMS_SERVICE.start_service('my_new_service_1b');
DBMS_SERVICE.start_service('my_new_service_2b');
END;
/
CONN sys/SysPassword1@//localhost:1521/my_new_service_1 AS SYSDBA
SHOW CON_NAME
CON_NAME
------------------------------
PDB1
SQL>
CONN sys/SysPassword1@//localhost:1521/my_new_service_1b AS SYSDBA
SHOW CON_NAME
CON_NAME
------------------------------
PDB2
SQL>
ALTER SESSION SET CONTAINER=pdb2 SERVICE=my_new_service_1b;
Session altered.
SQL>1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
# Create FRA location.
mkdir -p /u01/app/oracle/fast_recovery_area
# Container (cdb1) with pluggable database (pdb1).
dbca -silent -createDatabase \
-templateName General_Purpose.dbc \
-gdbname cdb1 -sid cdb1 -responseFile NO_VALUE \
-characterSet AL32UTF8 \
-sysPassword SysPassword1 \
-systemPassword SysPassword1 \
-createAsContainerDatabase true \
-numberOfPDBs 1 \
-pdbName pdb1 \
-pdbAdminPassword SysPassword1 \
-databaseType MULTIPURPOSE \
-memoryMgmtType auto_sga \
-totalMemory 2048 \
-storageType FS \
-datafileDestination "/u02/oradata/" \
-redoLogFileSize 50 \
-emConfiguration NONE \
-ignorePreReqs
export ORACLE_SID=cdb1
export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES
# Set required parameters.
sqlplus / as sysdba <<EOF
alter pluggable database pdb1 save state;
alter system set db_create_file_dest = '/u02/oradata';
alter system set db_recovery_file_dest_size = 10G;
alter system set db_recovery_file_dest = '/u01/app/oracle/fast_recovery_area';
exit;
EOF
# Enable ARCHIVELOG mode.
sqlplus / as sysdba <<EOF
shutdown immediate;
startup mount;
alter database archivelog;
alter database open;
exit;
EOF
# Delete the instance.
#dbca -silent -deleteDatabase -sourceDB cdb1 -sysDBAUserName sys -sysDBAPassword SysPassword1Please to add comments
No comments yet. Be the first to comment!