归档模式下,使用RMAN的同一备份两次用于不完全恢复
SCN的序列的递增性不随数据库的任何操作而改变,即使是RESETLOGS也如此。RESETLOGS清除所有联机日志文件中未应用的重做记录,RES
实验理论基础:
SCN的序列的递增性不随数据库的任何操作而改变,即使是RESETLOGS也如此。
RESETLOGS清除所有联机日志文件中未应用的重做记录,RESETLOGS只重置日志文件的序列号为1,但对SCN无影响,SCN仍按原序列递增。
在控制文件中保存resetlogs SCN和计数器,以便唯一地标识用RESETLOGS选项执行的每一次打开数据库的操作。
这个值被写进每个数据文件头以及重做日志文件。
如果重做日志文件的日志序列号与Oracle的要求值不相符,则在恢复中不能应用重做日志文件。
执行不完全恢复后,数据库要求日志序列号为1的日志文件,所以原来的日志序列中剩余的日志文件将不可用。
RESETLOGS操作创建数据库的新形体,即一个拥有从1开始的新的日志序列号流的数据库。
根据以上理论:SCN为顺序数据流,在数据库存在期间始终递增,而日志文件序列流也是递增序列,只不过会因RESETLOGS而重置为1,但日志文件序列流中的SCN序列流却保持递增不变。
因此可以用RESETLOGS之前的归档日志流和RESETLOGS之后的归档日志流来连接和延续SCN序列流,这样就实现了用RESETLOGS之前的备份恢复RESETLOGS之后的数据。
前提是:
保证两股日志流(RESETLOGS之前的归档日志流和RESETLOGS之后的归档日志流)完整,并且有相应两股日志流的控制文件。
建议:在RESETLOGS前保证数据库以前备份的数据安全,在创建RESETLOGS之后的第一个一致性备份之前,一定不可删掉在RESETLOGS前创建的一致数据库备份。
如空间足够,建议永久保留RESETLOGS前创建的一致数据库备份。
实验思路、步骤:
1.关库做备份--RMAN,记下SCN与时间,,记录序号及REDO。
2.打开库,记下时间/SCN,删除一个用户,做基于时间点的不完全恢复。记录不完全恢复后的SCN,归档序号
3.在恢复后的库,记下时间/SCN,再删除一个用户,使用步骤1中备份可以对RESETLOS后的库再次做不完全恢复。
##########################################################################################################
SYS@bys1>col name for a50
SYS@bys1>select * from (select name,recid,sequence#,status,applied from v$archived_log order by recid desc) where rownumNAME RECID SEQUENCE# S APPLIED
-------------------------------------------------- ---------- ---------- - ---------
/u01/archbys1/arc_1_31_829941492.arc 120 31 A NO
/u01/archbys1/arc_1_30_829941492.arc 119 30 A NO
/u01/archbys1/arc_1_29_829941492.arc 118 29 A NO
/u01/archbys1/arc_1_28_829941492.arc 117 28 A NO
BYS@bys1>select incarnation#,resetlogs_change#,resetlogs_time,prior_resetlogs_time,status,resetlogs_id from v$database_incarnation;后来补充-可以从此视图查出历次RESETLOGS情况
INCARNATION# RESETLOGS_CHANGE# RESETLOGS_TIME PRIOR_RESETLOGS_TIM STATUS RESETLOGS_ID
------------ ----------------- ------------------- ------------------- ------- ------------
1 1 2009/08/13 23:00:48 PARENT 694825248
2 754488 2013/08/01 08:58:04 2009/08/13 23:00:48 PARENT 822301084
3 2541692 2013/10/27 19:18:12 2013/08/01 08:58:04 PARENT 829941492
4 3228984 2013/11/06 00:14:08 2013/10/27 19:18:12 PARENT 830736848
5 3229505 2013/11/06 00:27:42 2013/11/06 00:14:08 CURRENT 830737662
SYS@bys1>startup mount;
ORACLE instance started.
Total System Global Area 631914496 bytes
Fixed Size 1338364 bytes
Variable Size 385876996 bytes
Database Buffers 239075328 bytes
Redo Buffers 5623808 bytes
SYS@bys1>exit
[oracle@bys001 ~]$ cat fullback.sh
rman log /home/oracle/backfull-`date +%Y%m%d-%H%M`.log connect target /;
run {
backup full tag 'bys001-full' database
format "/home/oracle/bys001full_%d_%t_%s"
plus archivelog
format "/home/oracle/bys001arch_%d_%t_%s"
delete all input;
}
exit
[oracle@bys001 ~]$ sh fullback.sh
RMAN> RMAN> 2> 3> 4> 5> 6> 7> RMAN>
[oracle@bys001 ~]$ sqlplus / as sysdba
SYS@bys1>alter database open;
Database altered.
###############
4.记录当前系统的SCN,并删除一个用户
SYS@bys1>select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
SYS@bys1>select dbid,checkpoint_change# from v$database;
DBID CHECKPOINT_CHANGE#
---------- ------------------
3957527513 3228508
SYS@bys1>col name for a40
SYS@bys1>select file#,name,checkpoint_change#,to_char(checkpoint_time,'yyyy-mm-dd hh24:mi:ss') cptime from v$datafile;
FILE# NAME CHECKPOINT_CHANGE# CPTIME
---------- ---------------------------------------- ------------------ -------------------
1 /u01/oradata/bys1/system01.dbf 3228508 2013-11-05 23:51:15
2 /u01/oradata/bys1/sysaux01.dbf 3228508 2013-11-05 23:51:15
3 /u01/oradata/bys1/undotbs01.dbf 3228508 2013-11-05 23:51:15
4 /u01/oradata/bys1/users01.dbf 3228508 2013-11-05 23:51:15
5 /u01/oradata/bys1/example01.dbf 3228508 2013-11-05 23:51:15
6 /u01/oradata/bys1/test1.dbf 3228508 2013-11-05 23:51:15
SYS@bys1> select GROUP#,sequence#,STATUS,FIRST_CHANGE#,to_char(FIRST_TIME,'yyyy/mm/dd:hh24:mi:ss') time from V$log;
GROUP# SEQUENCE# STATUS FIRST_CHANGE# TIME
---------- ---------- ---------------- ------------- -------------------
1 31 INACTIVE 3222825 2013/11/05:22:08:56
2 32 CURRENT 3228378 2013/11/05:23:38:08 可以看到当前REDO日志的序号是32
3 30 INACTIVE 3218774 2013/11/05:22:00:30
SYS@bys1>set time on
23:55:34 SYS@bys1> select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------
3228983
23:55:35 SYS@bys1>conn test/test
Connected.
23:55:53 TEST@bys1>select * from cat;
TABLE_NAME TABLE_TYPE
------------------------------ -----------
TEST1 SYNONYM
23:56:06 TEST@bys1>conn / as sysdba
Connected.
23:56:18 SYS@bys1>drop user test cascade;
User dropped.
删除用户完成
######################################################################

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values and pointers to data rows, and is suitable for non-primary key column queries.

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

MySQL supports four index types: B-Tree, Hash, Full-text, and Spatial. 1.B-Tree index is suitable for equal value search, range query and sorting. 2. Hash index is suitable for equal value searches, but does not support range query and sorting. 3. Full-text index is used for full-text search and is suitable for processing large amounts of text data. 4. Spatial index is used for geospatial data query and is suitable for GIS applications.

MySQL and MariaDB can coexist, but need to be configured with caution. The key is to allocate different port numbers and data directories to each database, and adjust parameters such as memory allocation and cache size. Connection pooling, application configuration, and version differences also need to be considered and need to be carefully tested and planned to avoid pitfalls. Running two databases simultaneously can cause performance problems in situations where resources are limited.
