从archive 到 noarchive step by step

--1.FROM noarchivelog mode To archivelog mode

  --2.FROM stop auto archive To start auto archive

  ----------------------------------------------------------

  --step by step

  ----------------------------------------------------------

  1.conn / as sysdba

  2.archive log list;                        --查看archive状态(noarchivelog and stop archive)

  3.shutdown immediate;

  4.modify init.ora                        --修改init.ora

  --log_archive_start = true

  --log_archive_dest_1 = "location=C:/oracle/oradata/uwszmes/archive"

  --log_archive_format = %%ORACLE_SID%%T%TS%S.ARC

  5.startup mount;

  6.archive log list;                        --查看archive状态(noarchivelog and start archive)

  7.alter database archivelog;

  8.archive log list;                        --查看archive状态(archivelog and start archive)

  9.alter system switch logfile;                --对日志文件做切换归档

  a.host dir C:/oracle/oradata/uwszmes/archive        --查看归档目录下是否有归档文件生成

  b.alter system switch logfile;                --再次做切换并查看归档文件是否生成

  c.host dir C:/oracle/oradata/uwszmes/archive

  d.shutdown immediate;

  e.startup                                --重启一次DB查看归档状态是否有做永久改变

  f.archive log list;                        --查看archive为(archivelog mode and start auto archive)

  g.host dir C:/oracle/oradata/uwszmes/archive

  h.alter system switch logfile;                --再次检查是否可以正常归档

  i.host dir C:/oracle/oradata/uwszmes/archive

  j.shutdown immediate;                        --再次shutdown DB为从archivelog到noarchivelog做准备

  k.startup mount;

  l.archive log list;                        --当前为archivelog mode and start auto archive

  m.alter database noarchivelog;                --从archivelog修改为noarchivelog

  n.alter database open;                        --打开DB

  o.archive log list;                        --当前为noarchivelog模式自动归档为启动状态

  p.alter system switch logfile;                --手工切换日志(不会生成归档日志文件)

  q.host dir  C:/oracle/oradata/uwszmes/archive

  r.startup force                                --强迫重新启动DB

  s.archive log list;                        --此时DB仍然处于noarchivelog模式下自动归档为启动

  t.archive log stop;                        --改变自动归档为停止状态

  u.archive log list;

  v.archvie log start;                        --用archive log start|stop来切换自动归档方式

  w.archive log list;                        --此时为(noarchivelog mode,start auto archive)

  x.--end the lab----

  --=======================================

  ==============================================

  --From noarchivelog To archivelog (从非归档到归档模式)

  --        alter database archivelog|noarchivelog;

  --start|stop auto archivelog(停止|启动 自动归档)

  --        archive log start|stop|list

  --step by step

  1. init.ora

  log_archive_start = true

  log_archive_dest_1 = "location=C:/oracle/oradata/uwszmes/archive"

  log_archive_format = %%ORACLE_SID%%T%TS%S.ARC

  2.shutdown immediate;

  3.startup mount;

  4.archive log list;

  5.alter database archivelog|noarchivelog;

  6.archive log list;

  7.archive log stop;

  8.archive log list;

  9.alter database open;

  a.archive log list;

  b.host dir /w C:/oracle/oradata/uwszmes/archive

  c.alter system switch logfile;

  d.host dir /w C:/oracle/oradata/uwszmes/archive

  e.archive log start;

  f.alter system switch logfile;

  g.host dir /w C:/oracle/oradata/uwszmes/archive

  h.archive log list;

  ==============================================

  以权限最高用户身份进入数据库

  SQL> conn / as sysdba

  Connected to an idle instance.

  启动数据库

  SQL> startup

  ORACLE instance started.

  Total System Global Area 285212672 bytes

  Fixed Size 1218992 bytes

  Variable Size 96470608 bytes

  Database Buffers 184549376 bytes

  Redo Buffers 2973696 bytes

  Database mounted.

  Database opened.

  SQL> set lines 1000 pages 1000

查看是否在归档模式下

  SQL> archive log list

  Database log mode No Archive Mode

  Automatic archival Disabled

  Archive destination USE_DB_RECOVERY_FILE_DEST

  Oldest online log sequence 2

  Current log sequence 4

  查看数据库默认归档日志存放目录

  SQL> show parameter recover

  NAME TYPE VALUE

  ---------------------------------------------------------------------------------------------------------------

-------------

  db_recovery_file_dest string /opt/oracle/flash_recovery_area

  db_recovery_file_dest_size big integer 2G

  recovery_parallelism integer 0

  数据库归档方式配置

  1. 正常关闭数据库

  SQL> shutdown

  Database closed.

  Database dismounted.

  ORACLE instance shut down.

  2. 启动数据库到加载状态

  SQL> startup mount

  ORACLE instance started.

  Total System Global Area 285212672 bytes

  Fixed Size 1218992 bytes

  Variable Size 96470608 bytes

  Database Buffers 184549376 bytes

  Redo Buffers 2973696 bytes

  Database mounted.

  3. 修改数据库为归档模式

  SQL> alter database archivelog;

  Database altered.

  4. 查看归档模式是否被修改

  SQL> archive log list

  Database log mode Archive Mode

  Automatic archival Enabled

  Archive destination USE_DB_RECOVERY_FILE_DEST

  Oldest online log sequence 2

  Next log sequence to archive 4

  Current log sequence 4

  5. 修改归档路径(可选)

  先在oracle家目录创建一个目录archive专门放归档日志

  [oracle@lukai ~]$ mkdir archive

  [oracle@lukai ~]$ ls -l

  total 8

  drwxr-xr-x 2 oracle oinstall 4096 Jul 25 11:12 archive

  -rw-r--r-- 1 oracle oinstall 2079 Jul 17 01:12 sqlnet.log

  然后修改归档路径

  SQL> alter system set log_archive_dest_1='location=/home/oracle/archive' scope=both;

  System altered.

  6. 打开数据库查看数据库归档状态

  SQL> alter database open;

  Database altered.

  SQL> archive log list

  Database log mode Archive Mode

  Automatic archival Enabled

  Archive destination /home/oracle/archive

  Oldest online log sequence 2

  Next log sequence to archive 4

  Current log sequence 4

  7. 切换日志,看是否生效

  首先去刚才创建的归档目录下查看现在是否有归档日志

  然后在切换日志

  SQL> alter system switch logfile;

  System altered.

  再次去刚才在oracle家目录创建archive下查看是否生成归档日志

  8.手动归档 自动归档 切换

  alter system set log_archive_start=true scope=spfile;//开启自动归档

  默认为手动归档 即为false,需要重启数据库才能生效。

  注意:Oracle数据库在ARCHIVELOG(归档日志)方式下,可实施在线日志的归档备份,以便以后数据库发生故障时对数据库实现数

据恢复,但数据库运行在此模式下,会产生大量的归档日志(archived redo log),并且耗费大量硬盘空间,一般建议启用此模式时

,将归档日志转移到磁带机上,或者定期将归档日志转移到其他存储介质中。


原文:http://oracle.chinaitlab.com/exploiture/805606.html

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值