Thursday, 28 May 2020

configuring standby database using rman duplicate command without backup


configuring standby database using rman duplicate command without backup

Servers details:


Environments
hostname
Ip address
instance
Primary server
Prim-host
primdb

Standby Server
Stdby-host
stdbydb


-        Install 18c grid standalone software in the DR server
-        Install the RDBMS home similar version as prod 12.2.0

Prepare primary server:


1.      Check database is in archivelog mode or not.

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     123816
Next log sequence to archive   123818
Current log sequence           123818

2.      Check the force logging is enabled or not in primary database.
SQL> select force_logging from v$database;

FORCE_LOGGING
---------------------------------------
NO
Enable force logging using below command.

SQL> ALTER DATABASE FORCE LOGGING;

Database altered.

SQL> select force_logging from v$database;

FORCE_LOGGING
---------------------------------------
YES

3.      Create password file in primary database.
orapwd file=orapwPRIMDB password=Ora935#kfd


4.      Create standby redologs in primary database to enable real time apply.

set lines 180
col MEMBER for a60
select b.thread#, a.group#, a.member, b.bytes FROM v$logfile a, v$log b WHERE a.group# = b.group#;

   THREAD#     GROUP# MEMBER                                                       B.BYTES/1024/1024
---------- ---------- ------------------------------------------------------------ -----------------
         1          1 +DATA/PRIMDB/ONLINELOG/group_1.259.1028024215                           200
         1          1 +DATA/PRIMDB/ONLINELOG/group_1.260.1028024217                           200
         1          2 +DATA/PRIMDB/ONLINELOG/group_2.261.1028024219                           200
         1          2 +DATA/PRIMDB/ONLINELOG/group_2.262.1028024221                           200
         1          3 +DATA/PRIMDB/ONLINELOG/group_3.263.1028024223                           200
         1          3 +DATA/PRIMDB/ONLINELOG/group_3.264.1028024223                           200

ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 SIZE 200M;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 SIZE 200M;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 SIZE 200M;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 SIZE 200M;

SQL> select a.group#, a.member, b.bytes FROM v$logfile a, v$standby_log b WHERE a.group# = b.group#;

    GROUP# MEMBER                                                            BYTES
---------- ------------------------------------------------------------ ----------
         4 +DATA/PRIMDB/ONLINELOG/group_4.801.1041440071              209715200
         4 +DATA/PRIMDB/ONLINELOG/group_4.478.1041440071              209715200
         6 +DATA/PRIMDB/ONLINELOG/group_6.545.1041439901              209715200
         6 +DATA/PRIMDB/ONLINELOG/group_6.368.1041439901              209715200
         5 +DATA/PRIMDB/ONLINELOG/group_5.311.1041440081              209715200
         5 +DATA/PRIMDB/ONLINELOG/group_5.567.1041440081              209715200
         7 +DATA/PRIMDB/ONLINELOG/group_7.474.1041440103              209715200
         7 +DATA/PRIMDB/ONLINELOG/group_7.771.1041440105              209715200

8 rows selected.

5.      Set parameter in primary database.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(PRIMDB,STDBYDB)' scope=both;

System altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=+DATA VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=PRIMDB' scope=both;

System altered.
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=STDBYDB LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=STDBYDB' scope=both;

System altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_1=ENABLE scope=both;

System altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE scope=both;

System altered.

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;

System altered.

SQL> ALTER SYSTEM SET fal_server=STDBYDB scope=both;

System altered.

6.      Take pfile as backup

SQL> create pfile='/tmp/primpfile.ora' from spfile;

File created.
7.      Copy pfile and password file to standby server $ORACLE_HOME/dbs location.

Standby server configuration:


1.      Rename the pfile as initSTDBYDB and Modify as below.

*.audit_file_dest='/opt/oracle/oracle_base/admin/STDBYDB/adump'
*.audit_trail='db'
*.compatible='12.2.0'
*.control_file_record_keep_time=38
*.control_files='+DATA/STDBYDB/CONTROLFILE/current.257.1041446223','+DATA/STDBYDB/CONTROLFILE/current.258.1041446227'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_name='PRD2020D'
*.db_recovery_file_dest='+DATA'
*.db_recovery_file_dest_size=107374182400
*.db_unique_name='STDBYDB'
*.diagnostic_dest='/opt/oracle/oracle_base'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=STDBYDBXDB)'
*.fal_server='PRIMDB'
*.local_listener=''
*.log_archive_config='DG_CONFIG=(PRIMDB,STDBYDB)'
*.log_archive_dest_1='LOCATION=+DATA VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=STDBYDB'
*.log_archive_dest_2='SERVICE=PRIMDB LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PRIMDB'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.pga_aggregate_target=15G
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=1400
*.sga_max_size=50G
*.sga_target=50G
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'

