在Linux上迁移Oracle数据库数据可以通过多种方法实现,主要包括使用Data Pump (expdp/impdp)、RMAN (Recovery Manager) 以及Oracle GoldenGate等工具。以下是使用Data Pump和RMAN进行数据迁移的详细步骤:
前提条件:
迁移步骤:
源服务器操作:
创建目录对象:
[root@linux100] # su - oracle
[oracle@linux100] # sqlplus / as sysdba
SQL create or replace directory tmpDir as '/tempFile';
使用expdp导出数据表:
[oracle@linux100] # expdp username/password@Ip:port/database schemas dbTest directory tmpDir dumpfile export.dmp logfile export.log;
复制dmp文件到目标服务器:
[oracle@linux100] # scp -P 2222 /tempFile/export.dmp name@xxx.xxx.xxx.xxx:/home/tempFile;
目标服务器操作:
创建目录对象:
[root@linux101] # su - oracle
[oracle@linux101] # sqlplus / as sysdba
SQL create or replace directory tmpDir as '/tempFile';
使用impdp导入数据表:
[oracle@linux101] # impdp username/password@Ip:port/database schemas dbTest directory tmpDir dumpfile export.dmp job_namemyjob;
前提条件:
迁移步骤:
源服务器操作:
连接到RMAN:
[oracle@linux100] # rman target /
备份数据库:
RMAN backup database plus archivelog;
迁移数据文件:
RMAN run {
allocate channel c1 type disk;
allocate channel c2 type disk;
restore database from tag 'backup_tag';
switch datafile all;
release channel c1;
release channel c2;
}
更新初始化参数文件:
[oracle@linux100] # sqlplus / as sysdba
SQL ALTER SYSTEM SET DB_FILE_NAME_CONVERT '/old/path,/new/path' SCOPESPFILE;
SQL ALTER SYSTEM SET LOG_FILE_NAME_CONVERT '/old/path,/new/path' SCOPESPFILE;
关闭数据库并启动到NOMOUNT状态:
SQL shutdown immediate;
SQL startup nomount;
目标服务器操作:
创建目录对象:
[root@linux101] # su - oracle
[oracle@linux101] # sqlplus / as sysdba
SQL create or replace directory tmpDir as '/tempFile';
使用RMAN恢复数据库:
RMAN startup nomount;
RMAN @/target-directory/crdb.sql;