Oracle数据备份与还原笔记
一、备份shr数据库
1.创建directory目录用于数据库备份还原,也可以不创建使用已有的directory目录
create or replace directory DMPDIR as '/home/easbak';
select * from dba_directories;
2.赋权 directory目录
grant read,write on directory DMPDIR to eas86;
3.导出数据库备份
expdp eas86/eas86@orcl directory=DMPDIR schemas=eas86 dumpfile=eas_zs_20230320.dmp EXCLUDE=STATISTICS
二、还原shr数据库
1.创建新数据库表空间
create tablespace EAS_D_SHR0320_STANDARD datafile '/home/oracle/easdata/EAS_D_SHR0320_STANDARD.dbf' size 2000m autoextend on next 200m maxsize unlimited;
create tablespace EAS_D_SHR0320_INDEX datafile '/home/oracle/easdata/EAS_D_SHR0320_INDEX.dbf' size 200m autoextend on next 50m maxsize unlimited;
create tablespace EAS_D_SHR0320_TEMP datafile '/home/oracle/easdata/EAS_D_SHR0320_TEMP.dbf' size 200m autoextend on next 50m maxsize unlimited;
create temporary tablespace EAS_T_SHR0320_STANDARD tempfile '/home/oracle/easdata/EAS_T_SHR0320_STANDARD.dbf' size 100m autoextend on next 50m maxsize unlimited;
2.创建新的用户并指定默认表空间
create user SHR0320 identified by SHR0320 default tablespace EAS_D_SHR0320_STANDARD temporary tablespace EAS_T_SHR0320_STANDARD profile default account unlock;
3.授权新用户
Grant create session, create table, create procedure, create view, create sequence, create trigger, create materialized view, SELECT ANY DICTIONARY to SHR0320;
grant read,write on directory dmpdir to SHR0320;
4.导入新库,用新的用户及表空间替换原备份中的用户和表空间
impdp SHR0320/SHR0320 directory=DMPDIR dumpfile= eas_zs_20230320.dmp logfile=eas_zs_20230320.log REMAP_SCHEMA=eas86:SHR0320 remap_tablespace= EAS_D_EAS86_STANDARD:EAS_D_SHR0320_STANDARD remap_tablespace= EAS_D_EAS86_INDEX:EAS_D_SHR0320_INDEX remap_tablespace= EAS_D_EAS86_TEMP2:EAS_T_SHR0320_STANDARD
三、其它注意事项
1.expdp、impdp命令在Oracle用户下使用,创建数据库表用户、表空间、授权等命令在sqlplus下使用;
2.若原数据库过大(超过32G),需要创建多个数据表空间文件
alter tablespace EAS_D_SHR0818_STANDARD add datafile '/home/oracle/easdata/EAS_D_SHR0320_STANDARD01.dbf' size 2000m autoextend on next 200m maxsize unlimited;
3.若还原数据库出现报错导致还原失败,可删除用户及表空间,重新操作
drop user shr0818 cascade;
Oracle数据备份与还原笔记
本文2024-09-17 01:12:22发表“s-hr cloud知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-shr-65935.html