8wDlpd.png
8wDFp9.png
8wDEOx.png
8wDMfH.png
8wDKte.png
Oracle迁移表空间 Oracle
admin 2023-1-10

# 0、创建文件
mkdir /data/ldx
chown oracle /data/ldx

# 1、备份文件
cd /u01/app/oracle/oradata/ldx/
cp /u01/app/oracle/oradata/ldx/TS_ETL.DBF  /data/ldx/TS_ETL.DBF
cp /u01/app/oracle/oradata/ldx/TS_FIN.DBF  /data/ldx/TS_FIN.DBF
cp /u01/app/oracle/oradata/ldx/TS_HIST.DBF  /data/ldx/TS_HIST.DBF
cp /u01/app/oracle/oradata/ldx/TS_INFO.DBF  /data/ldx/TS_INFO.DBF
cp /u01/app/oracle/oradata/ldx/TS_LMCONFIG.DBF  /data/ldx/TS_LMCONFIG.DBF
cp /u01/app/oracle/oradata/ldx/TS_LMDATA.DBF  /data/ldx/TS_LMDATA.DBF
cp /u01/app/oracle/oradata/ldx/TS_PARA.DBF  /data/ldx/TS_PARA.DBF
cp /u01/app/oracle/oradata/ldx/TS_RDM.DBF  /data/ldx/TS_RDM.DBF
cp /u01/app/oracle/oradata/ldx/TS_RDMEDW.DBF  /data/ldx/TS_RDMEDW.DBF
cp /u01/app/oracle/oradata/ldx/TS_RDMETL.DBF  /data/ldx/TS_RDMETL.DBF
cp /u01/app/oracle/oradata/ldx/TS_RDMODS.DBF  /data/ldx/TS_RDMODS.DBF
cp /u01/app/oracle/oradata/ldx/TS_RPCONFIG.DBF  /data/ldx/TS_RPCONFIG.DBF
cp /u01/app/oracle/oradata/ldx/TS_RPDATA.DBF  /data/ldx/TS_RPDATA.DBF
cp /u01/app/oracle/oradata/ldx/TS_SETT.DBF  /data/ldx/TS_SETT.DBF
cp /u01/app/oracle/oradata/ldx/TS_WOLFDATA.DBF  /data/ldx/TS_WOLFDATA.DBF
cp /u01/app/oracle/oradata/ldx/TS_WOLF.DBF  /data/ldx/TS_WOLF.DBF
cp /u01/app/oracle/oradata/ldx/TS_stconfig.DBF  /data/ldx/TS_STCONFIG.DBF
cp /u01/app/oracle/oradata/ldx/TS_stdata.DBF  /data/ldx/TS_STDATA.DBF
cp /u01/app/oracle/oradata/ldx/VLDATA.dbf  /data/ldx/TS_VLDATA.DBF
cp /u01/app/oracle/oradata/ldx/VLCONFIG.dbf  /data/ldx/TS_VLCONFIG.DBF

# 2、
sqlplus / as sysdba <<EOF
-- 把数据文件所属的表空间Offline,在SQLPLUS里运行如下命令
alter tablespace TS_ETL offline;
-- 修改表空间文件路径alter database rename file '旧文件路径' to '新文件路径';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_etl.DBF' to '/data/ldx/TS_etl.DBF';
-- 当执行重命名命令后,ORACLE会认为数据库文件损坏,提示:“需要恢复介质” 
shutdown immediate; -- 关闭数据库
startup mount; --以归档模式启动数据库,不打开数据库
recover datafile '/data/ldx/TS_etl.DBF'; --介质恢复
alter database open;
alter tablespace TS_ETL online;
exit;
EOF


