Oracle cold Backup Recovery and oracle recovery

Source: Internet
Author: User

I. Cold backup
1. When the database is shut down normally, you must know the name and path of the backup file before performing the cold backup.
Copy codeThe Code is as follows:
SQL> select name from v $ datefile;
SQL> select name from v $ controlfile;
SQL> select member from v $ logfile;

2. files to be backed up for cold backup include:
All data files, all control files, and all online redo log files
3. Cold backup steps
① Shut down the instance to be backed up normally)
② Copy all important files to the backup directory
③ Start the database after the backup is completed
4. Use cold backup for database recovery
Non-archive mode: copy the backup file back to the original directory and start the database.
Archive mode:
① Copy data files and control files back to the original directory
② SQL> startup mount;
SQL> recover database using backup controlfile;
③ Drag the archived and online logs to the CMD command window to run the logs.
④ SQL> alter database open resetlogs;

Ii. Recovery from different machines

Cold Backup Recovery Method
A. Do not create an instance: (the database name on the source machine is orcl)
① Create an orcl folder under the oradata directory on the target machine, and copy all the data files on the source machine and the on-line redo files to this directory.
② Create an orcl folder under the admin directory on the target machine, and then create Six folders in orcl: adump, bdump, cdump, udump, dpdump, and pfile.
③ Copy the password file of the source machine to the database directory of the target machine.
④ Use the oradim command in cmd oradim-new-sid orcl to create a service. The sid is orcl (preferably the same name as the database name backed up by the source machine, so you do not need to recreate the password file)
⑤ Copy the pfile of the source machine to a directory on the target machine, modify the path of the relevant files in the pfile, and create a parameter file through SQL> create spfile from pfile = 'file path.
6. Run the "SQL> alter database backup controlfile to trace" command to rebuild the control file. A trace file is generated in the udump folder. open the file and find the following file and copy it to the text, modify the corresponding path and save it as: createctl. copy the SQL file (SQL script file) to the target machine.
Note: SQL> alter database backup controlfile to trace as 'aa.txt '; will be created in the dbs directory in linux
Copy codeThe Code is as follows:
STARTUP NOMOUNT
Create controlfile reuse database "ORCL" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
# MAXLOGHISTORY 292
LOGFILE
GROUP 1 'C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ redo01.log' SIZE 50 M,
GROUP 2 'C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ REDO02.LOG 'SIZE 50 M,
GROUP 3 'C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ REDO03.LOG 'SIZE 50 M
-- STANDBY LOGFILE
DATAFILE
'C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ system01.dbf ',
'C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ undotbs01.dbf ',
'C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ sysaux01.dbf ',
'C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ users01.dbf ',
'C: \ ORACLE \ PRODUCT \ 10.2.0 \ ORADATA \ ORCL \ bank_data02.dbf'
Character set ZHS16GBK;

7c: \> set ORACLE_SID = orcl
C: \> sqlplus "/as sysdba"
SQL> create spfile from pfile = 'C: \ pfile.txt ';
SQL> @ c: \ createctl. SQL;
SQL> shutdown immediate;
SQL> startup;
SQL> alter database open resetlogs;
Add the following snippet to tnsnames. ora under network \ admin.
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 127.0.0.1) (PORT = 1521 ))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)

Using net configuration to create a listener for an orcl instance

B. Create an instance (the instance SID is consistent with the source database SID)
① Delete all files under oradata \ orcl of the target machine, and copy all data files and redo files from the source machine to this directory.
② Delete the password file of the target machine and copy the password file of the source machine to the target machine.
③ Recreate the control file of the target machine on the source machine: SQL> alter database backup controlfile to trace; then a trace file is generated in the udump folder, open the file, find the above section, and copy it to the text, modify the corresponding path and save it as: createctl. copy the SQL file (SQL script file) to the target machine.

Copy codeThe Code is as follows:
C: \> sqlplus "/as sysdba"
SQL> @ c: \ createctl. SQL;
SQL> shutdown immediate;
SQL> startup;
SQL> alter database open resetlogs;

⑤ Add the following fragments to tnsnames. ora under network \ admin:
Copy codeThe Code is as follows:
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 127.0.0.1) (PORT = 1521 ))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)

⑥ Use net configuration to create a listener for the orcl instance

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.