Oracle-user-managed backup (1)

Source: Internet
Author: User

Oracle-user-managed backup (1) I. first, you must know the table space and file information in the database. There are several performance views: v $ datafile, v $ tablespace, v $ tempfile, v $ logfile, v $ controlfile, dba_tablespaces, dba_data_files can be used to view the location and name of a tablespace or file. dba_data_files can be used to view the tablespace that each data file belongs. You can also use $ datafile and v $ tablespace to check which table space each data file belongs. Example: SQL> select t. name tablespace, d. name datafile from v $ tablespace t join v $ datafile d on t. ts # = d. ts #; tablespace datafile contains invalid SYSTEM/u01/oradata/wilson/system01.dbfSYSAUX/u01/oradata/wilson/logs/u01/oradata/wilson/logs/u01/oradata/wilson/users01.dbfEXAMPLE/u01/ oradata/wilson/example01.dbfPAUL/u01/orada Ta/wilson/paul01.dbfSUN/u01/oradata/wilson/logs/u01/oradata/wilson/logs/u01/oradata/wilson/logs/u01/oradata/wilson/mssm_1dbfPAUL/u01/ oradata/wilson/paul02.dbf 2. backup method 1. in non-archive mode and non-archive mode, disabling the database for full backup is the only option. Find the location of each file in the view given above. The control file to be backed up and the entire data file set should be backed up. It is best to put the temporary file and spfile, the password files (in/u01/oracle/dbs) are also backed up. You must close the database cleanly before backup, so there is no need to back up online redo logs. However, if the database is closed improperly, you must back up online redo logs. Otherwise, the database cannot be opened after restoration. (In fact, it is best to back up data under whatever circumstances) 2. in archive mode, you can back up data when you close the database or when you open the database. (1) when you close the database, backup is the same as that in non-archive mode, one difference is that online redo logs are not backed up. Instead, archive logs are backed up. (2) When you open the database, the backup is non-consistent, so you must back up the archive log files. There are three steps as follows: (1) backup control file backup control files can be controlled in two ways: alter database backup confile to <filename>; alter database backup confile to trace as <filename>; the first form generates a binary backup, and the output file will be a strict read consistency copy of the current control file; the second form generates a logical backup, use a set of SQL commands in the specified file to create a new control file that contains the same database physical structure information as the current control file. The create controlfile command must be executed in non-load mode and a new control file is generated at the location specified by the control_files parameter; the new control file generated by this command only contains data related to the physical structure. For example, RMAN backup will be lost. Create a directory/tmp/con in the operating system and back up the control file in the first form. SQL> alter database backup controlfile to '/tmp/con/c1.ctl'; Database altered. SQL>! Ls-l/tmp/contotal 9636-rw-r ----- 1 oracle oinstall 9846784 Aug 23 c1.ctl back up the control file in the second form; SQL> alter database backup controlfile to trace as '/tmp/con/c2.ctl'; Database altered. SQL>! Ls-l/tmp/contotal 9648-rw-r ----- 1 oracle oinstall 9846784 Aug 23 07 c1.ctl-rw-r -- 1 oracle oinstall 7107 Aug 23 c2.ctl backup it as long as the control file changes, we recommend that you back up the control file every time you back up the backup. (2) for archiving log file backup, execute alter system archive log current, locate the archiving log location, and copy it to another location. For more information about how to set archive logs, see archive mode (3) copy data files when their tablespace is in backup mode; for more information about backup mode, see backup mode in oracle to see which tablespaces are available; SQL> select tablespace_name, contents from region; TABLESPACE_NAME CONTENTS region --------- SYSTEM region quota UNDOTEMP TEMPORARYUSERS PERMANENTEXAMPLE PERMANENTPAUL PERMANENTMYTEMP TEMPORARYSUN limit UNDOASSM limit CONTENTS ---------------- -------------- --------- MSSM PERMANENT12 rows selected. check the data files in the tablespace. SQL> select tablespace_name, file_name from dba_data_files; TABLESPACE_NAME FILE_NAME invalid PAUL/u01/oradata/wilson/paul01.dbfUSERS/u01/oradata/wilson/logs/u01/oradata/wilson/logs/u01/oradata/wilson/sysaux01.dbfSYSTEM/u01/ oradata/wilson /System01.dbfEXAMPLE/u01/oradata/wilson/example01.dbfSUN/u01/oradata/wilson/logs/u01/oradata/wilson/logs/u01/oradata/wilson/logs/u01/oradata/wilson /mssm_1dbfPAUL/u01/oradata/wilson/paul02.dbf11 rows selected. before backup, create a directory/tmp/hb to change the sun tablespace to backup mode. SQL> alter Tablespace sun begin backup; tablespace altered. back up the data files in the tablespace, SQL>! Cp/u01/oradata/wilson/sun01.dbf/tmp/hb check the result. SQL>! Ls-l/tmp/hbtotal 20516-rw-r ----- 1 oracle oinstall 20979712 Aug 22 01 sun01.dbf end backup, SQL> alter tablespace sun end backup; Tablespace altered. manual backup (in archive mode) must be performed when the database is opened. Although backup can be performed at the operating system level, backup cannot be used. You can also use SQL> alter database begin backup; Database altered. All tablespaces are in backup mode at one time. Another point is that you cannot back up temporary tablespaces, or even place them in backup mode. SQL> alter tablespace temp begin backup; alter tablespace temp begin backup * ERROR at line 1: ORA-03217: invalid option for alter of TEMPORARY TABLESPACE (4) backup of parameter files and password files is not necessary for their backup, but it is best to back up them for convenient restoration; parameter files, in order to back up spfile, use the following command to generate a text file. SQL> create pfile = 'initwilson. ora 'from spfile; if the dynamic parameter file is damaged at some time, you can use this command to re-create it in non-load mode or disable the instance,, Create spfile from pfile = 'initwilson. ora '; password file. to back up the password file, save a copy of the command used to create it. For example, orapwd file = $ ORACLE_HOME/dbs/orapwd <SID> password = oracle entries = 5, where <SID> is the Instance name. If the password file is damaged at a certain time, simply run the script to recreate it.

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.