RAC中多实例开启归档和闪回

下面是针对其中一个实例的步骤记录
注意事项:
0、参数修改只在一个节点执行即可,记得sid='*'
1、每个实例需切换环境变量
2、开归档需先关闭DB再mount来开启
3、闪回区开启需先设置大小再设置位置

以下操作只在节点1执行
1、设置环境变量、关闭DB之前先设置下归档路径
[oracle@mydb1 ~ ]\$ export ORACLE_SID=testdb1
[oracle@mydb1 ~ ]\$ env | grep ORA
ORACLE_SID=testdb1
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1

[oracle@mydb1 ~ ]\$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Apr 21 15:38:36 2023
Version 19.18.0.0.0
Copyright (c) 1982, 2022, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.18.0.0.0

SQL> archive log list;
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 18
Current log sequence 20

SQL> set linesize 200
SQL> alter system set log_archive_dest_1='location=+ARCHDG' sid='*' scope=both;
System altered.

SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.18.0.0.0

2、关闭DB,在节点1开启归档,并启动所有节点DB
[oracle@mydb1 ~ ]\$ srvctl status database -d testdb
Instance testdb1 is running on node mydb1
Instance testdb2 is running on node mydb2
[oracle@mydb1 ~ ]\$
[oracle@mydb1 ~ ]\$ srvctl stop database -d testdb
[oracle@mydb1 ~ ]\$
[oracle@mydb1 ~ ]\$ srvctl status database -d testdb
Instance testdb1 is not running on node mydb1
Instance testdb2 is not running on node mydb2

[oracle@mydb1 ~ ]\$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Apr 21 15:40:32 2023
Version 19.18.0.0.0
Copyright (c) 1982, 2022, Oracle. All rights reserved.
Connected to an idle instance.

SQL> startup mount
ORACLE instance started.
Total System Global Area 6.0130E+10 bytes
Fixed Size 37254216 bytes
Variable Size 8187281408 bytes
Database Buffers 5.1808E+10 bytes
Redo Buffers 96960512 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.

SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> exit

[oracle@mydb1 ~ ]\$ srvctl start database -d testdb
[oracle@mydb1 ~ ]\$
[oracle@mydb1 ~ ]\$ srvctl status database -d testdb
Instance testdb1 is running on node mydb1
Instance testdb2 is running on node mydb2

3、开启闪回,根据实际情况设置闪回区大小,默认保留2天/1440分钟
[oracle@mydb1 ~ ]\$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Apr 21 15:42:19 2023
Version 19.18.0.0.0
Copyright (c) 1982, 2022, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.18.0.0.0

SQL> set linesize 200
SQL> show parameter db_recovery_file;
NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
db_recovery_file_dest string
db_recovery_file_dest_size big integer 0
SQL> select flashback_on from v\$database;
FLASHBACK_ON
------------------------------------------------------
NO

SQL> alter system set db_recovery_file_dest_size=8g sid='*' scope=both;
System altered.

SQL> alter system set db_recovery_file_dest='+ARCHDG' sid='*' scope=both;
System altered.

SQL> alter database flashback on;
Database altered.

SQL> select flashback_on from v\$database;
FLASHBACK_ON
------------------------------------------------------
YES

SQL> show parameter db_recovery_file;
NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
db_recovery_file_dest string +ARCHDG
db_recovery_file_dest_size big integer 8G

SQL> show parameter db_flashback_retention_target
NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
db_flashback_retention_target integer 1440

SQL> alter system switch logfile;
System altered.
SQL>

posted @ 2023-04-27 09:34  ritchy  阅读(339)  评论(0编辑  收藏  举报