如何在 Oracle 12c 中恢复转储文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26158376/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to restore dump file in Oracle 12c
提问by
I want to restore a database in oracle 12c. I have done something for it but while importing data I got some errors about non-existing users in db.Because the database needs some users which must defined in oracle 12c. I created users for db which db needs but in oracle 12 creating user system was changed about session issues. I had to put c## expression in front username and problem still persists. I tried different methods to restore but it wasn't imported all tables and data. I think it's about the user problem.My question how can i create a user same as with the backup db user and restore database.
我想在oracle 12c 中恢复一个数据库。我为此做了一些事情,但是在导入数据时,我遇到了一些关于 db 中不存在用户的错误。因为数据库需要一些必须在 oracle 12c 中定义的用户。我为db创建了db需要的用户,但在oracle 12中创建用户系统因会话问题而改变。我不得不将 c## 表达式放在前面的用户名中,但问题仍然存在。我尝试了不同的方法来恢复,但它没有导入所有表和数据。我认为这是关于用户问题。我的问题是如何创建与备份数据库用户相同的用户并恢复数据库。
采纳答案by Lalit Kumar B
Based on OP's input via answer to my comments :
根据 OP 通过回答我的评论提供的输入:
/ AS SYSDBA
will by default connect to CDB
and not your local PDB
. There are many ways, however, as of now, you need to first connect to your local PDB
as:
/ AS SYSDBA
默认情况下将连接到CDB
而不是您的本地PDB
. 有很多方法,但是,到目前为止,您需要首先连接到本地PDB
:
SYS@<pdb service_name> AS SYSDBA
Then execute your CREATE USER
and other commands :
然后执行您的CREATE USER
和其他命令:
CREATE USER HASTANE IDENTIFIED BY HASTANE DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP;
GRANT DBA TO HASTANE;
IMP HASTANE/HASTANE FILE=c:\VERI.DMP FULL=Y
回答by Umesh Acharya
Step One: create pdbuser
第一步:创建pdbuser
Run Sqlplus sys/ as sysdba , (if has password you should type it next)
run
alter session set container=pdbDBName---;
(eg:pdborcl)run
create user test identified by password default tablespace users temporary tablespace temp;
run
grant pdb_dba to test;
run
grant dba to test;
运行 Sqlplus sys/ 作为 sysdba ,(如果有密码,你应该输入它下一步)
运行
alter session set container=pdbDBName---;
(例如:pdborcl)跑
create user test identified by password default tablespace users temporary tablespace temp;
跑
grant pdb_dba to test;
跑
grant dba to test;
Step two: Add pdbname in the tns file
第二步:在tns文件中添加pdbname
run
CMD
run
tnsping cdbDB
(eg: tnsping orcl)find tns path and open tnsnames.ora file( if not exist make it in same directory of current file)
add pdbDBName like cdbDBName(eg:orcl) see below example
跑
CMD
运行
tnsping cdbDB
(例如:tnsping orcl)找到 tns 路径并打开 tnsnames.ora 文件(如果不存在则将其放在当前文件的同一目录中)
添加 pdbDBName 像 cdbDBName(eg:orcl) 见下面的例子
example:
例子:
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
pdbORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdborcl)
)
)
Step three: Check tnsping from command prompt
第三步:从命令提示符检查 tnsping
Run
CMD
tnsping pdbDB(eg: tnsping pdborcl)
see tns status. it should be ok with path details.
跑
CMD
tnsping pdbDB(例如:tnsping pdborcl)
查看 tns 状态。路径详细信息应该没问题。
Step Four connect to pdbDB
第四步连接pdbDB
Run Sqlplus
test/password@pdborcl-- do not use semicolon. now you are connected to pdb database
运行 Sqlplus
test/password@pdborcl--不要使用分号。现在您已连接到 pdb 数据库
Step Five: Import Dump file
第五步:导入转储文件
Run
CMD
Type
imp test/password@pdborcl file=myfile.dump
now it should start importing process
跑
CMD
键入
imp test/password@pdborcl file=myfile.dump
现在就应该开始导入过程
Note : if pluggable database is on shutdown mode. mount it to open mode before starting import process
注意:如果可插拔数据库处于关闭模式。在开始导入过程之前将其安装到打开模式
Run Sqlplus
connect with sys/ as sysdba (it will connect to cdbdatabase)
alter pluggable database all open
运行 Sqlplus
与 sys/ 作为 sysdba 连接(它将连接到 cdbdatabase)
更改可插拔数据库全部打开
回答by Harvey
IMPORT PROCEDUREFor importing full DB dump into 12c database. Assuming that during DB installation you have created container and one pluggable DB (pd1).
导入程序用于将完整的 DB 转储导入 12c 数据库。假设在 DB 安装期间您已经创建了容器和一个可插拔 DB (pd1)。
GO to SQL PLUS
转到 SQL PLUS
CONN / AS SYSDBA
CONN system/syspassword@//localhost:1521/pd1 # connected to pluggable DB
CREATE USER pdusr IDENTIFIED BY pdpass3344;
CREATE OR REPLACE DIRECTORY impdir AS 'C:\app\oracle\oradata\impdir';
GRANT READ, WRITE ON DIRECTORY impdir TO pdusr;
GRANT DBA,CONNECT TO pdusr; # granted permissions to pd1 DB because we are connected to mrmspd
Exit sql plus, open CMD
退出sql plus,打开CMD
impdp system/syspassword@//localhost:1521/pd1 full=Y directory=impdir dumpfile=expdat.dmp logfile=impdp_mrms.log
And make sure you put expdat.dmp in C:\app\oracle\oradata\impdir
并确保将 expdat.dmp 放在 C:\app\oracle\oradata\impdir
回答by ik_zelf
First learn something about that database. Here is a document about usermanagement in 12c Administering User Accounts and SecurityThe DBA essentialsin general is a very good starting point
首先了解有关该数据库的一些信息。这是 12c管理用户帐户和安全性中有关用户管理的文档The DBAEssentials 一般是一个非常好的起点
You are looking in the root of a container database and you need to create your users in a local PDB and import your data in there. Easiest is to create a tnsalias for that pdb that points to the specific PDB service_name for the import.
您正在查看容器数据库的根目录,并且需要在本地 PDB 中创建用户并在其中导入数据。最简单的方法是为该 pdb 创建一个 tnsalias,指向导入的特定 PDB service_name。