2.      rename the password file as orapwSTDBYDB
3.      add entry in /etc/oratab file.

vi /etc/oratab
STDBYDB:/opt/oracle/product/12.2.0.1/dbhome_1:N

4.      start the instance in nomount

$. oraenv
STDBYDB
$sqlplus / as sysdba
startup nomount

configuring network:

              
1.      add tns entry in both primary and standby (in RDBMS home)
tnsnames.ora in primary

PRIMDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = prim-host)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = PRIMDB)
    )
  )

STDBYDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = stdby-host )(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = STDBYDB)
      (UR=A)
    )
  )

tnsnames.ora in standby (RDBMS home)

PRIMDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = prim-host)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = PRIMDB)
    )
  )

STDBYDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = stdby-host )(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = STDBYDB)
      (UR=A)
    )
  )

2.      configure listener in standby server.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = stdby-host)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = STDBYDB_DGMGRL)
      (ORACLE_HOME = /opt/oracle/product/18.0.0/grid)
      (SID_NAME = STDBYDB)
    )
  )

3.      Tnsping check.

oracle@Stdby-host:~[DB->STDBYDB]$tnsping STDBYDB

TNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 27-MAY-2020 10:39:52

Copyright (c) 1997, 2016, Oracle.  All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = stdby-host)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = STDBYDB) (UR=A)))
OK (10 msec)
oracle@Stdby-host:~[DB->STDBYDB]$tnsping PRIMDB

TNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 27-MAY-2020 10:39:57

Copyright (c) 1997, 2016, Oracle.  All rights reserved.

Used parameter files:

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = prim-host)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = PRIMDB)))
OK (30 msec)
4.      Password file authentication check from standby server
oracle@Stdby-host:~[DB->STDBYDB]$sqlplus sys/Ora935#kfd@STDBYDB as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed May 27 10:47:20 2020

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

Last Successful login time: Wed May 27 2020 08:32:16 +00:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select host_name from v$instance;

HOST_NAME
----------------------------------------------------------------
Stdby-host
oracle@Stdby-host:~[DB->STDBYDB]$sqlplus sys/Ora935#kfd@PRIMDB  as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed May 27 10:49:11 2020

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

Last Successful login time: Wed May 27 2020 10:48:48 +00:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select host_name from v$instance;

HOST_NAME
----------------------------------------------------------------
Prim-host
5.      Password file authentication check from primary server.
oracle@Prim-host:~[DB->PRIMDB]$sqlplus sys/Ora935#kfd@PRIMDB  as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed May 27 12:50:33 2020

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

Last Successful login time: Wed May 27 2020 12:50:26 +02:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select host_name from v$instance;

HOST_NAME
----------------------------------------------------------------
Prim-host

SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
oracle@Prim-host:~[DB->PRIMDB]$sqlplus sys/AppleT0p#^1@STDBYDB as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed May 27 12:51:07 2020

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

Last Successful login time: Wed May 27 2020 12:47:21 +02:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select host_name from v$instance;

HOST_NAME
----------------------------------------------------------------
Stdby-host


Database restore for standby:


1.      Prepare script restore_stdby_db.sh
$cat restore_stdby_db.sh

rman target sys/Ora935#kfd@PRIMDB AUXILIARY sys/AppleT0p#^1@STDBYDB  log= RMAN_restore.log << EOF
run
{
DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE NOFILENAMECHECK;
}
EOF

If file location is different in standby use file convert as below in command.
DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE DORECOVER SPFILE
SET db_unique_name='stdbydb'
SET db_file_name_convert='/u01/primdb/','/u01/stdbydb'
SET log_file_name_convert='/u01/primdb/','/u01/stdbydb'
SET job_queue_processes='0'
NOFILENAMECHECK;

2.      Put database in recovery mode.
SQL> SELECT NAME,OPEN_MODE,DB_UNIQUE_NAME,DATABASE_ROLE,PROTECTION_MODE FROM V$DATABASE;

NAME      OPEN_MODE            DB_UNIQUE_NAME                 DATABASE_ROLE    PROTECTION_MODE
--------- -------------------- ------------------------------ ---------------- --------------------
PRD2020D  MOUNTED              STDBYDB                      PHYSICAL STANDBY MAXIMUM PERFORMANCE
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

3.      Add DR database to HA(standalone grid infrastructure).

$. oraenv
+ASM
$srvctl add database -d STDBYDB -o /opt/oracle/product/12.2.0.1/dbhome_1 -p +DATA/STDBYDB/PARAMETERFILE/spfile.644.1041511849
4.      Modify startup option and database role.
Export grid home/ASM.
$. oraenv
+ASM
srvctl modify database -d STDBYDB -role PHYSICAL_STANDBY -startoption MOUNT



