Linux服务器磁盘扩展和Oracle表空间文件迁移操作记录(四)

2015-07-16 12:08:29 · 作者: · 浏览: 3
_DB6]$ mv /AFC_DB3/oradata/idx_ud_sale13.dbf /AFC_DB6/oradata/idx_ud_sale13.dbf


[oracle@ccsvr AFC_DB6]$ mv /AFC_DB3/oradata/dx_operation05.dbf /AFC_DB6/oradata/idx_operation05.dbf


?[oracle@ccsvr AFC_DB6]$ mv /AFC_DB3/oradata/data_ud_sale23.dbf /AFC_DB6/oradata/data_ud_sale23.dbf


[oracle@ccsvr AFC_DB6]$ cd oradata/


?[oracle@ccsvr oradata]$ ls -lh


total 14G


-rw-r-----? 1 oracle oinstall? 11G May 17 22:00 data_ud_sale23.dbf


-rw-r-----? 1 oracle oinstall 2.1G May 17 22:00 idx_operation05.dbf


-rw-r-----? 1 oracle oinstall 1.1G May 17 22:00 idx_ud_sale13.dbf


?


启动数据库挂载:


[oracle@ccsvr oradata]$ sqlplus / as sysdba;?


SQL> startup mount;


ORACLE instance started.


?


Total System Global Area 2147483648 bytes


Fixed Size? ? ? ? ? ? ? 1220432 bytes


Variable Size? ? ? ? ? ? ? ? 218103984 bytes


Database Buffers? ? 1912602624 bytes


Redo Buffers? ? ? ? ? ? ? 15556608 bytes


Database mounted.


使用rename命名使移动后的数据文件生效:


SQL> alter database rename file '/AFC_DB3/oradata/idx_ud_sale13.dbf' to '/AFC_DB6/oradata/idx_ud_sale13.dbf';


Database altered.


SQL> alter database rename file '/AFC_DB3/oradata/dx_operation05.dbf' to '/AFC_DB6/oradata/idx_operation05.dbf';


Database altered.


SQL> alter database rename file '/AFC_DB3/oradata/data_ud_sale23.dbf' to '/AFC_DB6/oradata/data_ud_sale23.dbf';


Database altered.


打开数据库


SQL> alter database open;


Database altered.


最后,根据需要,增加三个数据库文件,扩大表空间:


SQL> alter tablespace IDX_UD_SALE add datafile '/AFC_DB6/oradata/idx_ud_sale14.dbf' size 4096M;


Tablespace altered.


SQL> alter tablespace IDX_OPERATION add datafile '/AFC_DB6/oradata/idx_operation06.dbf' size 2048M;


Tablespace altered.


SQL> alter tablespace DATA_UD_SALE add datafile '/AFC_DB6/oradata/data_ud_sale24.dbf' size 8192M;


Tablespace altered.


检查下AFC_DB6的数据文件:


[oracle@ccsvr oradata]$ pwd


/AFC_DB6/oradata


[oracle@ccsvr oradata]$ ls -alh


total 28G


drwxr-xr-x? 2 oracle oinstall 4.0K May 17 22:48 .


drwxrwxrwx? 4 root? root? ? 4.0K May 17 22:04 ..


-rw-r-----? 1 oracle oinstall? 11G May 17 22:30 data_ud_sale23.dbf


-rw-r-----? 1 oracle oinstall 8.1G May 17 22:50 data_ud_sale24.dbf


-rw-r-----? 1 oracle oinstall 2.1G May 17 22:30 idx_operation05.dbf


-rw-r-----? 1 oracle oinstall 2.1G May 17 22:46 idx_operation06.dbf


-rw-r-----? 1 oracle oinstall 1.1G May 17 22:30 idx_ud_sale13.dbf


-rw-r-----? 1 oracle oinstall 4.1G May 17 22:44 idx_ud_sale14.dbf


即有移动过来的数据文件,也有新增的数据文件。


再查看表空间使用,已经下降了:


?


磁盘使用情况也正常了。


至此,操作完成。


最后附上查看表空间的SQL代码:


增加表空间大小的四种方法


Meathod1:给表空间增加数据文件
ALTER TABLESPACE app_data ADD DATAFILE
'D:\ORACLE\PRODUCT\10.2.0\ORADATA\EDWTEST\APP03.DBF' SIZE 50M;
?
Meathod2:新增数据文件,并且允许数据文件自动增长
ALTER TABLESPACE app_data ADD DATAFILE
'D:\ORACLE\PRODUCT\10.2.0\ORADATA\EDWTEST\APP04.DBF' SIZE 50M
AUTOEXTEND ON NEXT 5M MAXSIZE 100M;
?
Meathod3:允许已存在的数据文件自动增长
ALTER DATABASE DATAFILE 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\EDWTEST\APP03.DBF'
AUTOEXTEND ON NEXT 5M MAXSIZE 100M;
?
Meathod4:手工改变已存在数据文件的大小
ALTER DATABASE DATAFILE 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\EDWTEST\APP02.DBF'
RESIZE 100M;