Home Database Mysql Tutorial 达梦(6)联机备份恢复

达梦(6)联机备份恢复

Jun 07, 2016 pm 03:28 PM
backup recover database online

达梦数据库的联机备份颇花了我不少时间,关键是附带的文档感觉说得不清楚。不过测试出来后觉得达梦的这个设计还是比较简明的。 为了让后面学习的人不用花我这么多时间,把测试流程整理了下放在下面: 主要测试了: 1. 不包含归档的联机全备 2. 包含归档的联机全

达梦数据库的联机备份颇花了我不少时间,关键是附带的文档感觉说得不清楚。不过测试出来后觉得达梦的这个设计还是比较简明的。
为了让后面学习的人不用花我这么多时间,把测试流程整理了下放在下面:
主要测试了:
1. 不包含归档的联机全备
2. 包含归档的联机全备
3. 不包含归档的联机全备的恢复
4. 不包含归档的联机全备文件加上归档日志的恢复
5. 包含归档的联机全备的恢复

测试版本: V7.1.2.215-Build(2013.11.08-36626trunc)

一。检查并设置数据库为归档模式
联机备份必须处在归档模式下,可用下面两条sql查看数据库当前状态
--查看归档是否打开
select arch_mode from v$database;
--查看归档日志信息
select arch_name,arch_type,arch_dest from v$dm_arch_ini;
Copy after login

二。创建测试数据
-- 创建表空间test_data(数据文件TEST_DATA01.DBF大小为50m)
create tablespace test_data datafile 'C:\dmdbms\data\DAMENG\TEST_DATA01.DBF' size 50;
-- 增加用户
create user "TESTUSER" identified by "111111" default tablespace "TEST_DATA";
-- 授权
grant "DBA" to "TESTUSER";
-- 创建模式
create schema test_sch authorization testuser;
-- 创建 表
create table test_sch.t1(id int primary key ,name varchar(20)) storage(on test_data)
-- 插入数据
insert into test_sch.t1 values(1,'aaa');
insert into test_sch.t1 values(2,'bbb');
-- 检索数据
select * from test_sch.t1;
Copy after login

三。备份数据库
1. 不包含归档的联机全备
-- 仅备份数据库,不备份日志 
backup database full to dmbkname03_noarc bakfile 'C:\xcl\online_noarc\dmbkname03_noarc.bak' backupinfo '测试全库联机备份不包含归档' maxsize 50 without log ;
Copy after login

2. 再次插入数据
insert into test_sch.t1 values(3,'dmbkname03_noarc');
Copy after login

3. 包含归档的联机全备
-- 备份数据库,并包含日志
backup database full to dmbkname04 bakfile 'C:\xcl\online\dmbkname04.bak' backupinfo '测试全库联机备份' maxsize 50 ;
Copy after login

备份完成的后续工作:

1. 继续插入一笔数据
-- 插入数据
insert into test_sch.t1 values(4,'dmbkname04');

-- 检索数据
select * from test_sch.t1;

SQL> select * from test_sch.t1;


行号       ID          NAME
---------- ----------- ----------------
1          1           aaa
2          2           bbb
3          3           dmbkname03_noarc
4          4           dmbkname04


已用时间: 1.245(毫秒). 执行号:99.
Copy after login
2 将归档备份一份到另一个目录
3. 在"DM服务查看器"中停掉对应的实例服务"DmServiceDMSERVER"
4. 将dm.ini 备份一份到另一个目录
5. 删除数据库目录
在"C:\dmdbms\data"目录下删除数据库所在目录"DAMENG".此时数据库就被删除了。
这时,你去"DM服务查看器"刷新下,就看不到"DmServiceDMSERVER"这个服务了

四。恢复测试

达梦数据库的恢复通常分两步走.
第一,通过dminit重新初始化出一个和备份数据库相同的名字的库
第二. 执行恢复命令恢复.

a. 不包含归档的联机全备的恢复

1. 初始化数据库
c:\dmdbms\bin>dminit.exe  PATH=C:\dmdbms\data  DB_NAME=DAMENG  INSTANCE_NAME=DMSERVER
Copy after login
2.恢复数据库
-- 不包含归档
c:\dmdbms\bin> dmrestore ini_path=C:\xcl\dm.ini  file=C:\xcl\online_noarc\dmbkname03_noarc.bak
Copy after login
3. 启动服务,进入数据库查看恢复结果
SQL>select * from test_sch.t1;


行号       ID          NAME
---------- ----------- ----
1          1           aaa
2          2           bbb


已用时间: 60.990(毫秒). 执行号:3.
Copy after login

