Oracle RMAN 11g Backup and Recovery- P14

39 419 0
Oracle RMAN 11g Backup and Recovery- P14

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

618 Part V: Appendixes recordSpec This subclause defines which objects that commands such as change, crosscheck, delete, and list will work on Syntax Diagram , ’ ’ filename , ARCHIVELOG primaryKey , BACKUPSET primaryKey , ’ ’ , BACKUPPIECE PROXY media_handle primaryKey ’ ’ tag_name TAG , ’ filename ’ , primaryKey CONTROLFILECOPY , DATAFILECOPY ’ tag_name TAG DATAFILECOPY NODUPLICATES NODUPLICATES ALL LIKE ’ ’ string_pattern ’ tempfileSpec This subclause is used to define tempfiles by name or file number that should be operated on by the parent command Syntax Diagram ’ filename ’ integer Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark Appendix A: RMAN Syntax Reference Guide 619 toDestSpec This subclause is used to specify a directory or an Automatic Storage Management disk group for disk backups for the RMAN operation that the subclause is used in Syntax Diagram toDest_string ’ ’ untilClause This subclause defines a limit based on time, SCN, restore point, or log sequence number that is referenced by the parent RMAN command Syntax Diagram UNTIL SCN integer UNTIL SEQUENCE UNTIL TIME ’ THREAD integer date_string integer ’ Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark This page intentionally left blank Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark APPENDIX B RMAN Scripting Examples Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark 622 Part V: Appendixes e have gotten a number of requests for scripts related to RMAN The nice thing about RMAN is that scripting it is a pretty straightforward process In this chapter, we provide you with some basic scripts for both Windows and Linux to get you started These scripts assume that you are using the Oracle flash recovery area (FRA), which will manage disk space and backup retention for you If you are not using the FRA, perhaps you might want to customize these scripts for your own needs We will leave that to your ingenuity and skill! RMAN Scripts for Windows These scripts were written and tested using Windows XP First, we give you an example batch script that will call RMAN for a backup of the database and the archived redo logs We will then show you a method of scheduling these scripts from the operating system Note that this is just one method of scheduling automated backups You might also choose to use Oracle Enterprise Manager (OEM) to schedule and manage your backups Using Oracle Enterprise Manager is covered in Chapter 13, so you can reference that chapter for information on scheduling backups in OEM Creating a Windows Script to Schedule Backups This is a pretty basic script; you might want to augment it for incremental backups, backup validation, or other operations Note that the script will return an error message if the backup fails To create this script, you might use Notepad, or some other text editor, and might call this script something like backup.bat rem ******************************************************************** rem * Script Name: backup.bat rem * Script Purpose: This script will call RMAN and execute the command rem * file specified on the command line rem * Usage backup.bat @echo off rem rem RMAN BACKUP SCRIPT rem For WIN XP rem echo %1 set oracle sid %1 if "%2" "backup" rman target / cmdfile c:\oracle\scripts\backup.scr if not ERRORLEVEL echo "WARNING - FAILURE OCCURRED" if "%2" "arch" rman target / cmdfile c:\oracle\scripts\arch.scr if not ERRORLEVEL echo "WARNING - FAILURE OCCURRED" Note that this script calls two command files, backup.scr and arch.scr, which in this case are located in the c:\oracle\scripts directory Here is the backup.scr script: Backup as compressed backupset database plus archivelog delete input; This is the arch.scr script: Backup as compressed backupset archivelog all delete input; Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark Appendix B: RMAN Scripting Examples 623 Again, each of these scripts would be created using a text editor and placed in the c:\oracle\ scripts directory If you put them somewhere else, you will need to edit the backup.bat script to point to the correct location of these scripts Scheduling the Backup Now, we want to schedule the backup We will use the Windows schtasks utility to perform this operation In our experience, schtasks is a rarely used but powerful scheduling utility In this example, we are scheduling a daily database backup using the backup.bat file We also have an example of scheduling the archived redo log backup and an example of how to remove a scheduled task: schtasks /create /tn "database backup" /sc weekly /d SUN /st 14:50:00 /tr "c:\bc\rman\backup.bat rob10r2 backup>\>c:\bc\rman\backup.output" rem schtasks /delete /tn "database backup" schtasks /create /tn "archivelog backup" /sc daily /st 14:50:00 /tr "c:\bc\rman\backup.bat rob10r2 arch>\>c:\bc\rman\backup.output" You have a number of scheduling options when using the schtasks scheduler The schtasks scheduler will request the login ID of the user that will be running the job RMAN Scripts for Unix These scripts were written and tested on Red Hat Linux Version In this section, we have a backup script (backup.ksh) and the related command-line files that will be used to execute the actual backup You can use Cron or at to schedule this script in Unix First, here is our example shell script for our Unix backup: #/bin/ksh # Script name: backup.ksh # Usage: backup.ksh # Note: We assume the oracle environment is already setup except for # ORACLE HOME If not, you will need to setup your environment correctly set ORACLE SID $1 if [ "$2" "backup" ]; then rman target / cmdfile /home/oracle/scripts/backup.scr fi if [ "$2" "arch" ]; then rman target / cmdfile /home/oracle/scripts/arch.scr fi The backup.scr script is the same as you saw earlier: Backup as compressed backupset database plus archivelog delete input; As is the arch.scr script: Backup as compressed backupset archivelog all delete input; Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark This page intentionally left blank Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark APPENDIX C Setting Up an RMAN Test Environment Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark 626 Part V: Appendixes s the complexity of production enterprise environments grows with each passing year, we DBAs are finding the same complexity creeping into our test environments For example, in Oracle9i RMAN Backup & Recovery, the test environment was seemingly complex for us: a Windows laptop for minor tweaks and screen shots, another Windows server for more robust testing, and a Sun Blade 150 for multi-OS interaction and Unix commands Among these three machines, we were able to all technical reviews (combined with years of actual experience in the workplace, of course) A For the 10g RMAN book, the test environment included two Linux boxes with a shared FireWire disk drive (running RAC, of course), Matthew’s trusty Windows laptop, that old Sun Blade, and a stand-alone Linux box And Matthew still went hunting with his colleagues looking for other RAC clusters, tape storage jukeboxes, and Oracle Enterprise Manager repositories That being said, things have taken an interesting turn since the last book We authors had to travel significantly during the production of this book, so the needs changed dramatically, from a tactical standpoint Because of the up and down, thrashed and trashed nature of B&R testing, testing from a remote location can be difficult And you can’t connect to your datacenter from a plane yet Yet In addition, this was the first time that we wrote against Beta code (long story), so there are plenty of hiccups that simply prevented traditional solutions So, what did our test environment look like this time? One late-model Apple MacBook Pro, running VMWare Fusion, and an external hard drive That’s it (Okay, Matthew still relied on those RAC clusters in the datacenter.) He installed RHEL 5, copied the VMWare slice, and had a multiserver environment running from his laptop— gotta love modern times Now, Matthew had a completely mobile lab environment, with plenty of hard-drive space and a built-in way to trash everything and start over using his virtual snapshots The only limit was that his late-model Mac had 3GB of memory, so he had to pick and choose environments carefully when running them simultaneously With new models running up to 8GB, Matthew’s looking forward to having that problem solved soon as well Granted, as discussed later in this appendix, this does not, in any way, come close to looking like a true production environment Therefore, he can’t any performance benchmarking on his laptop, or expect that he has ensured that scripts are free of bugs in production But, with the exact OS running (RHEL) and exact database version, he has gone a long way toward assurance that he knows what he’s doing and how it will behave As stated back in Oracle9i RMAN Backup & Recovery, test environments can be tricky to describe or to provide advice about Every shop has its own concept of what testing is required, and at what level, for application design, quality assurance, version control, and so forth And with RMAN playing a more integral role in a wider array of DBA activities, it’s increasingly difficult to separate an RMAN test environment from other test environments But, you are looking at this book now, and we have opinions on testing backup strategies As we like to say, everyone has a backup strategy Few have a recovery strategy Testing backups is only a fraction of the work If you not test your recovery strategies, then you don’t have backups, no matter how many files you’ve written to how many thousands of dollars’ worth of equipment A test environment for backup and recovery is different from other testing environments First of all, you have to be able to remove datafiles, or even the entire database, on a whim, without having to clear it with other users In other words, you need your own database Or two If you begin testing RMAN functionality on a shared database, pretty soon you’ll either start getting angry phone calls from other users, or find yourself locked out of the machine by the SA Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark Appendix C: Setting Up an RMAN Test Environment 627 A backup and recovery test environment is simply too volatile to share Think about it from the other end: you’re busy testing a backup yourself, when suddenly the backup aborts because someone started removing datafiles in order to test their own restore and recovery On the other hand, you need to test your strategies in an environment that most closely matches that of your production databases Therefore, you can’t always run in isolation, because you might need to tune your backup on a large, production-grade server that has the same kind of load as production What we suggest, then, is that you approach RMAN backup and recovery testing as a twotiered investigation: First, get comfortable with functionality and behavior in the isolation of a small test server Second, take the lessons you’ve learned, and schedule time to test on a larger, production-grade database server That way, you can schedule time on a test box for a backup/ recovery test outage, and avoid spending that valuable time trying to learn lessons that you could have figured out on your workstation So, what does this approach look like more specifically? The answer is provided in this appendix The Test Box The first-level test machine for RMAN functionality doesn’t need to be a supercomputer In fact, you should think of the first level of testing as just a rehearsal— you’re reading through your lines, getting the placement right, and talking through the steps with the other actors and the director Match Your Production Environment If possible, your RMAN testing should take place on the same operating system that you run in production This is a rather humorous thing to say, we know: who has a single OS in their environment anymore? Anyway, if you will be backing up only Solaris servers, it makes sense to invest a little money in a Sun workstation That way, you can begin production environment matching as soon as possible Go Cheap It’s not that critical to have your first wave of testing take place on the same OS as your production environment RMAN acts the same on all platforms, and the exercises in this book work on all platforms So, if you’re in the market for an RMAN test box, we have only two words: go cheap Buy a commodity-priced computer that runs Windows or Linux I’ve grown quite fond of my cut-rate Linux cluster that Scott Jesse outlined in the Oracle Press book Oracle Database 10g High Availability with RAC, Flashback, and Data Guard (2004) It is a two-node RAC tester for under $1,500, bought refurbished from Dell’s Outlet As far as what to look for in a cheap test environment, we provide the following advice: ■ Processor speed Don’t worry about processor speed at the RMAN proof-of-concept level RMAN simply does not rely on CPUs that heavily As you move into heavy parallelization in production, CPU speeds might grow in testing importance Even if you monitor for performance at this level, the data is meaningless when compared with your production environment Instead, spend money on other resources, mainly disk space and memory Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark ... Control, 312–313 NetBackup, 159 Oracle and Data Protector integration, 175 Oracle backup and recovery See backup and recovery architecture RMAN See RMAN architecture archival backups, 240–241 archive... logical backup and recovery, 26 Oracle database, 14–16 Oracle logical structures, 21 Oracle memory and RMAN, 13–14 Oracle processes, 11–12 Oracle redo logs, 16–20 Oracle terminology, 7–9 other Oracle. .. parameter syntax diagram, configure command, 576 backupOperand parameter syntax diagram, backup command, 567 backups, RMAN, 225–238 backup command See backup command options compatibility issues, 227–228

Ngày đăng: 28/10/2013, 21:15

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan