Oracle DataGuard: Single-node to RAC cluster hosting environment setup

demand
As business grows, data volume becomes more and more complex, data volume becomes larger and larger, and requirements for database and server performance, high availability, disaster tolerance become higher and higher.Taking the current database environment as an example, the size of Windows 2008 r2 server + NAS storage + Oracle11.2.0.1+12T+300GARCH/day has become very bulky and no longer suitable for fast-growing business scenarios.
Therefore, according to business scenarios, data size, and customer needs, it is proposed that the database be migrated to Linux+OracleRAC environment, synchronization is completed before master-backup switching, to meet the high availability and disaster tolerance needs of the database.

Implementation Steps
DBCA creates a cluster test database (orcl);
Primary and standby database parameter settings;
Delete cluster database control files and data files, log files;
Start only the instance of RAC Node 1 for database synchronization;
Start Node 2 after archive pursuit is complete;
Monitor database synchronization status;
Monitor cluster status.

Primary Database Environment

Network Planning

The main and backup environments are in the same computer room, and in order not to affect the production environment, a direct connection network is pulled to configure the local area network environment.Host configuration 192.168.1.1, standby RAC node 1 configuration 192.168.1.2.
Keep in mind that DNS is not generated automatically to avoid loops within two machines that affect network routing with the core switch.

Reference Documents
How to Create a RAC Standby Database
http://www.oracle.com/technetwork/cn/database/dataguardoverview-091578-zhs.html
http://www.oracle.com/technetwork/database/features/availability/twp-dataguard-11gr2-1-131981.pdf

Main Library Environment Checks and Parameter Settings

# Whether to turn on force logging
SQL> select force_logging from v$database;

FORCE_LOGGING
---------------------------------------
YES
#   Force on if NO
SQL> alter database force logging;
Database altered.

# Whether to turn on archiving
SQL> archive log list

Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           G:\arch
Oldest online log sequence     100
Next log sequence to archive   102
Current log sequence           102
#    If not, restart the database to mount and open the archive
SQL> startup mount
ORACLE instance started.
Total System Global Area 2147483648 bytes
Fixed Size 2926472 bytes
Variable Size 1392511096 bytes
Database Buffers 738197504 bytes
Redo Buffers 13848576 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.

# (oracle)tnsnames.ora service configuration
# The backup database needs to be configured and the files will be copied to the RAC dual-node when the configuration is complete
ORCL_PRI =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.1)(PORT = 1523))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )

test_rac =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.2)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
      (UR = A)
    )
  )

# (oracle) Password files are copied to each node of the repository (this time, password files are generated directly in the repository)
cd $ORACLE_HOME/dbs
orapwd file=orapwdorcl1 entries=5 ignorecase=y password=xxxxxx

# (oracle) Register static listener.ora
LISTENER3 = 
  (DESCRIPTION = 
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.1)(PORT= 1523))
  )

SID_LIST_LISTENER3 =
  (SID_LIST = 
    (SID_DESC = 
      (GLOBAL_NAME = orcl)
      (ORACLE_HOME =D:\app\Administrator\product\11.2.0\dbhome_1)
      (SID_NAME = orcl)
        (ENVS = "EXTPROC_DLLS=ONLY:D:\app\Administrator\product\11.2.0\dbhome_1\bin\oracle11.dll")
    )
  )

lsnrctl start LISTENER3

lsnrctl status LISTENER3
............
Service "orcl" has 1 instance(s).
  Instance "orcl", status UNKNOW, has 1 handler(s) for this service...

# (oracle) Test whether the listener can connect properly on the repository
tnsping  orcl_pri
sqlplus xxx/yyy@orcl_pri

# (oracle) data file path
SQL> select name from v$datafile;
..................

# (oracle) log file path

SQL> select member from v$logfile;
............

