eygle.com   eygle.com
eygle.com  
 

« November 11, 2005 | Blog首页 | November 13, 2005 »



November 12, 2005

Oracle HowTo:如何通过只读方式更改Oracle数据文件位置

作者:eygle

出处:http://blog.eygle.com

在Oracle数据库中,有多种方式可以移动数据文件的位置,之前介绍过几种方法:Oracle HowTo:在非归档模式下如何更改数据文件位置Oracle HowTo:如何移动数据文件的位置?
以上两种方法,可能在要求较高的24x7系统中不适合采用,因为会使表空间长时间不可用。
特别是当表空间数据文件巨大时,物理拷贝可能需要较长的时间。

本文推荐另外一种方法,可以做一个折中,以下是一个简单的步骤说明:
1.将表空间置于只读
只读状态可以使数据仍然可为用户访问.
alter tablespace tablespace_name read only;
2.物理拷贝文件
3.将表空间offline
alter tablespace tablespace_name offline;
4.rename数据文件
alter database rename file 'old_dir_file' to 'new_dir_file';
5.将表空间联机
alter tablespace tablespace_name online;
6.将表空间置于read write模式
alter tablespace tablespace_name read write;
以下是示范步骤:
1.将表空间置于只读状态
[oracle@jumper oracle]$ sqlplus "/ as sysdba"

SQL*Plus: Release 9.2.0.4.0 - Production on Sat Nov 12 21:10:49 2005

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /opt/oracle/oradata/conner/archive
Oldest online log sequence     7
Next log sequence to archive   10
Current log sequence           10
SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------
/opt/oracle/oradata/conner/system01.dbf
/opt/oracle/oradata/conner/undotbs01.dbf
/opt/oracle/oradata/conner/users01.dbf

SQL> alter tablespace users read only;

Tablespace altered.

2.物理拷贝文件

SQL> ! cp /opt/oracle/oradata/conner/users01.dbf /opt/oracle/oradata/users01.dbf

3.将表空间脱机
SQL> alter tablespace users offline;

Tablespace altered.

4.修改文件名称
SQL> alter database rename file '/opt/oracle/oradata/conner/users01.dbf' to '/opt/oracle/oradata/users01.dbf';

Database altered.

5.将表空间联机
SQL> alter tablespace users online;

Tablespace altered.

6.将表空间置于读写状态
SQL> alter tablespace users read write;

Tablespace altered.

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------
/opt/oracle/oradata/conner/system01.dbf
/opt/oracle/oradata/conner/undotbs01.dbf
/opt/oracle/oradata/users01.dbf

SQL> 

Posted by eygle at 9:50 PM | Comments (4)


Oracle HowTo:如何移动数据文件的位置?

作者:eygle

出处:http://blog.eygle.com

在Oracle数据库中,有多种方式可以移动数据文件的位置,之前介绍过一种方法:Oracle HowTo:在非归档模式下如何更改数据文件位置
其实可以采用的方法有多种,本文继续补充几种常用方法:
采用offline的方式
第一步,将表空间offline
alter tablespace tablespace_name offline;
第二步,cp文件到新的目录并rename修改控制文件
第三步,将相应表空间online
当然这种方式同样会影响期间的表空间使用。

以下是简单的示范步骤:
1.将表空间offline
[oracle@jumper oracle]$ sqlplus "/ as sysdba"

SQL*Plus: Release 9.2.0.4.0 - Production on Sat Nov 12 18:14:21 2005

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production

SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Enabled
Archive destination            /opt/oracle/oradata/conner/archive
Oldest online log sequence     6
Current log sequence           9
SQL> select name from v$datafile;

NAME
---------------------------------------------------------
/opt/oracle/oradata/conner/system01.dbf
/opt/oracle/oradata/conner/undotbs01.dbf
/opt/oracle/oradata/conner/users01.dbf

SQL> alter tablespace users offline;

Tablespace altered.

2.拷贝相应的数据文件
SQL> ! cp /opt/oracle/oradata/conner/users01.dbf /opt/oracle/oradata/users01.dbf

SQL> alter tablespace users rename datafile '/opt/oracle/oradata/conner/users01.dbf'
     to '/opt/oracle/oradata/users01.dbf';

Tablespace altered.

3.将表空间online
SQL> alter tablespace users online;

Tablespace altered.

SQL> select name from v$datafile;

NAME
------------------------------------------------------------------------
/opt/oracle/oradata/conner/system01.dbf
/opt/oracle/oradata/conner/undotbs01.dbf
/opt/oracle/oradata/users01.dbf

当然还有一些其他的方法可以采用.

Posted by eygle at 9:09 PM | Comments (6)



CopyRight © 2004-2008 eygle.com, All rights reserved.