达梦数据库的联机备份颇花了我不少时间,关键是附带的文档感觉说得不清楚。不过测试出来后觉得达梦的这个设计还是比较简明的。 为了让后面学习的人不用花我这么多时间,把测试流程整理了下放在下面: 主要测试了: 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;
二。创建测试数据
-- 创建表空间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;
三。备份数据库
1. 不包含归档的联机全备
-- 仅备份数据库,不备份日志 backup database full to dmbkname03_noarc bakfile 'C:\xcl\online_noarc\dmbkname03_noarc.bak' backupinfo '测试全库联机备份不包含归档' maxsize 50 without log ;
2. 再次插入数据
insert into test_sch.t1 values(3,'dmbkname03_noarc');
3. 包含归档的联机全备
-- 备份数据库,并包含日志 backup database full to dmbkname04 bakfile 'C:\xcl\online\dmbkname04.bak' backupinfo '测试全库联机备份' maxsize 50 ;
备份完成的后续工作:
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.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=DMSERVER2.恢复数据库
-- 不包含归档 c:\dmdbms\bin> dmrestore ini_path=C:\xcl\dm.ini file=C:\xcl\online_noarc\dmbkname03_noarc.bak3. 启动服务,进入数据库查看恢复结果
SQL>select * from test_sch.t1; 行号 ID NAME ---------- ----------- ---- 1 1 aaa 2 2 bbb 已用时间: 60.990(毫秒). 执行号:3.
b. 不包含归档的联机全备文件加上归档日志的恢复
1. 初始化数据库
--再次用不包含归档的备份测试,但指定归档日志目录 dminit.exe PATH=C:\dmdbms\data DB_NAME=DAMENG INSTANCE_NAME=DMSERVER2.恢复数据库
dmrestore ini_path=C:\xcl\dm.ini file=C:\xcl\online_noarc\dmbkname03_noarc.bak archive_dir=C:\xcl\online_noarc\arc23. 启动服务,进入数据库查看恢复结果
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>
c.包含归档的联机全备的恢复
1. 初始化数据库
dminit.exe PATH=C:\dmdbms\data DB_NAME=DAMENG INSTANCE_NAME=DMSERVER2.恢复数据库
-- 数据库全库备份,并包含日志 dmrestore ini_path=C:\xcl\dm.ini file=C:\xcl\online\dmbkname04.bak3. 启动服务,进入数据库查看恢复结果
SQL>select * from test_sch.t1; 行号 ID NAME ---------- ----------- ---------------- 1 1 aaa 2 2 bbb 3 3 dmbkname03_noarc 已用时间: 62.508(毫秒). 执行号:3.
五.总结
达梦数据库的文档中并没有说明,dmrestore命令即能恢复脱机备份,也能恢复联机备份。导致我在执行backup命令后,
误以为要有resotre恢复。但数据库被破坏后,又没法进disql执行restore.后测试才知,dmrestore命令通杀脱机和联机两种恢复方式。
从上面的测试可看出,基本上达梦的备份流程就是发命令,生成备份文件,并同时备份dm.ini。有些情况下还要备份归档日志。
然后恢复是用dminit重新初始化一个库再用dmrestore恢复。 在达梦数据库中dm.ini非常重要,备份时一定要记得把这个也一同备份。
MAIL: xcl_168@aliyun.com
BLOG: http://blog.csdn.net/xcl168

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.

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 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.

MySQL is suitable for beginners because: 1) easy to install and configure, 2) rich learning resources, 3) intuitive SQL syntax, 4) powerful tool support. Nevertheless, beginners need to overcome challenges such as database design, query optimization, security management, and data backup.

Yes,SQLisaprogramminglanguagespecializedfordatamanagement.1)It'sdeclarative,focusingonwhattoachieveratherthanhow.2)SQLisessentialforquerying,inserting,updating,anddeletingdatainrelationaldatabases.3)Whileuser-friendly,itrequiresoptimizationtoavoidper

ACID attributes include atomicity, consistency, isolation and durability, and are the cornerstone of database design. 1. Atomicity ensures that the transaction is either completely successful or completely failed. 2. Consistency ensures that the database remains consistent before and after a transaction. 3. Isolation ensures that transactions do not interfere with each other. 4. Persistence ensures that data is permanently saved after transaction submission.

MySQL is not only a database management system (DBMS) but also closely related to programming languages. 1) As a DBMS, MySQL is used to store, organize and retrieve data, and optimizing indexes can improve query performance. 2) Combining SQL with programming languages, embedded in Python, using ORM tools such as SQLAlchemy can simplify operations. 3) Performance optimization includes indexing, querying, caching, library and table division and transaction management.

MySQL uses SQL commands to manage data. 1. Basic commands include SELECT, INSERT, UPDATE and DELETE. 2. Advanced usage involves JOIN, subquery and aggregate functions. 3. Common errors include syntax, logic and performance issues. 4. Optimization tips include using indexes, avoiding SELECT* and using LIMIT.


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Linux new version
SublimeText3 Linux latest version

Zend Studio 13.0.1
Powerful PHP integrated development environment