# (oracle) initialization parameter configuration
# Some parameters are not modified because the primary library already has a single-node standby Library
# Online Modification
alter system set fal_server = 'orcl_dr,testrac';    
alter system set log_archive_dest_3='SERVICE=test_rac LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=testrac';

Standby environment preparation and parameter settings (Node 1)

# (oracle) Whether to turn on force logging
SQL> select force_logging from v$database;

FORCE_LOGGING
---------------------------------------
YES
#   Force on if NO
SQL> alter database force logging;
Database altered.

# (oracle) Whether to turn on archiving
SQL> archive log list
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           +ORAARCH/orcl/archivelog 
Oldest online log sequence     100
Next log sequence to archive   102
Current log sequence           102
#     If not, restart the database to mount and open the archive
SQL> startup mount
ORACLE instance started.
Total System Global Area 2147483648 bytes
Fixed Size 2926472 bytes
Variable Size 1392511096 bytes
Database Buffers 738197504 bytes
Redo Buffers 13848576 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.

# (oracle)tnsnames.ora service configuration
# The backup database needs to be configured and the files will be copied to the RAC dual-node when the configuration is complete
ORCL_PRI =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.1)(PORT = 1523))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )

test_rac =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.2)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
      (UR = A)
    )
  )

# (oracle) Register static listener.ora
# The backup database needs to be configured, after which files are copied to the RAC dual-node to modify SID_NAME and HOST information
LISTENER = 
  (DESCRIPTION = 
    (ADDRESS = (PROTOCOL = TCP)(HOST = testrac1)(PORT= 1521))
  )

SID_LIST_LISTENER =
  (SID_LIST = 
    (SID_DESC = 
      (GLOBAL_NAME = orcl)
      (ORACLE_HOME = /opt/oracle/database/product/11.2.0)
      (SID_NAME = orcl1)
    )
  )

ADR_BASE_LISTENER = /opt/oracle/database

lsnrctl start LISTENER

lsnrctl status
............
Service "LISTENER" has 1 instance(s).
  Instance "orcl1", status UNKNOW, has 1 handler(s) for this service...

# (oracle) Test whether the listener can connect properly on the main library
tnsping  test_rac
sqlplus xxx/yyy@test_rac

# (oracle) data file path
SQL> select name from v$datafile;
..................

# (oracle) log file path
SQL> select member from v$logfile;
...............

# (oracle) downtime, Under Oracle users
srvctl stop database -d orcl
srvctl status database -d orcl

# (oracle) Remove registration information from OCR
srvctl remove instance -d orcl -i orcl1
srvctl remove instance -d orcl -i orcl2
srvctl remove database -d orcl 

# (grid) Delete data, log files, control files
asmcmd

# (oracle) Initialize parameter configuration, start database to nomount state
# Online Modification
alter system set db_files=2000 scope=spfile;

alter system set db_unique_name=testrac scope=spfile;
alter system set service_names=orcl;

alter system set control_files='+ORADATA/orcl/controlfile/controlfile01.ora','+ORADATA/orcl/controlfile/controlfile02.ora','+ORAFRA/orcl/controlfile/controlfile03.ora' scope=spfile;

alter system set log_archive_config='dg_config=(orcl_pri,test_rac)'; 

alter system set log_archive_dest_1='LOCATION=+ORAARCH VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=testrac';

alter system set log_archive_dest_2='SERVICE=orcl_pri LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl';

alter system set fal_client=test_rac;

alter system set fal_server=orcl_pri;

alter system set db_file_name_convert='D:\APP\ADMINISTRATOR\ORADATA\ORCL','+ORADATA/orcl/datafile','G:\DATA','+ORADATA/orcl/datafile','F:\DATA','+ORADATA/orcl/datafile','E:\DATA','+ORADATA/orcl/datafile','C:\ORADATA','+ORADATA/orcl/datafile' scope=spfile;

alter system set log_file_name_convert='G:\arch\ORCL','+ORADATA/orcl/onlinelog' scope=spfile;

