Here I will try to explain about the Oracle DB flashback technology and how you can use this in a practical scenario.
REQUIREMENT:
Our application was going through a load testing. Every time after a load test, testers were asking us to database restoration to it's previous state. Altogether their requirement was like this
Lets say database initial state: A
They prepare their testdata and load testdata into database for testing of 200 users:
After Testing Database state, let's say: B (because insertion of new data and transaction happened during load test has changed the Database state to B)
Before running the 2nd load test for 300 user:
Testers require the DB state should be in State A (because they don't want their testdata and transaction data to be there in the database)
After making the DB in state A, they use their prepared testdata and start load test for 300 users.
In the same way they need to do the activities for few iteration.
Now as a DBA 2 ways came to mind .
Way-1:
Take a consistent backup of database on state A. Then after each load test restore the database with the consistent backup using rman.
This will work, but this is a lengthy procedure, testers has to wait until DB restore and DB size was also big enough to take time for restoration.
Way-2:
At DB state A. Make database flashback on, then create a restore point. Each time after load test we need to flash back the DB to restore point, drop the restore point then open the database with resetlogs. Then We will create the restore point once again. Give it to tester for load testing.
This way is quite easier and time saving one. So I preferred way-2 and did my job.
Complete steps for preparing DB flashback on and create restore restore point.
Let's say now database is in open state with state A:
To activate flashback
sql> alter system set db_flashback_retention_target=4320 scope=both;
sql>alter database flashback on;
sql>create restore point restore_back guarantee flashback database;
Give to the tester for testing
After load test Database state changed to B
Revert back to restore point
sql>startup mount force;
sql>flashback database to restore point restore_back;
sql>drop restore point restore_back ;
Open The database with resetlogs
sql>alter database open resetlogs;
create a restore point
create restore point restore_back guarantee flashback database;
Now check the DB state should be A
For checking the DB state here is the query
sql>select current_scn from v$database;
Every time you restore the DB and then open with resetlogs, check the scn should be same as it was there at the beginning (At DB state A)
No comments:
Post a Comment