通過HP 3PAR存儲底層快照技術,快速啟動測試數據庫
#基於HP 3Par快照同步技術的數據庫快速復制
生產集群數據庫,通過存儲底層復制技術生成快照數據,利用快照數據,可以將數據庫快速打開,新的數據庫可以用於測試,恢復等用途。
下面是啟動快速數據庫的具體步驟,底層復制操作由存儲廠家完成。
-
確認主機環境信息
fgscrmdb#[/]machinfo fgscrmdb#[/]hostname
- 檢查3Par存儲掛載情況 (root)
fgscrmdb#[/]3parinfo -i
Device File Name Size [MB]
==================================================
/dev/rdisk/disk213 1024
/dev/rdisk/disk214 1024
/dev/rdisk/disk215 1024
/dev/rdisk/disk216 1024
/dev/rdisk/disk217 512000
/dev/rdisk/disk218 512000
/dev/rdisk/disk220 512000
/dev/rdisk/disk221 512000
/dev/rdisk/disk222 512000
/dev/rdisk/disk223 512000
/dev/rdisk/disk224 512000
/dev/rdisk/disk225 512000
/dev/rdisk/disk227 512000
/dev/rdisk/disk228 512000
/dev/rdisk/disk229 512000
/dev/rdisk/disk230 512000
/dev/rdisk/disk231 512000
/dev/rdisk/disk232 512000
/dev/rdisk/disk233 512000
/dev/rdisk/disk234 512000
/dev/rdisk/disk235 512000
/dev/rdisk/disk236 512000
/dev/rdisk/disk237 512000
/dev/rdisk/disk238 512000
/dev/rdisk/disk239 512000
/dev/rdisk/disk240 512000
/dev/rdisk/disk241 512000
/dev/rdisk/disk242 512000
/dev/rdisk/disk243 512000
/dev/rdisk/disk244 512000
/dev/rdisk/disk245 512000
/dev/rdisk/disk246 512000
/dev/rdisk/disk247 512000
/dev/rdisk/disk248 512000
/dev/rdisk/disk249 512000
/dev/rdisk/disk250 512000
/dev/rdisk/disk251 512000
/dev/rdisk/disk252 512000
/dev/rdisk/disk253 512000
/dev/rdisk/disk254 512000
/dev/rdisk/disk255 512000
/dev/rdisk/disk256 512000
/dev/rdisk/disk257 512000
/dev/rdisk/disk258 512000
/dev/rdisk/disk259 512000
/dev/rdisk/disk260 512000
/dev/rdisk/disk261 512000
/dev/rdisk/disk262 512000
3. 修改3Par存儲磁盤屬組和權限 (root)
fgscrmdb#[/]3parinfo -i | grep pubdb | awk ‘{print "chown grid:asmadmin "$1}‘ > /tmp/3pardisk.pubdb.chown
fgscrmdb#[/]3parinfo -i | grep pubdb | awk ‘{print "chmod 660 "$1}‘ > /tmp/3pardisk.pubdb.chmod
fgscrmdb#[/]sh /tmp/3pardisk.pubdb.chown
fgscrmdb#[/]sh /tmp/3pardisk.pubdb.chmod
4. grid用戶進行ASM磁盤組磁盤發現掃描
grid@fgscrmdb:[/home/grid]kfod a=‘/dev/rdisk/*‘ disks=all ds=true o=all
Disk Size Path
========================================
1: 1024 Mb /dev/rdisk/disk212
2: 1024 Mb /dev/rdisk/disk213
3: 1024 Mb /dev/rdisk/disk214
4: 1024 Mb /dev/rdisk/disk215
5: 1024 Mb /dev/rdisk/disk216
6: 512000 Mb /dev/rdisk/disk217
7: 512000 Mb /dev/rdisk/disk218
8: 512000 Mb /dev/rdisk/disk219
9: 512000 Mb /dev/rdisk/disk220
10: 512000 Mb /dev/rdisk/disk221
11: 512000 Mb /dev/rdisk/disk222
12: 512000 Mb /dev/rdisk/disk223
13: 512000 Mb /dev/rdisk/disk224
14: 512000 Mb /dev/rdisk/disk225
15: 512000 Mb /dev/rdisk/disk226
16: 512000 Mb /dev/rdisk/disk227
17: 512000 Mb /dev/rdisk/disk228
18: 512000 Mb /dev/rdisk/disk229
19: 512000 Mb /dev/rdisk/disk230
20: 512000 Mb /dev/rdisk/disk231
21: 512000 Mb /dev/rdisk/disk232
22: 512000 Mb /dev/rdisk/disk233
23: 512000 Mb /dev/rdisk/disk234
24: 512000 Mb /dev/rdisk/disk235
25: 512000 Mb /dev/rdisk/disk236
26: 512000 Mb /dev/rdisk/disk237
27: 512000 Mb /dev/rdisk/disk238
28: 512000 Mb /dev/rdisk/disk239
29: 512000 Mb /dev/rdisk/disk240
30: 512000 Mb /dev/rdisk/disk241
31: 512000 Mb /dev/rdisk/disk242
32: 512000 Mb /dev/rdisk/disk243
33: 512000 Mb /dev/rdisk/disk244
34: 512000 Mb /dev/rdisk/disk245
35: 512000 Mb /dev/rdisk/disk246
36: 512000 Mb /dev/rdisk/disk247
37: 512000 Mb /dev/rdisk/disk248
38: 512000 Mb /dev/rdisk/disk249
39: 512000 Mb /dev/rdisk/disk250
40: 512000 Mb /dev/rdisk/disk251
41: 512000 Mb /dev/rdisk/disk252
42: 512000 Mb /dev/rdisk/disk253
43: 512000 Mb /dev/rdisk/disk254
44: 512000 Mb /dev/rdisk/disk255
45: 512000 Mb /dev/rdisk/disk256
46: 512000 Mb /dev/rdisk/disk257
47: 512000 Mb /dev/rdisk/disk258
48: 512000 Mb /dev/rdisk/disk259
49: 512000 Mb /dev/rdisk/disk260
50: 512000 Mb /dev/rdisk/disk261
51: 512000 Mb /dev/rdisk/disk262
ORACLE_SID ORACLE_HOME
+ASM /grid/app/11.2.0.4/grid
5. grid用戶進行新增磁盤組掛載
grid@fgscrmdb:[/home/grid]sqlplus / as sysasm
SQL> alter diskgroup PUBDBDATA_DG mount;
SQL> alter diskgroup YYDBADATA_DG mount;
SQL> alter diskgroup YYDBBDATA_DG mount;
6. 檢查crs資源中磁盤組信息
grid@fgscrmdb:[/home/grid]crsctl stat res -t
NAME TARGET STATE SERVER STATE_DETAILS
Local Resources
ora.FGSCRM_OCRDG.dg
ONLINE ONLINE fgscrmdb
ora.LISTENER.lsnr
ONLINE ONLINE fgscrmdb
ora.PUBDBDATA_DG.dg
ONLINE ONLINE fgscrmdb
ora.YYDBADATA_DG.dg
ONLINE ONLINE fgscrmdb
ora.YYDBBDATA_DG.dg
ONLINE ONLINE fgscrmdb
ora.asm
ONLINE ONLINE fgscrmdb Started
ora.ons
OFFLINE OFFLINE fgscrmdb
grid@fgscrmdb:[/home/grid]sqlplus / as sysasm
SQL> show parameter asm;
NAME TYPE VALUE
asm_diskgroups string PUBDBDATA_DG, YYDBADATA_DG, YY
DBBDATA_DG
asm_diskstring string /dev/rdisk/disk*
7. 創建原有生產數據庫的pfile文件並調整參數值
grid@fgscrmdb:[/home/grid]asmcmd
ASMCMD> find --type PARAMETERFILE ./ *
+PUBDBDATA_DG/PUBDB/PARAMETERFILE/spfile.267.923089341
+PUBDBDATA_DG/PUBDB/spfilepubdb.ora
+YYDBADATA_DG/YYDBA/PARAMETERFILE/spfile.267.923058269
+YYDBADATA_DG/YYDBA/spfileyydba.ora
+YYDBBDATA_DG/YYDBB/PARAMETERFILE/spfile.267.923059267
+YYDBBDATA_DG/YYDBB/spfileyydbb.ora
ASMCMD> cp +PUBDBDATA_DG/PUBDB/spfilepubdb.ora /tmp
copying +PUBDBDATA_DG/PUBDB/spfilepubdb.ora -> /tmp/spfilepubdb.ora
ASMCMD> cp +YYDBADATA_DG/YYDBA/spfileyydba.ora /tmp
copying +YYDBADATA_DG/YYDBA/spfileyydba.ora -> /tmp/spfileyydba.ora
ASMCMD> cp +YYDBBDATA_DG/YYDBB/spfileyydbb.ora /tmp
copying +YYDBBDATA_DG/YYDBB/spfileyydbb.ora -> /tmp/spfileyydbb.ora
oracle@fgscrmdb:[/home/oracle]cd $ORACLE_HOME/dbs
oracle@fgscrmdb:[/oracle/app/oracle/11.2.0.4/db_1/dbs]cp /tmp/*.ora ./
oracle@fgscrmdb:[/oracle/app/oracle/11.2.0.4/db_1/dbs]strings spfilepubdb.ora > initpubdb.ora
oracle@fgscrmdb:[/oracle/app/oracle/11.2.0.4/db_1/dbs]vi initpubdb.ora
#以__開頭的參數為數據庫記錄的動態參數,這些內容可以刪除
._gby_hash_aggregation_enabled=FALSE
._gc_policy_time=0
._high_priority_processes=‘VKTM|LMS|LGWR‘
._memory_imm_mode_without_autosga=FALSE
._optim_peek_user_binds=FALSE
._optimizer_adaptive_cursor_sharing=FALSE
._optimizer_cartesian_enabled=FALSE
._optimizer_extended_cursor_sharing=‘NONE‘
._optimizer_extended_cursor_sharing_rel=‘NONE‘
._optimizer_use_feedback=FALSE
._PX_use_large_pool=TRUE
._undo_autotune=FALSE
._use_adaptive_log_file_sync=‘FALSE‘
.audit_trail=‘db‘
.commit_logging=‘BATCH‘
.compatible=‘11.2.0.4.0‘
.control_files=‘+PUBDBDATA_DG/pubdb/controlfile/current.345.930096785‘#Restore Controlfile
.db_block_size=8192
.db_create_file_dest=‘+PUBDBDATA_DG‘
.db_domain=‘‘
.db_files=10000
.db_name=‘pubdb‘
.deferred_segment_creation=FALSE
.diagnostic_dest=‘/oracle/app/oracle‘
.dispatchers=‘(PROTOCOL=TCP) (SERVICE=pubdbXDB)‘
.event=‘28401 TRACE NAME CONTEXT FOREVER, LEVEL 1:10949 TRACE NAME CONTEXT FOREVER‘
.fast_start_parallel_rollback=‘HIGH‘
.open_cursors=1000
.parallel_force_local=TRUE
.processes=8000
.recyclebin=‘OFF‘
.remote_login_passwordfile=‘exclusive‘
.session_cached_cursors=500
.sessions=1655
*.undo_retention=10800
#需要進行調整的參數,cluster_database需要改為FALSE
*.cluster_database=FALSE
#需要註意創建必要的目錄結構
*.audit_file_dest=‘/oracle/app/oracle/admin/pubdb/adump‘
#需要刪除的參數
.log_archive_dest_1=‘LOCATION=+PUBDBARCH_DG‘
.remote_listener=‘pubdb-scan:1521‘
#與實例相關的參數需要進行修改,刪除節點2的內容,並修改節點1的值為
.instance_number=1
.thread=1
.undo_tablespace=‘UNDOTBS1‘
#內存參數需要進行調整
.sga_max_size=100G
.sga_target=0
.db_cache_size=60G
.shared_pool_size=20G
.large_pool_size=2G
.pga_aggregate_target=20G
8. 創建必要的目錄
`oracle@fgscrmdb:[/oracle/app/oracle/11.2.0.4/db_1/dbs]mkdir -p /oracle/app/oracle/admin/pubdb/adump`
9. 創建口令文件
`oracle@fgscrmdb:[/oracle/app/oracle/11.2.0.4/db_1/dbs]orapwd file=orapwpubdb password=08080808`
10. 調整oracle可執行程序權限,不調整權限的情況下,oracle用戶無法訪問磁盤組內容
oracle@fgscrmdb:[/oracle/app/oracle/11.2.0.4/db_1/bin]ls -la oracle
-rwsr-s--x 1 oracle oinstall 574113064 Mar 9 09:41 oracle
oracle@fgscrmdb:[/home/oracle]su - grid
grid@fgscrmdb:[/home/grid]cd $ORACLE_HOME/bin
grid@fgscrmdb:[/grid/app/11.2.0.4/grid/bin]./setasmgidwrap o=/oracle/app/oracle/11.2.0.4/db_1/bin/oracle
grid@fgscrmdb:[/grid/app/11.2.0.4/grid/bin]ls -la /oracle/app/oracle/11.2.0.4/db_1/bin/oracle
-rwsr-s--x 1 oracle asmadmin 574113064 Mar 9 09:41 /oracle/app/oracle/11.2.0.4/db_1/bin/oracle
11. 創建spfile參數文件,啟動實例進行測試 (先通過pfile啟動進行驗證,正確後,創建spfile,並用spfile重啟數據庫實例)
oracle@fgscrmdb:[/oracle/app/oracle/11.2.0.4/db_1/dbs]rm spfilepubdb.ora
oracle@fgscrmdb:[/oracle/app/oracle/11.2.0.4/db_1/dbs]export ORACLE_SID=pubdb
SQL> startup nomount;
SQL> create spfile from pfile;
SQL> startup force nomount;
SQL> alter database mount;
SQL> alter database noarchivelog;
SQL> alter database open;
SQL> shutdown immediate;
12. 註冊數據庫資源
-d <db_unique_name> Unique name for the database
-n <db_name> Database name (DB_NAME), if different from the unique name given by the -d option
-o <oracle_home> ORACLE_HOME path
-p <spfile> Server parameter file path
-a "<diskgroup_list>" Comma separated list of disk groups
oracle@fgscrmdb:[/home/oracle]srvctl add database -d pubdb -n pubdb -o $ORACLE_HOME -p $ORACLE_HOME/dbs/spfilepubdb.ora
oracle@fgscrmdb:[/home/oracle]srvctl config database -d pubdb
13. 測試通過集群啟停數據庫資源
oracle@fgscrmdb:[/home/oracle]srvctl start database -d pubdb
oracle@fgscrmdb:[/home/oracle]crsctl stat res -t
通過HP 3PAR存儲底層快照技術,快速啟動測試數據庫