需求:
将zxjfdb2、zxjfdb4上面的ocdbhis库中的用户OCHIS整体迁移到migudb3、migudb4上面的migudb2库。
ocdbhis 与 migudb2均为rac数据库。
步骤:
1.检查环境:
1)该用户涉及的表空间,保证目标库的表空间包含原库表空间,而且容量充足:
select tablespace_name,sum(bytes/1024/1024/1024) gb from dba_segments where owner='&OCHIS' group by tablespace_name;
2)临时表空间,确保两边的表空间一致。
SELECT a.tablespace_name "TABLESPACE_NAME", a.total "TOTAL(MB)", (a.total - nvl(b.used, 0)) "FREE(MB)" , nvl(b.used,0) "USED(MB)", round(nvl(b.used,0) * 100 / a.total, 3) "USED_PERCENT(%)" FROM (SELECT tablespace_name, SUM (bytes)/1024/1024 total FROM dba_temp_files GROUP BY tablespace_name) a, (SELECT tablespace_name, SUM (bytes_cached)/1024/1024 used FROM v$temp_extent_pool GROUP BY tablespace_name) b WHERE a.tablespace_name = b.tablespace_name(+);
3)检查role
select distinct GRANTED_ROLE from dba_role_privs where grantee in ('&OCHIS') order by 1;
4)检查profile
select distinct PROFILE from dba_users where username in ('&OCHIS') order by 1;
5)检查tnsnames.ora
cat $ORACLE_HOME/network/admin/tnsnames.ora
6)检查dblink
select * from DBA_DB_LINKS where OWNER in ('PUBLIC','&OCHIS');
7)检查源端与目标端的网络连通,因为需要使用scp讲dmp文件复制到对端。
8)检查源端与目标端的文件系统是否足够容纳所有的dump文件。
9)检查目标端的归档空间是否充足,避免导入期间,归档满。
2.通知应用同事关闭与OCHIS用户相关的应用
3.将OCHIS用户锁上,避免用户数据变化。
alter user OCHIS account lock;
4.在源库导出数据
1)创建directory
chmod oracle:oinstall /oratemp
create directory ggdump as '/oratemp';
2)编写parfile
#####按照用户导出
zxjfdb2:/oratemp$cat expdp_ochis.par
userid='/ as sysdba'
directory=ggdump
dumpfile=expdp_ochis_%U.dmp
logfile=expdp_ochis.log
parallel=8 ----8个并行
compression=all ----压缩
CLUSTER=N
exclude=statistics ----取消导出统计信息
SCHEMAS=(
OCHIS
)
#####按照用户导出元数据,供参考
#userid='/ as sysdba'
#directory=ggdump
#dumpfile=expdp_ich_metadata.dmp
#logfile=expdp_ich_metadata.log
#CONTENT=METADATA_ONLY
#CLUSTER=N
#SCHEMAS=(
#PUBDBA,
#OCHIS
#)
#####按照表导出纯数据,供参考
#userid='/ as sysdba'
#directory=ggdump
#dumpfile=expdp_ich_pubdba_data.dmp
#logfile=expdp_ich_pubdba_data.log
#CONTENT=DATA_ONLY
#CLUSTER=N
#TABLES=(
#PUBDBA.ACCNT_AGREEMENT
#PUBDBA.CARRIER_ACCNT_BANK_INFO
#)
3)导出并查看日志
nohup expdp parfile=expdp_ochis.par > expdp_ochis.par.out &
tail -f expdp_ochis.par.out
5.拷贝数据
scp expdp_*.dmp migudb3:/backup
6.目标端导入数据
1)创建directory
2)编写parfile
migudb3:/backup#cat impdp_ochis.par
userid='/ as sysdba'
directory=ggdump
dumpfile=expdp_ochis_%U.dmp
logfile=impdp_ochis.log
parallel=8
CLUSTER=N
3)导入并查看日志
nohup impdp parfile=impdp_ich_metadata.par > impdp_ich_metadata.par.out &
tail -f impdp_ich_metadata.par.out
7.收集统计信息
migudb3:/backup#cat gather_ochis_info.sh
sqlplus / as sysdba <<EOF
set echo on
set verify on
spool gather_ochis_info.log
exec dbms_stats.gather_schema_stats(ownname=>'OCHIS',estimate_percent=>10,method_opt=>'for all columns size 1',cascade=>true,force=>true,degree=>8,no_invalidate=>false);
spool off
exit
EOF
8.目标库解锁OCHIS用户
alter user ochis account unlock;
9.通知应用同事检查应用。
将zxjfdb2、zxjfdb4上面的ocdbhis库中的用户OCHIS整体迁移到migudb3、migudb4上面的migudb2库。
ocdbhis 与 migudb2均为rac数据库。
步骤:
1.检查环境:
1)该用户涉及的表空间,保证目标库的表空间包含原库表空间,而且容量充足:
select tablespace_name,sum(bytes/1024/1024/1024) gb from dba_segments where owner='&OCHIS' group by tablespace_name;
2)临时表空间,确保两边的表空间一致。
SELECT a.tablespace_name "TABLESPACE_NAME", a.total "TOTAL(MB)", (a.total - nvl(b.used, 0)) "FREE(MB)" , nvl(b.used,0) "USED(MB)", round(nvl(b.used,0) * 100 / a.total, 3) "USED_PERCENT(%)" FROM (SELECT tablespace_name, SUM (bytes)/1024/1024 total FROM dba_temp_files GROUP BY tablespace_name) a, (SELECT tablespace_name, SUM (bytes_cached)/1024/1024 used FROM v$temp_extent_pool GROUP BY tablespace_name) b WHERE a.tablespace_name = b.tablespace_name(+);
3)检查role
select distinct GRANTED_ROLE from dba_role_privs where grantee in ('&OCHIS') order by 1;
4)检查profile
select distinct PROFILE from dba_users where username in ('&OCHIS') order by 1;
5)检查tnsnames.ora
cat $ORACLE_HOME/network/admin/tnsnames.ora
6)检查dblink
select * from DBA_DB_LINKS where OWNER in ('PUBLIC','&OCHIS');
7)检查源端与目标端的网络连通,因为需要使用scp讲dmp文件复制到对端。
8)检查源端与目标端的文件系统是否足够容纳所有的dump文件。
9)检查目标端的归档空间是否充足,避免导入期间,归档满。
2.通知应用同事关闭与OCHIS用户相关的应用
3.将OCHIS用户锁上,避免用户数据变化。
alter user OCHIS account lock;
4.在源库导出数据
1)创建directory
chmod oracle:oinstall /oratemp
create directory ggdump as '/oratemp';
2)编写parfile
#####按照用户导出
zxjfdb2:/oratemp$cat expdp_ochis.par
userid='/ as sysdba'
directory=ggdump
dumpfile=expdp_ochis_%U.dmp
logfile=expdp_ochis.log
parallel=8 ----8个并行
compression=all ----压缩
CLUSTER=N
exclude=statistics ----取消导出统计信息
SCHEMAS=(
OCHIS
)
#####按照用户导出元数据,供参考
#userid='/ as sysdba'
#directory=ggdump
#dumpfile=expdp_ich_metadata.dmp
#logfile=expdp_ich_metadata.log
#CONTENT=METADATA_ONLY
#CLUSTER=N
#SCHEMAS=(
#PUBDBA,
#OCHIS
#)
#####按照表导出纯数据,供参考
#userid='/ as sysdba'
#directory=ggdump
#dumpfile=expdp_ich_pubdba_data.dmp
#logfile=expdp_ich_pubdba_data.log
#CONTENT=DATA_ONLY
#CLUSTER=N
#TABLES=(
#PUBDBA.ACCNT_AGREEMENT
#PUBDBA.CARRIER_ACCNT_BANK_INFO
#)
3)导出并查看日志
nohup expdp parfile=expdp_ochis.par > expdp_ochis.par.out &
tail -f expdp_ochis.par.out
5.拷贝数据
scp expdp_*.dmp migudb3:/backup
6.目标端导入数据
1)创建directory
2)编写parfile
migudb3:/backup#cat impdp_ochis.par
userid='/ as sysdba'
directory=ggdump
dumpfile=expdp_ochis_%U.dmp
logfile=impdp_ochis.log
parallel=8
CLUSTER=N
3)导入并查看日志
nohup impdp parfile=impdp_ich_metadata.par > impdp_ich_metadata.par.out &
tail -f impdp_ich_metadata.par.out
7.收集统计信息
migudb3:/backup#cat gather_ochis_info.sh
sqlplus / as sysdba <<EOF
set echo on
set verify on
spool gather_ochis_info.log
exec dbms_stats.gather_schema_stats(ownname=>'OCHIS',estimate_percent=>10,method_opt=>'for all columns size 1',cascade=>true,force=>true,degree=>8,no_invalidate=>false);
spool off
exit
EOF
8.目标库解锁OCHIS用户
alter user ochis account unlock;
9.通知应用同事检查应用。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31441616/viewspace-2152181/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/31441616/viewspace-2152181/