Oracle-full recovery of User Management (1) I. categories can be divided into full recovery in non-archive mode and archive mode. full recovery is mainly for archive mode, and it is difficult to achieve full recovery in non-archive mode, unless online redo logs are not overwritten during restoration. II. non-archive related properties 1. in non-archive mode, the only option after data files are lost is to restore the entire database. restoring a complete database is the data files and control files used for restoration. 3. the premise for restoration is to back up data. Because it is not in archive mode, only cold backup can be performed, mainly to back up all data files and control files. Online redo log files can be backed up without being backed up when the database is shut down normally. We recommend that you back up the log files, in this way, you do not need to recreate it. III. recovery in non-archive Mode 1. if the disk where data files are stored is not damaged, but some data files are lost for some reason, copy the backup database (all data files and control files) to the original location. 2. If the disk is damaged, it cannot be placed in the original location and must be placed in the new disk. In this way, you must modify the information of the parameter file and control file to open the database normally. 3 .. now simulate the second scenario (Disk damage). First, perform a cold backup on the database and create a directory/u01/ubackup, copy all files (data files, control files, and online redo log files) under/u01/oradata/wilson to the ubackup directory. The command is as follows,
[oracle@oracle11g ubackup]$ cp /u01/oradata/wilson/* /u01/ubackup
Assume that the disk mounted to the/u01/oradata/wilson directory is damaged,
[Oracle @ oracle11g wilson] $ rm-f *. dbf (delete data files and simulate disk corruption)
Because the disk is damaged, the cold backup database cannot be restored to this disk. A new disk must be added. You can add a new disk (8 GB) on the VM, and then create a directory md under/u01/oradata/to mount the new disk.
[oracle@oracle11g oradata]$ mkdir md
(1) partition the new disk,
[root@oracle11g ~]# fdisk /dev/sdbCommand (m for help): nPartition number (1-8): 1First cylinder (0-1866): 1Last cylinder or +size or +sizeM or +sizeK (1-1866, default 1866): 1866Command (m for help): pDisk /dev/sdb (Sun disk label): 7 heads, 80 sectors, 1866 cylindersUnits = cylinders of 560 * 512 bytes Device Flag Start End Blocks Id System/dev/sdb1 1 1866 522200 83 Linux native
Because the disk is small, it is directly divided into one partition. You can see an additional sdb1 in the directory/dev. (2) run the following command to create a system file for sdb1,
[root@oracle11g dev]# mkfs.ext3 sdb1
(3) mount the disk to the/u01/oradata/md directory. The command is as follows,
[root@oracle11g oradata]# mount /dev/sdb1 /u01/oradata/md
(4) In the/u01/oradata directory,
[oracle@oracle11g oradata]$ lltotal 17drwxr-xr-x 3 root root 1024 Aug 29 23:10 mddrwxr-x--- 3 oracle oinstall 4096 Aug 25 17:09 wilson
Md is root and cannot be used by user oralce. Therefore, modify the permission by using the following command,
[root@oracle11g oradata]# chown -R oracle:oinstall md
(5) switch to the oracle user (su-oracle) and copy the cold backup database to the/u01/oradata/md directory,
[oracle@oracle11g md]$ cp /u01/ubackup/* /u01/oradata/md/
(6) modify the spfile. First, convert the spfile to pfile. Because pfile is of the text type, you can directly modify it.
SQL> create spfile from pfile;File created.
Change pfile to/u01/oradata/wilson/directory. After modification, convert it to spfile. The command is as follows,
SQL> create spfile from pfile;File created.
(7) related data files in the control file, online redo log files and temporary files are still in the original location, and all change control files. Because the spfile has been modified, the database can enter the mount state. -- In this case, you can view the position and name of the data file in the v $ datafile dynamic performance view.
SQL> select file#,name from v$datafile; FILE# NAME ---------- ----------------------------------- 1 /u01/oradata/wilson/system01.dbf 2 /u01/oradata/wilson/sysaux01.dbf 3 /u01/oradata/wilson/undotbs01.dbf 4 /u01/oradata/wilson/users01.dbf 5 /u01/oradata/wilson/example01.dbf 6 /u01/oradata/wilson/paul01.dbf 7 /u01/oradata/wilson/sun01.dbf 8 /u01/oradata/wilson/smallundo1.dbf 9 /u01/oradata/wilson/assm_1.dbf 10 /u01/oradata/wilson/mssm_1dbf 11 /u01/oradata/wilson/paul02.dbf FILE# NAME- --------- ----------------------------------- 12 /u01/oradata/wilson/appl_01.dbf12 rows selected.
Modify the name of the data file in the control file. The command is as follows,
SQL> alter database rename file '/u01/oradata/wilson/system01.dbf' to '/u01/oradata/md/system01.dbf';
Modify each data file or modify it in batches. -- View the location and name of online redo log files in the dynamic performance view of v $ logfile.
SQL> select group#,member from v$logfile; GROUP# MEMBER ---------- ----------------------------------- 3 /u01/oradata/wilson/redo03.log 1 /u01/oradata/wilson/redo01.log 2 /u01/oradata/wilson/redo02.log
Modify the name of the connection redo log file in the control file. The command is as follows,
SQL>alter database rename file '/u01/oradata/wilson/redo01.log' to '/u01/oradata/md/redo01.log' ;
Modify each online redo log file. -- View the location and name of the temporary file in the dynamic performance view of v $ tempfile.
SQL> select file#,name from v$tempfile; FILE# NAME ---------- ----------------------------------- 1 /u01/oradata/wilson/temp01.dbf 2 /u01/oradata/wilson/mytemp01.dbf
Modify the name of a temporary file in the control file. The command is as follows,
SQL>alter database rename file ‘/u01/oradata/wilson/temp01.dbf' to ‘/u01/oradata/md/temp01.dbf';
Modify each temporary file. (8) You can open the database. The command is as follows,
SQL> alter database open;
4. The online redo log files are backed up. The following describes the situation where online redo logs are not backed up. (In non-archive mode) 1. recovery steps: (1) shut down the database; (2) restore data files and control files from the backup; (3) cancel-based recovery; (4) When opening the database, with the resetlogs option. 2. As described in the previous two steps, you can delete online redo log files in the directory/u01/oradata/md. The command is as follows,
[Oracle @ oracle11g md] $ rm-f redo0 * then enters the mount status. The restore command is as follows: SQL> recover database until cancel using backup controlfile; prompt to enter cancel and use the following command, you can create online redo logs again. SQL> alter database open resetlogs; this allows you to open the database normally.