DM8逻辑备份还原

DM8逻辑备份还原

逻辑备份就是创建数据库对象的逻辑拷贝并存入一个二进制转储文件:dmp文件,这些记录的导出与其物理位置无关,导入的实质就是读取被导出的二进制转储文件并将其恢复到数据库。达梦数据库提供两个命令行工具逻辑导出(dexp)和逻辑导入(dimp)分别用来实现对 DM 数据库的逻辑备份和逻辑还原。逻辑备份和逻辑还原要求数据库处于正常打开状态,进行联机操作。dexp 和 dimp 是 DM 数据库自带的工具,只要安装了 DM 数据库,就可以在安装目录/dmdbms/bin 中找到。
逻辑导出和逻辑导入数据库对象分为四种级别:数据库级、用户级、模式级和表级。四种级别独立互斥,不能同时存在。
四种级别所提供的功能:
 数据库级(FULL):导出或导入整个数据库中的所有对象。
 用户级(OWNER):导出或导入一个或多个用户所拥有的所有对象。
 模式级(SCHEMAS):导出或导入一个或多个模式下的所有对象。
 表级(TABLE):导出或导入一个或多个指定的表或表分区。

  • dexp 逻辑导出

dexp 工具可以对本地或者远程数据库进行数据库级、用户级、模式级和表级的逻辑备份。备份的内容非常灵活,可以选择是否备份索引、数据行和权限,是否忽略各种约束(外键约束、非空约束、唯一约束等),在备份前还可以选择生成日志文件,记录备份的过程以供查看。

使用 dexp 工具
dexp 工具需要从命令行启动。在 cmd 命令行工具中找到 dexp 所在安装目录/dmdbms/bin,输入 dexp 和参数后回车。
通过help命令可以查看dexp工具的参数名称、描述及默认值。
dexp参数详解如下:

[dmdba@DM8-Study bin]$ ./dexp help
dexp V8.1.1.78-Build(2020.04.28-121039)ENT 
Format:  ./dexp  KEYWORD=value or KEYWORD=(value1,value2,...,valueN)

Example: ./dexp  SYSDBA/SYSDBA GRANTS=Y TABLES=(SYSDBA.TAB1,SYSDBA.TAB2,SYSDBA.TAB3)

USERID              Imperative argument and be as the first argument

Keyword             Explanation(default value)
--------------------------------------------------------------------------------
USERID              username/password Format:USER/PWD*MPP_TYPE@SERVER:PORT#SSLPATH@SSLPWD
FILE                export file (dexp.dmp)
DIRECTORY           the path of the export file
FULL                export all database (N)
OWNER               export with the user method, Format (user1,user2,...)
SCHEMAS             export with the schema method, Format (schema1,schema2,...)
TABLES              export with the table method, Format (table1,table2,...)
FUZZY_MATCH         whether to support fuzzy matching when export with the table method (N)
QUERY               export with the table sub-set method, the select statement
PARALLEL            the thread number be used to export
TABLE_PARALLEL      the thread number be used to export one table, convert into single thread when MPP
TABLE_POOL          the buffer number of one table
EXCLUDE             ignore appointed objects 
                        Format EXCLUDE=(ROWS,INDEXES,CONSTRAINTS) or
                               EXCLUDE=TABLES:table1,table2 or
                               EXCLUDE=SCHEMAS:sch1,sch2
INCLUDE             include appointed objects 
                        Format INCLUDE=(ROWS,INDEXES,CONSTRAINTS) or 
                               INCLUDE=TABLES:table1,table2
CONSTRAINTS         export constraints (Y)
TABLESPACE          export objects with tablespace (N)
GRANTS              export grants (Y)
INDEXES             export indexes (Y)
TRIGGERS            export triggers (Y)
ROWS                export rows (Y)
LOG                 the log file of the display show
NOLOGFILE           not use log file (N)
NOLOG               log message not display on console (N)
LOG_WRITE           information write into file directly: YES(Y),NO(N)
DUMMY               user message input: print(P), all input YES(Y),all input NO(N) 
PARFILE             argument file name
FEEDBACK            show the process every x rows(0)
COMPRESS            whether to compress export data or not (N)
ENCRYPT             whether to encrypt export data or not (N)
ENCRYPT_PASSWORD    the password of encrypt
ENCRYPT_NAME        the name of encrypt
FILESIZE            the max size of single file
FILENUM             numbers of files of one template
DROP                delete origin table after exported, but no cascade (N)
DESCRIBE            describe of data file, recorded in data file
LOCAL               login with MPP_LOCAL when MPP(N)
HELP                output help information

导出整个数据库