sqlplus / as sysdba <<EOF
alter tablespace TS_ETL offline;
alter tablespace TS_FIN offline;
alter tablespace TS_HIST offline;
alter tablespace TS_INFO offline;
alter tablespace TS_LMCONFIG offline;
alter tablespace TS_LMDATA offline;
alter tablespace TS_PARA offline;
alter tablespace TS_RDM offline;
alter tablespace TS_RDMEDW offline;
alter tablespace TS_RDMETL offline;
alter tablespace TS_RDMODS offline;
alter tablespace TS_RPCONFIG offline;
alter tablespace TS_RPDATA offline;
alter tablespace TS_SETT offline;
alter tablespace TS_WOLFDATA offline;
alter tablespace TS_WOLF offline;
alter tablespace TS_STCONFIG offline;
alter tablespace TS_STDATA offline;
alter tablespace TS_VLDATA offline;
alter tablespace TS_VLCONFIG offline;

ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_etl.DBF' to '/data/ldx/TS_ETL.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_fin.DBF' to '/data/ldx/TS_FIN.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_hist.DBF' to '/data/ldx/TS_HIST.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_info.DBF' to '/data/ldx/TS_INFO.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_lmconfig.DBF' to '/data/ldx/TS_LMCONFIG.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_lmdata.DBF' to '/data/ldx/TS_LMDATA.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_para.DBF' to '/data/ldx/TS_PARA.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_RDM.DBF' to '/data/ldx/TS_RDM.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_rdmedw.DBF' to '/data/ldx/TS_RDMEDW.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_rdmetl.DBF' to '/data/ldx/TS_RDMETL.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_rdmods.DBF' to '/data/ldx/TS_RDMODS.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_rpconfig.DBF' to '/data/ldx/TS_RPCONFIG.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_rpdata.DBF' to '/data/ldx/TS_RPDATA.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_sett.DBF' to '/data/ldx/TS_SETT.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_wolfdata.DBF' to '/data/ldx/TS_WOLFDATA.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_wolf.DBF' to '/data/ldx/TS_WOLF.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_stconfig.DBF' to '/data/ldx/TS_STCONFIG.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/TS_stdata.DBF' to '/data/ldx/TS_STDATA.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/VLDATA.dbf' to '/data/ldx/TS_VLDATA.DBF';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/ldx/VLCONFIG.dbf' to '/data/ldx/TS_VLCONFIG.DBF';
shutdown immediate;
startup mount;
recover datafile '/data/ldx/TS_ETL.DBF';
recover datafile '/data/ldx/TS_FIN.DBF';
recover datafile '/data/ldx/TS_HIST.DBF';
recover datafile '/data/ldx/TS_INFO.DBF';
recover datafile '/data/ldx/TS_LMCONFIG.DBF';
recover datafile '/data/ldx/TS_LMDATA.DBF';
recover datafile '/data/ldx/TS_PARA.DBF';
recover datafile '/data/ldx/TS_RDM.DBF';
recover datafile '/data/ldx/TS_RDMEDW.DBF';
recover datafile '/data/ldx/TS_RDMETL.DBF';
recover datafile '/data/ldx/TS_RDMODS.DBF';
recover datafile '/data/ldx/TS_RPCONFIG.DBF';
recover datafile '/data/ldx/TS_RPDATA.DBF';
recover datafile '/data/ldx/TS_SETT.DBF';
recover datafile '/data/ldx/TS_WOLFDATA.DBF';
recover datafile '/data/ldx/TS_WOLF.DBF';
recover datafile '/data/ldx/TS_STCONFIG.DBF';
recover datafile '/data/ldx/TS_STDATA.DBF';
recover datafile '/data/ldx/TS_VLDATA.DBF';
recover datafile '/data/ldx/TS_VLCONFIG.DBF';
alter database open;
alter tablespace TS_ETL online;
alter tablespace TS_FIN online;
alter tablespace TS_HIST online;
alter tablespace TS_INFO online;
alter tablespace TS_LMCONFIG online;
alter tablespace TS_LMDATA online;
alter tablespace TS_PARA online;
alter tablespace TS_RDM online;
alter tablespace TS_RDMEDW online;
alter tablespace TS_RDMETL online;
alter tablespace TS_RDMODS online;
alter tablespace TS_RPCONFIG online;
alter tablespace TS_RPDATA online;
alter tablespace TS_SETT online;
alter tablespace TS_WOLFDATA online;
alter tablespace TS_WOLF online;
alter tablespace TS_STCONFIG online;
alter tablespace TS_STDATA online;
alter tablespace TS_VLDATA online;
alter tablespace TS_VLCONFIG online;
exit;
EOF
最新回复 (1)
    • 朕弟分享 | 专注小众,乐于分享!
      3
          
返回
发新帖 搜索 反馈 回顶部