b. 不包含归档的联机全备文件加上归档日志的恢复
1. 初始化数据库
--再次用不包含归档的备份测试,但指定归档日志目录
dminit.exe  PATH=C:\dmdbms\data  DB_NAME=DAMENG  INSTANCE_NAME=DMSERVER
Copy after login
2.恢复数据库
dmrestore ini_path=C:\xcl\dm.ini  file=C:\xcl\online_noarc\dmbkname03_noarc.bak archive_dir=C:\xcl\online_noarc\arc2
Copy after login
3. 启动服务,进入数据库查看恢复结果
SQL>select * from test_sch.t1;


行号       ID          NAME
---------- ----------- ----------------
1          1           aaa
2          2           bbb
3          3           dmbkname03_noarc
4          4           dmbkname04


已用时间: 62.247(毫秒). 执行号:3.
SQL>
Copy after login

c.包含归档的联机全备的恢复
1. 初始化数据库
dminit.exe  PATH=C:\dmdbms\data  DB_NAME=DAMENG  INSTANCE_NAME=DMSERVER
Copy after login
2.恢复数据库
-- 数据库全库备份,并包含日志
dmrestore ini_path=C:\xcl\dm.ini  file=C:\xcl\online\dmbkname04.bak
Copy after login
3. 启动服务,进入数据库查看恢复结果
SQL>select * from test_sch.t1;


行号       ID          NAME
---------- ----------- ----------------
1          1           aaa
2          2           bbb
3          3           dmbkname03_noarc


已用时间: 62.508(毫秒). 执行号:3.
Copy after login

五.总结
达梦数据库的文档中并没有说明,dmrestore命令即能恢复脱机备份,也能恢复联机备份。导致我在执行backup命令后,
误以为要有resotre恢复。但数据库被破坏后,又没法进disql执行restore.后测试才知,dmrestore命令通杀脱机和联机两种恢复方式。
从上面的测试可看出,基本上达梦的备份流程就是发命令,生成备份文件,并同时备份dm.ini。有些情况下还要备份归档日志。

然后恢复是用dminit重新初始化一个库再用dmrestore恢复。 在达梦数据库中dm.ini非常重要,备份时一定要记得把这个也一同备份。

MAIL: xcl_168@aliyun.com

BLOG: http://blog.csdn.net/xcl168




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 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 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)

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

How does Go language implement the addition, deletion, modification and query operations of the database? How does Go language implement the addition, deletion, modification and query operations of the database? Mar 27, 2024 pm 09:39 PM

Go language is an efficient, concise and easy-to-learn programming language. It is favored by developers because of its advantages in concurrent programming and network programming. In actual development, database operations are an indispensable part. This article will introduce how to use Go language to implement database addition, deletion, modification and query operations. In Go language, we usually use third-party libraries to operate databases, such as commonly used sql packages, gorm, etc. Here we take the sql package as an example to introduce how to implement the addition, deletion, modification and query operations of the database. Assume we are using a MySQL database.

How to restore deleted comments on Xiaohongshu? Any tips for deleted comments? How to restore deleted comments on Xiaohongshu? Any tips for deleted comments? Mar 27, 2024 am 11:56 AM

Xiaohongshu is a popular social e-commerce platform where users can share shopping experiences, life details, etc. During use, some users may experience their comments being deleted. So, how to restore deleted comments on Xiaohongshu? 1. How to restore deleted comments on Xiaohongshu? If it is found that a comment has been deleted by mistake, users can choose to wait for the official Xiaohongshu team to restore it. In this case, it’s best to be patient and wait as the official team may automatically process and resume comments after a while. If you find that a comment has been deleted, consider republishing similar content. But when reposting, please make sure the content complies with Xiaohongshu’s community guidelines to avoid being removed again. 3. Contact Xiaohongshu customer service: If you think your comment has been mistakenly

How does Hibernate implement polymorphic mapping? How does Hibernate implement polymorphic mapping? Apr 17, 2024 pm 12:09 PM

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

An in-depth analysis of how HTML reads the database An in-depth analysis of how HTML reads the database Apr 09, 2024 pm 12:36 PM

HTML cannot read the database directly, but it can be achieved through JavaScript and AJAX. The steps include establishing a database connection, sending a query, processing the response, and updating the page. This article provides a practical example of using JavaScript, AJAX and PHP to read data from a MySQL database, showing how to dynamically display query results in an HTML page. This example uses XMLHttpRequest to establish a database connection, send a query and process the response, thereby filling data into page elements and realizing the function of HTML reading the database.

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

See all articles