search
HomeDatabaseMysql Tutorial数据库的逻辑备份和物理备份--非RMAN

数据库的逻辑备份和物理备份--非RMAN,不用借助其他工具,只要归档日志和物理备份就可以实现的备份

数据库的备份和恢复

常规而且重要,恢复得到理想状态

逻辑备份

利用EXP备份,从数据库提取写入操作系统文件

1.可以导出一个完整的数据库
2.也可以导出一个模式的文件或者一个定特定表
3.称为转储文件,默认为扩展名为.dmp
4. 表或用户模式从一个数库到另一个数据库,重新识别表
5.到处程序创建存储指定表,而不是数据库的逻辑备份

利用iMP导入成程序导入

导入数据,从*.dmp的数据导入删除或者丢失的数据。

不用借助其他工具,只要归档日志和物理备份就可以实现的备份

物理备份

 无论冷备份还是热备份,物理备份就是把数据库当中的数据文件做相应的拷贝,只

是冷备份是指脱机备份,
热被备份是指联机备份。
  
  1.冷备份,,脱机备份,就是要把数据库的服务器(服务)停掉
 1)SQL> shutdown immediate
 2)停掉数据库之后,数据目录oradata当中的相应的文件数据文件,日志文件,控制

文件,拷贝到一个地方
 3)拷贝当相关的路径下,比如c:/bak
 4)若果数据库的文件(目录oradata下)丢失或者损坏,就可以直接从备份中把全部物

理文件考进来,全部覆盖原来的文件。
   这样会造成子备份之日起所有新增数据的丢失。
 5)复制完成后,就可以重新启动数据库。
冷备份就是一个物理拷贝。

 
  2.热备份,正常情况下的备份
 1)不用关机,联机备份,一起正常运转。
 2)置于归档方式,查看归档方式
  archive log list
  
  目录redo01.log,redo02.log,redo03.log叫做联机日志,轮流写入。
热备份一定要置成归档方式,用归档来恢复。

 日志两类:联机日志和归档日志。
 路劲为 USE_BD_RECOVERY_FILE_DEST
 1、sql>alter system set log_archiver_start=true scop =spfile
 2、shutdown immediate 停掉数据库。
 3、startup mount,启动到有控制文件,但是不打开数据文件
 4、alter database archive 将数据库切换到归档方式
 5、alter database open
    总体上,将数据库的非归档方式和自动归档方式的禁用改成起作用

 6、archive log list 查看归档方式

 7、相关的备份工作可以开始
 假定当前的某个数据库进行一些备份工作
  SQL>alter tablespace tt begin backup;开始备份某个表
   Tablespace alter
    物理操作系统命令可以把tt.dbf拷贝到c:/temp。
   物理备份到某个路径
  SQL>alter tablespace  tt END BACKUP;
   Tablespace altered.
  SQL>alter system archive log current;将当前联机日志归档,
    system altered.
  SQL>alter system swich LOGFILE ;切换联机日志
  
  SQL>alter system swich LOGFILE ;
  SQL>shutdown immediate
  删除数据文件,再打开会出现一个错误
  startup 会提示问题。
  SQL>select * from v$recover_filel;会发现某个号文件找不到,就是  

 刚才删除的哪个文件
  SQL>alter database datafile 6 offline drop;
  SQL>alter database open
  把刚才备份到c:/temp的文件拷贝回来。
  SQL>select * from tt.deparment;不可以
  SQL>recover datafile 6;  指定auto
  SQL>alter database datafile 6 online;从归档的路径下。

总结:有效的赖以实现恢复的归档日志,做热备份,当数据库出现问题时候,客户数
恢复到指定的环节。归档的时候,做一个swich LOGFILE 。无论冷人备份也都还是物理备份
有效,就是 一个物理的拷贝,区别就是一个脱机,一个是联机。

当数据库中的控制文件丢掉一个或者几个的时候,我们通过什么办法弥补?


1、控制文件丢失,常规情况下可以备份控制文件。

 alter database backup controlfile to trace;备份路径
   可以查看 trace 的路径 show parameter dest/dump
  ps:11g的在/u01/app/Oracle/diag/rdbms/
     $ORACLE_SID/$ORACLE_SID/trace
 tarce中最新的文件,就是包含我们的控制文件备份信息,其中:
  1、注释信息不需要,
  2、需要从startup nomount开始的
  3、包括ALTER DATABASE OPEN;
  4、保存到专门的文件里,比如 ctl.sql
  5、删除控制文件。
  6、启动数据库后SQL>@ctl.sql,可以重建控制文件。

2、丢失日志文件,一个或者多个

 1、丢失日志文件,假定丢失了。
 2、SQL>recover database until cancel;基于取消的恢复数据库
 3、SQL>alter database open resetlogs;

更多Oracle相关信息见Oracle 专题页面 ?tid=12

linux

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
Explain the InnoDB Buffer Pool and its importance for performance.Explain the InnoDB Buffer Pool and its importance for performance.Apr 19, 2025 am 12:24 AM

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

MySQL vs. Other Programming Languages: A ComparisonMySQL vs. Other Programming Languages: A ComparisonApr 19, 2025 am 12:22 AM

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ​​such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ​​have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Learning MySQL: A Step-by-Step Guide for New UsersLearning MySQL: A Step-by-Step Guide for New UsersApr 19, 2025 am 12:19 AM

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

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

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

Video Face Swap

Video Face Swap

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

Hot Tools

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.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software