Backup of control files can be performed in two formats: Text backup and binary backup.
Backup text format
SQL> alterdatabase backup controlfile to trace as '/bk/con. SQL ';
Databasealtered.
Backup binary format
SQL> alterdatabase backup controlfile to trace as '/bk/con. ctl ';
Databasealtered.
---- Add the as clause to customize the storage location
SQL>! Cp/etc/passwd/u01/tiger/oradata/orcl2/control01.ctl
SQL> altersystem swirch logfile;
Alter systemswirch logfile
*
ERROR at line 1:
ORA-02065: illegal options for ALTER SYSTEM
SQL> altersystem switch logfile;
Alter systemswitch logfile
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
SQL> conn/assysdba
Connected to anidle instance.
SQL> startup
Oracle instancestarted.
Total SystemGlobal Area 314572800 bytes
Fixed Size 1219136 bytes
VariableSize 109053376 bytes
DatabaseBuffers 197132288 bytes
RedoBuffers 7168000 bytes
ORA-00205: errorin identifying control file, check alert log for more info
We can find that there is a problem with the control file during the mount operation, so that we can restore the control file based on the text file of the control file backed up earlier.
Createcontrolfile reuse database "ORCL2" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
# MAXLOGHISTORY 292
LOGFILE
GROUP 1'/u01/tiger/oradata/orcl2/redo01.log' SIZE 50 M,
GROUP 2'/u01/tiger/oradata/orcl2/redo02.log 'SIZE 50 M,
GROUP 3 '/u01/tiger/oradata/orcl2/redo03.log' SIZE50M
DATAFILE
'/U01/tiger/oradata/orcl2/system01.dbf ',
'/U01/tiger/oradata/orcl2/tiger. dbf ',
'/U01/tiger/oradata/orcl2/sysaux01.dbf ',
'/U01/tiger/oradata/orcl2/users01.dbf ',
'/U01/tiger/oradata/orcl2/undotbs02.dbf ',
'/U01/tiger/oradata/orcl2/undotbs01 ',
'/U01/tiger/oradata/orcl2/tiger01.dbf'
CHARACTER SETZHS16GBK
SQL> alterdatabase open;
Alter databaseopen
*
ERROR at line 1:
ORA-01113: file1 needs media recovery
ORA-01110: datafile 1: '/u01/tiger/oradata/orcl2/system01.dbf'
SQL> recoverdatabase;
Media recoverycomplete.
SQL> alterdatabase open;
Databasealtered.