Backup and restore

1. Oracle failure types: statement failure, user process failure, instance failure, media failure
2. Backup type: 1) According to physical and logical points, physical backup (backup physical files) and logical backup (backup tables and other logical components)
2) According to the backup strategy: full backup, incremental backup, differential backup
3. Recovery classification: instance recovery, media recovery (complete and incomplete recovery).
4, rman: recovery manager:
components: target database target (database to be backed up), server session, rman database, recovery catalog catalog, mml (media manager for tape backup), flash recovery area, auxiliary database.
Steps: Create a recovery directory, register the target database to the recovery directory, configure channels, backup and recovery
Notes: 1) The target database must be configured in archive mode 2) Use the backup command for backup, and restore (rebuild files) and recover (synchronous recovery) ) Two commands
5. Data pump logical backup:
Export data: The suffix of the export file is .dmp, and the command expdp can export the library, table space, table, and user mode.
Import data: restore data, command impdp
6. Flashback technology: quickly recover from any logical errors.
Including: flashback query, flashback version query, flashback transaction query, flashback database, flashback delete, flashback table.
You need to set the flashback recovery area, which can be flashback based on scn and time point.
Flashback database: need to be in archive mode, need to establish flashback recovery area
Flashback table: need to start row movement feature,
flashback delete: need to start the recycle bin (start by default), clear the recycle bin with the purge command.
Flashback table and delete can not use sys user.
Experimental command:
1. rman physical backup, backup all physical files of the entire database
sql>shutdown immediate --- execute
startup mount
alter database archivelog in sql --- set the database to archive log mode
alter database open;
$rman target sys/oracle11g --- Enter the rman mode in the linux command line
rman>backup database --- backup all files in the entire database
rman>shutdown immediate --- close the database and
rename the user01 tablespace file at this time
rman>startup mount
restore database; --- restore the database, complete You should be able to see that user01 has recovered
recover database;
alter database open;
2. Use expdp and impdp to import and export logical objects to achieve logical backup.
sql>host mkdir '/opt/oracle/backup'; ---Create a local directory for storing backup files
create directory dump_dir as '/opt/oracle/backup'; ---Specify the operation directory name and bind it to the local directory
Unlock the scott user and set the connect, resource permissions
grant read, write on directory dump_dir to scott; --- Grant the scott user permission to operate dump_dir
$expdp scott/password directory=dump_dir dumpfile=scotttab.dmp tables=emp,dept --- After the linux command line export
is complete, you can delete scott's emp table and verify that the table has been deleted
$impdp scott/password directory=dump_dir dumpfile =scotttab.dmp tables=emp,dept ---
Check scott's emp table after importing and importing on the linux command line to ensure that it can be queried
3. Use flashback technology
1) Flashback database
sql>startup mount
alter database flashback on ; --- Open the flashback log function
alter database open;
set time on; --- Display the system time
Delete the table emp of the scott user, close the database again and load the
flashback database to timestamp to_timestamp('2017-6-10 10:40 :25','yyyy-mm-dd hh24:mi:ss');
--- Flash the database back to the set time (the time before deletion) to see if the emp table is restored successfully
alter database open resetlogs;
2) Flashback table: You must use ordinary users, sys user prohibits flashback table, use scott user to operate
sql>alter table dept enable row movement;
insert or delete data in dept table, the query operation is successful
sql> flashback table dept to timestamp to_timestamp('2017-6-10 10:40:25','yyyy-mm-dd hh24:mi:ss'));
Verify that the flashback is successful
3) Flashback delete: recoverable drop The table deleted by the table statement uses the recycle bin function, which is enabled by default and does not support the sys user
sql>drop table emp;
select object_name,original_name,type from user_recyclebin; ---View the recycle bin
flashback table emp to before drop; -- -Recover deleted emp table
4) Flashback query: you can query old data or restore to old data
sql>update scott.emp set sal=2000 where empno=7844; ---change the value of emp table
commit;
select from scott .emp ---Check the current value
select
from scott.emp as of timestamp to_timestamp('2017-6-10 10:40:25','yyyy-mm-dd hh24:mi:ss'));
---Check value at past point in time

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324654421&siteId=291194637