среда, 28 января 2026 г.

Duplicate Point-In-Time Recovered PDB Using Backup

Resources

Subject

At times, we might need to duplicate a production pluggable database to a Past Point in Time- in order to:

  • Refresh Test/Dev environment
  • Perform testing
  • Table Point-in-Time Recovery requires Enterprise Edition, therefore sometimes we need have scenario how to restore table in PDB on our SE2 instances

    RMAN-06455: Table Point-in-Time Recovery requires Enterprise Edition
  • Generate reports, etc.

Scenario

Source: orcl-01/CDB19 instance with PDBs: PPDB, TPDB, PDB$SEED
Destination: orcl-01/TCDB19 dummy(temporary) created instance for recover all PDBs from backup of orcl-01/CDB19 instance
  • In order to duplicate a PDB, an auxiliary instance has to be created as a CDB on the same or different host.
  • The PDB can be restored / recovered point-in-time using older backups of a production database and the required archive logs so as not to affect the production database.
  • On duplication of PDB(s), RMAN duplicates the root (CDB$ROOT) and the seed database (PDB$SEED) as well.
  • The resulting duplicate database is a fully-functional CDB that contains the root, the seed database, and the duplicated PDBs.
  • Subsequently, the recovered PDB may be plugged into another CDB (e.g. to source orcl-01/CDB19 as PPDB_RCVRD pdb in case if planned remain PDB for a long time of testing/generating reports and etc.)

Objective:

We need to perform Point-In-Time Restoration (PITR) on orcl-01/CDB19/PPDB pdb and then plug it as PPDB_RCVRD pdb into dummy(temporary) orcl-01/TCDB19 instance using backups and archive logs of orcl-01/CDB19 instance.

Implementation

Prepare pfile and start the auxiliary instance of orcl-01/TCDB19 in NOMOUNT mode using a pfile that includes the declaration:
enable_pluggable_database=TRUE
show parameter compatible='19.0.0'
sga_max_size and sga_target less than on orcl-01/CDB19 and available on host orcl-01
local_listener='LISTENER_CDB19' will used, because it primary listener on orcl-01
log_archive_dest_1 don't forget specify to /arch/TCDB19 disk to prevent creating archivelogs in the default dir /opt/oracle/db19c/dbs
su -
mkdir -p /data/TCDB19
chown oracle:oinstall /data/TCDB19
 
mkdir -p /arch/TCDB19
chown oracle:oinstall /arch/TCDB19
Generate pfile from source orcl-01/CDB19 instance for take into account all configured parameters in template of pfile for auxiliary instance of orcl-01/TCDB19:
su - oracle

ORACLE_HOME=/opt/oracle/db19c
ORACLE_SID=CDB19
 
sqlplus / as sysdba
SQL> create pfile from spfile;
!ls -lht /opt/oracle/db19c/dbs | head -3
exit
 
cat /opt/oracle/db19c/dbs/initCDB19.ora
cat > /opt/oracle/db19c/dbs/initTCDB19.ora
*.compatible='19.0.0'
*.control_files='/data/TCDB19/control01.ctl'
*.cpu_count=5
*.db_block_size=8192
*.db_create_file_dest='/data'
*.db_name='TCDB19'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=TCDB19XDB)'
*.enable_pluggable_database=true
*.filesystemio_options='SETALL'
*.global_names=FALSE
*.local_listener='LISTENER_CDB19'
*.processes=200
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_max_size=10G
*.sga_target=10G
*.diagnostic_dest='/opt/oracle'
*.use_large_pages='ONLY'
*.log_archive_dest_1 = 'LOCATION=/arch/TCDB19 mandatory reopen=20'
Start the auxiliary instance of orcl-01/TCDB19 in NOMOUNT mode using a pfile
export ORACLE_HOME=/opt/oracle/db19c
export ORACLE_SID=TCDB19
 
# Made sure that we have Huge pages enough to start instance with 12G sga
grep Huge /proc/meminfo
AnonHugePages:         0 kB
HugePages_Total:   36876
HugePages_Free:     8201
 
sqlplus / as sysdba
 
Connected to an idle instance.
 
SYS@TCDB19:SQL>
 
startup nomount pfile='/opt/oracle/db19c/dbs/initTCDB19.ora';
 
SYS@TCDB19:SQL> !grep Huge /proc/meminfo
AnonHugePages:         0 kB
HugePages_Total:   36876
HugePages_Free:     2080
Start the RMAN client and connect to the auxiliary instance as AUXILIARY:
#export ORACLE_SID=TCDB19
echo $ORACLE_SID

export NLS_DATE_FORMAT='Mon DD YYYY HH24:MI:SS'

