sql >> Database >  >> RDS >> Database

Gegevens migreren met Network_link

Bron :exa01dm05 (Oracle 11g)
Doel :exa02dm06  (Oracle 18c)

1. Maak de dumpmap aan op de PDB en 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. Voeg het tnsnames-item van SOURCE toe aan de 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. Maak de dblink in de PDB bij 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. Creëert het sql-bestand met de DDL voor alle tablespaces


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. Hernoem het pad van de databestanden in het sqlfile (tablespaces.sql) volgens het doel.

6. Creëer tablespaces op doel:


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

7. Voer de import uit met netwerk_link. Ik gebruik 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. Hercompileer ongeldige objecten:


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. Verzamel statistieken:


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. Snelste controle of rij bestaat in PostgreSQL

  2. Benchmarking van beheerde PostgreSQL-cloudoplossingen - deel vier:Microsoft Azure

  3. Voorloop- en volgtekens verwijderen in MySQL

  4. Hoe zorg ik ervoor dat MySQL een INDEX gebruikt voor weergavequery's?