Showing posts with label db_file_name_convert. Show all posts
Showing posts with label db_file_name_convert. Show all posts

Wednesday, December 27, 2023

Oracle: Will "set newname for database to new" work in active DB duplication?

Dears,

Today, while I was assisting my colleague to get a standby db build using active db duplication command.

Source DB is 30TB in size.

Background: the standby database was activated last saturday due to primary server hardware issue.

We were left with no flashback option, since it wasnt enabled. So db restore in the old primary was the only way to reinstate (we differed OS utilities).


Challenge: The db had a mix of non-OFM and OFM format of datafiles.

So I discussed with my colleague and proposed to move all the files to OMF format for 

  1. auto standby file management
  2. ease of datafile maintenance operations later

We noticed the DB had
  • db_file_name_convert
  • db_create_file_dest
parameters set. When I fired the active db duplication asis, with no change to these 2 param setting.
I noticed, Oracle trying to restore even the OMF files into the same path in target as if it is restoring the non-OMF files (file names had encrypted identity).

So I decided to remove db_file_name_convert, after reading oracle doc, I felt this is the main culprit.
To ensure the datafiles gets the benefit of db_create_file_dest parameter, I introduced

"set newname for database to new" as well to the duplicate rman run command.

run
{
allocate channel prmry1 type disk;
...
allocate channel auxiliary channel stby1 type disk;
...
set newname for database to new;
duplicate target database for standby from active databvase
dorecover
spfile
   parameter...
...
NOFILENAMECHECK;
}

All the files got restored to the location indicated by db_create_file_dest as I expected.
This worked perfectly fine.

Thanks

Sunday, April 23, 2023

Part 1: Inventory application setup (low code) using apex

Objective: Setup an inventory application (low code) using Oracle APEX


Part 1: Downloading APEX binaries and Setting up the oracle DB for the APEX install


APEX Installation steps:


Step 1) 
Go to the following url & download the apex bin:
http://www.oracle.com/technetwork/developer-tools/apex/downloads/index.html
FileName: apex_22.2_en.zip

Step 2)
Copy the file to the Linux Server into some directory
I kept in /u01/app/oracle/APEXBIN [empty directory]

Step 3)
Unzip the apex_22.2_en.zip file

Step 4)
It should create the below directories and files

[oracle@vcentos79-oracle-sa1 APEXBIN]$ ls -altr
total 186012
drwxr-xr-x. 6 oracle oinstall      4096 Nov 11 19:38 apex
drwxr-xr-x. 9 oracle oinstall       112 Apr 19 20:26 ..
-rwxr-xr-x. 1 oracle oinstall 190469084 Apr 19 20:26 apex_22.2_en.zip
drwxr-xr-x. 2 oracle oinstall        64 Apr 19 20:26 META-INF
drwxr-xr-x. 4 oracle oinstall        58 Apr 19 20:26 .
[oracle@vcentos79-oracle-sa1 APEXBIN]$

Step 5) 
Create a pluggable database in 19c

CREATE PLUGGABLE DATABASE inventorypdb ADMIN USER inventoryadm IDENTIFIED BY inventoryadm;

Error:

SQL> CREATE PLUGGABLE DATABASE inventorypdb ADMIN USER inventoryadm IDENTIFIED BY inventoryadm;
CREATE PLUGGABLE DATABASE inventorypdb ADMIN USER inventoryadm IDENTIFIED BY inventoryadm
                                                                                        *
ERROR at line 1:
ORA-65016: FILE_NAME_CONVERT must be specified

SQL>

Because I didnt have either db_create_file_dest or db_file_name_convert params set

SQL> sho parameter convert;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert                 string
log_file_name_convert                string
pdb_file_name_convert                string
SQL> show parameter db_create
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest                  string
db_create_online_log_dest_1          string
db_create_online_log_dest_2          string
db_create_online_log_dest_3          string
db_create_online_log_dest_4          string
db_create_online_log_dest_5          string

Solution:

SQL> show parameter db_create;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest                  string      /oradata/

Now:

SQL> CREATE PLUGGABLE DATABASE inventorypdb ADMIN USER inventoryadm IDENTIFIED BY inventoryadm;
Pluggable database created.
SQL>

SQL> alter pluggable database INVENTORYPDB OPEN;
Pluggable database altered.

