配置本地归档
归档配置有两种方式:一是联机归档配置,数据库服务器启动情况下,使用SQL语句完成dmarch.ini和ARCH_INI配置;二是手动配置归档,数据库服务器未启动的情况下,手动编写dmarch.ini文件和设置参数ARCH_INI。下面将分别说明这两种归档如何配置。
联机配置归档
使用SQL语句配置本地归档。语法如下:
ALTER DATABASE <ADD|MODIFY|DELETE> ARCHIVELOG <归档配置语句>;
<归档配置语句>::= 'DEST = <归档目标>,TYPE = <归档类型>'
<归档类型>::=<local方式>|<remote方式>
<local方式>::=LOCAL [,FILE_SIZE = <文件大小>][,SPACE_LIMIT = <空间大小限制>]
<remote方式>::=REMOTE [,FILE_SIZE = <文件大小>][,SPACE_LIMIT = <空间大小限制>],INCOMING_PATH = <归档存放路径>
使用SQL语句开启和关闭归档模式。
语法如下:
ALTER DATABASE ARCHIVELOG | NOARCHIVELOG;
在归档模式下,不允许删除本地归档。
例如,RAC环境联机归档配置如下:
1)修改数据库为MOUNT状态。
节点1:
SQL> alter database mount;
executed successfully
used time: 00:00:01.852. Execute id is 0.
节点2:
SQL> alter database mount;
executed successfully
used time: 00:00:01.853. Execute id is 0.
2)配置本地归档。
节点1:
SQL> alter database add archivelog 'dest=/dm7/data/local_arch,type=local,file_size=256,space_limit=0';
executed successfully
used time: 3.110(ms). Execute id is 0.
节点2:
SQL> alter database add archivelog 'dest=/dm7/data/local_arch,type=local,file_size=256,space_limit=0';
executed successfully
used time: 3.171(ms). Execute id is 0.
3)开启归档模式。
节点1:
SQL> alter database archivelog;
executed successfully
used time: 11.986(ms). Execute id is 0.
节点2:
SQL> alter database archivelog;
executed successfully
used time: 11.780(ms). Execute id is 0.
4)修改数据库为OPEN状态。
节点1:
SQL> alter database open;
executed successfully
used time: 00:00:01.466. Execute id is 0.
节点2:
SQL> alter database open;
executed successfully
used time: 711.999(ms). Execute id is 0.
5)查看归档配置文件dmarch.ini
节点1:
[dmdba@dmrac1 rac0_config]$ pwd
/dm7/data/rac0_config
[dmdba@dmrac1 rac0_config]$ cat dmarch.ini
#DaMeng Database Archive Configuration file
#this is comments
ARCH_WAIT_APPLY = 1 --性能模式,是否等待重演完成,取值0:高性能模式, 1:数据一致模式。本地归档取值NULL
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm7/data/local_arch
ARCH_FILE_SIZE = 256
ARCH_SPACE_LIMIT = 0
节点2:
[dmdba@dmrac2 rac1_config]$ pwd
/dm7/data/rac1_config
[dmdba@dmrac2 rac1_config]$ cat dmarch.ini
#DaMeng Database Archive Configuration file
#this is comments
ARCH_WAIT_APPLY = 1 --性能模式,是否等待重演完成,取值0:高性能模式, 1:数据一致模式。本地归档取值NULL
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm7/data/local_arch
ARCH_FILE_SIZE = 256
ARCH_SPACE_LIMIT = 0
6)检查ARCH_INI参数是否为1
节点1:
SQL> select * from v$dm_ini where para_name='ARCH_INI';
LINEID PARA_NAME PARA_VALUE MIN_VALUE MAX_VALUE MPP_CHK SESS_VALUE FILE_VALUE DESCRIPTION PARA_TYPE
---------- --------- ---------- --------- --------- ------- ---------- ---------- ----------- ---------
1 ARCH_INI 1 0 1 N 1 1 dmarch.ini SYS
used time: 30.251(ms). Execute id is 5.
节点2:
SQL> select * from v$dm_ini where para_name='ARCH_INI';
LINEID PARA_NAME PARA_VALUE MIN_VALUE MAX_VALUE MPP_CHK SESS_VALUE FILE_VALUE DESCRIPTION PARA_TYPE
---------- --------- ---------- --------- --------- ------- ---------- ---------- ----------- ---------
1 ARCH_INI 1 0 1 N 1 1 dmarch.ini SYS
used time: 29.498(ms). Execute id is 13.
禁用归档
1修改数据库为MOUNT状态。
节点1:
SQL> alter database mount;
executed successfully
used time: 00:00:01.858. Execute id is 0.
节点2:
SQL> alter database mount;
executed successfully
used time: 00:00:01.858. Execute id is 0.
2.禁用归档
节点1:
SQL> alter database noarchivelog;
executed successfully
used time: 42.916(ms). Execute id is 0.
节点2:
SQL> alter database noarchivelog;
executed successfully
used time: 42.533(ms). Execute id is 0.
3.删除配置的本地归档设置
节点1:
SQL> alter database delete archivelog 'dest=/dm7/data/local_arch,type=local,file_size=256,space_limit=0';
executed successfully
used time: 0.931(ms). Execute id is 0.
节点2:
SQL> alter database delete archivelog 'dest=/dm7/data/local_arch,type=local,file_size=256,space_limit=0';
executed successfully
used time: 0.952(ms). Execute id is 0.
4.删除之前生成的归档日志文件(可选项)
节点1:
SQL> sf_archivelog_delete_before_time(sysdate+1);
DMSQL executed successfully
used time: 2.907(ms). Execute id is 7.
节点2:
SQL> sf_archivelog_delete_before_time(sysdate+1);
DMSQL executed successfully
used time: 3.542(ms). Execute id is 16.
5.打开数据库
节点1:
SQL> alter database open;
executed successfully
used time: 00:00:01.609. Execute id is 0.
节点2:
SQL> alter database open;
executed successfully
used time: 00:00:02.304. Execute id is 0.
6.检查归档配置文件dmarch.ini的内容是否已经被删除
节点1:
[dmdba@dmrac1 rac0_config]$ cat dmarch.ini
#DaMeng Database Archive Configuration file
#this is comments
ARCH_WAIT_APPLY = 1 --性能模式,是否等待重演完成,取值0:高性能模式, 1:数据一致模式。本地归档取值NULL
节点2:
[dmdba@dmrac2 rac1_config]$ cat dmarch.ini
#DaMeng Database Archive Configuration file
#this is comments
ARCH_WAIT_APPLY = 1 --性能模式,是否等待重演完成,取值0:高性能模式, 1:数据一致模式。本地归档取值NULL
7.检查ARCH_INI参数是否为0
节点1:
SQL> select * from v$dm_ini where para_name='ARCH_INI';
LINEID PARA_NAME PARA_VALUE MIN_VALUE MAX_VALUE MPP_CHK SESS_VALUE FILE_VALUE DESCRIPTION PARA_TYPE
---------- --------- ---------- --------- --------- ------- ---------- ---------- ----------- ---------
1 ARCH_INI 0 0 1 N 0 0 dmarch.ini SYS
used time: 7.086(ms). Execute id is 8.
节点2:
SQL> select * from v$dm_ini where para_name='ARCH_INI';
LINEID PARA_NAME PARA_VALUE MIN_VALUE MAX_VALUE MPP_CHK SESS_VALUE FILE_VALUE DESCRIPTION PARA_TYPE
---------- --------- ---------- --------- --------- ------- ---------- ---------- ----------- ---------
1 ARCH_INI 0 0 1 N 0 0 dmarch.ini SYS
used time: 14.366(ms). Execute id is 18.
手动配置归档示例如下:
1)手动编辑dmarch.ini文件,之后保存在dm.ini所在的目录。dmarch.ini文件内容如下:
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm7/data/local_arch
ARCH_FILE_SIZE = 256
ARCH_SPACE_LIMIT = 0
2)编辑dm.ini文件,设置参数ARCH_INI=1,保存。
3)启动服务器,服务器已运行于归档模式。
多路归档,指配置多个本地归档。配置的第一个归档,称为第一路归档,后面依次是第二路、第三路......