search
HomeDatabaseMysql TutorialOracle:RMAN 备份与恢复实例

命令: connect target / (connect target system/oracle@ora10g,如果数据库没有起来,也可要直接在rman命令下用startup进行启动

1. 检查数据库模式:
   sqlplus /nolog
   conn /as sysdba
   archive log list (查看数据库是否处于归档模式中)

   若为非归档,则修改数据库归档模式。
   startup mount
   alter database archivelog
   alter database open

2.连接到target数据库

命令: connect target  / (connect target system/Oracle@ora10g,如果数据库没有起来,也可要直接在rman命令下用startup进行启动数据库) 
可以连接到target database.(rman 一边连接到target数据库,另外一边连接到control file(nocatalog mode),control file 中存储rman 的备份信息)

3.用list backupset 命令查看有没有备份的东西

4. 常用备份命令:
 备份全库:
RMAN> backup database plus archivelog delete input;     (备份全库及控制文件、服务器参数文件与所有归档的重做日志,并删除旧的归档日志)
备份表空间:
RMAN> backup tablespace system plus archivelog delete input;     (备份指定表空间及归档的重做日志,并删除旧的归档日志)_
备份归档日志:
RMAN> backup archivelog all delete input;


======================对整个数据库进行备份==================

1.对整个数据库进行全备份(full backup)。

    只要输入命令: backup database;

2.list backupset 查看备份的具体信息

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1       Full    6.80M      DISK        00:00:02     06-DEC-08     
        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20081206T201041
        Piece Name: /home/oracle/flash_recovery_area/ORA10G/backupset/2008_12_06/o1_mf_ncsnf_TAG20081206T201041_4mntz78s_.bkp
  Control File Included: Ckp SCN: 782019       Ckp time: 06-DEC-08
  SPFILE Included: Modification time: 06-DEC-08

BS(backupset), piece是一个文件,一个BS包含多个piece.

3.rman中缺省的参数,可以通过 show all ;
来进行查看(RMAN configuration parameters),我们在使用backup database命令中,可以把这些default value 用固定的值来进行替代.

4.我们可以把备份的文件才备份的目录中拷贝到磁带上,,然后删除备份目录下面的备份文件,如果下次需要恢复的话,只要把文件重新拷回到用来的备份目录就可以了
5.查看control file 文件中的备份信息(因为我们做的备份是在nocatalog模式下),control file 在/u01/oracle/oradata/ora10g目录下,由于control file 是个二进制文件,要查看control file 文件中的内容,用strings control03.ctl,发现control03.ctl中有rman备份的信息了

 
====================0级增量备份===============

概念:全备份和0级增量备份。全备份和0级增量备份几乎是一样的。唯一的区别,0级增量备份能作为增量备份的基础,而全备份不能作为增量备份的基础。其它方面完全一致

1.backup incremental level=0(leve 0) database;(增量为0的备份)
2.backup incremental level 1(level=1) database;(增量为1的备份)
 
在上面的备份中,我们备份了datafile,controlfile和parameter file.没有备份的文件有归档日志,重做日志和口令文件没有备份.口令文件不需要备份,我们用orapw来创建一个

新的口令文件.rman 在nocatalog模式下,不能够对redo log file 进行备份


===================备份archivelog 在nocatalog模式下=================

命令:backup database plus archivelog delete input(delete input的意思在备份完成后,删除 archivelog文件,这个选项可要可不要,这个命令也可以用 backup incremental level=0(1,2...)来进行备份)


=======================备份表空间====================

backup tablespace tablespacename

如果我们不知道tablespace的名字,在rman中,可要通过report schema命令,来查看表空间的名字

MAN> report schema;
Report of database schema

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    480      SYSTEM               ***     /home/oracle/oradata/ora10g/system01.dbf
2    25       UNDOTBS1             ***     /home/oracle/oradata/ora10g/undotbs01.dbf
3    250      SYSAUX               ***     /home/oracle/oradata/ora10g/sysaux01.dbf
4    5        USERS                ***     /home/oracle/oradata/ora10g/users01.dbf
5    200      PERFSTAT             ***     /home/oracle/oradata/ora10g/perfstat.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    20       TEMP                 32767       /home/oracle/oradata/ora10g/temp01.dbf

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
MySQL: Essential Skills for Beginners to MasterMySQL: Essential Skills for Beginners to MasterApr 18, 2025 am 12:24 AM

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL: Structured Data and Relational DatabasesMySQL: Structured Data and Relational DatabasesApr 18, 2025 am 12:22 AM

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL: Key Features and Capabilities ExplainedMySQL: Key Features and Capabilities ExplainedApr 18, 2025 am 12:17 AM

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

The Purpose of SQL: Interacting with MySQL DatabasesThe Purpose of SQL: Interacting with MySQL DatabasesApr 18, 2025 am 12:12 AM

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

MySQL for Beginners: Getting Started with Database ManagementMySQL for Beginners: Getting Started with Database ManagementApr 18, 2025 am 12:10 AM

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

MySQL's Role: Databases in Web ApplicationsMySQL's Role: Databases in Web ApplicationsApr 17, 2025 am 12:23 AM

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

MySQL: Building Your First DatabaseMySQL: Building Your First DatabaseApr 17, 2025 am 12:22 AM

The steps to build a MySQL database include: 1. Create a database and table, 2. Insert data, and 3. Conduct queries. First, use the CREATEDATABASE and CREATETABLE statements to create the database and table, then use the INSERTINTO statement to insert the data, and finally use the SELECT statement to query the data.

MySQL: A Beginner-Friendly Approach to Data StorageMySQL: A Beginner-Friendly Approach to Data StorageApr 17, 2025 am 12:21 AM

MySQL is suitable for beginners because it is easy to use and powerful. 1.MySQL is a relational database, and uses SQL for CRUD operations. 2. It is simple to install and requires the root user password to be configured. 3. Use INSERT, UPDATE, DELETE, and SELECT to perform data operations. 4. ORDERBY, WHERE and JOIN can be used for complex queries. 5. Debugging requires checking the syntax and use EXPLAIN to analyze the query. 6. Optimization suggestions include using indexes, choosing the right data type and good programming habits.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools