sql >> データベース >  >> RDS >> Database

Network_linkを使用したデータの移行

    ソース :exa01dm05(Oracle 11g)
    ターゲット :exa02dm06(Oracle 18c)

    1.PDBと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.TARGETDBサーバーexa02dm06にSOURCEのtnsnamesエントリを追加します

    
    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.ターゲットのPDBにdblinkを作成します。

    
    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.すべてのテーブルスペースのDDLを使用してsqlfileを作成します

    
    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.ターゲットに応じてsqlfile(tablespaces.sql)のデータファイルパスの名前を変更します。

    6.ターゲットにテーブルスペースを作成します:

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

    7.network_linkを使用してインポートを実行します。パーファイル「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.無効なオブジェクトを再コンパイルします:

    
    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.統計を収集する:

    
    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. ORA-00997の回避策:LONGデータ型の不正使用

    2. 致命的:ユーザーpostgresのパスワード認証に失敗しました(pgAdmin4を使用したpostgresql11)

    3. SQL ServerでのIIF()のしくみ

    4. SQLServer2008の分割機能