Tuesday, 26 May 2020

OGG-06535 Extract does not support the database compatible setting 12.2.0.

Below error come if you are configuring goldengate version 12.2 for the database with compatibility version 12.2.0

 OGG-06535  Extract does not support the database compatible setting 12.2.0.

reason: goldengate 12.2 will not support the database version with 12.2.0.

solution: install goldengate version 12.3 or 19.1

goldengate 19.1.0.0.4 installation for oracle

goldengate 19.1.0.0.4 installation for oracle.


1. Download file below.

191004_fbo_ggs_Linux_x64_shiphome.zip

2. After unzip, you will get the file 191004_fbo_ggs_Linux_x64_shiphome

3. update response file.
[oracle@localhost opt]$ cd /opt/191004_fbo_ggs_Linux_x64_shiphome/Disk1/response

vi oggcore.rsp

INSTALL_OPTION=ORA12C    /* this parameter indicates database version, ORA12C is for oracle 12c if DB version is 19c value should be ORA19C, Refer response file. */
SOFTWARE_LOCATION=/u01/app/oracle/products/ogg19
START_MANAGER=NO
DATABASE_LOCATION=/u01/app/oracle/product/12.2.0/dbhome_1
INVENTORY_LOCATION=/u01/app/oraInventory
UNIX_GROUP_NAME=oinstall

4. Install in silent mode.
[oracle@localhost Disk1]$ ./runInstaller -silent -nowait -responseFile /opt/191004_fbo_ggs_Linux_x64_shiphome/Disk1/response/oggcore.rsp

Wednesday, 13 May 2020

ORA-19588: archived log RECID 75889 STAMP is no longer valid

this issue come when there is parallel archivelog backups ran try to take backup or try to delete same archivelog.
Make sure another archivelog backup jobs running on the database and take the same archivelog files backup.



Tuesday, 12 May 2020

ORA-28040: No matching authentication protocol.

when you use old version client to connect to connect latest database server version, you may get below issue.

ORA-28040: No matching authentication protocol.

Ex: oracle 11.1 client is trying to connect 12.2 database server.

you may set the parameter SQLNET.ALLOWED_LOGON_VERSION_SERVER in sqlnet.ora to fix the issue.
you can find the full details about the parameter settings here 

Monday, 11 May 2020

ASMCMD-8102: no connection to Oracle ASM; command requires Oracle ASM to run


One of the servers in my environment, i found ASM instance strange behavior, none of the ASM commands works and saying idle instance, but you can see the ASM instance is running if i check with ps -ef and database also running fine, i am able to switch logfile. 

when i run ASM commands i am getting below error.

oracle@oradb_dev:~[DB->orcl]$asmcmd lsdg
Connected to an idle instance.
ASMCMD-8102: no connection to Oracle ASM; command requires Oracle ASM to run

when i try to connect ASM instance, it says idle instance.

oracle@oradb_dev:~[DB->orcl]$sqlplus / as sysasm

SQL*Plus: Release 12.2.0.1.0 Production on Fri May 8 07:14:24 2020

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

Connected to an idle instance.

SQL> 

I can see the following message in alertlog.

Process m000 died, see its trace file
2020-05-07T11:36:25.151381+00:00
Process m000 died, see its trace file
2020-05-07T11:36:38.154337+00:00


Fix:
Oracle suggest to restart the HA stack. after restart HA stack, issue got resolved.

Monday, 4 May 2020

ORA-02374: conversion error loading table,ORA-12899: value too large for column


When you run import dump into a database you may get below error.

ORA-02374: conversion error loading table "DATA"."TEST_TABLE"
ORA-12899: value too large for column AT_TEXT (actual: 2001, maximum: 2000)
ORA-02372: data for row: AT_TEXT : '999999934389384734HUKL83434JJ'

Reason: you can observe the error messages saying column length of the table is not sufficient to import the data, its saying column length is 2000 characters but value to be loaded into the column is 2001. how its possible?, how the table in source is having more characters in the column?.

Its due to character set change from source to target, you may find the message in import log as below.

import done in AL32UTF8 character set and AL16UTF16 NCHAR character set
export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
Warning: possible data loss in character set conversions

in the above message its clearly saying export is done in  WE8MSWIN1252 and doing import in AL32UTF8

Solution:
1. you can import the only metadata of the table first and increase column length and import it, make sure the data is validated in this case, because you may get strange characters in the data. to avoid this you may regenerate data.
2. character set conversion, before importing to the target database, you need to import into a dummy database which is in the same character set as source then convert into target database character set by using tools like DMU tool, CSALTER etc.

you can check here how to convert character set using CSALTER