rman auxiliary sys/oracle catalog rmancat@rmandb
connected to auxiliary database: TCDB19 (not mounted)

RMAN>
Potential issues:
# RMAN-06617 [Doc ID 1646262.1|https://support.oracle.com/epmos/faces/DocumentDisplay?id=1646262.1]
# LIST BACKUP OF ARCHIVELOG ALL;

# RMAN-20005: target database name is ambiguous
# export ORACLE_SID=CDB19
# rman target=/ catalog rmancat@rmandb
# connected to target database: CDB19 (DBID=3865731291)
# RMAN> list db_unique_name all;

# RMAN-05500: the auxiliary database must be not mounted when issuing a DUPLICATE command
# sqlplus / as sysdba
# SYS@TCDB19:SQL>
# select status from v$instance;
# shutdown immediate;
# startup nomount pfile='/opt/oracle/db19c/dbs/initTCDB19.ora';
# exit

rman auxiliary sys/oracle catalog rmancat@rmandb
connected to auxiliary database: TCDB19 (not mounted)

RMAN>
RUN {
 set until time "to_date('Jan 29 2026 04:00:00','Mon DD YYYY HH24:MI:SS')";
 duplicate database 'CDB19' dbid 3865731291 to 'TCDB19' noopen backup location '/db_backup/CDB19/rman/backup' pluggable database PPDB;
}

🛈 dbid 3865731291 was specified for orcl-01/CDB19 instance because in RMAN catalog registered several instances with the same name

e.g. orcl-01/CDB19 & orcl-stage-02/CDB19 therefore issued RMAN-20005: target database name is ambiguous above, so need to specify dbid

🛈 Example duplication orcl-01/CDB19 CDB with CDB$ROOT, PDB$SEED and all PDBs if require to PITR CDB and all PDBs

#duplicate database 'CDB19' to 'TCDB19' noopen backup location '/backup/CDB19/rman/backup'
Open the duplicate database with the RESETLOGS option:
#export ORACLE_HOME=/opt/oracle/db19C
export ORACLE_SID=TCDB19

sqlplus / as sysdba

SYS@TCDB119:SQL>

select status from v$instance;

alter database open resetlogs;

show pdbs;

SYS@TCDB19:SQL>

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PPDB                           MOUNTED
         4 TPDB                           MOUNTED

Rename recovered PPDB pdb to PPDB_RCVRD

🛈 Reason: In case if we open PITR pdb with old name the listener will register second service PPDB as for source(production) PPDB pdb,

and this may cause create connections from applications to temporary recovered PDB, that's why it must be renamed to prevent such collision

SYS@TCDB19:SQL> 

-- Unplug and drop PPDB pdb from dummy orcl-01/TCDB19 instance while retaining its data files
ALTER PLUGGABLE DATABASE PPDB CLOSE;
ALTER PLUGGABLE DATABASE PPDB UNPLUG INTO '/data/TCDB19/ppdb_rcvrd.xml';
DROP PLUGGABLE DATABASE PPDB KEEP DATAFILES;

🛈 We issued rman duplicate just for orcl-01/CDB19/PPDB pdb, so others pdbs (TPDBS) can be removed from destination dummy(temporary) orcl-01/TCDB19 instance:

--ALTER PLUGGABLE DATABASE TPDB UNPLUG INTO '/data/TCDB19/tpdb_rcvrd.xml';
-- ORA-01173: data dictionary indicates missing data file from system tablespace
--DROP PLUGGABLE DATABASE TPDB KEEP DATAFILES;
-- Therefore can be deleted from dummy orcl-01/TCDB19 instance
DROP PLUGGABLE DATABASE TPDB INCLUDING DATAFILES;

Plug in PDB PPDB as PPDB_RCVRD into dummy orcl-01/TCDB19 instance using existing data files:

CREATE PLUGGABLE DATABASE PPDB_RCVRD USING '/data/TCDB19/ppdb_rcvrd.xml' NOCOPY TEMPFILE REUSE;

alter pluggable database PPDB_RCVRD open;
alter pluggable database PPDB_RCVRD save state;

alter session set container=PPDB_RCVRD;

🛈 Subsequently, the recovered PDB may be plugged into another CDB instead of dummy(temporary) orcl-01/TCB19 instance, e.g. to source orcl-01/CDB19 as PPDB_RCVRD pdb in case if planned remain PDB for a long time of testing/generating reports and etc. So on orcl-01/CDB19 instance must have free PDB slot according SE2 license, therefore:

🛈 Unplug and drop PDB3 pdb from production orcl-01/CDB19 instance while retaining its data files to free PDB slot for PPDB_RCVRD PDB

