企业Oracle数据库备份实施手记

网友投稿 631 2022-05-29

作为企业应用的核心数据库,备份必不可少;如果单位预算多的,可以考虑直接上专业的备份软件(NetBackup、CommVault等均可),预算不多的话,也可以像我一样,通过oracle数据库自带的RMAN工具,来实现自动备份;

以下为我司ERP系统的配置过程,以及备份策略,以此记录以备参考;

关于备份策略,因为企业ERP的备份数据量并不大,所以只定义两级策略,策略如下:

另外,根据业务人员的要求,数据库备份保留策略为14天,如下所示:

RMAN> show all;

using target database control file instead of recovery catalog

RMAN configuration parameters for database with db_unique_name OADB are:

CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS;

CONFIGURE BACKUP OPTIMIZATION OFF; # default

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default

CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default

CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE MAXSETSIZE TO UNLIMITED; # default

CONFIGURE ENCRYPTION FOR DATABASE OFF; # default

CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default

CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default

CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default

CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/oracle/app/product/11.2.0/dbhome_1/dbs/snapcf_oadb.f'; # default

RMAN>

# 注:控制文件的备份,在备份脚本内定义;

备份的自动周期性执行,则是通过Linux系统自动的Crontab服务来实现:

# 确保crond服务运行,且开机自动启动:

# systemctl start crond && systemctl enable crond

# systemctl status crond

● crond.service - Command Scheduler

Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)

Active: active (running) since Wed 2020-01-22 12:15:28 CST; 1 years 0 months ago

Main PID: 1679 (crond)

CGroup: /system.slice/crond.service

└─1679 /usr/sbin/crond -n

Jan 22 12:15:28 ly-eims-web-01 systemd[1]: Started Command Scheduler.

Jan 22 12:15:28 ly-eims-web-01 crond[1679]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 5% if used.)

Jan 22 12:15:28 ly-eims-web-01 crond[1679]: (CRON) INFO (running with inotify support)

# 以下定义全量备份为周日执行,增量备份为周一到周六执行:

# 注:crontab的定义,在oracle用户环境内配置;

$ crontab -l

0 3 * * 0 /dbbackup/ltdb/scripts/cron_full_oadb.sh

0 3 * * 1-6 /dbbackup/ltdb/scripts/cron_incr_oadb.sh

# 此处嵌套了一层,将备份脚本的所有输出,重定向到磁盘日志文件,以备后查:

$ more /dbbackup/ltdb/scripts/cron_full_oadb.sh

/dbbackup/ltdb/scripts/full_oadb.sh >> /dbbackup/ltdb/backuplog/full_oadb/full_oadb_`date +%Y%m%d-%H%M%S`.log

$ more /dbbackup/ltdb/scripts/cron_incr_oadb.sh

/dbbackup/ltdb/scripts/incr_oadb.sh >> /dbbackup/ltdb/backuplog/incr_oadb/incr_oadb_`date +%Y%m%d-%H%M%S`.log

$ more /dbbackup/ltdb/scripts/full_oadb.sh

echo -e '******Start********_'$(date '+%Y%m%d%H%M%S')

export ORACLE_SID=oadb

export ORACLE_BASE=/oracle/app

export ORACLE_HOME=/oracle/app/product/11.2.0/dbhome_1

export PATH=$ORACLE_HOME/bin:$PATH

rman target sys/oracle@oadb<

run{

allocate channel c1 type disk;

backup as compressed backupset incremental level 0 tag 'oadb_incr_L0' format

'/dbbackup/ltdb/oadb/full_%d_%T_%s' database include current controlfile;

backup as compressed backupset archivelog all format '/dbbackup/ltdb/oadb/arclog_0_%s_%p_%t_%d' delete input;

crosscheck backup;

delete noprompt expired backup;

delete noprompt obsolete;

crosscheck archivelog all;

delete noprompt expired archivelog all;

release channel c1;

}

exit;

企业Oracle数据库备份实施手记

EOF

说明:

1. 数据库的备份目录(/dbbackup/ltdb/oadb/)需要事先创建好;

2. 本次实施,备份目录/dbbackup,使用的是华为云上的 sfs 弹性文件服务挂载的目录,执行备份前,需要先挂载好 sfs文件系统,并配置好oracle用户权限;

$ more /dbbackup/ltdb/scripts/incr_oadb.sh

echo -e '******Start********_'$(date '+%Y%m%d%H%M%S')

export ORACLE_SID=oadb

export ORACLE_BASE=/oracle/app

export ORACLE_HOME=/oracle/app/product/11.2.0/dbhome_1

export PATH=$ORACLE_HOME/bin:$PATH

rman target sys/oracle@oadb <

run{

allocate channel c1 type disk;

backup as compressed backupset incremental level 1 tag 'oadb_incr_L1' format

'/dbbackup/ltdb/oadb/incr_%d_%T_%s' database include current controlfile;

backup as compressed backupset archivelog all format '/dbbackup/ltdb/oadb/arclog_1_%s_%p_%t_%d' delete input;

crosscheck backup;

delete noprompt expired backup;

delete noprompt obsolete;

crosscheck archivelog all;

delete noprompt expired archivelog all;

release channel c1;

}

exit;

EOF

如上,rman的备份操作配置完成!

Oracle 数据库

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:java web现在流行用什么框架?
下一篇:工资最高的那群人,都经历了什么?
相关文章