rac環境數據文件誤建到rac節點本地處理
在一次RAC例行巡檢時,查詢表空間的使用情況,節點1竟然拋出來,dbwr 進程無法lock ‘D:oraclefcdataLIXORA.DBF’ 這個數據文件;感覺不對啊,非常不祥的感覺;
光看名字就可以猜到,數據文件建到rac 節點2本地;
看下文件狀態吧:
SQL> select file_name,tablespace_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
+DATA/lixora/datafile/sys_yyxt.271.785089053
+DATA/lixora/datafile/sys_yyxt.270.785089231
+DATA/lixora/datafile/sys_yyxt.269.785089375
+DATA/lixora/datafile/users.276.784277257
+DATA/lixora/datafile/sysaux.274.784277257
+DATA/lixora/datafile/undotbs1.275.784277257
+DATA/lixora/datafile/system.273.784277257
+DATA/lixora/datafile/undotbs2.284.784277321
+DATA/lixora/datafile/sys_yyxt.268.785089665
+DATA/lixora/datafile/sys_yyxt.265.785089753
+DATA/lixora/datafile/sys_yyxt.264.785089843
FILE_NAME
--------------------------------------------------------------------------------
+DATA/lixora/datafile/sys_yyxt.400.785089933
+DATA/lixora/datafile/sys_yyxt01
+DATA/lixora/datafile/sys_yyxt02.dbf
+DATA/lixora/datafile/sys_jkxt.401.785090209
+DATA/lixora/datafile/sys_yyxt03.dbf
+DATA/lixora/datafile/sys_yyxt201401
+DATA/lixora/datafile/sys_yyxt201402
+DATA/lixora/datafile/sys_yyxt201403
+DATA/lixora/datafile/sys_yyxt201404
+DATA/lixora/datafile/sys_yyxt201405
+DATA/lixora/datafile/sys_yyxt201407
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/product/10.2.0/db_1/dbs/D:oraclefcdataLIXORA.DBF --------------嚇死寶寶了!
/u01/app/oracle/product/10.2.0/db_1/dbs/D:oraclefcdataLIXORADATA.DBF ------------------嚇死寶寶了!
24 rows selected.
果不其然,文件建到了rac 節點本地,而且數據文件名,要多奇葩,有多奇葩,這哥們真是縱觀古今,然後大手一揮,寫下‘hello word ’ 然後會心一笑。。。。。
我們的開發人員也是夠慘的啊,單機的oracle也搞不清楚,更不用涉及rac了。。。。。。。
再次確認下,dbfile 確實建在了/u01/app/oracle/product/10.2.0/db_1/dbs/ 目錄下
SQL> !ls /u01/app/oracle/product/10.2.0/db_1/dbs/
ab_+ASM2.dat
D:oraclefcdataLIXORAtemp.DBF hc_+ASM2.dat initdw.ora orapw+ASM2
CdbsMutex
D:oraclefcdataLIXORATEMP.DBF hc_orcl2.dat init.ora orapworcl2
D:oraclefcdataLIXORADATA.DBF
D:\oracle\oradata\orcl\hhygbp_temp_dbf initlixora2.ora initorcl2.ora snapcf_lixora2.f
D:oraclefcdataLIXORA.DBF hc_lixora2.dat init+ASM2.ora orapwlixora2 snapcf_orcl2.f
仔細看下內容好像哪裡有點問題吧?
貌似是temp 文件啊
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
+DATA/lixora/tempfile/temp.283.784277305
/u01/app/oracle/product/10.2.0/db_1/dbs/D:oraclefcdataLIXORATEMP.DBF -------
----到底是什麼時候出現這個問題的呢?
SQL> select CREATION_TIME,NAME from v$datafile where name='/u01/app/oracle/product/10.2.0/db_1/dbs/D:oraclefcdataLIXORA.DBF';
CREATION_TIM
------------
NAME
--------------------------------------------------------------------------------
18-MAY-15
/u01/app/oracle/product/10.2.0/db_1/dbs/D:oraclefcdataLIXORA.DBF
SQL> select CREATION_TIME,NAME from v$datafile where name='/u01/app/oracle/product/10.2.0/db_1/dbs/D:oraclefcdataLIXORADATA.DBF';
CREATION_TIM
------------
NAME
--------------------------------------------------------------------------------
18-MAY-15
/u01/app/oracle/product/10.2.0/db_1/dbs/D:oraclefcdataLIXORADATA.DBF
接下來一個個來處理下吧
------tempfile 誤建到rac 節點本地處理:
temp 文件處理簡單,先刪除了 ,重新加個就行
SQL> select * from v$tempfile;
FILE# CREATION_CHANGE# CREATION_TIM TS# RFILE# STATUS ENABLED BYTES BLOCKS CREATE_BYTES BLOCK_SIZE
---------- ---------------- ------------ ---------- ---------- ------- ---------- ---------- ---------- ------------ ----------
NAME
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 388351 26-MAY-12 3 1 ONLINE READ WRITE 1.0737E+10 1310720 20971520 8192
+DATA/lixora/tempfile/temp.283.784277305
2 6324358667 18-MAY-15 10 1 ONLINE READ WRITE 83886080 10240 83886080 8192
/u01/app/oracle/product/10.2.0/db_1/dbs/D:oraclefcdataLIXORATEMP.DBF
SQL> alter database tempfile '/u01/app/oracle/product/10.2.0/db_1/dbs/D:oraclefcdataLIXORATEMP.DBF' offline;
Database altered.
SQL> alter database tempfile '/u01/app/oracle/product/10.2.0/db_1/dbs/D:oraclefcdataLIXORATEMP.DBF' drop;
Database altered.
SQL> select * from v$tempfile;
FILE# CREATION_CHANGE# CREATION_TIM TS# RFILE# STATUS ENABLED BYTES BLOCKS CREATE_BYTES BLOCK_SIZE
---------- ---------------- ------------ ---------- ---------- ------- ---------- ---------- ---------- ------------ ----------
NAME
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 388351 26-MAY-12 3 1 ONLINE READ WRITE 1.0737E+10 1310720 20971520 8192
+DATA/lixora/tempfile/temp.283.784277305
SQL> show parameter db_crea
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest string +DATA
db_create_online_log_dest_1 string
db_create_online_log_dest_2 string
db_create_online_log_dest_3 string
db_create_online_log_dest_4 string
db_create_online_log_dest_5 string
SQL> select * from v$tablespace;
TS# NAME INC BIG FLA ENC
---------- ------------------------------ --- --- --- ---
0 SYSTEM YES NO YES
1 UNDOTBS1 YES NO YES
2 SYSAUX YES NO YES
4 USERS YES NO YES
3 TEMP NO NO YES
5 UNDOTBS2 YES NO YES
7 SYS_YYXT YES NO YES
6 SYS_JKXT YES NO YES
8 LIXORA YES NO YES
9 LIXORADATA YES NO YES
10 LIXORATEMP NO NO YES
11 rows selected.
SQL> alter tablespace LIXORATEMP add tempfile '+DATA' size 100m autoextend on;
Tablespace altered.
SQL> select * from v$tempfile;
FILE# CREATION_CHANGE# CREATION_TIM TS# RFILE# STATUS ENABLED BYTES BLOCKS CREATE_BYTES BLOCK_SIZE
---------- ---------------- ------------ ---------- ---------- ------- ---------- ---------- ---------- ------------ ----------
NAME
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 388351 26-MAY-12 3 1 ONLINE READ WRITE 1.0737E+10 1310720 20971520 8192
+DATA/lixora/tempfile/temp.283.784277305
2 6629906774 04-AUG-15 3 2 ONLINE READ WRITE 104857600 12800 104857600 8192
+DATA/lixora/tempfile/temp.1592.886865983
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
----數據文件遷移到 rac asm 存儲上:
這裡提供2個方法: rman cp;dbms_file_transfer.copy_file 【plsql 包 直接拷貝
SQL> select file_name, tablespace_name ,bytes/1024/1024/1024 from dba_data_files where tablespace_name='LIXORA';
FILE_NAME
--------------------------------------------------------------------------------
TABLESPACE_NAME BYTES/1024/1024/1024
------------------------------ --------------------
/u01/app/oracle/product/10.2.0/db_1/dbs/D:oraclefcdataLIXORA.DBF
LIXORA .0390625
SQL> select file_name, tablespace_name ,bytes/1024/1024/1024 from dba_data_files where tablespace_name='LIXORADATA';
FILE_NAME
--------------------------------------------------------------------------------
TABLESPACE_NAME BYTES/1024/1024/1024
------------------------------ --------------------
/u01/app/oracle/product/10.2.0/db_1/dbs/D:oraclefcdataLIXORADATA.DBF
LIXORADATA .3515625
create directory test1 as '/u01/app/oracle/product/10.2.0/db_1/dbs/';
create directory test2 as '+DATA/lixora/datafile/';
alter tablespace LIXORA offline;
alter tablespace LIXORADATA offline;
exec dbms_file_transfer.copy_file('TEST1','D:oraclefcdataLIXORA.DBF','TEST2','LIXORA.DBF');
exec dbms_file_transfer.copy_file('TEST1','D:oraclefcdataLIXORADATA.DBF','TEST2','LIXORADATA.DBF');
alter database rename file '/u01/app/oracle/product/10.2.0/db_1/dbs/D:oraclefcdataLIXORA.DBF' to '+DATA/lixora/datafile/LIXORA.DBF';
alter database rename file '/u01/app/oracle/product/10.2.0/db_1/dbs/D:oraclefcdataLIXORADATA.DBF' to '+DATA/lixora/datafile/LIXORADATA.DBF';
alter tablespace LIXORA online;
alter tablespace LIXORADATA online;
++++++++++++++++++++++++++++rman copy ++++++++++++++++++++++++++++
RMAN>
sql "alter tablespace LIXORA offline";
sql "alter tablespace LIXORADATA offline";
RMAN>
copy datafile '/u01/app/oracle/product/10.2.0/db_1/dbs/D:oraclefcdataLIXORA.DBF' to '+DATA/lixora/datafile/LIXORA.DBF';
copy datafile '/u01/app/oracle/product/10.2.0/db_1/dbs/D:oraclefcdataLIXORADATA.DBF' to '+DATA/lixora/datafile/LIXORADATA.DBF';
SQL>
alter database rename file '/u01/app/oracle/product/10.2.0/db_1/dbs/D:oraclefcdataLIXORA.DBF' to '+DATA/lixora/datafile/LIXORA.DBF';
alter database rename file '/u01/app/oracle/product/10.2.0/db_1/dbs/D:oraclefcdataLIXORADATA.DBF' to '+DATA/lixora/datafile/LIXORADATA.DBF';
SQL>
alter tablespace LIXORA online;
alter tablespace LIXORADATA online;
總結:
開發人員嚴重缺乏對oracle 數據庫(單機,rac)的了解,當然這個也是管理上的疏忽;
從另一個方面也可以看出,業務用戶權限管理太粗狂,過於簡單粗暴,需要好好審計,規劃下;
具體其他的就不想再多說了。。。。。。。