SQL> select name,open_mode from v$pdbs;
NAME            OPEN_MODE
--------------- ----------
PDB$SEED        READ ONLY
..
INVENTORYPDB    READ WRITE
SQL>

Wednesday, February 9, 2022

Standby setup in oracle 19c using active database duplication (no OMF or ASM)

Objective of this exercise:
Setup a standby database using active database duplication in oracle 19c. The database isnt using OMF or ASM.

oracle document used for reference: https://docs.oracle.com/en/database/oracle/oracle-database/19/sbydb/creating-oracle-data-guard-physical-standby.html#GUID-0DC30726-3471-4588-BFE0-9CA0736328E2

Create an example primary db:
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname ORA19C01 -sid ORA19C01 -responseFile NO_VALUE -characterSet AL32UTF8 -sysPassword <syspass> -systemPassword <systempass> -databaseType MULTIPURPOSE -automaticMemoryManagement false -totalMemory 2000 -storageType FS -datafileDestination /oradata  -redoLogFileSize 50 -emConfiguration NONE -ignorePreReqs

Setting up the primary DB for dataguard setup:
1) Enable appropriate logging (there are other 2 modes available as well, which is an enhancement to support batch loads)

SQL> alter database force logging;
Database altered.

SQL> select name,open_mode,database_role,log_mode,force_logging from v$database;
NAME      OPEN_MODE            DATABASE_ROLE    LOG_MODE     FORCE_LOGG
--------- -------------------- ---------------- ------------ ----------
ORA19C01  READ WRITE           PRIMARY          NOARCHIVELOG YES
SQL>

2) Configure redo transport authentication:

setup the below params:
log_archive_dest_n
fal_server

3) Add necessary standby redologs
Always add g+1 number of standby logfile. Where g is the numbe of redologs found in primary.
alter database add standby logfile ('<path>') size 50M;

4) Setup initialization params on primary db (supports both primary and standby role)

primary: chicago
standby: boston

Primary role params:
DB_NAME=chicago
DB_UNIQUE_NAME=chicago
LOG_ARCHIVE_CONFIG='DG_CONFIG=(chicago,boston)'
CONTROL_FILES='/arch1/chicago/control1.ctl', '/arch2/chicago/control2.ctl'
LOG_ARCHIVE_DEST_1=
 'LOCATION=USE_DB_RECOVERY_FILE_DEST 
  VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
  DB_UNIQUE_NAME=chicago'
LOG_ARCHIVE_DEST_2=
 'SERVICE=boston ASYNC
  VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) 
  DB_UNIQUE_NAME=boston'
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc

Standby role params:
FAL_SERVER=boston
DB_FILE_NAME_CONVERT='/boston/','/chicago/'
LOG_FILE_NAME_CONVERT='/boston/','/chicago/' 
STANDBY_FILE_MANAGEMENT=AUTO

Actual:
alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(ORA19C01,ORA19C01SB1)';
alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ORA19C01';
alter system set LOG_ARCHIVE_DEST_2='SERVICE=ORA19C01SB1 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORA19C01SB1';
alter system set LOG_ARCHIVE_FORMAT='ORA19C01_%t_%s_%r.arc' scope=spfile;

alter system set FAL_SERVER=ORA19C01SB1;
alter system set DB_FILE_NAME_CONVERT='/ORA19C01SB1/','/ORA19C01/' scope=spfile;
alter system set LOG_FILE_NAME_CONVERT='/ORA19C01SB1/','/ORA19C01/' scope=spfile;
alter system set STANDBY_FILE_MANAGEMENT=AUTO;

5) Create a Backup Copy of the Primary Database Data Files
6) Create a Control File for the Standby Database
7) Create a Parameter File for the Standby Database
8) Copy Files from the Primary System to the Standby System

Note:The steps 5 through 8 will be done using active database cloning.

9) Set Up the Environment to Support the Standby Database

a) Add /etc/oratab entry

standby:
[oracle@localhost dbs]$ tail -1 /etc/oratab
ORA19C01SB1:/u01/app/oracle/product/19.0.0/db_1:N
[oracle@localhost dbs]$

b) Copy password file from primary to standby

