Showing posts with label Backups. Show all posts
Showing posts with label Backups. Show all posts

19 Backup & Restore a database with RMAN cold.



Again let's talk about backups. There are two types of backup: 

• Saying backups cold. In this case the base is inaccessible to users and it performs a simple file copy appropriate to restore in case of trouble.
• The hot backup. Aurrez you understand, it is a backup open database while user continues to work on their preferred base. It is usually this type of configuration found in production mode or can not afford to stop a database to save.

However, in some cases (Bureau study, Publisher, test environment, ..) it may be desirable to set up a backup strategy without it becoming too complicated. 

Again, a bit of thought before acting will save time later and avoid crisis situations. 

Start from the premise that the base is large and arrange for any table contains many columns of type CLOB. 

Notes: The table imports with CLOB columns are very long, because processed line by line. 

Solution 1: export for backup / import for restoration. 

Compared our case study, it may be possible but may take considerable time. 
So in case of data loss, restoration can be problematic:
• Duration of import / export relatively long.
• In panic mode, we do not think at all. And you can forget, for example to create tables containing CLOB (if you still use the utility imp.exe) to redirect tablespace (impdp.exe), and probably other issues that do not come to mind.

Solution 2: Stopping the base, and all copies of the database file or from a tape backup location. 

So to restore, just stop again and copy the database files. 
As everyone knows, database administration and recovery tests in most editors are a high priority. (Irony -)). So when restoring the probality missing a data file is quite high and hit the restoration of your database becomes more complicated. 


I suggest you stop the "DIY" and uses this ORACLE kindly put at our disposal. 
I am willing to nominate Recovery Manager (RMAN). 

To restore, it is necessary to have a backup. 

Before effecuter it, you connect yourself with a test user and create some tables and fill. 
Unless you (which should be the case) schemes with applications you need. 

Step 1:'s perform a cold backup database: 

Start> Run> cmd 

 sqlplus / nolog
 CONNECT / AS SYSDBA
 SHUTDOWN IMMEDIATE;
 QUIT

RMAN target /
RMAN> STARTUP MOUNT;
RMAN> BACKUP DATABASE FULL;
RMAN> ALTER DATABASE OPEN;
RMAN> QUIT

Note: Throughout this example, we see that RMAN has authority to stop or start a base! 

Step 2: Returning in SQL PLUS 

 TRUNCATE TABLE T1; 
 DROP TABLE T3; 
sqlplus / nolog 
SQL> CONNECT LAO / LAO - (this is my test with three user table t1, t2, t3. Original?)

Whoops! I wanted to do the opposite! 

Quickly go into panic mode; 
SQL> CONNECT / AS SYSDBA
SQL> SHUTDOWN IMMEDIATE;

And while my database is stopped, a colleague of goodwill deletes files related to SYSTEM tablespace (which of course were not saved) ==> laws MURPHY (maximum pain in the ass). 

You can always go with your dump! 


Step 3: stop the panic and remembered that we had taken the time to think to solve this kind of problems. 

Start> Run> cmd 

SET ORACLE_SID = oradb (if ever there are several bases on your computer). 

RMAN target /
RMAN> STARTUP MOUNT;
RMAN> RESTORE DATABASE;

.... If all goes well, a little message that says "End of restore in DD / MM / YY" 

RMAN> QUIT 

Just a little effort, 

sqlplus / nolog
SQL> CONNECT / AS SYSDBA
SQL> RECOVER DATABASE UNTIL CANCEL;

The insults you receive some of our friend ORACLE. 
Simply type without trembling and then CANCEL 

SQL> ALTER DATABASE OPEN RESETLOGS; 

Oh and magic, a message saying "Database changed" 

Let's crazy! 
SQL> CONNECT LAO / LAO 

Maintanant and you can check! the tables are all the, and with the same number of lines at the time of backup. 

Conclusion: This method is the same that the proposed solution number 2: one small detail is that RMAN handles for you to know which files to backup and especially where they are! 

0 Logical Backups

  • Logical Backups can be taken by 1)Tables 2) Users 3) Full database
  • Logical backup works as an alternative backup system.
  • The beauty about logical backup is we can be selective(which means we can backup/restore only the required objects which cannot be possible with physical backup)
  • Logical backup also offers incremental backup style
  • From oracle 8i we can export huge database to multiple dump files(Across systems)
  • From oracle 8i we can implement transportable tablespace using exports
  • From 10g we have advanced version of export know as pump
  • Export creates two files 1)Dump file 2)logfile(Optionall)
  • Export can be used to copy objects from one schema to another schema
  • Export can also be used for copying objects from one database to another database
  • Export dumpfile is platform independent so that we can export from one operating system to another and transfer the dump file using FTP to target server with same or different operating system followed by importing
  • When we go for oracle version updates it is highly recommended to take a full database export as a safety precaution.
  • As the database gets fragmented over a period of time because of transactions, we suppose to perform database level reorganization(REORG)-usually between 3 to 4 months.For this reorg process we follow
  1. Full export
  2. Drop existing database
  3. Create brand new databasse
  4. full import
  • While export or import,we can mention dfferent options like
  1. Table name
  2. Indexes
  3. Grants
  4. rows
  5. Compresses
  6. Feedback
  • The export dump file size is usually 8 to 10 times less than the database size.Reasons below
  1. System tablespace-not exported
  2. temporary tablespace-not exported
  3. undo-not exported(As it contains before image) where we export only the committed data.
  4. Index-only definitions are exported but not the data.Because of all above reasons the dump file is so small when compared to the database size.
  • Logical Backup takes more time when compared to physical backup
  • Import is 6 to 8 times slower than export as
  1. Export is only selecting data
  2. Import has to 1)Create table 2)Insert data 3)Indexes need to be created 4)constraints are to be enabled
  • Where we migrate from one platform to another then inorder to transfer the database we have to go with export/import.

0 Cold BackUp or physical backup


  • In oracle DBA we know that backup is an one of the important concept let us discuss about cold backup.
  • There are two types of backup 1) cold backup 2) hot backup
  • We need to shutdown the database and we need to take the backup of control file,redo log file, and database file at os level
  • In case of database running with No Archive Log mode then we can only go for simple restore after going through crash
  • If it is in Archive Log mode we can either go for Simple Restore or restore+recovery
  • Simple restore can even be performed by os admin where as recovery required DBA admin
  • Recoveries are of two types 1) Complete recovery  2) Incomplete Recovery
  • Complete recovery is possible only when we have 1)present Control file 2)current online redo log file
  • If any of the above two files missing then we end up with going for instance crash recovery
  • Complete recovery is possible in two ways
  1.  Online----Both system and undotbs datafile must be present
  2. Offline-----Any datafile can be missing
  • Instance crash recovery offers three choices
  1. Until cancel--Apply all the available archives  logs against latest cold backup-this is how offers us maximum recovery until time
  2. We can recover assuming archives are avilable upto time based recovery
  • Until SCN number---recover upto specified SCN number using archives logs
  • At the end of ICR we must reset logs then only we can open database.           
 

Oracle DBA Tutorial Copyright © 2011 - |- Template created by O Pregador - |- Powered by Blogger Templates