在归档模式下移动数据文件:步骤如下
采用offline的方式
1,将表空间offline
alter tablespace tablespace_name offline;
2,cp文件到新的目录并rename修改控制文件
3 ,将相应表空间online
当然这种方式同样会影响期间的表空间使用。
--实际操作如下:
操作系统版本:
oracle@ntsmshost:~$ uname -a
Linux ntsmshost 3.0.0-25-server #41-Ubuntu SMP Mon Aug 13 18:18:27 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
oracle数据版本
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
[oracle@dataSub arch]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_datasub-lv_root
36G 32G 1.8G 95% /
tmpfs 4.0G 88K 4.0G 1% /dev/shm
/dev/sda1 485M 60M 400M 14% /boot
/dev/sdb1 197G 189M 187G 1% /oracle
--1.将表空间offline
[oracle@dataSub arch]$ sqlplus "/ as sysdba"
确认是否是归档模式
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oracle/oradata/dw/arch
Oldest online log sequence 201
Next log sequence to archive 208
Current log sequence 208
--查询表空间以及对应的数据文件
select a.name,b.name from v$datafile a ,v$tablespace b where a.ts#=b.ts#;
--2,迁移DWTBS表空间,现将其offline
alter tablespace DWTBS offline;
--3,拷贝相应的数据文件,我这里采取是移动mv
mv /db/app/oracle/oradata/dw/dwtbs01.DBF /oracle/oradata/dw
--4,修改控制文件,将数据文件重命名
alter tablespace DWTBS rename datafile '/db/app/oracle/oradata/dw/dwtbs01.DBF' to '/oracle/oradata/dw/dwtbs01.DBF';
--5,将表空间online
alter tablespace DWTBS online;
select name from v$datafile;
--其他用户表空间同样的步骤
--system表空间迁移:
--1. 关闭数据库
SQL> shutdown immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
--2. 复制system表空间对应数据文件去新路径
--3. 以mount启动数据库
SQL> startup mount
ORACLE 例程已经启动。
Total System Global Area 135338868 bytes
Fixed Size 453492 bytes
Variable Size 109051904 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
数据库装载完毕。
--4. 修改system表空间对应数据文件去新路径
alter database rename file '/db/app/oracle/oradata/dw/system01.dbf' to '/oracle/oradata/dw/system01.dbf';
alter database rename file '/db/app/oracle/oradata/dw/system02.dbf' to '/oracle/oradata/dw/system02.dbf';
--5. 打开数据库
SQL> alter database open;
--offline数据文件时,必须要进行介质恢复,步骤如下;
1.先将相应的数据文件 offline
alter database datafile '/db/app/oracle/oradata/dw/dwtbs01.dbf' offline;
2.把数据文件 copy 到新位置
3. alter database rename file '/db/app/oracle/oradata/dw/dwtbs01.dbf' to '/oracle/oradata/dw/abc.dbf';
4. 介质恢复(offline 数据文件必须要介质恢复)
recover datafile'/oracle/oradata/dw/abc.dbf';
5. 将相应的数据文件 online
sql>alter database datafile'/oracle/oradata/dw/abc.dbf' online;
采用offline的方式
1,将表空间offline
alter tablespace tablespace_name offline;
2,cp文件到新的目录并rename修改控制文件
3 ,将相应表空间online
当然这种方式同样会影响期间的表空间使用。
--实际操作如下:
操作系统版本:
oracle@ntsmshost:~$ uname -a
Linux ntsmshost 3.0.0-25-server #41-Ubuntu SMP Mon Aug 13 18:18:27 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
oracle数据版本
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
[oracle@dataSub arch]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_datasub-lv_root
36G 32G 1.8G 95% /
tmpfs 4.0G 88K 4.0G 1% /dev/shm
/dev/sda1 485M 60M 400M 14% /boot
/dev/sdb1 197G 189M 187G 1% /oracle
--1.将表空间offline
[oracle@dataSub arch]$ sqlplus "/ as sysdba"
确认是否是归档模式
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oracle/oradata/dw/arch
Oldest online log sequence 201
Next log sequence to archive 208
Current log sequence 208
--查询表空间以及对应的数据文件
select a.name,b.name from v$datafile a ,v$tablespace b where a.ts#=b.ts#;
--2,迁移DWTBS表空间,现将其offline
alter tablespace DWTBS offline;
--3,拷贝相应的数据文件,我这里采取是移动mv
mv /db/app/oracle/oradata/dw/dwtbs01.DBF /oracle/oradata/dw
--4,修改控制文件,将数据文件重命名
alter tablespace DWTBS rename datafile '/db/app/oracle/oradata/dw/dwtbs01.DBF' to '/oracle/oradata/dw/dwtbs01.DBF';
--5,将表空间online
alter tablespace DWTBS online;
select name from v$datafile;
--其他用户表空间同样的步骤
--system表空间迁移:
--1. 关闭数据库
SQL> shutdown immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
--2. 复制system表空间对应数据文件去新路径
--3. 以mount启动数据库
SQL> startup mount
ORACLE 例程已经启动。
Total System Global Area 135338868 bytes
Fixed Size 453492 bytes
Variable Size 109051904 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
数据库装载完毕。
--4. 修改system表空间对应数据文件去新路径
alter database rename file '/db/app/oracle/oradata/dw/system01.dbf' to '/oracle/oradata/dw/system01.dbf';
alter database rename file '/db/app/oracle/oradata/dw/system02.dbf' to '/oracle/oradata/dw/system02.dbf';
--5. 打开数据库
SQL> alter database open;
--offline数据文件时,必须要进行介质恢复,步骤如下;
1.先将相应的数据文件 offline
alter database datafile '/db/app/oracle/oradata/dw/dwtbs01.dbf' offline;
2.把数据文件 copy 到新位置
3. alter database rename file '/db/app/oracle/oradata/dw/dwtbs01.dbf' to '/oracle/oradata/dw/abc.dbf';
4. 介质恢复(offline 数据文件必须要介质恢复)
recover datafile'/oracle/oradata/dw/abc.dbf';
5. 将相应的数据文件 online
sql>alter database datafile'/oracle/oradata/dw/abc.dbf' online;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23073818/viewspace-1073548/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/23073818/viewspace-1073548/