Primary:
[oracle@localhost dbs]$ cp orapwORA19C01 orapwORA19C01SB1
[oracle@localhost dbs]$ scp orapwORA19C01SB1 oracle@192.168.50.5:/u01/app/oracle/product/19.0.0/db_1/dbs
oracle@192.168.50.5's password:
orapwORA19C01SB1                                                             100% 2048   236.6KB/s   00:00
[oracle@localhost dbs]$


c) Make static entry in listener & tns entry for both the primary and standby in both the servers

Standby listener:
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = ORA19C01SB1)
      (ORACLE_HOME = /u01/app/oracle/product/19.0.0/db_1)
      (SID_NAME = ORA19C01SB1)
    )
  )

Primary listener:
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = ORA19C01)
      (ORACLE_HOME = /u01/app/oracle/product/19.0.0/db_1)
      (SID_NAME = ORA19C01)
    )
  )

Both tnsnames.ora:
ORA19C01 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.50.4)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ORA19C01)
    )
  )
ORA19C01SB1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.50.5)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ORA19C01SB1)
    )
  )

d) Add only db_name and db_unique_name parameter and startup nomount the standby database

[oracle@localhost dbs]$ cat initORA19C01SB1.ora
db_name=ORA19C01
db_unique_name=ORA19C01SB1
[oracle@localhost dbs]$

SQL> select instance_name,status from v$instance;
INSTANCE_NAME    STATUS
---------------- ------------
ORA19C01SB1      STARTED

e) start the local listener if not done already in both primary and standby
f) Create the dump destination and controlfile, datafile, redologfile directories manually. Since we arent using ASM or OMF

primary:
[oracle@localhost dbs]$ find /oradata|grep -Ev ".dbf|.log|.ctl|mf"
/oradata
/oradata/ORA19C01
/oradata/ORA19C01/archives
/oradata/ORA19C01/archives/ORA19C01
[oracle@localhost dbs]$

Standby:
[oracle@localhost oradata]$ find /oradata
/oradata
/oradata/ORA19C01SB1
/oradata/ORA19C01SB1/archives
/oradata/ORA19C01SB1/archives/ORA19C01SB1
[oracle@localhost oradata]$

Location of controlfile, datafile, redologfile: /oradata/ORA19C01SB1
Location of archives: /oradata/ORA19C01SB1/archives/ORA19C01SB1
adump: /u01/app/oracle/admin/ORA19C01SB1/adump

10) Frame the active database duplication command
reference: https://docs.oracle.com/en/database/oracle/oracle-database/19/sbydb/creating-data-guard-standby-database-using-RMAN.html#GUID-C713FD5C-3375-45E4-A78F-4063006DAC5B

ex:
DUPLICATE TARGET DATABASE
  FOR STANDBY
  FROM ACTIVE DATABASE
  DORECOVER
  SPFILE
    SET "db_unique_name"="foou" COMMENT "Is a duplicate"
    SET LOG_ARCHIVE_DEST_2="service=inst3 ASYNC REGISTER
     VALID_FOR=(online_logfile,primary_role)"
    SET FAL_SERVER="inst1" COMMENT "Is primary"
  NOFILENAMECHECK;

Actuals:

File: sbysetup.cmd
Contents:
DUPLICATE TARGET DATABASE
  FOR STANDBY
  FROM ACTIVE DATABASE
  DORECOVER
  SPFILE
    PARAMETER_VALUE_CONVERT='ORA19C01','ORA19C01SB1'
    SET "db_name"="ORA19C01"
    SET "db_unique_name"="ORA19C01SB1"
    SET DB_FILE_NAME_CONVERT='/ORA19C01/','/ORA19C01SB1/'
    SET LOG_FILE_NAME_CONVERT='/ORA19C01/','/ORA19C01SB1/'
    SET LOG_ARCHIVE_DEST_2="service=ORA19C01 ASYNC REGISTER
     VALID_FOR=(online_logfile,primary_role)"
    SET FAL_SERVER="ORA19C01"
  NOFILENAMECHECK;

Notes:
db_file_name_convert & log_file_name_convert arent required in case you use OMF. Ensure to unset this params in source as well, otherwise you will recieve an RMAN- error.
db_name param is needed in the duplicate command, since your using PARAMETER_VALUE_CONVERT keyword in the duplicate command.

11) Make service based test connection to both primary and standby, if required stop the firewall on the host or make necessary exceptions.

