Oracle Rac 开启归档日志并修改归档路径

一、开启归档日志:

1、查看归档状态:

SQL> archive log list;
Database log mode           No Archive Mode
Automatic archival           Disabled
Archive destination           USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     23
Current log sequence           24

2、查看节点实例状态:

 SQL> select instance_name,host_name,status from gv$instance;

INSTANCE_NAME     HOST_NAME            STATUS
---------------- ------------------------------ ------------
racdb2         rac2                OPEN
racdb1         rac1                OPEN

3、查看数据库集群参数:

SQL> show parameter cluster;

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
cluster_database             boolean     TRUE
cluster_database_instances         integer     2
cluster_interconnects             string

4、备份参数文件: 

SQL> create pfile='/tmp/racdb-bak.ora' from spfile;

File created.

 5、修改cluster_database参数:

SQL> alter system set cluster_database=false scope=spfile sid='*';

System altered.

 6、切换到grid用户,两节点停止数据库,再从节点1启动到mount状态:

[grid@rac1 ~]$ srvctl stop database -d racdb
[grid@rac1 ~]$ srvctl start instance -d racdb -i racdb1 -o mount

 7、切换到oracle用户,查询节点1数据库实例状态:

SQL> select instance_name,status from v$instance;

INSTANCE_NAME     STATUS
---------------- ------------
racdb1         MOUNTED

 8、修改数据库成归档模式:

SQL> alter database archivelog;

Database altered.

 9、将集群参数修改回去: 

SQL> alter system set cluster_database=true scope=spfile sid='*';

System altered.

10、关闭节点1数据库:

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

 11、切换到grid用户,再启动两节点数据库:

[grid@rac1 ~]$ srvctl start database -d racdb
[grid@rac1 ~]$ srvctl status database -d racdb
Instance racdb1 is running on node rac1
Instance racdb2 is running on node rac2

 12、切换到oracle用户下,查看归档状态:

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

SQL> select name,log_mode from v$database;

NAME      LOG_MODE
--------- ------------
RACDB      ARCHIVELOG

 二、修改归档路径:

1、在asm目录中创建归档目录:

[grid@rac1 ~]$ asmcmd
ASMCMD> 
ASMCMD> ls
CRS/
DATA/
ASMCMD> cd data
ASMCMD> ls
RACDB/
ASMCMD> cd racdb 
ASMCMD> ls
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
spfileracdb.ora
ASMCMD> mkdir archivelog
ASMCMD> ls
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
archivelog/
spfileracdb.ora
ASMCMD> cd archivelog
ASMCMD> pwd
+data/racdb/archivelog

 2、修改归档路径:

SQL> alter system set log_archive_dest_1='location=+DATA/RACDB/archivelog' scope=spfile sid='*';

System altered.

3、重启两节点数据库:

[grid@rac1 ~]$ srvctl stop database -d racdb

[grid@rac1 ~]$ srvctl start database -d racdb

4、重新查看归档状态:

 SQL> archive log list;
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           +DATA/racdb/archivelog
Oldest online log sequence     24
Next log sequence to archive   25
Current log sequence           25

你可能感兴趣的:(Oracle)