###sample
1. 首先确定本地文件系统(存放备份集)足够大,可以使用如下语句查询当前数据库实际的使用总大小
Rman 备份进度:
select sum("已使用空间(M)") from
(
SELECT Upper(F.TABLESPACE_NAME) "表空间名",
D.TOT_GROOTTE_MB "表空间大小(M)",
D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空间(M)",
To_char(Round(( D.TOT_GROOTTE_MB - F.TOTAL_BYTES ) / D.TOT_GROOTTE_MB * 100, 2), ‘990.99‘)
|| ‘%‘ "使用比",
F.TOTAL_BYTES "空闲空间(M)",
F.MAX_BYTES "最大块(M)"
FROM (SELECT TABLESPACE_NAME,
Round(Sum(BYTES) / ( 1024 * 1024 ), 2) TOTAL_BYTES,
Round(Max(BYTES) / ( 1024 * 1024 ), 2) MAX_BYTES
FROM SYS.DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) F,
(SELECT DD.TABLESPACE_NAME,
Round(Sum(DD.BYTES) / ( 1024 * 1024 ), 2) TOT_GROOTTE_MB
FROM SYS.DBA_DATA_FILES DD
GROUP BY DD.TABLESPACE_NAME) D
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME
ORDER BY 1)
2. 开始在本地备份,备份目录需要自定义如/oracle/10g/backup
Rman target /
CONFIGURE DEVICE TYPE DISK PARALLELISM 4 BACKUP TYPE TO BACKUPSET;
2.1 将备份存放为脚本 backup.sh
man trace reco1.log <<eof
connect target /
run{
allocate channel c1 type disk format ‘/oracle/10g/backup/%U‘;
BACKUP INCREMENTAL LEVEL 0 DATABASE;
BACKUP ARCHIVELOG ALL;
backup current controlfile for standby;
}
exit
eof
2.2 oracle用户后台执行
Nohup sh backup.sh &
2.3.检查备份的进度:
SELECT SID,
SERIAL#,
CONTEXT,
SOFAR,
TOTALWORK,
ROUND(SOFAR / TOTALWORK * 100, 2)
"%_COMPLETE"
FROM gV$SESSION_LONGOPS
WHERE OPNAME LIKE ‘RMAN%‘ AND OPNAME NOT LIKE ‘%aggregate%‘ AND
TOTALWORK != 0 AND SOFAR <> TOTALWORK;
3. 在本地创建pfile 文件(/tmp/dba/pfile.ora),使用生产的参数文件,检查以下参数是否要随着DG库实际环境调整
audit_file_dest, background_dump_dest, control_files, core_dump_dest, log_archive_dest_1, user_dump_dest, local_listener, log_archive_config, db_unique_name, control_files, fal_client etc
sqlplus / as sysdba
SQL> create pfile=‘/tmp/dba/pfile.ora‘ from spfile;
File created.
4.
4.1 移动备份片和参数文件到新的主机,最好能新主机(DG) 和旧主机使用相同的目录。
(还有一种简单的方法,使用存储映射的方法,在新主机重新挂在相同的NAS device)
scp pfile.ora root@58.2.104.11:/tmp/dba
4.2 移动密码文件到新主机 DG
Cd $ORACLE_HOME/dbs
scp orapwcore* root@58.2.104.11:/tmp/dba
登陆新主机DG,修改文件权限为oracle用户,并且移动到对应目录
Cd /tmp/dba
chown opcore:oinstall *
su – opcore
cd /tmp/dba
cp orapwcore* $ORACLE_HOME/dbs
cp pfile.ora $ORACLE_HOME/dbs/initcore1.ora
5.编辑新主机DG库的tnsnames.ora (在$ORACLE_HOME/network/admin 目录下)
参考旧主机的tnsname.ora 加入网络信息,方便新主机 DG传日志
6. 新主机上使用上面创建的 pfile 启动新主机(DG) 上的数据库
sqlplus "/ as sysdba"
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size
1218292 bytes
Variable Size 62916876 bytes
Database Buffers 96468992 bytes
Redo Buffers 7168000
bytes
7. 恢复备库的控制文件
(RMAN>backup current controlfile for standby format ‘备份路径‘;) for primary
7.1
旧主机上备份 for standby
RMAN>backup current controlfile format ‘/tmp/dba/standby.ctl’;
cd /tmp/dba
scp standby.ctl root@58.2.104.11:/tmp/dba
7.2
新主机DG上恢复控制文件
备库重启到nomount状态,恢复控制文件,启动到mount
RMAN>restore standby controlfile from ‘/tmp/dba/standby.ctl ‘
SQL>alter database mount standby database;
8. 新主机检查可以用来恢复的归档日志文件
export NLS_DATE_FORMAT=‘YYYY-MM-DD HH24:MI:SS‘;
(RMAN> list backup of archivelog all)
RMAN>list backup of archivelog time between "to_date(‘2019-03-01 00:00:00‘,‘yyyy-mm-dd,hh24:mi:ss‘)" and "to_date(‘2019-03-01 06:00:00‘,‘yyyy-mm-dd hh24:mi:ss‘)";
检查所有重做线程的最后一个存档序列, 并选择其中有 "下一个 scn(Next SCN)" 的最小存档序列。如38833,
选择完最小的存档序列,使用38833+1
(Device Type DISK)
Thrd Seq Low SCN Low Time Next SCN Next Time
1 38833 114944541420 2019-03-01 00:38:59 114944807665 2019-03-01 00:41:40
2 38198 114944543989 2019-03-01 00:39:01 114945682491 2019-03-01 00:55:11
9.新主机准备restore.sh
###以下脚本是用来 将数据文件 指向新主机的新目录的拼凑
set linesize 999 linesize 999 head off feedback off
select ‘set newname for datafile ‘||‘‘||FILE#||‘‘||‘ to ‘||chr(39)||replace(name,‘+NEW_DATA/rcore/datafile‘,‘+NEW_DATA/rcore_new/datafile‘)||‘‘||‘.dbf‘‘;‘ from v$datafile;
spool off
10.在新环境下运行resotore.sh
10.1 resotore.sh (ASM的路径都要与db_uniq_name 一样,如果不一样,创建目录将会失败)
rman target / log=‘/tmp/rcore_new.log‘ <<EOF
run{
sql ‘alter session set NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"‘;
set until sequence 38834 thread 1;
set newname for datafile 1 to ‘+NEW_DATA/rcore_new/datafile/system.422.983499857.dbf;
set newname for datafile 2 to ‘+NEW_DATA/rcore_new/datafile/undotbs1.454.983492257.dbf;
……
restore database;
switch datafile all;
switch tempfile all;
recover database;
release channel ch00;
}
EOF
10,2 运行
Nohup sh resotore.sh &
10.3 观察恢复的进度
SELECT SID,
SERIAL#,
CONTEXT,
SOFAR,
TOTALWORK,
ROUND(SOFAR / TOTALWORK * 100, 2)
"%_COMPLETE"
FROM gV$SESSION_LONGOPS
WHERE OPNAME LIKE ‘RMAN%‘ AND OPNAME NOT LIKE ‘%aggregate%‘ AND
TOTALWORK != 0 AND SOFAR <> TOTALWORK;
11.恢复完成之后,rename online_log
11.1 生成rename 脚本
set linesize 999 linesize 999 head off feedback off
select ‘alter database rename file ‘||‘‘‘‘||member||‘‘‘‘||‘ to ‘||chr(39)||replace(member,‘+NEW_FRA/rcore/onlinelog‘,‘+NEW_FRA/rcore_new/onlinelog‘)||‘‘‘;‘ from v$logfile;
spool off
11.2 After renaming the redolog files, the database can be opened
SQL> select member from v$logfile;
SQL>@rename_log.sql
SQL> alter database open
附录:手工挂载NAS device in AIX
umount /bakfs
1.mount 格式 (for ORA-27054 ERRORS WHEN RUNNING RMAN WITH NFS) FOR AIX and NAS device
mount -F nfs -o cio,rw,bg,hard,nointr,rsize=32768,wsize=32768,proto=tcp,noac,vers=3,timeo=600 "nas.sw1.crb":/ifs/data/bak /bakfs
2.数据库参数设置 (只是在当前实例级别生效,重启instance丢失):(for ORA-27054 ERRORS WHEN RUNNING RMAN WITH NFS)FOR AIX
alter system set events ‘10298 trace name context forever, level 32‘;
3.change to asynch to directio, for (RMAN-00600 [8083], LFI-00005 Free some memory failed in lfibrdt(), LFI-00004 Call to lfibgl() failed) AIX and NAS device
SQL> show parameter filesystemio_options
NAME
------------------------------------
TYPE
----------------------------------------------------------------
VALUE
------------------------------
filesystemio_options
string
asynch
alter system set filesystemio_options=directio scope=spfile;
4. ORA-19870: error reading backup piece (for restore in ASM disk issue)
export ORACLE_SID=+ASM1
show parameter shared_pool_size
show parameter large_pool
show parameter db_cache_size
edit init+ASM1.ora
shared_pool_size = 5G
large_pool_size = 1G
db_cache_size = 1G
sga_max_size=8192M
processes=70
sessions=80
( Increase the PROCESSES parameter in the ASM parameter file
Processes = 25 + 15n, where n is the number of instances on the box using ASM for their storage.)
5.
ORA-19870: error reading backup piece /bakfs/rman/CORE_LVL0_20190228_pgtr15p1_s88880_p1
ORA-19504: failed to create file "+NEW_DATA/core/datafile/rb_data01.dbf.dbf"
ORA-17502: ksfdcre:4 Failed to create file +NEW_DATA/core/datafile/rb_data01.dbf.dbf
ORA-15173: entry ‘core‘ does not exist in directory ‘/‘
ASM 只能自动创建跟db_uniq_name相同的目录。
Change restore.sh 脚本
附录:
https://blog.csdn.net/hw_libo/article/details/6878885
本文的目的就是在紧急状态下,需要立即终止正在进行的RMAN备份进程。
(1)查看RMAN分配的各个通道的进程号
SQL> SELECT sid, spid, client_info
FROM v$process p, v$session s
WHERE p.addr = s.paddr
AND client_info LIKE ‘%rman%‘;
SID SPID CLIENT_INFO
---------- ------------------------ -------------------------
525 26244 rman channel=t1
1023 26245 rman channel=t2
699 26246 rman channel=t3
(2)根据第(1)中得到的进程号,终止RMAN备份
注:这里既要kill 掉RMAN备份脚本的PID,也要kill 掉RMAN中分配的各个通道的PID
subsdb1:~ # ps -ef | grep 26244
oracle 26244 26224 7 17:12 ? 00:01:49 oraclesubsdb (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
root 9877 9603 0 17:34 pts/11 00:00:00 grep 26244
subsdb1:~ # kill -9 26244
subsdb1:~ # ps -ef | grep 26245
oracle 26245 26224 5 17:12 ? 00:01:13 oraclesubsdb (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
root 9968 9603 0 17:35 pts/11 00:00:00 grep 26245
subsdb1:~ # kill -9 26245
subsdb1:~ # ps -ef | grep 26246
oracle 26246 26224 4 17:12 ? 00:01:03 oraclesubsdb (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
root 10009 9603 0 17:35 pts/11 00:00:00 grep 26246
subsdb1:~ # kill -9 26246
subsdb1:~ # ps -ef | grep rman
oracle 26224 25962 0 17:11 pts/3 00:00:03 rman target / nocatalog
root 10061 9603 0 17:35 pts/11 00:00:00 grep rman
subsdb1:~ # kill -9 26224
subsdb1:~ # ps -ef | grep rman
root 10102 9603 0 17:36 pts/11 00:00:00 grep rman
subsdb1:~ # ps -ef | grep 26246
root 10213 9603 0 17:36 pts/11 00:00:00 grep 26246
此时RMAN备份操作已经被终止。查看(1)中的SQL语句时,结果为空。
说明:如果单单kill掉RMAN的进程号,那么RMAN备份并没有停止,而是要连channel进程也一起掉才可以!
---------------------
作者:bosco1986
来源:CSDN
原文:https://blog.csdn.net/hw_libo/article/details/6878885
版权声明:本文为博主原创文章,转载请附上博文链接!
2.
v$asm_disk Shows FREE_MB as 0 After Datafiles/Tablespaces Dropped
v$asm_disk shows FREE_MB as 0MB for all the disks which are part of the affected diskgroup.
When executed check all norepair on the diskgroup. it shows Warning messages as Disk directory mismatch on the disks.
===
Thu May 29 19:04:57 2014
SQL> /* ASMCMD */ALTER DISKGROUP P0302_DG_FLASH CHECK NOREPAIR
NOTE: starting check of diskgroup P0302_DG_FLASH
Thu May 29 18:04:58 2014
GMON checking disk 1 for group 2 at 13 for pid 35, osid 14440
NOTE: disk P0302_ASMDISK009, used AU total mismatch: DD={4294966447, 0} AT={216, 0} >>>
SUCCESS: check of diskgroup P0302_DG_FLASH found no errors
SUCCESS: /* ASMCMD */ALTER DISKGROUP P0302_DG_FLASH CHECK NOREPAIR
Thu May 29 19:05:35 2014
SQL> /* ASMCMD */ALTER DISKGROUP P0302_DG_FLASH CHECK NOREPAIR
NOTE: starting check of diskgroup P0302_DG_FLASH
Thu May 29 18:05:35 2014
GMON checking disk 1 for group 2 at 14 for pid 35, osid 14440
NOTE: disk P0302_ASMDISK009, used AU total mismatch: DD={4294966447, 0} AT={216, 0}
SUCCESS: check of diskgroup P0302_DG_FLASH found no errors
SUCCESS: /* ASMCMD */ALTER DISKGROUP P0302_DG_FLASH CHECK NOREPAIR
There is a mismatch between used space in the disk directory and the actual used space. This is a known issue in pre 11.2 asm-compatible diskgroups (where Used Space Directory does not exist). This is possible because we batch the update to used space in disk directory. So, if we perform allocations/de-allocations during rebalance, we will run into this. We created USD to fix this. Unfortunately, it cannot be backported.
The fix for that created USD. It cannot be backported. Users will have to advance the compatibility of the diskgroup to 11.2 to ensure that this will not happen again.
Bug 8451024 - V$ASM_DISK REPORTS ZERO FOR FREE SPACE : SPACE MISMATCH FOR ALL DISKS
Base Bug 5077325 - FREESPACE LIST TO TRACK THE FREE SPACE IN AN ASM DISK
NOTE: Similar issue occurs using ASMCMD as well. If any of the files / directories deleted using "rm -rf" command in a diskgroup at asm command prompt will lead to this issue having diskgroup compatibility pre 11.2.
Initially run the check all repair to fix the issue.
Login to ASM instance, Run the below command
SQL> ALTER DISKGROUP <DG_NAME> CHECK ALL REPAIR;
原文:https://www.cnblogs.com/feiyun8616/p/10456138.html