转载

将Oracle数据库改为归档模式并启用Rman备份

如下Linux环境下对单节点数据库采用文件系统情况的配置归档模式过程。


首先查看数据库归档模式和磁盘使用情况,确定归档文件放到什么位置:

[oracle@gisdbserver ~]$ sqlplus / as sysdba

SQL> archive log list

Database log mode              No Archive Mode

Automatic archival             Disabled

Archive destination            /dbback/archivelog

Oldest online log sequence     92

Current log sequence           97




根据如下磁盘使用情况,在相应的目录下建立相关归档和备份目录:

[root@gisdbserver ~]# df -h

Filesystem                           Size  Used Avail Use% Mounted on

/dev/mapper/vg_gisdbserver-lv_root    99G  3.8G   90G   4% /

tmpfs                                 16G   76K   16G   1% /dev/shm

/dev/sda2                            485M   39M  421M   9% /boot

/dev/sda1                            200M  260K  200M   1% /boot/efi

/dev/mapper/vg_gisdbserver-LogVol03  481G  198M  457G   1% /dbback

/dev/mapper/vg_gisdbserver-LogVol04  407G  9.3G  377G   3% /home

/dev/mapper/vg_gisdbserver-LogVol02   99G  4.5G   89G   5% /opt

/dev/sdb                             441G   72G  347G  18% /oradata


创建相关归档日志存放目录:


[root@gisdbserver ~]# cd /dbback/

[root@gisdbserver dbback]# mkdir archivelog

[root@gisdbserver dbback]# chown -R oracle:oinstall archivelog/

[root@gisdbserver dbback]# mkdir rman

[root@gisdbserver dbback]# chown oracle:oinstall rman/

[root@gisdbserver rman]# mkdir fullback

[root@gisdbserver rman]# mkdir archiveback

[root@gisdbserver rman]# chown oracle:oinstall archiveback/

[root@gisdbserver rman]# chown oracle:oinstall fullback/


登录数据库指定归档存放目录:


[oracle@gisdbserver ~]$ sqlplus / as sysdba

SQL> alter system set log_archive_dest_1='location=/dbback/archivelog';

System altered.

SQL> show parameter log_archive_dest_1

NAME                                 TYPE        VALUE

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

log_archive_dest_1                   string      location=/dbback/archivelog



要将非归档数据库模式改为归档模式,需要在mount状态下执行alter database archivelog命令才行,如下:


SQL> archive log list

Database log mode              No Archive Mode

Automatic archival             Disabled

Archive destination            /dbback/archivelog

Oldest online log sequence     92

Current log sequence           97


SQL> alter database archivelog;

alter database archivelog

*

ERROR at line 1:

ORA-01126: database must be mounted in this instance and not open in any

instance


因此需要在合适的时间关闭数据库,重新启动到mount状态下才能改变为归档模式。

SQL> shutdown immediate;

SQL> startup mount;


SQL> alter database archivelog;



要开启rman备份,需要对配置rman相关的一些参数,具体如下:

oracle@gisdbserver ~]$ rman target /

RMAN> backup DATABASE include CURRENT controlfile format '/dbback/rman/fullback/data_%d_%T_%s_%p' plus archivelog format '+/dbback/rman/archiveback/arch_%d_%T_%s';


以上语句也可以通过linuxcrontab bash脚本方式进行自动化运行。



run{

 DELETE NOPROMPT expired archivelog ALL;

 allocate channel d1 TYPE disk maxpiecesize=30G;

 allocate channel d2 TYPE disk maxpiecesize=30G;

backup DATABASE include CURRENT controlfile format '/dbback/rman/fullback/data_%d_%T_%s_%p' plus archivelog       format '+/dbback/rman/archiveback/arch_%d_%T_%s';

 release channel d1;

 release channel d2;

 crosscheck backup;

 DELETE noprompt obsolete REDUNDANCY 1;

}



正文到此结束
Loading...