顯示具有 cds 標籤的文章。 顯示所有文章
顯示具有 cds 標籤的文章。 顯示所有文章

2017年10月17日 星期二

CDS 7 版掛載 oracle db and recovery

--MAXDATAFILES

在  /act/act_scripts/oracleclone/Clone_generateCtrlFileScript.sh
裡面指定了 MAXDATAFILES=4000
每次更新完要手動改這個script 不然掛主資料庫的時候一定會死掉

掛載完之後,主要的SCRIPT是 AppMount.sh

要處理的部分:

SGA底下的參數要拿掉
在 no mount 下 re-create control file
recover



./Clone_generateCtrlFileScript.sh hisspx /act/mnt/Job_3769585_mountpoint_1508134264362/datafile /act/mnt/Job_3769585_mountpoint_1508134264362/



chown oracle10:dba /act/mnt/Job_3769585_mountpoint_1508134264362/hisspx

f7n3:/act/act_scripts/oracleclone> ./recoverRman.sh /act/mnt/Job_3769585_mountpoint_1508134264362/ hisspx




SQL> startup nomount pfile='/act/mnt/Job_3769585_mountpoint_1508134264362/inithisspx.ora';
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> @/act/act_scripts/oracleclone/Clone_createCtrlFile_hisspx_g.sql;

Control file created.

SQL>



SQL> alter database open read only;
alter database open read only
*
ERROR at line 1:
ORA-16008: indeterminate control file checkpoint

SQL> alter database open resetlogs;

Database altered.

SQL>



Step By Step

Application Manager 選擇要使用的 APP , 選擇 Restore , 選擇要掛的版本,選擇 mount

選擇 storage pool 擺在比較空的地方

選擇 mount point (不選的話會放在 /act/mnt/JobXXXXXX )

選擇要掛的 HOST  <-- 注意不要選錯

選 App Aware Mount

填 sid , username , ORACLE_HOME , TNS_ADMIN , DB MEM , SGA% ,

Redo / shared_pool / db_cache , db_recovery_fiel_dest_size 都填 100
( 不填值的話會抓 backup pfile 裡的值,碰到比較小的機器就會炸)

跑完以後

f7n3:/> sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.4.0 - Production on Tue Oct 17 15:33:40 2017

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Connected to an idle instance.

沒起來 看看原因

SQL> startup;
ORA-00821: Specified value of sga_target 4112M is too small, needs to be at least 31024M
SQL>

SGA不夠大...

到掛載點下找 pfile

*.db_keep_cache_size=32212254720
*.log_buffer=62914560
*.sort_area_size=1024000
*.shared_pool_size=100m
*.db_cache_size=100m
*.db_recovery_file_dest='/hisspx/flash_recovery_area/hisspx'
*.db_recovery_file_dest_size=100m

把這些抓掉

然後指定 pfile 重開看看

SQL> startup pfile=/hisspx/inithisspx.ora;
ORACLE instance started.

Total System Global Area 4311744512 bytes
Fixed Size                  2089576 bytes
Variable Size             805309848 bytes
Database Buffers         3489660928 bytes
Redo Buffers               14684160 bytes
ORA-00205: error in identifying control file, check alert log for more info

找不到 control file ...
翻一下 pfile 看看 control file 在哪裡...

*.control_files='/hisspx/admin/hisspx/control/control01.ctl','/hisspx/admin/hisspx/control/control02.ctl'

f7n3:/hisspx> ls -alh /hisspx/admin/hisspx/control/             
total 0
drwxr-xr-x  2 oracle10 dba 256 2017-10-17 15:30 .
drwxr-xr-x  6 oracle10 dba 256 2017-10-17 15:30 ..
f7n3:/hisspx>

空的 -_____-

因為要抓 control file 就挫塞了 所以現在應該是在 no mount 模式

在  /act/act_scripts/oracleclone  底下有一個  Clone_generateCtrlFileScript.sh 
是用來長 control file 用的.

參考了一下 OracleAppMount.sh  這隻的使用方式應該是

./Clone_generateCtrlFileScript.sh $nsid $backupdir $ORACLE_BASE"/oradata"

