程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> ORACLE11G在同一台linux服務器從實例1全庫導入到實例2上

ORACLE11G在同一台linux服務器從實例1全庫導入到實例2上

編輯:Oracle教程

ORACLE11G在同一台linux服務器從實例1全庫導入到實例2上


前期導出命令:

[root@powerlong4 ~]# su - oracle
[oracle@powerlong4 ~]$ export ORACLE_SID=pt1;
[oracle@powerlong4 ~]$ expdp \'sys/systestpd as sysdba\' DIRECTORY=dir_dump_t3 FULL=YES DUMPFILE=expdpfull_pd_20150529_02.dmp
......

1,開始導入

先在實例2上建立管道目錄:

[oracle@pttest4 ~]$ export ORACLE_SID=pt2;
[oracle@pttest4 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Wed Jun 3 21:22:43 2015

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>  CREATE OR REPLACE DIRECTORY dir_dump_t3  AS '/home/oracle/expdpimpdp/';

Directory created.

SQL> 

開始導入全庫備份集:

impdp \'sys/syspddev@pt2 as sysdba\' directory=dir_dump_t3 dumpfile=expdpfull_pd_20150529_02.dmp nologfile=y TABLE_EXISTS_ACTION=REPLACE 
......

<版權所有,文章允許轉載,但必須以鏈接方式注明源地址,否則追究法律責任!>
原博客地址: http://blog.csdn.net/mchdba/article/details/46335861
原作者:黃杉 (mchdba)


2,導入報錯:

ORA-02374: conversion error loading table "puser"."RES_APPROVE_CONTENT"
ORA-12899: value too large for column CREATED_POSITION_CD (actual: 24, maximum: 20)

3,懷疑導入目標錯誤,驗證:

 [oracle@pttest4 admin]$ export ORACLE_SID=pt2;
[oracle@pttest4 admin]$ 
[oracle@pttest4 admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri May 29 21:06:27 2015

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> 
SQL> 
SQL> select name from v$database;

NAME
------------------
pt2

SQL>

4,檢查兩者的編碼

到出庫實例庫1:

SQL> SELECT * FROM V$NLS_PARAMETERS WHERE PARAMETER IN ('NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET');
PARAMETER                                                        VALUE
---------------------------------------------------------------- ----------------------------------------------------------------
NLS_CHARACTERSET                                                 ZHS16GBK
NLS_NCHAR_CHARACTERSET                                           AL16UTF16

SQL> 

到導入的庫實例2庫

SQL> SELECT * FROM V$NLS_PARAMETERS WHERE PARAMETER IN ('NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET');
PARAMETER                                                        VALUE
---------------------------------------------------------------- ----------------------------------------------------------------
NLS_CHARACTERSET                                                 AL32UTF8
NLS_NCHAR_CHARACTERSET                                           AL16UTF16

SQL> 

看到導出導入庫實例1實例2的字符集不同,所以問題就在這裡了

5,解決:

[oracle@pttest4 admin]$ export ORACLE_SID=pt2;
[oracle@pttest4 admin]$ 
[oracle@pttest4 admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri May 29 21:06:27 2015

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> 
SQL>connect username/password as SYSDBA;
SQL>SHUTDOWN IMMEDIATE;
SQL>STARTUP MOUNT;
SQL>ALTER SYSTEM ENABLE RESTRICTED SESSION;
SQL>ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
SQL>ALTER SYSTEM SET AQ_TM_PROCESSES=0;
SQL>ALTER DATABASE OPEN;

SQL>  ALTER DATABASE CHARACTER SET ZHS16GBK ;
ALTER DATABASE CHARACTER SET ZHS16GBK;
*ERROR at line 1:
ORA-12712: new character set must be a superset of old character set
報字符集不兼容,此時下INTERNAL_USE指令不對字符集超集進行檢查:

SQL>ALTER DATABASE CHARACTER SET INTERNAL_USE ZHS16GBK;
SQL>SHUTDOWN IMMEDIATE;
SQL>STARTUP;

6,再去檢查兩個實例的編碼

[oracle@pttest4 expdpimpdp]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri May 29 21:32:12 2015

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name from v$database;

NAME
---------
pt2

SQL> 

SQL> SELECT * FROM V$NLS_PARAMETERS WHERE PARAMETER IN ('NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET');
Warning: connection was lost and re-established
PARAMETER                                                        VALUE
---------------------------------------------------------------- ----------------------------------------------------------------
NLS_CHARACTERSET                                                 ZHS16GBK
NLS_NCHAR_CHARACTERSET                                           AL16UTF16

SQL> 

導出實例上:

[oracle@pttest4 expdpimpdp]$ export ORACLE_SID=pt1;
[oracle@pttest4 expdpimpdp]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri May 29 21:32:50 2015

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name from v$database;

NAME
---------
pt1

SQL> SELECT * FROM V$NLS_PARAMETERS WHERE PARAMETER IN ('NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET');
PARAMETER                                                        VALUE
---------------------------------------------------------------- ----------------------------------------------------------------
NLS_CHARACTERSET                                                 ZHS16GBK
NLS_NCHAR_CHARACTERSET                                           AL16UTF16

SQL> 

此時,兩個實例上字符集一模一樣了,保持一致。

7,重新導入impdp

[oracle@pttest4 admin]$ export ORACLE_SID=pt2;
[oracle@pttest4 admin]$ impdp \'sys/sysdevpd@pt2 as sysdba\' directory=dir_dump_t3 dumpfile=expdpfull_pd_20150529_02.dmp nologfile=y TABLE_EXISTS_ACTION=REPLACE

OK,一切正常,可以導入到實例2上面了。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved