Home Database Mysql Tutorial 备份和恢复

备份和恢复

Jun 07, 2016 pm 03:59 PM
copy backup definition recover data this

备份定义:备份是一份数据副本。这个数据副本包含着数据库的主要部分,例如控制文件和数据文件。备份就像是一项安全措施,他可以防止意外的数据丢失,即便原始数据丢失了,我们也可以通过备份来重新构建数据。 备份分为物理备份和逻辑备份。物理备份,将实际

备份定义:备份是一份数据副本。这个数据副本包含着数据库的主要部分,例如控制文件和数据文件。备份就像是一项安全措施,他可以防止意外的数据丢失,即便原始数据丢失了,我们也可以通过备份来重新构建数据。

备份分为物理备份和逻辑备份。物理备份,将实际组成的数据库的操作系统文件从一处拷贝到另外一处的备份过程,可以使用Oracle的恢复管理器(recovery Manager,RMAN)或操作系统命令进行数据的物理备份。

根据数据库的备份策略可分为:全部数据库备份和部分数据库备份。

全部数据库备份:包含所有数据库文件和至少一个控制文件。部分数据库备份:可能包括0个或多个表空间,或者0个或多个数据文件,归档日志后控制文件。

根据备份类型可以分为完全备份和增量备份。完全备份,在对数据文件进行备份是将数据文件的所有数据块全部备份出来,不论该数据块是否被修改过。增量备份,自上一次备份后,数据文件中发生变化的数据块的一个副本。

根据实施物理备份时的数据库状态分为冷备份和热备份。冷备份又称为一直备份和脱机备份,在数据库没有打开的情况下创建的。热备份是不一致备份或联机备份,当数据库中可读写的数据库文件和控制文件的系统改变号(SCN)在不一致的条件下备份。

逻辑备份与恢复,就是对数据库实施导入和导出,导出,数据库的逻辑备份,实质是读取一个数据库记录集并将这个记录写入一个文件,这些记录的导出与其物理位置无关。

导入,数据库的逻辑恢复,实质是读取被导出的二进制转储文件并将其恢复到数据库。

逻辑备份创建数据库对象的逻辑拷贝并存入一个二进制转储文件,这种二进制转储文件一般都是.dmp文件。

恢复定义:就是当发生故障后,利用已备份的数据文件或者控制文件,重新建立一个完整的数据库。恢复分为实例恢复和介质恢复。实例恢复是当Oracle实例出现失败后,Oracle自动进行的恢复。介质恢复是当存放数据库的介质出现故障时所做的恢复。

数据泵是一种在数据库之间或在数据库与操作系统文件之间传输数据或元数据的高速机制。

数据泵可以用来在两个数据库之间或者单个数据库内把数据库从一个用户复制到另外一个用户,他还可以用来把整个数据库的逻辑结构副本、一个用户列表、一个库表列表或一个表空间列表提取到可移植的操作系统。

数据泵工具可以从命令行实用程序expdp和impdp中调用,或者通过PL/SQL程序包DBMS_DATAPUMP调用。

数据泵技术的特定:1、导入/导出的所有工作都由数据库实例完成。2、可以使用DBMS_DATAPUMPPL/SQL建立、检测和调整数据泵任务。3、可以对IMPDP/EXPDP导入/导出任务进行重新启动(类似于网络下载的断点续传)

如果要将数据导出到一个文件中,首先要做的就是为输出路径建立一个数据库的DIRECTORY对象,然后还要给将要进行数据导入和导出的用户授予访问权限。

使用CREATE DITECTORY创建目录对象window环境下:CREATEDIRECTORY pbdir AS ‘D:\datadump’; Unix环境下:CREATEDIRECTORY pbdir AS ‘/oracle/datapump/dumps’;

为用户授权:grant read,write on directorypbdir to pb;授完权后用户可以使用数据泵导入和导出操作了。

