共计 2775 个字符,预计需要花费 7 分钟才能阅读完成。
如下 Linux 环境下对 Oracle 单节点数据库采用文件系统情况的配置归档模式过程。首先查看数据库归档模式和磁盘使用情况,确定归档文件放到什么位置:
[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’;
以上语句也可以通过 linux 的 crontab 和 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;
}
更多 Oracle 相关信息见 Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12
本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-05/144130.htm