12) Frame a shell script to call the command we framed above....
File: sbysetup.sh
Contents:
cd /home/oracle/dba/SbySetup;
export ORACLE_SID=ORA19C01SB1;export ORAENV_ASK=NO;. oraenv >/dev/null 2>&1;
rman target sys/sys@ORA19C01 auxiliary sys/sys@ORA19C01SB1 cmdfile=sbysetup.cmd log=sbysetup_duplicate.log

13) Invoke the shell script:
nohup sh sbysetup.sh > nh_sbysetup.out &

14) Wait for the duplicate command to finish

15) Verify the output:

Output:
[oracle@localhost SbySetup]$ head -5 sbysetup_duplicate.log
Recovery Manager: Release 19.0.0.0.0 - Production on Wed Feb 9 23:25:59 2022
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.
[oracle@localhost SbySetup]$ head -10 sbysetup_duplicate.log
Recovery Manager: Release 19.0.0.0.0 - Production on Wed Feb 9 23:25:59 2022
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.
connected to target database: ORA19C01 (DBID=3909934395)
connected to auxiliary database: ORA19C01 (not mounted)
RMAN> DUPLICATE TARGET DATABASE
[oracle@localhost SbySetup]$ tail -4 sbysetup_duplicate.log
Finished Duplicate Db at 09-FEB-22
Recovery Manager complete.
---

[oracle@localhost SbySetup]$ grep -iE "RMAN-|ORA-" sbysetup_duplicate.log
[oracle@localhost SbySetup]$

16) Verify file locations:
SQL> select name from v$datafile;
NAME
----------------------------------
/oradata/ORA19C01SB1/system01.dbf
/oradata/ORA19C01SB1/sysaux01.dbf
/oradata/ORA19C01SB1/undotbs01.dbf
/oradata/ORA19C01SB1/users01.dbf
SQL> select member from v$logfile;
MEMBER
----------------------------------
/oradata/ORA19C01SB1/redo03.log
/oradata/ORA19C01SB1/redo02.log
/oradata/ORA19C01SB1/redo01.log
SQL> select name from v$controlfile;
NAME
------------------------------------
/oradata/ORA19C01SB1/control01.ctl
/oradata/ORA19C01SB1/control02.ctl
SQL> select name from v$tempfile;
NAME
--------------------------------
/oradata/ORA19C01SB1/temp01.dbf
SQL>

[oracle@localhost SbySetup]$

17) There is no automatic recovery initated by the duplication command, hence we manually kick off the recovery..

command: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;


SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Database altered.

SQL> select process,pid,status,client_process from v$managed_standby;
PROCESS   PID                      STATUS       CLIENT_P
--------- ------------------------ ------------ --------
DGRD      14968                    ALLOCATED    N/A
ARCH      14970                    CONNECTED    ARCH
DGRD      14972                    ALLOCATED    N/A
ARCH      14974                    CONNECTED    ARCH
ARCH      14976                    CONNECTED    ARCH
ARCH      14978                    CONNECTED    ARCH
RFS       15576                    IDLE         UNKNOWN
RFS       15578                    IDLE         LGWR
RFS       15581                    IDLE         Archival
MRP0      15790                    WAIT_FOR_LOG N/A
10 rows selected.

SQL> /
PROCESS   PID                      STATUS       CLIENT_P  SEQUENCE#
--------- ------------------------ ------------ -------- ----------
DGRD      14968                    ALLOCATED    N/A               0
ARCH      14970                    CONNECTED    ARCH              0
DGRD      14972                    ALLOCATED    N/A               0
ARCH      14974                    CONNECTED    ARCH              0
ARCH      14976                    CONNECTED    ARCH              0
ARCH      14978                    CONNECTED    ARCH              0
RFS       15576                    IDLE         UNKNOWN           0
RFS       15578                    IDLE         LGWR             32
RFS       15581                    IDLE         Archival          0
MRP0      15790                    WAIT_FOR_LOG N/A              32
10 rows selected.

cmd: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Database altered.
SQL>

The recovery is cancelled.

Thanks

OKV platform certificate rotation - pitfall , awareness!!!!

OKV version: 21.9 Setup: Multimaster R/W cluster Plan: https://docs.google.com/spreadsheets/d/e/2PACX-1vSaXXTjj9cE1fvYpNmsDNBOkTIw78yTwQ6a9o...