恢复方法分类:完全恢复,将数据库恢复到数据库失败时的状态。不完全备份,将数据库恢复到数据库失败前的某一时刻的状态。

Expdp的导出方式:

数据库方式

整个数据库被导出到操作系统文件中,包括用户账户、公用的同义词、角色及资源

用户模式

可以导出一个或多个用户下的所有数据和元数据

表导出

导出的数据包括用于一组表的所有数据和元数据

表空间方式

导出时提取用于一个表空间中所有对象的数据和元数据,另外还提取依赖于指定表空间列表中所有对象的任何依赖对象。

对于索引之类的某些对象,在导出时只会导出元数据。由数据泵导出程序所创建的文件称为转储文件。

完整的数据库导出要求用户拥有EXP_FULL_DATABASE角色。

windows环境下:使用SYSTEM用户实施完全数据库导出

d:expdpsystem/passwd directory = pbdir dumpfile=alldb.dmp full=y;

unix环境下:$ expdp system/passwd directory=pbdirdumpfile=alldb.dmp full=y;

其中system/passwd是用户和密码;directory:导出数据的目录;dumpfile:转储文件名称;full=y;表示实施的是完全数据库。

用户模式导出方式:可以省略full=y参数,使用schemas=schema_list参数来表示要导出的用户列表,如果有多个用户,则用户之间用逗号分隔。要想导出多个用户,必须具有EXP_FULL_DATABASE角色权限。

例如:expdp pb/123456 directory = pdbirdumpfile = pb.dmp schemas = pb;

表导出方式:需要使用tables = table_list参数取代schemas或full参数。其中table_list是一个用逗号分隔的待导出的表列表。

示例:expdp pb/123456 directory=pbdirdumpfile = pb_tables.dmp tables=person,student nologfile=y content = data_only

nologfile=y表示不会将操作日志写入磁盘,不过仍会在终端显示出来。content = data_only:表示只导出表中的数据而不导出元数据;如果是content = metadata_only,则表示只导出元数据而不导出表中的数据。如果不写这个参数,则二者全部导出。

表空间导出方式:要求数据库用户拥有EXP_FULL_DATABASE角色权限

要想用表空间方式执行表空间导出,需要使用参数tablespaces=tablespace_list指定要导出的表空间

示例:expdp system/passwddirectory=pbdir dumpfile=person_ts.dmp tablespaces=person;

只有用户导入不能导入表和表空间模式导出的数据。

读取导出文件pb.dmp,并且提取所有的DDL,将其放入到pb.sql文件中,不对操作日志进行写入磁盘操作。

d:>impdpsystem/passwd full=y directory=pbdir dumpfile=pb.dmp nologfile=y sqlfile=pb.sql

system/passwd:用户名和密码。directory:数据库目录对象。dumpfile:指定转储文件。full=y表示实施的是全部导入。nologyfile=y:表示不进行写日志操作。sqlfile:表示将元数据(如DDL语句)写入到指定的文件中。

使用exp导出整个数据库,要导出整个数据库仍然需要用户具有EXP_FULL_DATABASE角色权限。

示例:exp userid=pb/123456 direct=yfull=y rows=y file=d:\exp\pb.dmp log=d:\exp\pb.log。

userid:导出操作的用户名和密码;direct:是否按照直接路径导出;full=y:表示试试的是全部数据库导出操作;rows=y表示连同基表中的数据一同导出;file:导出文件,注意,这里不是使用数据泵是的数据库目录对象,而是操作系统的文件目录。log:导出操作日志文件。

导出某个用户的全部数据:与导出整个数据库相比,只是少了参数full=y。导出某个用户中的表,与导出某个用户全部数据相比只是多了tables=(person,student)语句。

使用imp导入整个数据库:imp pb/123456 file=d:\exp\pb.dmp log=d:\exp\pb.log full=y ignore=y;

参数ignore表示可以忽略导入过程中产生的错误。

