Database
 sql >> Baza danych >  >> RDS >> Database

Migracja danych za pomocą Network_link

Źródło :exa01dm05 (Oracle 11g)
Cel :exa02dm06  (Oracle 18c)

1. Utwórz katalog zrzutu na PDB i CDB

exa02dm06:. oraenv
ORACLE_SID = [oracle] ? CDBGPA
ORACLE_HOME = [/home/oracle] ? /u01/app/oracle/product/18.0.0.0/dbhome_1
The Oracle base remains unchanged with value /u01/app/oracle
exa02dm06: export ORACLE_SID=CDBGPA1
exa02dm06: sqlplus / as sysdba

SQL*Plus: Release 18.0.0.0.0 - Production on Thu Jan 28 15:29:13 2021
Version 18.2.0.0.0

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

Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.2.0.0.0

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PPDBTESTE READ WRITE NO
4 HPDBGDA READ WRITE NO

SQL> alter session set container = HPDBGDA;

Session altered.

SQL> CREATE OR REPLACE DIRECTORY MIG AS '/exp';

Directory created.

2. Dodaj wpis tnsnames SOURCE w TARGET DB server exa02dm06


gda_mig =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = exa01dm05)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = gda)
(UR=A)
)
)

$ tnsping gda_mig

TNS Ping Utility for Linux: Version 18.0.0.0.0 - Production on 28-JAN-2021 11:38:40

Copyright (c) 1997, 2017, Oracle. All rights reserved.

Used parameter files:

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = exa01dm05)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = gda) (UR=A)))
OK (10 msec)

3. Utwórz dblink w PDB w Target.


SQL> create public database link gda_link connect to system identified by xxxxx using 'gda_mig';

Database link created.

SQL> select sysdate from dual@gda_link;

SYSDATE
---------------
02-FEB-21

4. Tworzy plik sql z DDL dla wszystkich obszarów tabel


exa01dm05: impdp directory=MIG dumpfile=gda.dmp sqlfile=tablespaces.sql include=TABLESPACE full=yes
Import: Release 11.2.0.4.0 - Production on Thu Jan 28 15:42:35 2021

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

Username: system
Password:

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Master table "SYSTEM"."SYS_SQL_FILE_FULL_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_SQL_FILE_FULL_01": system/******** directory=DM_TESTE_MIG dumpfile=hsbd.dmp sqlfile=tablespaces.sql include=TABLESPACE full=yes
Processing object type DATABASE_EXPORT/TABLESPACE
Job "SYSTEM"."SYS_SQL_FILE_FULL_01" successfully completed at Thu Jan 28 15:42:48 2021 elapsed 0 00:00:01

5. Zmień nazwę ścieżki plików danych w pliku sql (tablespaces.sql) zgodnie z celem.

6. Utwórz przestrzenie tabel w miejscu docelowym:


exa01dm06: sqlplus "/ as sysdba" @tablespaces.sql

7. Wykonaj import za pomocą network_link. Używam pliku parfile „imp_gda.par”.


# cat imp_gda.par

directory=MIG
network_link=gda_link
logfile=import_gda.log
cluster=N
parallel=4
full=yes
exclude=schema:"IN ('SCOTT','SYS','SYSTEM','WMSYS','XDB','OJVMSYS','ORDDATA','ORDSYS','OUTLN','AUDSYS','CTXSYS')"

$ impdp \'sys@HPDBGDA as sysdba\' parfile=imp_gda.par

Import: Release 18.0.0.0.0 - Production on Tue Feb 2 12:13:35 2021
Version 18.2.0.0.0

Copyright (c) 1982, 2018, Oracle and/or its affiliates. All rights reserved.
Password:

Connected to: Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Starting "SYS"."SYS_IMPORT_FULL_01": "sys/********@HPDBGDA AS SYSDBA" parfile=imp_gda.par
Estimate in progress using BLOCKS method...
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 375.9 MB

8. Ponownie skompiluj nieprawidłowe obiekty:


SQL> alter session set container = HPDBGDA;

Session altered.

SQL> EXEC DBMS_UTILITY.compile_schema(schema => 'DBGDA', compile_all => FALSE);

PL/SQL procedure successfully completed.

9. Zbierz statystyki:


DECLARE
BEGIN
DBMS_STATS.GATHER_SCHEMA_STATS (ownname => 'DBGDA',
method_opt => 'for all columns size auto',
granularity => 'ALL',
cascade => TRUE);
END;
/

PL/SQL procedure successfully completed.


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Projektowanie baz danych z Vertabelo

  2. Model danych na temat imprezy dla dzieci

  3. WordPress – Za kulisami, część 2

  4. Zrozumienie operatora przestawnego w SQL

  5. Mity dotyczące wydajności:Obcięcie nie może zostać wycofane