一聚教程网:一个值得你收藏的教程网站

热门教程

oracle 10g rac及单实例开启归档操作例子

时间:2022-06-29 09:52:52 编辑:袖梨 来源:一聚教程网

一、单实例开启归档日志的顺序

1.首先需要对原参数文件进行备份

create pfile='f:\pfile1018.ora' from spfile;

2.调整归档日志的格式

alter system set log_archive_format='%s_%t_%r.log' scope=spfile;

3.设置归档路径
在做这一步之前,先要建好目录

alter system set log_archive_dest_1='location=/u01/app/oracle/archive';

4.设置一个小时必须强制归档

alter system set ARCHIVE_LAG_TARGET=3600 scope=both;

5.关闭数据库

shutdown immediate;

6.打开数据库到mount状态

startup mount;

7.开启归档

alter database archivelog;

8.打开数据库

alter database open;

9.对当前日志进行归档测试

alter system archive log current;

注意:上面的步骤适用于oracle10g\oracle11g。
如果对oracle9i则需要在第二步时加入以下语句:

alter system set log_archive_start=true scope=spfile;

二、oracle rac开启归档日志

10g与11g的rac开启归档的方法

SQL> select group#,thread# from v$log;
    GROUP#    THREAD#
---------- ----------
         1          1
         2          1
         3          2
         4          2
1、首先停掉数据库    
[root@btedb1 bin]# ./srvctl stop database -d btedb
2、将在其中数据库开启到mount
SQL> startup mount
ORACLE instance started.
Total System Global Area 1.4097E+10 bytes
Fixed Size                  2266624 bytes
Variable Size            3321891328 bytes
Database Buffers         1.0737E+10 bytes
Redo Buffers               35618816 bytes
Database mounted.

3、修改归档路径

SQL> alter system set log_archive_dest_1='LOCATION=+ARCHDG' scope=spfile sid='btedb1';
System altered.
SQL> alter system set log_archive_dest_1='LOCATION=+ARCHDG' scope=spfile sid='btedb2';
System altered.
SQL> alter system set log_archive_format='%s_%t_%r.log' scope=spfile sid='btedb1';
System altered.
SQL> alter system set log_archive_format='%s_%t_%r.log' scope=spfile sid='btedb2';
System altered.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.

4、调整强制归档时间间隔

SQL> show parameter lag
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
archive_lag_target                   integer     0
client_result_cache_lag              big integer 3000
plsql_ccflags                        string
SQL> alter system set archive_lag_target = 1800 scope = both sid = '*';
System altered.

5、关闭数据库并重启

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
将两个节点数据库进行启动
[root@btedb1 bin]# ./srvctl start database -d btedb

6、修改cluster_database

SQL> show parameter cluster_da
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
cluster_database                     boolean     TRUE
cluster_database_instances           integer     2
如果为false需要调整。因为在有的资料上说,先调为false再调整归档,其实不这样也是可以的!
SQL> alter system set cluster_database=true scope=spfile;
System altered.

热门栏目