指定用户的导入:如果导入时设置full=y,那么在导入时就可以通过fromuser和touser实现将一个用户中的数据导入另一个用户中。

例如:imp pn/123456 file=d:\exp\pb.dmpfromuser=pb touser=pbdemo help=y;

就是将pb用户中的数据导入到了pbdemo用户中。

椐]枫熼枫鷌妜犊楗╧yOracle以循环方式,写入联机重做日志文件。

热备份要备份的文件:1、所有数据文件,一个表空间一个表空间备份(设置表空间为备份状态、备份表空间的数据文件、恢复表空间为正常状态。)2、所有归档的重做日志文件(临时停止归档进程、记录下归档重做日志文件、重启归档进程、备份归档的重做日志文件)3、一个控制文件(通过alter database命令进行)

热备份优点:1、提供了完全的时间点恢复。2、在文件系统备份是允许数据库保持打开状态。

热备份缺点:1、难于维护且不能出错。2、若热备份不成功,则多得到的结果不可能用于时间点的恢复。
Statement of this Website
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

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)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Use ddrescue to recover data on Linux Use ddrescue to recover data on Linux Mar 20, 2024 pm 01:37 PM

DDREASE is a tool for recovering data from file or block devices such as hard drives, SSDs, RAM disks, CDs, DVDs and USB storage devices. It copies data from one block device to another, leaving corrupted data blocks behind and moving only good data blocks. ddreasue is a powerful recovery tool that is fully automated as it does not require any interference during recovery operations. Additionally, thanks to the ddasue map file, it can be stopped and resumed at any time. Other key features of DDREASE are as follows: It does not overwrite recovered data but fills the gaps in case of iterative recovery. However, it can be truncated if the tool is instructed to do so explicitly. Recover data from multiple files or blocks to a single

Open source! Beyond ZoeDepth! DepthFM: Fast and accurate monocular depth estimation! Open source! Beyond ZoeDepth! DepthFM: Fast and accurate monocular depth estimation! Apr 03, 2024 pm 12:04 PM

0.What does this article do? We propose DepthFM: a versatile and fast state-of-the-art generative monocular depth estimation model. In addition to traditional depth estimation tasks, DepthFM also demonstrates state-of-the-art capabilities in downstream tasks such as depth inpainting. DepthFM is efficient and can synthesize depth maps within a few inference steps. Let’s read about this work together ~ 1. Paper information title: DepthFM: FastMonocularDepthEstimationwithFlowMatching Author: MingGui, JohannesS.Fischer, UlrichPrestel, PingchuanMa, Dmytr

How to restore chat spark on TikTok How to restore chat spark on TikTok Mar 16, 2024 pm 01:25 PM

On Douyin, a short video platform full of creativity and vitality, we can not only enjoy a variety of exciting content, but also have in-depth communications with like-minded friends. Among them, chat sparks are an important indicator of the intensity of interaction between the two parties, and they often inadvertently ignite the emotional bonds between us and our friends. However, sometimes due to some reasons, the chat spark may be disconnected. So what should we do if we want to restore the chat spark? This tutorial guide will bring you a detailed introduction to the content strategy, hoping to help everyone. How to restore the spark of Douyin chat? 1. Open the Douyin message page and select a friend to chat. 2. Send messages and chat to each other. 3. If you send messages continuously for 3 days, you can get the spark logo. On a 3-day basis, send pictures or videos to each other

Google is ecstatic: JAX performance surpasses Pytorch and TensorFlow! It may become the fastest choice for GPU inference training Google is ecstatic: JAX performance surpasses Pytorch and TensorFlow! It may become the fastest choice for GPU inference training Apr 01, 2024 pm 07:46 PM