nsid 是新的 db 的 SID ,  第二個參數應該是備份目錄的掛載點 , 
第三個參數好像是用來長 redo 用的 , redo會長在  $BASEDIR/$SID/redo*.log
--> oracle owner 要對 redo 所在的位置有讀寫權 不然 redo 會 create fail .

所以 
f7n3:/act/act_scripts/oracleclone> ./Clone_generateCtrlFileScript.sh hisspx /hisspx /hisspx/oradata

----
修正一下 第二個參數是用來找備份的 datafile 用的 ,要告訴它 datafile 所在的位置

f7n3:/act/act_scripts/oracleclone> ./Clone_generateCtrlFileScript.sh hisspx /hisspx/datafile /hisspx/oradata
----
跑完之後會長出一個 Clone_createCtrlFile_hisspx_g.sql
內容就是 recreate control  file

CREATE CONTROLFILE SET DATABASE hisspx RESETLOGS ......之類的

回到 sqlplus 下,因為現在是在 no mount mode ,所以可以直接

SQL> @Clone_createCtrlFile_hisspx_g.sql

Control file created.

SQL> 

來開開看

SQL> startup pfile=/hisspx/inithisspx.ora;
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL>

SQL> alter database open read only;
alter database open read only
*
ERROR at line 1:
ORA-16008: indeterminate control file checkpoint

SQL>

好像需要 recovrey 的樣子
再回到 /act/act_scripts/oracleclone  有一隻 recoverRman.sh 看起來是用來 recover 用的

需要兩個參數 備份掛載點 跟 新的DB的SID

./recoverRman.sh /hisspx hisspx

log 檔會寫在   dbrecover.txt  裡,可以 tail 看現在的進度

f7n3:/act/act_scripts/oracleclone> id
uid=206(oracle10) gid=205(dba) groups=202(spadmin)
f7n3:/act/act_scripts/oracleclone> export ORACLE_SID=hisspx
f7n3:/act/act_scripts/oracleclone> ./recoverRman.sh /hisspx hisspx
******* recovering database *********** 
run { catalog start with '/hisspx/archivelog' noprompt; recover database; }
RMAN> 2> 3> 4> 5> RMAN> f7n3:/act/act_scripts/oracleclone>

channel ORA_DISK_1: restore complete, elapsed time: 00:00:16
archive log filename=/hisspx/admin/hisspx/archivelog/1_811335_766335352.dbf thread=1 sequence=811335
archive log filename=/hisspx/admin/hisspx/archivelog/1_811336_766335352.dbf thread=1 sequence=811336
archive log filename=/hisspx/admin/hisspx/archivelog/1_811337_766335352.dbf thread=1 sequence=811337
archive log filename=/hisspx/admin/hisspx/archivelog/1_811338_766335352.dbf thread=1 sequence=811338
unable to find archive log
archive log thread=1 sequence=811339
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 10/17/2017 16:22:33
RMAN-06054: media recovery requesting unknown log: thread 1 seq 811339 lowscn 177120294171

RMAN> 

Recovery Manager complete.

跑到後來還是會有錯 不過也沒有後面的 archive log 可以用了。 直接 reset 吧

--BTW, 這時候應已經是 mount mode 了

SQL> alter database open resetlogs;  

Database altered.

SQL>alter system register;



TODO: 應該可以找一下 script 把炸的地方改掉
然後每隻 agent 都要去改一下....


補

在 nid_hisspx.log 發現 open_cursors 不足造成 change dbid fail

ORA-01000: maximum open cursors exceeded

由於desktop 在 7.0.3 沒有指定這個參數的功能

原廠建議手動加 alter system set open_cursors=1000 scope=both;

在 OracleAppMountComFunc.sh 有個 change_dbid 的 function

看起來是在用 nid 做 change dbid 的動作 先加在那邊看看

** 其實這個參數好像有寫在 pfile 裡,應該也可以在一開始用 sed 做 pfile 的時候就抓掉。

** 看起來是在每個檔案 change dbid 的時候炸的 如果每個檔案同時需要開 一個 cursor 那應該要改到跟 MAXFILES 一樣大...




2017/10/20 測試,好像可以開起來,不過 recover 就跑了快一個小時...
大約整趟跑完要 90min左右 ,  paging 會吃到快25%