export ORACLE_HOME=/opt/oracle/db19c
export ORACLE_SID=CDB19

sqlplus / as sysdba

SYS@CDB19:SQL> 
ALTER PLUGGABLE DATABASE PDB3 CLOSE;
ALTER PLUGGABLE DATABASE PDB3 UNPLUG INTO '/data/CDB19/pdb3.xml';
DROP PLUGGABLE DATABASE PDB3 KEEP DATAFILES;
--DROP PLUGGABLE DATABASE PDB3 INCLUDING DATAFILES;
Plug in PDB PPDB as PPDB_RCVRD into destination production orcl-01/CDB19 instance using existing data files:
export ORACLE_HOME=/opt/oracle/db19c
export ORACLE_SID=CDB19

sqlplus / as sysdba
SYS@CDB19:SQL> show pdbs;

CREATE PLUGGABLE DATABASE PPDB_RCVRD USING '/data/TCDB19/ppdb_rcvrd.xml' NOCOPY TEMPFILE REUSE;

alter pluggable database PPDB_RCVRD open;
alter pluggable database PPDB_RCVRD save state;

alter session set container=PPDB_RCVRD;

Disassemble dummy(temporary) orcl-01/TCDB19 instance

🛈 Use DBCA or do the same as removing the datafiles, redo logs, controlfiles manually:

export ORACLE_HOME=/opt/oracle/db19c
export ORACLE_SID=TCDB19

grep Huge /proc/meminfo
# HugePages_Total:   36876
# HugePages_Free:     2080

vi /opt/oracle/db19c/dbs/initTCDB19.ora
# *.sga_max_size=1G
# *.sga_target=1G

sqlplus / as sysdba

SYS@TCDB19:SQL>
DROP PLUGGABLE DATABASE PPDB_RCVRD INCLUDING DATAFILES;

shutdown immediate
--startup mount exclusive restrict
startup mount pfile='/opt/oracle/db19c/dbs/initTCDB19.ora' exclusive restrict;

!grep Huge /proc/meminfo
# HugePages_Total:   36876
# HugePages_Free:     1570
exit
du -hs /data/TCDB19
# 14G

rman target /
# connected to target database: TCDB19 (DBID=xxxxxxx, not open)

drop database including backups noprompt;

# database name is "TCDB19" and DBID is xxxxxxxx
#
# using target database control file instead of recovery catalog
#
# backup piece handle=/opt/oracle/db19c/dbs/c-xxxxxxxxx-20250202-00 RECID=1 STAMP=1192043760
# Deleted 1 objects
#
# database name is "TCDB19" and DBID is xxxxxxxxx
# database dropped

exit
du -hs /data/TCDB19
# 4.0K

du -hs /arch/TCDB19/
# 4.0K

du -hs /opt/oracle/diag/rdbms/tcdb19
# 18M

grep Huge /proc/meminfo
# HugePages_Total:   36876
# HugePages_Free:     8020

su -

#rm -R /data/TCDB19
#rm -R /arch/TCDB19

RMAN Point-In-Time Recovery

Mount the instance

su - oracle
cd /backups/CDB19/rman/backup
 
rman target /

RMAN> startup mount;

Restore the datafiles and Recover the database

RMAN> run
{
  allocate channel dev1 type disk;
  set until time "to_date('2026-09-26 02:00:00', 'yyyy-mm-dd h24:mi:ss')";
  restore database;
  recover database;
}
Recovery Manager complete.

Open the database and reset logs

RMAN> alter database open resetlogs;
database opened
RMAN> quit
🛈 This will update all current datafiles and online redo logs and all subsequent archived redo logs with a new RESETLOGS SCN and time stamp.

🛈 As soon as you have done a resetlogs run a full backup, this is important as should you suffer a second failure you will not be able to perform a second recovery because after resetting the logs the SCN numbers will no longer match any older backup files.

How to reset opc os user password on OCI DBSystems when SSH keys lost

Create "Console Connection" to Node OS of DB System

1. Go to required DB System in Oracle Cloud Console
2. Select "Console Connections" tab and click button "Create Console Connection"
3. Upload SSH public key (existent or generate new) e.g. recovery_key.pub
4. Once console connection "State" became "Active" go to "..." and click "Copy SSH string" in popup-menu for the active console connection
5. Execute in a local terminal(putty/bash) copied SSH string:
# path/to/recovery_key - it is private key of your public key recovery_key.pub
ssh -i path/to/recovery_key -o ProxyCommand='ssh -W %h:%p -p 443 ocid1.instanceconsoleconnection...' ocid1.instance...

