ORACLE 生产数据库数据迁移完善步骤

1.       设置新库为非归档模式,关闭flashback

节点2执行:

srvctlstop database -d prdweb

sqlplus/ as sysdba;

startupmount

alterdatabase flashback off;

alterdatabase noarchivelog;

alterdatabase open;

exit;

srvctlstart instance -d prdweb -i prdweb1

 

2.       查看旧库的tnsnames.ora,将旧库的tnsname.ora配置到新数据库

3.       toad查看旧库的db_profiles,所有的profiles 导入到新库

4.       查看旧库的role,如果有用户自建的role,需要先在新库建立

5.       列出要导出的用户,查看要导出数据大小,对象数

  select k.owner, k.MB, j.n

  from(select t.owner,sum(t.bytes)/1024/1024as MB

          from dba_segments t

         where t.owner in('AUDITOR',

                           'CERT',

                           'DATAINFO',

                           'DBCENTER',

                           'DBCENTERJJ',

                           'DBCENTERJJ2',

                           'DBCENTER_TEST',

                           'GAZX',

                           'GGZD',

                           'HKKH',

                           'HQ2010',

                           'HT3G',

                           'HTDBTRANSFER',

                           'HTJKMON',

                           'HTSC',

                           'HTSQL',

                           'HTZQ',

                           'JS',

                           'MNCG2010',

                           'MON_GW',

                           'TO',

                           'VIRTUALTRADE',

                           'WEBBRANCH',

                           'WFG_ADMIN',

                           'ZGZWZ',

                           'ZHANGLE',

                           'ZHANGLE_CERT')

         groupby t.owner) k,

       (select t.owner,count(*)as n

          from dba_objects t

         where t.owner in('AUDITOR',

                           'CERT',

                           'DATAINFO',

                           'DBCENTER',

                           'DBCENTERJJ',

                           'DBCENTERJJ2',

                           'DBCENTER_TEST',

                           'GAZX',

                           'GGZD',

                           'HKKH',

                           'HQ2010',

                           'HT3G',

                           'HTDBTRANSFER',

                           'HTJKMON',

                           'HTSC',

                           'HTSQL',

                           'HTZQ',

                           'JS',

                           'MNCG2010',

                           'MON_GW',

                           'TO',

                           'VIRTUALTRADE',

                           'WEBBRANCH',

                           'WFG_ADMIN',

                           'ZGZWZ',

                           'ZHANGLE',

                           'ZHANGLE_CERT')

         groupby t.owner) j where k.owner=j.owner orderby k.MB desc

 

select t.owner,t.object_name,t.object_type from dba_objects t where t.status='INVALID'

6.       导出数据

 

 

timeexpdp \'/ as sysdba\' directory=dpdir Exclude=Statistics Compression=metadata_onlydumpfile=prdweb_struc.dmp logfile=prdweb_struc.log full=y content=metadata_only

 

datafile=prdweb_`date'+%Y%m%d'`_%U.dmp

 

logfile=prdweb_`date'+%Y%m%d'`.log

 

timeexpdp \'/ as sysdba\' directory=dpdir Exclude=Statistics dumpfile=$datafilelogfile=$logfile filesize=20G parallel=10 full=y version=10.2.0.4

 

7.       创建数据库泵路径

createdirectory dpdir as ' /backup/dpdir';

 

8.       导入db_links

timeimpdp \'/ as sysdba\' directory=dpdir INCLUDE=DB_LINK dumpfile=prdweb_struc.dmplogfile=prdweb_imp_dblink.log

 

9.       toad导出表空间脚本,到新库重建

 

10.  数据导入到目标库

directory=dpdir

table_exists_action=truncate

data_options=skip_constraint_errors

skip_unusable_indexes=y

parallel=10

schemas=AUDITOR

,CERT

,DATAINFO

,DBCENTER

,DBCENTERJJ

,DBCENTERJJ2

,DBCENTER_TEST

,GAZX

,GGZD

,HKKH

,HQ2010

,HT3G

,HTDBTRANSFER

,HTJKMON

,HTMALL

,HTSC

,HTSQL

,HTZQ

,JS

,MNCG2010

,MON_GW

,TO

,VIRTUALTRADE

,WEBBRANCH

,WFG_ADMIN

,ZGZWZ

,ZHANGLE

,ZHANGLE_CERT

dumpfile=ep1_01.dmp,ep1_02.dmp,ep1_03.dmp,ep1_04.dmp,ep1_05.dmp,ep1_06.dmp,ep1_07.dmp,ep1_08.dmp,ep1_09.dmp

version=11.2.0.4

 

timeimpdp \'/ as sysdba\' parfile=prdweb.par logfile=prdweb_imp_`date'+%Y%m%d'`.log

 

11.   toad导出用户创建脚本,将用户授权重新执行一遍

sqlplus/ as sysdba;

@grant.sql

12.   编译失效对象

remrecompinvalid.sql

remrecompile invalid objects

sethead off

setfeedback off

setlinesize 200

setpagesize 0

spoolrecompinvalidsub.sql

selectdistinct 'execute dbms_utility.compile_schema('''||OWNER||''',FALSE);' fromDBA_OBJECTS where status='INVALID';

spooloff

setecho on

setfeedback on

settiming on

@recompinvalidsub.sql

 

13.   对比之前步骤得到的原库的失效对象和导入以后的失效对象,手动创建。

 

CREATEINDEX "CDC_INFO"."TEST_T_PACKAGE_INFO2_IDX1" ON"CSP_INFOS"."TEST_T_PACKAGE_INFO2" ("UPDATEID")TABLESPACE "CDC_INFO";

 

14.   手动收集所有用户的统计信息

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'AUDITOR'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'CERT'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'DATAINFO'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'DBCENTER'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'DBCENTERJJ'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'DBCENTERJJ2'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'DBCENTER_TEST'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'GAZX'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'GGZD'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'HKKH'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'HQ2010'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'HT3G'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'HTDBTRANSFER'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'HTJKMON'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'HTMALL'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'HTSC'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'HTSQL'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'HTZQ'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'JS'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'MNCG2010'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'MON_GW'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'TO'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'VIRTUALTRADE'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'WEBBRANCH'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'WFG_ADMIN'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'ZGZWZ'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'ZHANGLE'  ,CASCADE=>TRUE,DEGREE=>24 );

EXECDBMS_STATS.GATHER_SCHEMA_STATS (OWNNAME=>'ZHANGLE_CERT'  ,CASCADE=>TRUE,DEGREE=>24 );

 

15.   设置辛苦为归档模式,flashback打开

srvctlstop database -d prdweb

sqlplus/ as sysdba;

startupmount

alterdatabase archivelog;

alterdatabase open;

alterdatabase flashback on;

exit;

srvctlstart instance -d prdweb -i prdweb1

 

你可能感兴趣的:(ORACLE,ORACLE,备份恢复)