[dmdba@DM8-Study bin]$ ./dexp userid=sysdba/dameng123 file=exp_full.dmp log=exp_full.log directory=/dm8/exp
dexp V8.1.1.78-Build(2020.04.28-121039)ENT 
exporting NO. 1 SCHEMA : SYSDBA 
start export schema[SYSDBA].....
----- export total 0 SEQUENCE  ----- 
----- export total 0 VIEW  ----- 
----- export total 0 TRIGGER  ----- 
----- export total 0 COMMENT VIEW  ----- 
----- export total 0 COMMENT COL  ----- 
----- export total 0 PROCEDURE  ----- 
----- export total 0 SYNONYM  ----- 
----- export total 0 DBLINK  ----- 
----- export total 0 TRIGGER  ----- 
----- export total 0 PACKAGE  ----- 
----- export total 0 PKG_BODY  ----- 
----- export total 0 OBJECT of NO REFER OTHER CLASS  ----- 
----- export total 0 OBJECT of REFER OTHER CLASS  ----- 
----- export total 0 JCLASS  ----- 
----- export total 0 CLASS_BODY  ----- 
----- export total 0 DOMAIN  ----- 
the privilege of the object at the export mode...
schema[SYSDBA] export terminate.....
successfully exported NO.1 SCHEMA : SYSDBA
export total 1 SCHEMA
all the export process spent total    0.215 s
terminate export success without warning
  • 导出某个用户的对象
[dmdba@DM8-Study bin]$ ./dexp USERID=SYSDBA/dameng123    FILE=exp_user.dmp LOG=exp_user.log OWNER=sysdba DIRECTORY=/dm8/exp    
dexp V8.1.1.78-Build(2020.04.28-121039)ENT  
exporting NO. 1 SCHEMA : SYSDBA     
start export schema[SYSDBA].....    
----- export total 0 SEQUENCE  -----     
----- export total 0 VIEW  -----     
----- export total 0 TRIGGER  -----    
----- export total 0 COMMENT VIEW  -----
----- export total 0 COMMENT COL  -----     ----- export total 0 PROCEDURE  -----     
----- export total 0 SYNONYM  -----     
----- export total 0 DBLINK  -----    
----- export total 0 TRIGGER  -----     
----- export total 0 PACKAGE  -----     
----- export total 0 PKG_BODY  -----    
----- export total 0 OBJECT of NO REFER OTHER CLASS  -----     
----- export total 0 OBJECT of REFER OTHER CLASS  -----     
----- export total 0 JCLASS  -----     
----- export total 0 CLASS_BODY  -----     
----- export total 0 DOMAIN  -----  
the privilege of the object at the export mode... 
schema[SYSDBA] export terminate..... successfully    
exported NO.1 SCHEMA : SYSDBA export total 1 SCHEMA 
all the export process spent total    0.432 s 
terminate export success without    warning
  • 导出某个模式下的对象
./dexp USERID=SYSDBA/dameng123 FILE=exp_schema.dmp LOG=exp_schema.log SCHEMAS=CTISYS DIRECTORY=/dm8/exp
导出指定的表,并导出所有数据行、约束、索引
等信息
./dexp USERID=SYSDBA/dameng123 FILE=exp_tables.dmp LOG=exp_tables.log TABLES=test_exp DIRECTORY=/dm8/exp
  • dimp 逻辑导入

dimp 逻辑导入工具利用 dexp 工具生成的备份文件对本地或远程的数据库进行联机逻辑还原。dimp 导入是 dexp 导出的相反过程。还原的方式可以灵活选择,如是否忽略对象存在而导致的创建错误、是否导入约束、是否导入索引、导入时是否需要编译、是否生成日志等。

  • 导入整个数据库
[dmdba@DM8-Study bin]$ ./dimp userid=sysdba/dameng123    file=exp_full.dmp log=exp_full.log directory=/dm8/exp full=y
  • 导入某个用户拥有的对象
./dimp USERID=SYSDBA/dameng123 FILE=exp_user.dmp LOG=exp_user.log OWNER=sysdba DIRECTORY=/dm8/exp
  • 导入某个模式拥有的对象
./dimp USERID=SYSDBA/dameng123 FILE=exp_schema.dmp LOG=exp_schema.log SCHEMAS=CTISYS DIRECTORY=/dm8/exp
  • 导入某个指定表
./dimp USERID=SYSDBA/dameng123 FILE=exp_tables.dmp LOG=exp_tables.log TABLES=test_exp DIRECTORY=/dm8/exp

上面的操作示例选择了最基本的配置参数,当然用户如果有更复杂的需要,可以配置一些重要参数实现特定功能。比如,并行参数,要导入的表已经存在时的处理方式(跳过、追加、删除导入),以及查询过滤,加载方式等等。每次导入导出用户可以查看屏幕输入信息,或者查看生成日志,以确定导出导入操作是否成功。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值