# if you do not add private key to /ssh/keys on host of your terminal then use next command
ssh -i path/to/recovery_key -o ProxyCommand='ssh -i path/to/recovery_key -W %h:%p -p 443 ocid1.instanceconsoleconnection...' ocid1.instance...

🛈 Note: The terminal may appear hanging or blank. This is normal. Do not press any key or Enter. Go to next step below

Reboot OS on "Node" of DB system

1. Go to "Nodes" tab of DB System in Oracle Cloud Console and navigate to "..." against of first "Available" node and click "Reboot" in popup-menu
2. Immediately switch focus to the terminal window with active console connection
3. As the node restarts, you will see BIOS output

🛈 Note: On reboot: Power down, press ESC repeatedly until you're get in to the Boot Manager. Please press ESC more intensively/often

4. Choose Boot manager > EFI Internal Shell
5. Press ESC to interrupt the UEFI startup process
then enter
Shell>
FS0:
cd EFI
cd redhat
You should see a user.cfg file:
FS0:\EFI\redhat>
ls
Remove user.cfg
FS0:\EFI\redhat> rm user.cfg
then exit from "EFI Internal Shell"
FS0:\EFI\redhat> 
exit
6. Press ESC to return into EFI "Main Menu"
7. Select "Continue" and press Enter to get to Linux kernels menu for boot
8. You will be back in Boot manager, choose a kernel "Oracle Linux" (or whichever is the first option) and press ESC repeatedly and press E
you should be able to proceed with the next steps:
  • Locate the line starting with linux/linuxefi/vmlinuz or kernel. Scroll to the very end of this line and append the string: rw init=/bin/bash
    load_video
    set gfx_payload=keep
    insmod gzio
    linux ($root)/vmlinuz-5.4.17-2136.326.6.el8uek.x86_64 root=/dev/mapper/vg00-ro\
    ot ro LANG=en_US.UTF-8 audit=1 console=hvc0 console=tty0 console=ttyS0,9600n8 \
    crashkernel=auto  ipmi_si.tryacpi=0 ipmi_si.trydefaults=0 ipmi_si.trydmi=0 lib\
    iscsi.debug_libiscsi_eh=1 loglevel=3 net.ifnames=1 netroot=iscsi:169.128.0.2::\
    :1:iqn.2015-02.oracle.boot:uefi network-config=e2NvbmZpZzogZGlzYWJsZWR9Cg== no\
    modeset nvme_core.shutdown_timeout=10 rd.dm=0 rd.iscsi_param=node.session.time\
    o.replacement_timeout=6000 rd.luks=0 rd.lvm.lv=vg00 rd.md=0 vconsole.font=lata\
    rcyrheb-sun16 vconsole.keymap=us numa=off transparent_hugepage=madvise biosdev\
    name=1 rd_NO_DM PRODUCT=ORACLE_SERVER_X5-2 TYPE=X5_2_LITE_IAAS intremap=off rd\
    .net.timeout.dhcp=10 ip=dhcp,dhcp6 rw init=/bin/bash
    initrd  ($root)/initramfs-5.4.17-2136.326.6.el8uek.x86_64.img $tuned_initrd
        
  • Press Ctrl + X to boot

Reset the opc os user password

[root@localhost /] passwd opc
1. Go to DB System "Nodes" tab in Oracle Cloud Console restart node

🛈 Navigate to "..." against of first "Available" node and click "Reboot" in popup-menu

2. Check opc password:
ssh opc@xxx.xxx.xxx.xxx
opc@xxx.xxx.xxx.xxx's password:

[opc@ ~]$

Clean *.aud files

    sudo -i
    su - oracle
    cd  /u01/app/oracle/admin/orcl/adump
    du -sh
    find. -name "*.aud" -mtime +30 -delete
  

вторник, 27 января 2026 г.

visudo - description of what each column means

su -
visudo
Description what each column means
#-----------------------------------------------
# john ALL = (ALL:ALL) NOPASSWD: ALL
#  ^    ^      ^   ^              ^
#  |    |      |   |              |
# user  | all users|              |
#     host         |       all commands
#              all groups
#-----------------------------------------------
oracle  ALL=(ALL)       NOPASSWD: ALL

Install btop on Oracle Linux 8

To install btop++ on Oracle Linux 8, you can use the dnf package manager after enabling the EPEL repository.

Method 1: Using the EPEL Repository (Recommended)

The easiest way to install btop++ is by using the Extra Packages for Enterprise Linux (EPEL) repository.
1. Install the EPEL repository:
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

🛈 This command adds the EPEL repository configuration to your system.

2. Install btop
Once the repository is enabled, you can install btop (the executable name for btop++) using dnf:
sudo dnf install btop
3. Run btop:
btop