# (oracle) Register testrac information to the grid cluster
srvctl add database -d testrac -o /opt/oracle/database/product/11.2.0 -p +ORADATA/orcl/spfileorcl.ora -r PRIMARY -s open  -a "ORADATA,ORAARCH,ORAFRA"

srvctl add instance -d testrac -i orcl1 -n testrac1
srvctl add instance -d testrac -i orcl2 -n testrac2

# (oracle) Restart and manually generate a copy of the pfile to the repository
srvctl start database -d testrac -o nomount
srvctl status database -d testrac
create file=$ORACLE_HOME/pfile from spfile='+ORADATA/orcl/spfileorcl.ora';

# (oracle) Close cluster
srvctl stop database -d testrac

ADG Synchronization

# (oracle) Start node 1 database instance to nomount state
srvctl start database -d testrac -n testrac1 -o no mount

# (oracle) start synchronization
 Reference Appendix 1

standby and redo log file processing

# (oracle) Create standby log file s, one more than the primary library online log group
alter database add standby logfile group 11 '+ORADATA/orcl/standbylog/standby11a.dbf' size 1G;
..................
alter database add standby logfile group 17 '+ORADATA/orcl/standbylog/standby17a.dbf' size 1G;

# (oracle) Turn on real-time log recovery
alter database recover managed standby database disconnect from session using current logfile;

# (oracle) Primary library switches system logs (multiple times)
alter system switch logfile;

# (oracle) Open the backup Library
alter database recover managed standby database cancel;
alter database open;

# (oracle) rebuild the reserve redo log group
# View current log status
select GROUP#,STATUS from v$log;

# Turn off standby file automatic management
alter system set standby_file_management = 'MANUAL';

# Clean up and delete log groups and files for CLEARING status, and rebuild
alter database clear logfile group 1;
alter database drop logfile group 1;
alter database add logfile group 1 '+ORADATA/orcl/ONLINELOG/online01.ora' size 1G;
..................
# Clean up and delete log groups and files for CLEARING_CURRENT status, and rebuild
# Primary Library Switch Log
alter system switch logfile;

# Repository rebuild log
alter database clear logfile group 4;
alter database drop logfile group 4;
alter database add logfile group 4 '+ORADATA/orcl/ONLINELOG/online04.ora' size 1G;

# (oracle) Open the database real-time synchronization process (MRP)
alter system set standby_file_management = 'AUTO';
alter database recover managed standby database disconnect from session using current logfile;

Synchronization Check

# (oracle) Connect Standby Check
SQL> select sequence#,archived,applied from v$archived_log;
SEQUENCE# ARC APPLIED

99 YES YES
   100 YES YES
   101 YES IN-MEMORY

SQL> select to_number(substr(t.value,5,2)) h, to_number(substr(value,8,2)) s from v$dataguard_stats t where name = 'apply lag';
h s

0 0

# (oracle) main library

SQL> create table sync_test(id number, name varchar2(20));
SQL> insert into sync_test values(1,'haha');
SQL> commit;

(oracle)Reserve

SQL> select * from sync_test;

    ID         NAME
    -- ----------
     1         haha

Cluster Processing

# Pull up RAC cluster
# (oracle) Current cluster state
srvctl status database -d testrac
Instance orcl1 is running on node testrac1
Instance orcl2 is not running on node testrac2

# (oracle) pull up node 2 instance
srvctl start database -d testrac  -n testrac2

# (oracle) View cluster status
srvctl status database -d testrac
    Instance orcl1 is running on node testrac1
    Instance orcl2 is running on node testrac2

SQL> select inst_id,instance_name,status from gv$instance;
INST_ID INSTANCE_NAME STATUS

     1 orcl1            OPEN
     2 orcl2            OPEN
//More cluster status queries, see Appendix 2

Keywords: Database Oracle SQL network

Added by fwegan on Tue, 11 Jun 2019 20:20:08 +0300