启用oracle自动归档模式

 

1.创建保存备份的目录
mkdir /u01/oracle/oradata/archive/archive
chown -R oracle /u01/oracle/oradata/archive/archive
2. 切换到oracle用户
sqlplus /nolog
connect /as sysdba
3. 设置归档日志 目标地址

查看数据库是否在归档模式

SQL> select log_mode from v$database;


LOG_MODE
------------------------
NOARCHIVELOG


SQL> show parameter 'log_archive_dest_1'


NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1                   string
log_archive_dest_10                  string
log_archive_dest_11                  string
log_archive_dest_12                  string
log_archive_dest_13                  string
log_archive_dest_14                  string
log_archive_dest_15                  string
log_archive_dest_16                  string
log_archive_dest_17                  string
log_archive_dest_18                  string
log_archive_dest_19                  string


SQL> alter system set log_archive_dest_1='location=/u01/oracle/oradata/archive/archive' scope=spfile;


System altered.


SQL> show parameter log_archive_format;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_format                   string      %t_%s_%r.dbf

--设置日志文件名称格式 重起数据库后生效
alter system set log_archive_dest_1='location=/u01/oracle/oradata/archive' scope=spfile;

SQL> System altered.

 


4.关闭数据库
SQL> shutdown immediate;


5. 启动数据库并加载
SQL> startup mount;


6.将数据库切换 为归档模式
SQL> alter database archivelog;


SQL> select log_mode from v$database;


LOG_MODE
------------------------
ARCHIVELOG


7.打开数据库
SQL> alter database open;
8. 切换日志,强迫归档


SQL> alter system switch logfile;


9. SQL> select archiver from v$instance;


ARCHIVER
--------------
STARTED


--查看生成的归档文件全路经
SQL> select name from v$archived_log;

NAME
--------------------------------------------------------------------------------
/u01/oracle/oradata/archive/arch_50d8fe87_1_762534602_37.log


 

你可能感兴趣的:(数据库)