轉載請註明出處css
客戶數據庫存儲空間接近存滿,需購置一臺新的存儲,進行數據遷移,客戶容許少許停機時間。
利用ASM rebalance 進行遷移
能夠實現0宕機進行遷移,過程簡單,但遷移時間週期太長。python
利用rman copy進行遷移
須要少許停機時間,遷移時間短,過程複雜。sql
結合客戶的需求,最終採用的是rman copy進行存儲遷移。數據庫
運行如下sql命令bash
SET PAGES 1000
SET LINES 1000
COL PATH FOR A30
SELECT A.GROUP_NUMBER,
B.NAME ASM_NAME,
A.NAME DISK_NAME,
A.FAILGROUP,
A.PATH,
B.TYPE,
A.TOTAL_MB,
A.FREE_MB
FROM V$ASM_DISK A, V$ASM_DISKGROUP B
WHERE A.GROUP_NUMBER = B.GROUP_NUMBER;
存儲工程師安照需求劃分存儲,並採用多路徑軟件。 略
根據不一樣的操做系統,使用不一樣的方法進行綁定。 綁定過程略
備份包括ocr、votedisk
# ocrconfig -manualbackup --手工備份 (需root用戶) # ocrconfig -showbackup --查看備份 # ocrconfig -restore <filename> --恢復ocr
11G 中只需只需上面的命令,就能同時備份ocr與voteoracle
利用asmca命令建立如下diskgroup: ocrdg --存放ocr與vote newdata --存放數據文件
添加ocr信息至ocrdg上(root用戶) # ocrconfig -add +OCRDG 檢查ocr # ocrcheck 查看votedisk信息(grid用戶) $ crsctl query css votedisk 遷移votedisk(grid用戶) $ crsctl replace votedisk +OCRDG
SQL> create pfile='/home/grid/asmspfile.ora' from spfile;
SQL> create spfile='+OCRDG' from pfile='/home/grid/asmspfile.ora';
SQL> create pfile='/home/oracle/orcl_pfile.ora' from spfile='+DATADG/orcl/spfileorcl.ora';
SQL> create spfile='+NEWDATA' from pfile='/home/oracle/orcl_pfile.ora';
SQL> select ''''||file_name||'''' from dba_data_files;
$ vi rman_copy.sh
----------
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=orcl1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
rman target / nocatalog log=/tmp/rman_copy.log<<EOF
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
copy
datafile '+DATADG/orcl/datafile/system.259.874699969' to '+NEWDATA',
datafile '+DATADG/orcl/datafile/sysaux.260.874699995' to '+NEWDATA',
datafile '+DATADG/orcl/datafile/undotbs1.261.874700013' to '+NEWDATA',
datafile '+DATADG/orcl/datafile/undotbs2.263.874700041' to '+NEWDATA',
datafile '+DATADG/orcl/datafile/users.264.874700049' to '+NEWDATA';
}
EOF
rman target / nocatalog log=/tmp/rman_copy.log append <<EOF
copy current controlfile to '+NEWDATA';
EOF
--賦予執行權限
$ chmod +x rman_copy.sh
ASMCD> cd +newdata/orcl/CONTROLFILE
ASMCMD> ls
Backup.261.960651757
ASMCMD> cp Backup.261.960651757 control01.dbf
ASMCMD> cp Backup.261.960651757 control02.dbf
#control_files:
SQL> alter system set control_files='+newdata/orcl/CONTROLFILE/control01.dbf','+newdata/orcl/CONTROLFILE/control02.dbf' scope=spfile;
#db_create_file_dest
SQL> alter system set db_create_file_dest='+NEWDATA' SCOPE=SPFILE;
#archive:
SQL> alter system set log_archive_dest_1='LOCATION=+NEWDATA'
中止數據庫
$ srvctl stop database -d orcl
啓動至mount狀態
$ srvctl start database -d orcl -o mount SQL> show parameter control_files
數據文件
SQL> alter database rename file '+DATADG/orcl/datafile/sysaux.260.874699995' to '+newdata/orcl/datafile/SYSAUX.258.960651703';
SQL> alter database rename file '+DATADG/orcl/datafile/system.259.874699969' to '+newdata/orcl/datafile/SYSTEM.256.960651621';
SQL> alter database rename file '+DATADG/orcl/datafile/undotbs1.261.874700013' to '+newdata/orcl/datafile/UNDOTBS1.257.960651621';
SQL> alter database rename file '+DATADG/orcl/datafile/undotbs2.263.874700041' to '+newdata/orcl/datafile/UNDOTBS2.259.960651707';
SQL> alter database rename file '+DATADG/orcl/datafile/users.264.874700049' to '+newdata/orcl/datafile/USERS.260.960651735';
temp文件
SQL> alter database rename file '+DATADG/orcl/tempfile/temp.262.874700019' to '+newdata';
$ rman target / RMAN> recover database;
SQL> alter database open resetlogs;
--增長redo日誌組
alter database add logfile thread 1 group 5 '+Newdata' size 50m;
alter database add logfile thread 1 group 6 '+Newdata' size 50m;
alter database add logfile thread 2 group 7 '+Newdata' size 50m;
alter database add logfile thread 2 group 8 '+Newdata' size 50m;
--刪除redo日誌組
select GROUP#,status from v$log;
當status狀態爲inactive和unused狀態時能夠刪除。
alter database drop logfile group 4;
alter database drop logfile group 2;
alter database drop logfile group 1;
alter database drop logfile group 3;
$ srvctl modify database -d orcl -n orcl -p +NEWDATA/orcl/spfileorcl.ora
$ srvctl modify database -d orcl -n orcl -a NEWDATA
$ srvctl stop database -d orcl
$ srvctl start database -d orcl
--刪除原OCR,vote磁盤組
# ocrconfig -delete +CRSDG
# ocrcheck
確認信息
# crsctl query css votedisk
--dismount disk(每一個節點)
$ sqlplus / as sysasm
SQL> ALTER DISKGROUP CRSDG DISMOUNT;
SQL> alter diskgroup DATADG dismount;
--drop disk(任一節點執行)
$ sqlplus / as sysasm
SQL> drop diskgroup CRSDG force including contents;
SQL> drop diskgroup DATADG force including contents;
--delete resource(任一節點執行)
$ crsctl delete resource ora.NEWOCR.dg
$ crsctl delete resource ora.DATADG.dg