oracle 12c :5步开归档

时间:2022-12-18 08:42:22

查看归档状态:

[oracle@lemon01 ~]$ sqlplus / as sysdba;

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 19 14:25:54 2017

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


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

SQL> archive log list;   
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /u01/app/oracle/product/12.2.0/db_1/dbs/arch
Oldest online log sequence     21
Current log sequence           23

1.创建归档目录

[oracle@lemon01 ~]$ mkdir arch
2.指定归档位置

SQL> alter system set log_archive_dest_1='LOCATION=/home/oracle/arch' scope=both;
alter system set log_archive_dest_1='LOCATION=/home/oracle/arch' scope=both
*
ERROR at line 1:
ORA-32001: write to SPFILE requested but no SPFILE is in use
报错显示:已请求写入spfile,但启动时未使用spfile

解决办法:(参考网上资料)

SQL> show parameter spfile;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string
SQL> create spfile from pfile;

File created.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup 
ORACLE instance started.

Total System Global Area  763363328 bytes
Fixed Size                  8625368 bytes
Variable Size             599786280 bytes
Database Buffers          150994944 bytes
Redo Buffers                3956736 bytes
Database mounted.
Database opened.
再次执行报错的语句:

SQL> alter system set log_archive_dest_1='LOCATION=/home/oracle/arch' scope=both;

System altered.
3.关库,将库启到mount状态:

SQL> shutdown immediate; 
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area  763363328 bytes
Fixed Size                  8625368 bytes
Variable Size             599786280 bytes
Database Buffers          150994944 bytes
Redo Buffers                3956736 bytes
Database mounted.
4.切归档

SQL> alter database archivelog;

Database altered.

5.开库,查归档状态

SQL> alter database open;

Database altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/arch
Oldest online log sequence     21
Next log sequence to archive   23
Current log sequence           23
OK啦。

备注:上述报错是由于数据库开启时使用pfile参数文件启库,查看数据库用什么状态启库,可执行show parameter spfile,显示为空的时候,则是用pfile启动。可通过pfile文件创建spfile文件。

SQL> show parameter spfile;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u01/app/oracle/product/12.2.0
                                                 /db_1/dbs/spfileNAN.ora