Oracle19C RAC 开启归档

[root@oracle19crac01 ~]# su oracle
[oracle@oracle19crac01 root]$ source ~/.bash_profile 

$ORACLE_SID: racdb1
$ORACLE_HOME: /u01/app/oracle/product/19.0.0/dbhome_1

oracle@oracle19crac01[racdb1]/root$sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jul 14 14:47:25 2021
Version 19.3.0.0.0

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


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL>
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /u01/app/oracle/product/19.0.0/dbhome_1/dbs/arch
Oldest online log sequence     19
Current log sequence           20
SQL> 

开启归档模式的基本操作步骤如下:

1、关闭数据库实例。

[root@oracle19crac01 ~]# su grid
[grid@oracle19crac01 root]$ source ~/.bash_profile 

$ORACLE_SID: +ASM1
$ORACLE_HOME: /u01/app/19.0.0/grid

grid@oracle19crac01[+ASM1]/root$srvctl stop database -d racdb -o immediate
grid@oracle19crac01[+ASM1]/root$crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.LISTENER.lsnr
               ONLINE  ONLINE       oracle19crac01           STABLE
               ONLINE  ONLINE       oracle19crac02           STABLE
ora.chad
               ONLINE  ONLINE       oracle19crac01           STABLE
               ONLINE  ONLINE       oracle19crac02           STABLE
ora.net1.network
               ONLINE  ONLINE       oracle19crac01           STABLE
               ONLINE  ONLINE       oracle19crac02           STABLE
ora.ons
               ONLINE  ONLINE       oracle19crac01           STABLE
               ONLINE  ONLINE       oracle19crac02           STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.DATADG.dg(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        ONLINE  OFFLINE                               STABLE
ora.FRADG.dg(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        ONLINE  OFFLINE                               STABLE
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       oracle19crac01           STABLE
ora.SYSDG.dg(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.asm(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           Started,STABLE
      2        ONLINE  ONLINE       oracle19crac02           Started,STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.asmnet1.asmnetwork(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.cvu
      1        ONLINE  ONLINE       oracle19crac01           STABLE
ora.oracle19crac01.vip
      1        ONLINE  ONLINE       oracle19crac01           STABLE
ora.oracle19crac02.vip
      1        ONLINE  ONLINE       oracle19crac02           STABLE
ora.qosmserver
      1        ONLINE  ONLINE       oracle19crac01           STABLE
ora.racdb.db
      1        OFFLINE OFFLINE                               Instance Shutdown,ST
                                                             ABLE
      2        OFFLINE OFFLINE                               Instance Shutdown,ST
                                                             ABLE
ora.scan1.vip
      1        ONLINE  ONLINE       oracle19crac01           STABLE
--------------------------------------------------------------------------------
grid@oracle19crac01[+ASM1]/root$

2、把节点一的实例启动到 mount 状态。

[root@oracle19crac01 ~]# su oracle
[oracle@oracle19crac01 root]$ source ~/.bash_profile 

$ORACLE_SID: racdb1
$ORACLE_HOME: /u01/app/oracle/product/19.0.0/dbhome_1

oracle@oracle19crac01[racdb1]/root$sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jul 14 15:03:27 2021
Version 19.3.0.0.0

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

Connected to an idle instance.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 1879045424 bytes
Fixed Size                  8897840 bytes
Variable Size             570425344 bytes
Database Buffers         1291845632 bytes
Redo Buffers                7876608 bytes
Database mounted.
SQL> alter system set log_archive_dest='+fradg' scope=spfile sid='*';

System altered.

SQL> alter database archivelog;

Database altered.

SQL> shutdown immediate;
ORA-01109: database not open


Database dismounted.

ORACLE instance shut down.

SQL> startup
ORACLE instance started.

Total System Global Area 1879045424 bytes
Fixed Size                  8897840 bytes
Variable Size             570425344 bytes
Database Buffers         1291845632 bytes
Redo Buffers                7876608 bytes
Database mounted.
Database opened.
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            +FRADG
Oldest online log sequence     20
Next log sequence to archive   21
Current log sequence           21
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
oracle@oracle19crac01[racdb1]/root$

3、节点二登录到 oracle 用户,然后把数据库启动起来。启动完成之后我们开始配置 controlfile 位置、先查询一下 controlfile 的位置。

[root@oracle19crac02 ~]# su oracle
[oracle@oracle19crac02 root]$ source ~/.bash_profile 

$ORACLE_SID: racdb2
$ORACLE_HOME: /u01/app/oracle/product/19.0.0/dbhome_1

oracle@oracle19crac02[racdb2]/root$sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jul 14 15:08:10 2021
Version 19.3.0.0.0

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

Connected to an idle instance.

SQL> startup;
ORACLE instance started.

Total System Global Area 1879045424 bytes
Fixed Size                  8897840 bytes
Variable Size             570425344 bytes
Database Buffers         1291845632 bytes
Redo Buffers                7876608 bytes
Database mounted.
Database opened.
SQL> set line 400;
SQL> col name for a50;
SQL> select name from v$controlfile;

NAME
--------------------------------------------------
+DATADG/RACDB/CONTROLFILE/current.261.1078314505

SQL> alter system set control_files='+DATADG/RACDB/CONTROLFILE/current.261.1078314505','+FRADG' scope=spfile;

System altered.

SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
oracle@oracle19crac02[racdb2]/home/oracle$

4、在节点一上操作下面的命令关闭数据库

grid@oracle19crac01[+ASM1]/u01/app/19.0.0/grid/bin$srvctl stop database -d racdb -o immediate
grid@oracle19crac01[+ASM1]/u01/app/19.0.0/grid/bin$crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.LISTENER.lsnr
               ONLINE  ONLINE       oracle19crac01           STABLE
               ONLINE  ONLINE       oracle19crac02           STABLE
ora.chad
               ONLINE  ONLINE       oracle19crac01           STABLE
               ONLINE  ONLINE       oracle19crac02           STABLE
ora.net1.network
               ONLINE  ONLINE       oracle19crac01           STABLE
               ONLINE  ONLINE       oracle19crac02           STABLE
ora.ons
               ONLINE  ONLINE       oracle19crac01           STABLE
               ONLINE  ONLINE       oracle19crac02           STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.DATADG.dg(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        ONLINE  OFFLINE                               STABLE
ora.FRADG.dg(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        ONLINE  OFFLINE                               STABLE
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       oracle19crac01           STABLE
ora.SYSDG.dg(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.asm(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           Started,STABLE
      2        ONLINE  ONLINE       oracle19crac02           Started,STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.asmnet1.asmnetwork(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.cvu
      1        ONLINE  ONLINE       oracle19crac01           STABLE
ora.oracle19crac01.vip
      1        ONLINE  ONLINE       oracle19crac01           STABLE
ora.oracle19crac02.vip
      1        ONLINE  ONLINE       oracle19crac02           STABLE
ora.qosmserver
      1        ONLINE  ONLINE       oracle19crac01           STABLE
ora.racdb.db
      1        OFFLINE OFFLINE                               Instance Shutdown,ST
                                                             ABLE
      2        OFFLINE OFFLINE                               Instance Shutdown,ST
                                                             ABLE
ora.scan1.vip
      1        ONLINE  ONLINE       oracle19crac01           STABLE
--------------------------------------------------------------------------------
grid@oracle19crac01[+ASM1]/u01/app/19.0.0/grid/bin$

5、在节点一上将实例启动到 nomount 状态(这里只启动节点一)

grid@oracle19crac01[+ASM1]/u01/app/19.0.0/grid/bin$srvctl start instance -d racdb -i racdb1 -o nomount
grid@oracle19crac01[+ASM1]/u01/app/19.0.0/grid/bin$crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.LISTENER.lsnr
               ONLINE  ONLINE       oracle19crac01           STABLE
               ONLINE  ONLINE       oracle19crac02           STABLE
ora.chad
               ONLINE  ONLINE       oracle19crac01           STABLE
               ONLINE  ONLINE       oracle19crac02           STABLE
ora.net1.network
               ONLINE  ONLINE       oracle19crac01           STABLE
               ONLINE  ONLINE       oracle19crac02           STABLE
ora.ons
               ONLINE  ONLINE       oracle19crac01           STABLE
               ONLINE  ONLINE       oracle19crac02           STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.DATADG.dg(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        ONLINE  OFFLINE                               STABLE
ora.FRADG.dg(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        ONLINE  OFFLINE                               STABLE
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       oracle19crac01           STABLE
ora.SYSDG.dg(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.asm(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           Started,STABLE
      2        ONLINE  ONLINE       oracle19crac02           Started,STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.asmnet1.asmnetwork(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.cvu
      1        ONLINE  ONLINE       oracle19crac01           STABLE
ora.oracle19crac01.vip
      1        ONLINE  ONLINE       oracle19crac01           STABLE
ora.oracle19crac02.vip
      1        ONLINE  ONLINE       oracle19crac02           STABLE
ora.qosmserver
      1        ONLINE  ONLINE       oracle19crac01           STABLE
ora.racdb.db
      1        ONLINE  INTERMEDIATE oracle19crac01           Dismounted,HOME=/u01
                                                             /app/oracle/product/
                                                             19.0.0/dbhome_1,STAB
                                                             LE
      2        OFFLINE OFFLINE                               Instance Shutdown,ST
                                                             ABLE
ora.scan1.vip
      1        ONLINE  ONLINE       oracle19crac01           STABLE
--------------------------------------------------------------------------------
grid@oracle19crac01[+ASM1]/u01/app/19.0.0/grid/bin$

6、节点一登录 rman

oracle@oracle19crac01[racdb1]/home/oracle$rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Mon Jul 19 15:08:25 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database: RACDB (not mounted)

RMAN> restore controlfile from '+DATADG/RACDB/CONTROLFILE/current.261.1078314505';

Starting restore at 19-JUL-2021 15:15:27
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=623 instance=racdb1 device type=DISK

channel ORA_DISK_1: copied control file copy
output file name=+DATADG/RACDB/CONTROLFILE/current.261.1078314505
output file name=+FRADG/RACDB/CONTROLFILE/current.265.1078328799
Finished restore at 19-JUL-2021 15:15:29

RMAN> exit


Recovery Manager complete.
oracle@oracle19crac01[racdb1]/home/oracle$


oracle@oracle19crac01[racdb1]/home/oracle$sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Mon Jul 19 15:47:23 2021
Version 19.3.0.0.0

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


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> alter system set control_files='+DATADG/RACDB/CONTROLFILE/current.261.1078314505','+FRADG/RACDB/CONTROLFILE/current.265.1078328799' scope=spfile;
alter system set control_files='+DATADG/RACDB/CONTROLFILE/current.261.1078314505','+FRADG/RACDB/CONTROLFILE/current.265.1078328799' scope=spfile
                 *
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified


SQL> alter system set control_files='+DATADG/RACDB/CONTROLFILE/current.261.1078314505','+FRADG/RACDB/CONTROLFILE/current.265.1078328799' scope=spfile;

System altered.

SQL>  show parameter control_file;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      +DATADG/RACDB/CONTROLFILE/curr
                                                 ent.261.1078314505, +FRADG/RAC
                                                 DB/CONTROLFILE/current.265.107
                                                 8328799
SQL> alter database mount;

Database altered.

SQL> alter database open;

Database altered.

SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
oracle@oracle19crac01[racdb1]/home/oracle$

7、启动节点二数据库实例。

grid@oracle19crac02[+ASM2]/home/grid$srvctl start instance -d racdb -i racdb2
grid@oracle19crac02[+ASM2]/home/grid$crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.LISTENER.lsnr
               ONLINE  ONLINE       oracle19crac01           STABLE
               ONLINE  ONLINE       oracle19crac02           STABLE
ora.chad
               ONLINE  ONLINE       oracle19crac01           STABLE
               ONLINE  ONLINE       oracle19crac02           STABLE
ora.net1.network
               ONLINE  ONLINE       oracle19crac01           STABLE
               ONLINE  ONLINE       oracle19crac02           STABLE
ora.ons
               ONLINE  ONLINE       oracle19crac01           STABLE
               ONLINE  ONLINE       oracle19crac02           STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.DATADG.dg(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        ONLINE  OFFLINE                               STABLE
ora.FRADG.dg(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        ONLINE  OFFLINE                               STABLE
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       oracle19crac01           STABLE
ora.SYSDG.dg(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.asm(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           Started,STABLE
      2        ONLINE  ONLINE       oracle19crac02           Started,STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.asmnet1.asmnetwork(ora.asmgroup)
      1        ONLINE  ONLINE       oracle19crac01           STABLE
      2        ONLINE  ONLINE       oracle19crac02           STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.cvu
      1        ONLINE  ONLINE       oracle19crac01           STABLE
ora.oracle19crac01.vip
      1        ONLINE  ONLINE       oracle19crac01           STABLE
ora.oracle19crac02.vip
      1        ONLINE  ONLINE       oracle19crac02           STABLE
ora.qosmserver
      1        ONLINE  ONLINE       oracle19crac01           STABLE
ora.racdb.db
      1        ONLINE  ONLINE       oracle19crac01           Open,HOME=/u01/app/o
                                                             racle/product/19.0.0
                                                             /dbhome_1,STABLE
      2        ONLINE  ONLINE       oracle19crac02           Open,HOME=/u01/app/o
                                                             racle/product/19.0.0
                                                             /dbhome_1,STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       oracle19crac01           STABLE
--------------------------------------------------------------------------------
grid@oracle19crac02[+ASM2]/home/grid$

推荐文章

1条评论

  1. Hello! I know this is kinda off topic but I was wondering if you knew
    where I could find a captcha plugin for my comment form?
    I’m using the same blog platform as yours and I’m having problems
    finding one? Thanks a lot!

发表评论

邮箱地址不会被公开。 必填项已用*标注