The performance of JAX, promoted by Google, has surpassed that of Pytorch and TensorFlow in recent benchmark tests, ranking first in 7 indicators. And the test was not done on the TPU with the best JAX performance. Although among developers, Pytorch is still more popular than Tensorflow. But in the future, perhaps more large models will be trained and run based on the JAX platform. Models Recently, the Keras team benchmarked three backends (TensorFlow, JAX, PyTorch) with the native PyTorch implementation and Keras2 with TensorFlow. First, they select a set of mainstream

The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks Apr 29, 2024 pm 06:55 PM

I cry to death. The world is madly building big models. The data on the Internet is not enough. It is not enough at all. The training model looks like "The Hunger Games", and AI researchers around the world are worrying about how to feed these data voracious eaters. This problem is particularly prominent in multi-modal tasks. At a time when nothing could be done, a start-up team from the Department of Renmin University of China used its own new model to become the first in China to make "model-generated data feed itself" a reality. Moreover, it is a two-pronged approach on the understanding side and the generation side. Both sides can generate high-quality, multi-modal new data and provide data feedback to the model itself. What is a model? Awaker 1.0, a large multi-modal model that just appeared on the Zhongguancun Forum. Who is the team? Sophon engine. Founded by Gao Yizhao, a doctoral student at Renmin University’s Hillhouse School of Artificial Intelligence.

Slow Cellular Data Internet Speeds on iPhone: Fixes Slow Cellular Data Internet Speeds on iPhone: Fixes May 03, 2024 pm 09:01 PM

Facing lag, slow mobile data connection on iPhone? Typically, the strength of cellular internet on your phone depends on several factors such as region, cellular network type, roaming type, etc. There are some things you can do to get a faster, more reliable cellular Internet connection. Fix 1 – Force Restart iPhone Sometimes, force restarting your device just resets a lot of things, including the cellular connection. Step 1 – Just press the volume up key once and release. Next, press the Volume Down key and release it again. Step 2 – The next part of the process is to hold the button on the right side. Let the iPhone finish restarting. Enable cellular data and check network speed. Check again Fix 2 – Change data mode While 5G offers better network speeds, it works better when the signal is weaker

The U.S. Air Force showcases its first AI fighter jet with high profile! The minister personally conducted the test drive without interfering during the whole process, and 100,000 lines of code were tested for 21 times. The U.S. Air Force showcases its first AI fighter jet with high profile! The minister personally conducted the test drive without interfering during the whole process, and 100,000 lines of code were tested for 21 times. May 07, 2024 pm 05:00 PM

Recently, the military circle has been overwhelmed by the news: US military fighter jets can now complete fully automatic air combat using AI. Yes, just recently, the US military’s AI fighter jet was made public for the first time and the mystery was unveiled. The full name of this fighter is the Variable Stability Simulator Test Aircraft (VISTA). It was personally flown by the Secretary of the US Air Force to simulate a one-on-one air battle. On May 2, U.S. Air Force Secretary Frank Kendall took off in an X-62AVISTA at Edwards Air Force Base. Note that during the one-hour flight, all flight actions were completed autonomously by AI! Kendall said - "For the past few decades, we have been thinking about the unlimited potential of autonomous air-to-air combat, but it has always seemed out of reach." However now,

Tesla robots work in factories, Musk: The degree of freedom of hands will reach 22 this year! Tesla robots work in factories, Musk: The degree of freedom of hands will reach 22 this year! May 06, 2024 pm 04:13 PM

The latest video of Tesla's robot Optimus is released, and it can already work in the factory. At normal speed, it sorts batteries (Tesla's 4680 batteries) like this: The official also released what it looks like at 20x speed - on a small "workstation", picking and picking and picking: This time it is released One of the highlights of the video is that Optimus completes this work in the factory, completely autonomously, without human intervention throughout the process. And from the perspective of Optimus, it can also pick up and place the crooked battery, focusing on automatic error correction: Regarding Optimus's hand, NVIDIA scientist Jim Fan gave a high evaluation: Optimus's hand is the world's five-fingered robot. One of the most dexterous. Its hands are not only tactile

See all articles