Locations of visitors to this page

Friday, February 27, 2009

sqlplus hangs on infinite calling times(null)

sqlplus hangs on infinite calling times(null)



输入sqlplus回车没有反映,strace sqlplus跟踪发现在不停地调用times(NULL)

这是sqlplus 10.2.0.1的BUG, 在linux x86系统上如果运行时间大于249天就会发生
Bug 4612267 - OCI client spins when machine uptime >= 249 days
OCI clients may spin once the machine has been up for longer than
249 days (24.9 days on some machines).
The spin will show repeated calls to times() from sltrgatime64().

SQL*Plus 10.2.0.1 Hangs, When System Uptime Is Long Period of Time

补丁:OCI CLIENT IS IN AN INFINITE LOOP WHEN MACHINE UPTIME HITS 248 DAYS
或升级到10.2.0.2及以后版本

-fin-

Thursday, February 26, 2009

prevent remote login as sysdba - 禁止SYSDBA远程登录

prevent remote login as sysdba - 禁止SYSDBA远程登录




1.删除密码文件禁止sysdba登录

remote_login_passwordfile参数是EXCLUSIVE
且存在密码文件orapw
SQL> show parameter remote_login_passwordfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
remote_login_passwordfile            string      EXCLUSIVE
SQL> !ls -l $ORACLE_HOME/dbs/orapw$ORACLE_SID
-rw-r-----  1 oracle oinstall 2048 Feb 25 06:46 /home/oracle/app/oracle/product/10.2/dbs/orapwtest

SQL>

删除密码文件
SQL> !mv $ORACLE_HOME/dbs/orapw$ORACLE_SID $ORACLE_HOME/dbs/orapw$ORACLE_SID.old

SQL> !ls -l $ORACLE_HOME/dbs/orapw$ORACLE_SID*
-rw-r-----  1 oracle oinstall 2048 Feb 25 06:46 /home/oracle/app/oracle/product/10.2/dbs/orapwtest.old

SQL>

sysdba,sysoper不能远程登录了
SQL> conn sys/change_on_install@mgt:1541/test as sysdba
ERROR:
ORA-01031: insufficient privileges


SQL> conn sys/change_on_install@mgt:1541/test as sysoper
ERROR:
ORA-01031: insufficient privileges


SQL>

可以操作系统认证登录
SQL> conn / as sysdba
Connected.
SQL>



2.用orapwd的nosysdba选项禁止sysdba登录

orapwd重新创建密码文件, 密码不变, 加上nosysdba=y选项
[oracle@MGT ~]$ orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=change_on_install entries=5 force=y nosysdba=y
[oracle@MGT ~]$

禁止sysdba远程登录, 但允许本地sysdba登录(操作系统认证)和远程sysoper登录
SQL> conn sys/manager@mgt:1541/test as sysdba
ERROR:
ORA-01017: invalid username/password; logon denied


SQL> conn / as sysdba
Connected.
SQL> conn sys/manager@mgt:1541/test as sysoper
ERROR:
ORA-01017: invalid username/password; logon denied


Warning: You are no longer connected to ORACLE.
SQL>


3.设置remote_login_passwordfile禁止sysdba登录

重建密码文件
[oracle@MGT ~]$ orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=change_on_install entries=5 force=y
[oracle@MGT ~]$
可以连接sysdba
SQL> conn sys/change_on_install@mgt:1541/test as sysdba
Connected.
SQL>


设置remote_login_passwordfile=none, 重启数据库
alter system set remote_login_passwordfile=none scope=spfile;
SQL> conn / as sysdba
Connected.
SQL> alter system set remote_login_passwordfile=none scope=spfile;

System altered.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  419430400 bytes
Fixed Size                  2084392 bytes
Variable Size             251658712 bytes
Database Buffers          159383552 bytes
Redo Buffers                6303744 bytes
Database mounted.
Database opened.
SQL> show parameter remote_login_passwordfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
remote_login_passwordfile            string      NONE
SQL>

sysdba连接失败
SQL> conn sys/change_on_install@mgt:1541/test as sysdba
ERROR:
ORA-01017: invalid username/password; logon denied


Warning: You are no longer connected to ORACLE.
SQL> conn sys/change_on_install@mgt:1541/test as sysoper
ERROR:
ORA-01017: invalid username/password; logon denied


SQL>


恢复设置
SQL> conn / as sysdba
Connected.
SQL> alter system set remote_login_passwordfile=exclusive scope=spfile;

System altered.

SQL>
需要重启数据库


4. 修改密码散列值
alter user sys identified by values ... 将sys用户密码散列修改为一个不存在的值
SQL> conn sys/change_on_install@test as sysdba
Connected.
SQL> select username,password from dba_users where username='SYS';

USERNAME   PASSWORD
---------- ------------------------------
SYS        D4C5016086B2DC6A

SQL> alter user sys identified by values '1234567890123456';

User altered.

SQL> conn sys/change_on_install@test as sysdba
ERROR:
ORA-01017: invalid username/password; logon denied


Warning: You are no longer connected to ORACLE.
SQL> conn / as sysdba
Connected.
SQL> alter user sys identified by values 'D4C5016086B2DC6A';

User altered.

SQL>





外部链接:
Database Administrator Security and Privileges
Disable Remote SYSDBA Connections
ORA-1031 When Connecting Remotely AS SYSDBA
Why Can I Login AS SYSDBA With any Username and Password?
How to Set up the Oracle Password File
SYSDBA and SYSOPER Privileges in Oracle
Problem - REMOTE_LOGIN_PASSWORDFILE Policy Violation when remote_login_password_file Parameter is set to 'EXCLUSIVE'
Remote login as Sysdba to Oracle database server




-fin-

setting kernel parameters for oracle - 设置内核参数

setting kernel parameters for oracle - 设置内核参数



安装oracle前设置shmmax, shmall等内核参数

shmmax表示每个共享内存段的最大字节数
如果Oracle数据库实例SGA的大小大于shmmax, 将会分配多个共享内存段. 为了使整个SGA在同一个共享内存段中分配, 这样貌似性能好些, shmmax应当足够大, 可以设置为大于或等于SGA大小
参考TECH: Unix Semaphores and Shared Memory Explained中Shared memory allocation的介绍

shmall表示系统全局最多可以使用的共享内存的大小, 以页为单位
显然这个参数必须大于SGA, 因为可能其它程序也要用共享内存, 可以设置为等于或接近于物理内存大小
用getconf PAGE_SIZE查看页大小
[root@DEV-Blur-DB-1 ~]# getconf PAGE_SIZE
4096
[root@DEV-Blur-DB-1 ~]#

shmmni系统中最多共享内存段的数量, 缺省值是4096, 对于大多数系统应该够用了


查看目前设置的值
[root@DEV-Blur-DB-1 ~]# cat /proc/sys/kernel/shmmni
4096
[root@DEV-Blur-DB-1 ~]# cat /proc/sys/kernel/shmall
4294967296
[root@DEV-Blur-DB-1 ~]# cat /proc/sys/kernel/shmmax
68719476736

[root@DEV-Blur-DB-1 ~]# ipcs -lm

------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 67108864
max total shared memory (kbytes) = 17179869184
min seg size (bytes) = 1

[root@DEV-Blur-DB-1 ~]# echo $((67108864*1024))



头文件中设置的缺省值
less /usr/include/linux/shm.h
...
/*
 * SHMMAX, SHMMNI and SHMALL are upper limits are defaults which can
 * be increased by sysctl
 */

#define SHMMAX 0x2000000                 /* max shared seg size (bytes) */
#define SHMMIN 1                         /* min shared seg size (bytes) */
#define SHMMNI 4096                      /* max num of segs system wide */
#define SHMALL (SHMMAX/PAGE_SIZE*(SHMMNI/16)) /* max shm system wide (pages) */
#define SHMSEG SHMMNI                    /* max shared segs per process */

...

centos 5.2 中/etc/sysctl.conf重新设置了shmmax, shmall等缺省值, 增加了其大小
less /etc/sysctl.conf
...
# Controls the maximum shared segment size, in bytes
kernel.shmmax = 68719476736

# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 4294967296

...
shmmax 64G,shmall 16T, 比物理内存还大很多, 完全满足数据库要求, 不用再修改啦




外部链接:
Tuning and Optimizing Red Hat Enterprise Linux for Oracle 9i and 10g Databases
Installing Oracle Database 10g Release 2 on Linux - (RHEL 5)
linux / unix kernel parameters
Oracle® Database on AIX®,HP-UX®,Linux®,Mac OS® X,Solaris®,Tru64 Unix® Operating Systems Installation and Configuration Requirements Quick Reference (8.0.5 to 11.1)
Linux: How to Check Current Shared Memory, Semaphore Values

TECH: Unix
Semaphores and Shared Memory Explained



Relationship Between Common Init.ora Parameters and Unix Kernel Parameters
maxfiles - Soft file limit per process.
maxuprc - Maximum number of simultaneous user processes per userid.
nfile - Maximum number of simultaneously open files systemwide at any given time.
nproc - Maximum number of processes that can exist simultaneously in the system.
shmmax - The maximum size(in bytes) of a single shared memory segment.
shmmin - The minimum size(in bytes) of a single shared memory segment.
shmmni - The number of shared memory identifiers.
shmseg - The maximum number of shared memory segments that can be attached by a process.
semmns - The number of semaphores in the system.
semmni - The number of semaphore set identifiers in the system; determines the number of semaphore sets that can be created at any one time.
semmsl - The maximum number of sempahores that can be in one semaphore set. It should be same size as maximum number of Oracle processes.

-fin-

Tuesday, February 24, 2009

remote listener - 远程监听器

remote listener



配置远程监听器

远程监听器将客户端的连接重新定向(re-direct)到数据库服务器上的本地监听器

1.
数据库服务器上启一个本地监听器
grep -q "^LISTENER_LOCAL" $ORACLE_HOME/network/admin/listener.ora || \
cat >>$ORACLE_HOME/network/admin/listener.ora <<'EOF'
LISTENER_LOCAL =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = 1541)))
    )
  )
EOF
lsnrctl start LISTENER_LOCAL
[oracle@MGT ~]$ lsnrctl start LISTENER_LOCAL

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 24-FEB-2009 12:00:52

Copyright (c) 1991, 2007, Oracle.  All rights reserved.

Starting /home/oracle/app/oracle/product/10.2/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.4.0 - Production
System parameter file is /home/oracle/app/oracle/product/10.2/network/admin/listener.ora
Log messages written to /home/oracle/app/oracle/product/10.2/network/log/listener_local.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=MGT.s3lab.mot.com)(PORT=1541)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1541)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_LOCAL
Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date                24-FEB-2009 12:00:52
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/app/oracle/product/10.2/network/admin/listener.ora
Listener Log File         /home/oracle/app/oracle/product/10.2/network/log/listener_local.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=MGT.s3lab.mot.com)(PORT=1541)))
The listener supports no services
The command completed successfully
[oracle@MGT ~]$

tail -f $ORACLE_HOME/network/log/listener_local.log



2.
另找一台机器作为监听器服务器, 用来监听远程数据库
grep -q "^LISTENER_REMOTE" $ORACLE_HOME/network/admin/listener.ora || \
cat >>$ORACLE_HOME/network/admin/listener.ora <<'EOF'
LISTENER_REMOTE =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = 1531)))
    )
  )
EOF
lsnrctl start LISTENER_REMOTE
[oracle@DEV-RPT-2 ~]$ lsnrctl start LISTENER_REMOTE

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 24-FEB-2009 12:03:35

Copyright (c) 1991, 2007, Oracle.  All rights reserved.

Starting /home/oracle/app/oracle/product/10.2/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.4.0 - Production
System parameter file is /home/oracle/app/oracle/product/10.2/network/admin/listener.ora
Log messages written to /home/oracle/app/oracle/product/10.2/network/log/listener_remote.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DEV-RPT-2.s3lab.mot.com)(PORT=1531)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1531)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_REMOTE
Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date                24-FEB-2009 12:03:35
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/app/oracle/product/10.2/network/admin/listener.ora
Listener Log File         /home/oracle/app/oracle/product/10.2/network/log/listener_remote.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DEV-RPT-2.s3lab.mot.com)(PORT=1531)))
The listener supports no services
The command completed successfully
[oracle@DEV-RPT-2 ~]$

tail -f $ORACLE_HOME/network/log/listener_remote.log


3.
在数据库上配置本地/远程监听器参数
alter system set local_listener="(address=(protocol=tcp)(host=MGT.s3lab.mot.com)(port=1541))";
alter system set remote_listener="(address=(protocol=tcp)(host=DEV-RPT-2.s3lab.mot.com)(port=1531))";
SQL> alter system set local_listener="(address=(protocol=tcp)(host=MGT.s3lab.mot.com)(port=1541))";

System altered.

SQL> alter system set remote_listener="(address=(protocol=tcp)(host=DEV-RPT-2.s3lab.mot.com)(port=1531))";

System altered.

SQL>

在远程监听器服务器上显示
24-FEB-2009 12:04:26 * service_register * test * 0
24-FEB-2009 12:05:26 * service_update * test * 0
24-FEB-2009 12:05:38 * service_update * test * 0

查看监听器状态, 已经注册上了
lsnrctl status listener_remote
lsnrctl service listener_remote
[oracle@DEV-RPT-2 ~]$ lsnrctl status LISTENER_REMOTE

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 24-FEB-2009 12:14:06

Copyright (c) 1991, 2007, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1531)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_REMOTE
Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date                24-FEB-2009 12:03:35
Uptime                    0 days 0 hr. 10 min. 31 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/app/oracle/product/10.2/network/admin/listener.ora
Listener Log File         /home/oracle/app/oracle/product/10.2/network/log/listener_remote.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DEV-RPT-2.s3lab.mot.com)(PORT=1531)))
Services Summary...
Service "test" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
Service "test_XPT" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@DEV-RPT-2 ~]$ lsnrctl service LISTENER_REMOTE

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 24-FEB-2009 12:14:08

Copyright (c) 1991, 2007, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1531)))
Services Summary...
Service "test" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (address=(protocol=tcp)(host=MGT.s3lab.mot.com)(port=1541))
Service "test_XPT" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         REMOTE SERVER
         (address=(protocol=tcp)(host=MGT.s3lab.mot.com)(port=1541))
The command completed successfully
[oracle@DEV-RPT-2 ~]$


本地监听器显示:
24-FEB-2009 12:05:46 * service_register * test * 0
24-FEB-2009 12:14:02 * service_update * test * 0

监听器状态
[oracle@MGT ~]$ lsnrctl status listener_local

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 24-FEB-2009 12:12:57

Copyright (c) 1991, 2007, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1541)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_LOCAL
Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date                24-FEB-2009 12:00:52
Uptime                    0 days 0 hr. 12 min. 5 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/app/oracle/product/10.2/network/admin/listener.ora
Listener Log File         /home/oracle/app/oracle/product/10.2/network/log/listener_local.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=MGT.s3lab.mot.com)(PORT=1541)))
Services Summary...
Service "test" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
Service "test_XPT" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@MGT ~]$ lsnrctl service listener_local

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 24-FEB-2009 12:13:05

Copyright (c) 1991, 2007, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1541)))
Services Summary...
Service "test" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
Service "test_XPT" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
The command completed successfully
[oracle@MGT ~]$


4.
客户端通过远程监听器连接远程的数据库
conn kitty/kitty@DEV-RPT-2:1531/test
SQLL> conn kitty/kitty@DEV-RPT-2:1531/test
Connected.
SQLL>
远程监听器重定向(re-direct)了客户端的连接
实际上, 客户端最终连的还是数据库所在服务器上的监听器



外部链接:
How To Configure a Dispatcher or Instance to Register Against a Remote Listener
Init.ora Parameter "REMOTE_LISTENER" Reference Note
How To Set Up a 9i Database to Contact a Remote Listener
Conntinuing question "Remote Listener Registration"



-fin-

clearing nfs locks on netapp - 清除NetApp上NFS的锁

clearing nfs locks on netapp - 清除NetApp上NFS的锁



startup启动数据库时报错:
Tue Feb 24 09:18:15 2009
ORA-00202: control file: '/home/oracle/app/oracle/oradata/test/control01.ctl'
ORA-27086: unable to lock file - already in use
Linux-x86_64 Error: 11: Resource temporarily unavailable
Additional information: 8
因为文件建在netapp的nfs上, 怀疑是nfs的资源出了问题
查询google, 应该是数据库非正常关闭或网络意外中断, 导致nfs上的锁没有释放


关闭数据库, 卸载
shutdown immediate
umount /u02/oem_db

登录netapp存储, 释放锁
ssh root@LabNetapp1-A
priv set advanced
lock status -h
sm_mon -l MGT
lock status -h
LabNetapp1-A> priv set advanced
Warning: These advanced commands are potentially dangerous; use
         them only when directed to do so by Network Appliance
         personnel.
LabNetapp1-A*> lock status -h
======== NLM host MGT
13620 0x00099d9a:0xdf04c35c 0:0 1 GRANTED (0xc0000004327d94b8)
13620 0x00099dab:0xdf04c35c 0:0 1 GRANTED (0xc0000004327d9398)
13620 0x00099d99:0xdf04c35c 0:0 1 GRANTED (0xc0000004327d9278)
13620 0x00099da5:0xdf04c35c 0:0 1 GRANTED (0xc0000004327d9158)
13620 0x00099d9c:0xdf04c35c 0:0 1 GRANTED (0xc0000004327d9038)
13620 0x00099da9:0xdf04c35c 0:0 1 GRANTED (0xc00000042f68fed8)
13620 0x00099d9b:0xdf04c35c 0:0 1 GRANTED (0xc00000042f68fdb8)
13620 0x00109d14:0xdf04c35c 0:0 1 GRANTED (0xc00000042f68fc98)
13620 0x00099da4:0xdf04c35c 0:0 1 GRANTED (0xc00000042f68fa58)
13624 0x00109d13:0xdf04c35c 0:0 1 GRANTED (0xc00000042f68f938)
13624 0x00099d9d:0xdf04c35c 0:0 1 GRANTED (0xc00000042f68f818)
13624 0x00099d9e:0xdf04c35c 0:0 1 GRANTED (0xc00000042f68f6f8)
======== NLM host DEV-DB-2
...

LabNetapp1-A*> sm_mon -l MGT
Tue Feb 24 09:59:20 GMT [LabNetapp1-A: nsm.notify.no.address:error]: no address for host "MGT"
运行完sm_mon -l, 全部锁被清除

启数据库
mount /u02/oem_db
startup
成功


据说删除原来控制文件, 再拷个新的也可以跳过被锁文件. 没有验证过





外部链接:
ORA-01157 ORA-01110 ORA-27086 after crash prevents database from opening
Clearing NFS locks during network crash or outage for Oracle datafiles (需要netapp账号)
ORA-1157 ORA-1110 ORA-27086 Starting up Database


-fin-

Friday, February 20, 2009

generate random string - 产生随机字符串

generate random string - 产生随机字符串



提问: 如何产生随机字符串?

回答: 用dbms_random.string(opt, len)

第一个参数表示字符的类型, 可以是:
'u', 'U' - returning string in uppercase alpha characters 产生大写字符
'l', 'L' - returning string in lowercase alpha characters 产生小写字符
'a', 'A' - returning string in mixed case alpha characters 产生大小写混合字符
'x', 'X' - returning string in uppercase alpha-numeric characters 产生大写字母和数字混合字符
'p', 'P' - returning string in any printable characters. 产生所有可打印的字符(ASCII编码从32-126)
Otherwise the returning string is in uppercase alpha characters. 默认产生大写字符

第二个参数是字符串的长度


举例:
生成12到16个字符长度的包含大小写英文字母和数字的字符串
substr(translate(dbms_random.string('P', 1000)
                 ,'A~!@#$%^&*()_+=-`{}|\][:;"''?/>.<, '
                 ,'A')
       ,1,dbms_random.value(12,16+1))
首先生成一堆可显字符, 再删除其它特殊字符, 得到的就只有大小写和数字了
而且生成了1000个字符, 这样保证删除后的字符串长度也能够满足要求(12-16)
删除字符串使用的是translate函数, 比如translate('12345','a32','a')删除字符'2'和'3'


select substr(translate(dbms_random.string('P', 1000)
                        ,'A~!@#$%^&*()_+=-`{}|\][:;"''?/>.<, '
                        ,'A')
              ,1,dbms_random.value(12,16+1))
  from all_objects
 where rownum <= 10;
SQL> select substr(translate(dbms_random.string('P', 1000)
                        ,'A~!@#$%^&*()_+=-`{}|\][:;"''?/>.<, '
                        ,'A')
              ,1,dbms_random.value(12,16+1))
  from all_objects
 where rownum <= 10;
  2    3    4    5    6
SUBSTR(TRANSLATE(DBMS_RANDOM.STRING('P',1000),'A~!@#$%^&*()_+=-`{}|\][:;"''?/>.<,','A'),1,DBMS_RANDOM.VALUE(12,16+1))
--------------------------------------------------------------------------------------------------------------------------------------------
XQzByZYj33KVS
IyjBGqGPbwT0
dZtwIWc7Iw2y
SFMpCzfdsOJnB4
V0lZTKKhjDwbiV
xQr1bUz5FmmHnQv
HLbfMpxwTkTw
p1wij3yRCsBexU1z
UdiXMgPEzrvN8FC
c57XveMzreePm

10 rows selected.

SQL>




产生随机数字:

产生16位随机数字
select to_char(round(dbms_random.value(0,9999999999999999)),'FM0999999999999999') from dual;

select substr(translate(dbms_random.string('X', 1000)
                        ,'-ABCDEFGHIJKLMNOPQRSTUVWXYZ'
                        ,'-')
              ,1,16)
  from dual;





外部连接:
DBMS_RANDOM
ASCII



-fin-

Thursday, February 19, 2009

create standby database using rman - 使用RMAN创建备用数据库

create standby database using rman - 使用RMAN创建备用数据库




用RMAN, 不用DUPLICATE创建备库

1. 备库配置初始化参数文件

主库上生成参数文件
mkdir -p /u01/software/oracle/backup/DEV-RPT-2/test/rman/
sqlplus -s /nolog <<'EOF'
conn / as sysdba
create pfile='/u01/software/oracle/backup/DEV-RPT-2/test/rman/spbakcup.ora' from spfile;
exit
EOF
cat /u01/software/oracle/backup/DEV-RPT-2/test/rman/spbakcup.ora
[oracle@DEV-RPT-2 ~]$ mkdir -p /u01/software/oracle/backup/DEV-RPT-2/test/rman/
[oracle@DEV-RPT-2 ~]$ sqlplus -s /nolog <<'EOF'
> conn / as sysdba
> create pfile='/u01/software/oracle/backup/DEV-RPT-2/test/rman/spbakcup.ora' from spfile;
> exit
> EOF

File created.

[oracle@DEV-RPT-2 ~]$ cat /u01/software/oracle/backup/DEV-RPT-2/test/rman/spbakcup.ora
test.__db_cache_size=1862270976
test.__java_pool_size=16777216
test.__large_pool_size=16777216
test.__shared_pool_size=218103808
test.__streams_pool_size=0
*.archive_lag_target=1800
*.audit_file_dest='/home/oracle/app/oracle/admin/test/adump'
*.audit_sys_operations=TRUE
*.audit_trail='db_extended'
*.background_dump_dest='/home/oracle/app/oracle/admin/test/bdump'
*.compatible='10.2.0.4.0'
*.control_file_record_keep_time=30
*.control_files='/home/oracle/app/oracle/oradata/test/control01.ctl','/home/oracle/app/oracle/oradata/test/control02.ctl','/home/oracle/app/oracle/oradata/test/control03.ctl'
*.core_dump_dest='/home/oracle/app/oracle/admin/test/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='test'
*.db_recovery_file_dest='/home/oracle/app/oracle/oradata/test/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.fast_start_mttr_target=300
*.filesystemio_options='setall'
*.job_queue_processes=10
*.license_max_sessions=500
*.license_sessions_warning=150
*.log_archive_dest_1='LOCATION=/home/oracle/app/oracle/oradata/test/archive'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_format='%t_%s_%r.arc'
*.open_cursors=3000
*.pga_aggregate_target=50m
*.processes=1500
*.remote_login_passwordfile='EXCLUSIVE'
*.resource_limit=true
*.session_cached_cursors=200
*.sessions=1655
*.sga_target=2147483648
*.undo_management='AUTO'
*.undo_retention=10800
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/home/oracle/app/oracle/admin/test/udump'
*.utl_file_dir='/home/oracle/app/oracle/oradata/test/utlfile'
[oracle@DEV-RPT-2 ~]$

在备库上修改/增加参数db_unique_name, instance_name, db_file_name_convert, standby_archive_dest等

db_name必须跟主库一样

db_unique_name='test_s'
10g以前用lock_name_space

instance_name='test_s'

db_file_name_convert='/home/oracle/app/oracle/oradata/test/','/home/oracle/app/oracle/oradata/test_s/'
log_file_name_convert='/home/oracle/app/oracle/oradata/test/','/home/oracle/app/oracle/oradata/test_s/'
9i及以后可以转换多个文件名, 如 db_file_name_convert='/primary/dir1','/standby/dir1','/primary/dir2','/standby/dir2',...

standby_archive_dest='/home/oracle/app/oracle/oradata/test_s/archive'
跟log_archive_dest_1一致

mkdir -p /data/oracle/app/oracle/oradata/test_s/{archive,flash_recovery_area,utlfile}
mkdir -p /data/oracle/app/oracle/admin/test_s/{a,b,c,u,dp}dump
cat <<'EOF' |sed -f - /u01/software/oracle/backup/DEV-RPT-2/test/rman/spbakcup.ora >$ORACLE_HOME/dbs/inittest_s.ora
/test\.__/d
s/*\.//
/ˆdb_name/!s|/test/|/test_s/|g
$a \
db_unique_name='test_s'\
instance_name='test_s'\
db_file_name_convert='/home/oracle/app/oracle/oradata/test/','/home/oracle/app/oracle/oradata/test_s/'\
log_file_name_convert='/home/oracle/app/oracle/oradata/test/','/home/oracle/app/oracle/oradata/test_s/'\
standby_archive_dest='/home/oracle/app/oracle/oradata/test_s/archive'\
EOF
cat $ORACLE_HOME/dbs/inittest_s.ora
[oracle@DEV-pxy-1 ~]$ mkdir -p /data/oracle/app/oracle/oradata/test_s/{archive,flash_recovery_area,utlfile}
[oracle@DEV-pxy-1 ~]$ mkdir -p /data/oracle/app/oracle/admin/test_s/{a,b,c,u,dp}dump
[oracle@DEV-pxy-1 ~]$ cat <<'EOF' |sed -f - /u01/software/oracle/backup/DEV-RPT-2/test/rman/spbakcup.ora >$ORACLE_HOME/dbs/inittest_s.ora
> /test\.__/d
> s/*\.//
> /ˆdb_name/!s|/test/|/test_s/|g
> $a \
> db_unique_name='test_s'\
> instance_name='test_s'\
> db_file_name_convert='/home/oracle/app/oracle/oradata/test/','/home/oracle/app/oracle/oradata/test_s/'\
> log_file_name_convert='/home/oracle/app/oracle/oradata/test/','/home/oracle/app/oracle/oradata/test_s/'\
> standby_archive_dest='/home/oracle/app/oracle/oradata/test_s/archive'\
> EOF
[oracle@DEV-pxy-1 ~]$ cat $ORACLE_HOME/dbs/inittest_s.ora
archive_lag_target=1800
audit_file_dest='/home/oracle/app/oracle/admin/test_s/adump'
audit_sys_operations=TRUE
audit_trail='db_extended'
background_dump_dest='/home/oracle/app/oracle/admin/test_s/bdump'
compatible='10.2.0.4.0'
control_file_record_keep_time=30
control_files='/home/oracle/app/oracle/oradata/test_s/control01.ctl','/home/oracle/app/oracle/oradata/test_s/control02.ctl','/home/oracle/app/oracle/oradata/test_s/control03.ctl'
core_dump_dest='/home/oracle/app/oracle/admin/test_s/cdump'
db_block_size=8192
db_domain=''
db_file_multiblock_read_count=16
db_name='test'
db_recovery_file_dest='/home/oracle/app/oracle/oradata/test_s/flash_recovery_area'
db_recovery_file_dest_size=2147483648
fast_start_mttr_target=300
filesystemio_options='setall'
job_queue_processes=10
license_max_sessions=500
license_sessions_warning=150
log_archive_dest_1='LOCATION=/home/oracle/app/oracle/oradata/test_s/archive'
log_archive_dest_state_1='ENABLE'
log_archive_format='%t_%s_%r.arc'
open_cursors=3000
pga_aggregate_target=50m
processes=1500
remote_login_passwordfile='EXCLUSIVE'
resource_limit=true
session_cached_cursors=200
sessions=1655
sga_target=2147483648
undo_management='AUTO'
undo_retention=10800
undo_tablespace='UNDOTBS1'
user_dump_dest='/home/oracle/app/oracle/admin/test_s/udump'
utl_file_dir='/home/oracle/app/oracle/oradata/test_s/utlfile'
db_unique_name='test_s'
instance_name='test_s'
db_file_name_convert='/home/oracle/app/oracle/oradata/test/','/home/oracle/app/oracle/oradata/test_s/'
log_file_name_convert='/home/oracle/app/oracle/oradata/test/','/home/oracle/app/oracle/oradata/test_s/'
standby_archive_dest='/home/oracle/app/oracle/oradata/test_s/archive'

[oracle@DEV-pxy-1 ~]$



2. 备库创建密码文件

orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=change_on_install entries=5
密码跟主库相同

没有密码文件则会报错
Tue Feb 17 03:18:39 2009
Errors in file /home/oracle/app/oracle/admin/test/bdump/test_arc0_13704.trc:
ORA-01031: insufficient privileges
PING[ARC0]: Heartbeat failed to connect to standby 'test_s'. Error is 1031.


3. 启备库nomount

sqlplus -s /nolog <<'EOF'
conn / as sysdba
startup nomount
exit
EOF
lsnrctl status
[oracle@DEV-pxy-1 ~]$ sqlplus -s /nolog <<'EOF'
> conn / as sysdba
> startup nomount
> exit
> EOF
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size                  2085320 bytes
Variable Size             486542904 bytes
Database Buffers         1644167168 bytes
Redo Buffers               14688256 bytes
[oracle@DEV-pxy-1 ~]$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 16-FEB-2009 07:41:24

Copyright (c) 1991, 2007, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DEV-PXY-1)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date                15-JAN-2009 04:35:55
Uptime                    32 days 3 hr. 5 min. 29 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/app/oracle/product/10.2/network/admin/listener.ora
Listener Log File         /home/oracle/app/oracle/product/10.2/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DEV-pxy-1.s3lab.mot.com)(PORT=1521)))
Services Summary...
Service "s10" has 2 instance(s).
  Instance "s10", status UNKNOWN, has 1 handler(s) for this service...
  Instance "s10", status READY, has 1 handler(s) for this service...
Service "s10_XPT" has 1 instance(s).
  Instance "s10", status READY, has 1 handler(s) for this service...
Service "screen3" has 2 instance(s).
  Instance "screen3", status UNKNOWN, has 1 handler(s) for this service...
  Instance "screen3", status READY, has 1 handler(s) for this service...
Service "test_s" has 1 instance(s).
  Instance "test_s", status BLOCKED, has 1 handler(s) for this service...
Service "test_s_XPT" has 1 instance(s).
  Instance "test_s", status BLOCKED, has 1 handler(s) for this service...
The command completed successfully
[oracle@DEV-pxy-1 ~]$
备库是NOMOUNT状态, 所以是BLOCKED


4. 配置TNSNAME

主库配置TNSNAME
grep -q "ˆtest_s" $ORACLE_HOME/network/admin/tnsnames.ora || \
cat >>$ORACLE_HOME/network/admin/tnsnames.ora <<'EOF'
test_s =
  (DESCRIPTION =
    (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = DEV-pxy-1)(PORT = 1521)))
    (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = test_s))
  )

EOF
cat $ORACLE_HOME/network/admin/tnsnames.ora
[oracle@DEV-RPT-2 ~]$ grep -q "ˆtest_s" $ORACLE_HOME/network/admin/tnsnames.ora || \
> cat >>$ORACLE_HOME/network/admin/tnsnames.ora <<'EOF'
    (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = test_s))
  )
> test_s =
>   (DESCRIPTION =
>     (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = DEV-pxy-1)(PORT = 1521)))
>     (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = test_s))
>   )
>
> EOF
[oracle@DEV-RPT-2 ~]$ cat $ORACLE_HOME/network/admin/tnsnames.ora
em10 =
  (DESCRIPTION =
    (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = MGT)(PORT = 1521)))
    (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = em10))
  )

test =
  (DESCRIPTION =
    (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = 1521)))
    (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = test))
  )

test_s =
  (DESCRIPTION =
    (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = DEV-pxy-1)(PORT = 1521)))
    (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = test_s))
  )

[oracle@DEV-RPT-2 ~]$

备库最好也配上TNSNAMES
cat >$ORACLE_HOME/network/admin/tnsnames.ora <<'EOF'
test =
  (DESCRIPTION =
    (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = DEV-RPT-2)(PORT = 1521)))
    (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = test))
  )

test_s =
  (DESCRIPTION =
    (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = DEV-pxy-1)(PORT = 1521)))
    (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = test_s))
  )

EOF
[oracle@DEV-pxy-1 ~]$ cat >$ORACLE_HOME/network/admin/tnsnames.ora <<'EOF'
> test =
>   (DESCRIPTION =
>     (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = DEV-RPT-2)(PORT = 1521)))
>     (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = test))
>   )
>
> test_s =
>   (DESCRIPTION =
>     (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = DEV-pxy-1)(PORT = 1521)))
>     (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = test_s))
>   )
>
> EOF
[oracle@DEV-pxy-1 ~]$


5. 主库配置远程归档日志目录

主库:
set pages 50000 line 120
show parameter log_archive
alter system set log_archive_dest_2='SERVICE=test_s';
alter system set log_archive_dest_state_2='enable';
SQL> set pages 50000 line 120
SQL> show parameter log_archive

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_config                   string
log_archive_dest                     string
log_archive_dest_1                   string      LOCATION=/home/oracle/app/orac
                                                 le/oradata/test/archive
log_archive_dest_10                  string
log_archive_dest_2                   string
log_archive_dest_3                   string
log_archive_dest_4                   string
log_archive_dest_5                   string
log_archive_dest_6                   string
log_archive_dest_7                   string
log_archive_dest_8                   string
log_archive_dest_9                   string
log_archive_dest_state_1             string      ENABLE
log_archive_dest_state_10            string      enable
log_archive_dest_state_2             string      enable
log_archive_dest_state_3             string      enable
log_archive_dest_state_4             string      enable
log_archive_dest_state_5             string      enable
log_archive_dest_state_6             string      enable
log_archive_dest_state_7             string      enable
log_archive_dest_state_8             string      enable
log_archive_dest_state_9             string      enable
log_archive_duplex_dest              string
log_archive_format                   string      %t_%s_%r.arc
log_archive_local_first              boolean     TRUE
log_archive_max_processes            integer     2
log_archive_min_succeed_dest         integer     1
log_archive_start                    boolean     FALSE
log_archive_trace                    integer     0
SQL> alter system set log_archive_dest_2='SERVICE=test_s';

System altered.

SQL> alter system set log_archive_dest_state_2='enable';

System altered.

SQL>

此时归档失败, 告警日志显示:
Mon Feb 16 10:13:02 2009
Error 12528 received logging on to the standby
Mon Feb 16 10:13:02 2009
Errors in file /home/oracle/app/oracle/admin/test/bdump/test_arc0_13704.trc:
ORA-12528: TNS:listener: all appropriate instances are blocking new connections
PING[ARC0]: Heartbeat failed to connect to standby 'test_s'. Error is 12528.
跟踪文件:
*** 2009-02-16 10:13:02.558
*** SERVICE NAME:(SYS$BACKGROUND) 2009-02-16 10:13:02.557
*** SESSION ID:(1641.1) 2009-02-16 10:13:02.557
Redo shipping client performing standby login
OCIServerAttach failed -1
.. Detailed OCI error val is 12528 and errmsg is 'ORA-12528: TNS:listener: all appropriate instances are blocking new connections
'
*** 2009-02-16 10:13:02.669 62692 kcrr.c
Error 12528 received logging on to the standby
Error 12528 connecting to destination LOG_ARCHIVE_DEST_2 standby host 'test_s'
Error 12528 attaching to destination LOG_ARCHIVE_DEST_2 standby host 'test_s'
ORA-12528: TNS:listener: all appropriate instances are blocking new connections
*** 2009-02-16 10:13:02.669 62692 kcrr.c
PING[ARC0]: Heartbeat failed to connect to standby 'test_s'. Error is 12528.
*** 2009-02-16 10:13:02.669 60970 kcrr.c
kcrrfail: dest:2 err:12528 force:0 blast:1
*** 2009-02-16 10:18:02.769
Redo shipping client performing standby login
OCIServerAttach failed -1
.. Detailed OCI error val is 12528 and errmsg is 'ORA-12528: TNS:listener: all appropriate instances are blocking new connections
'
不用理会


6. 备份主库

NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss';export NLS_DATE_FORMAT
mkdir -p /u01/software/oracle/backup/DEV-RPT-2/test/rman/
[oracle@DEV-RPT-2 ~]$ mkdir -p /u01/software/oracle/backup/DEV-RPT-2/test/rman/

删除一些归档日志和备份, 省的太乱了
rman target /
crosscheck archivelog all;
delete noprompt expired archivelog all;
list backupset summary;
delete noprompt backupset;
[oracle@DEV-RPT-2 ~]$ rman target /

Recovery Manager: Release 10.2.0.4.0 - Production on Tue Feb 17 02:56:03 2009

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: TEST (DBID=1973292924)

RMAN> crosscheck archivelog all;

using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1632 devtype=DISK
validation failed for archived log
archive log filename=/home/oracle/app/oracle/oradata/test/archive/1_774_676622925.arc recid=1430 stamp=678018682
validation failed for archived log
archive log filename=/home/oracle/app/oracle/oradata/test/archive/1_775_676622925.arc recid=1431 stamp=678020482
validation failed for archived log
archive log filename=/home/oracle/app/oracle/oradata/test/archive/1_776_676622925.arc recid=1432 stamp=678022281
validation failed for archived log
...
validation succeeded for archived log
archive log filename=/home/oracle/app/oracle/oradata/test/archive/1_1337_676622925.arc recid=1993 stamp=679025996
validation succeeded for archived log
archive log filename=/home/oracle/app/oracle/oradata/test/archive/1_1338_676622925.arc recid=1994 stamp=679027799
Crosschecked 565 objects


RMAN> delete noprompt expired archivelog all;

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1632 devtype=DISK

List of Archived Log Copies
Key     Thrd Seq     S Low Time            Name
------- ---- ------- - ------------------- ----
1430    1    774     X 2009-02-05 10:01:19 /home/oracle/app/oracle/oradata/test/archive/1_774_676622925.arc
1431    1    775     X 2009-02-05 10:31:22 /home/oracle/app/oracle/oradata/test/archive/1_775_676622925.arc
1432    1    776     X 2009-02-05 11:01:22 /home/oracle/app/oracle/oradata/test/archive/1_776_676622925.arc
1433    1    777     X 2009-02-05 11:31:21 /home/oracle/app/oracle/oradata/test/archive/1_777_676622925.arc
...
1891    1    1235    X 2009-02-15 00:53:21 /home/oracle/app/oracle/oradata/test/archive/1_1235_676622925.arc
1892    1    1236    X 2009-02-15 01:23:23 /home/oracle/app/oracle/oradata/test/archive/1_1236_676622925.arc
1893    1    1237    X 2009-02-15 01:53:23 /home/oracle/app/oracle/oradata/test/archive/1_1237_676622925.arc
deleted archive log
archive log filename=/home/oracle/app/oracle/oradata/test/archive/1_774_676622925.arc recid=1430 stamp=678018682
deleted archive log
archive log filename=/home/oracle/app/oracle/oradata/test/archive/1_775_676622925.arc recid=1431 stamp=678020482
deleted archive log
archive log filename=/home/oracle/app/oracle/oradata/test/archive/1_776_676622925.arc recid=1432 stamp=678022281
deleted archive log
...
archive log filename=/home/oracle/app/oracle/oradata/test/archive/1_1235_676622925.arc recid=1891 stamp=678849804
deleted archive log
archive log filename=/home/oracle/app/oracle/oradata/test/archive/1_1236_676622925.arc recid=1892 stamp=678851603
deleted archive log
archive log filename=/home/oracle/app/oracle/oradata/test/archive/1_1237_676622925.arc recid=1893 stamp=678853402
Deleted 464 EXPIRED objects


RMAN> list backupset summary;


List of Backups
===============
Key     TY LV S Device Type Completion Time     #Pieces #Copies Compressed Tag
------- -- -- - ----------- ------------------- ------- ------- ---------- ---
6       B  0  A DISK        2009-02-16 10:49:32 1       1       NO         TAG20090216T104927
7       B  0  A DISK        2009-02-16 10:49:33 1       1       NO         TAG20090216T104927
8       B  0  A DISK        2009-02-16 10:49:35 1       1       NO         TAG20090216T104927
9       B  0  A DISK        2009-02-16 10:49:35 1       1       NO         TAG20090216T104927
10      B  0  A DISK        2009-02-16 10:49:38 1       1       NO         TAG20090216T104927
11      B  A  A DISK        2009-02-16 10:49:51 1       1       NO         TAG20090216T104943
12      B  A  A DISK        2009-02-16 10:49:54 1       1       NO         TAG20090216T104943
13      B  A  A DISK        2009-02-16 10:49:55 1       1       NO         TAG20090216T104943
14      B  A  A DISK        2009-02-16 10:49:56 1       1       NO         TAG20090216T104943
15      B  A  A DISK        2009-02-16 10:50:01 1       1       NO         TAG20090216T104943
16      B  A  A DISK        2009-02-16 10:50:03 1       1       NO         TAG20090216T104943
17      B  A  A DISK        2009-02-16 10:50:06 1       1       NO         TAG20090216T104943
18      B  A  A DISK        2009-02-16 10:50:10 1       1       NO         TAG20090216T104943
19      B  A  A DISK        2009-02-16 10:50:13 1       1       NO         TAG20090216T104943
20      B  A  A DISK        2009-02-16 10:50:14 1       1       NO         TAG20090216T104943

RMAN> delete noprompt backupset;

using channel ORA_DISK_1

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
6       6       1   1   AVAILABLE   DISK        /u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090216_0ek7ggpo_1_1
7       7       1   1   AVAILABLE   DISK        /u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090216_0gk7ggpo_1_1
8       8       1   1   AVAILABLE   DISK        /u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090216_0hk7ggpt_1_1
9       9       1   1   AVAILABLE   DISK        /u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090216_0dk7ggpn_1_1
10      10      1   1   AVAILABLE   DISK        /u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090216_0fk7ggpo_1_1
11      11      1   1   AVAILABLE   DISK        /u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0ik7ggqa_1_1
12      12      1   1   AVAILABLE   DISK        /u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0kk7ggqa_1_1
13      13      1   1   AVAILABLE   DISK        /u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0jk7ggqa_1_1
14      14      1   1   AVAILABLE   DISK        /u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0lk7ggqa_1_1
15      15      1   1   AVAILABLE   DISK        /u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0mk7ggqi_1_1
16      16      1   1   AVAILABLE   DISK        /u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0nk7ggqm_1_1
17      17      1   1   AVAILABLE   DISK        /u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0ok7ggqm_1_1
18      18      1   1   AVAILABLE   DISK        /u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0pk7ggqm_1_1
19      19      1   1   AVAILABLE   DISK        /u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0rk7ggqv_1_1
20      20      1   1   AVAILABLE   DISK        /u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0qk7ggqv_1_1
deleted backup piece
backup piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090216_0ek7ggpo_1_1 recid=6 stamp=678970169
deleted backup piece
backup piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090216_0gk7ggpo_1_1 recid=7 stamp=678970170
deleted backup piece
backup piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090216_0hk7ggpt_1_1 recid=8 stamp=678970174
deleted backup piece
backup piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090216_0dk7ggpn_1_1 recid=9 stamp=678970168
deleted backup piece
backup piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090216_0fk7ggpo_1_1 recid=10 stamp=678970170
deleted backup piece
backup piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0ik7ggqa_1_1 recid=11 stamp=678970187
deleted backup piece
backup piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0kk7ggqa_1_1 recid=12 stamp=678970189
deleted backup piece
backup piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0jk7ggqa_1_1 recid=13 stamp=678970188
deleted backup piece
backup piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0lk7ggqa_1_1 recid=14 stamp=678970190
deleted backup piece
backup piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0mk7ggqi_1_1 recid=15 stamp=678970198
deleted backup piece
backup piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0nk7ggqm_1_1 recid=16 stamp=678970199
deleted backup piece
backup piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0ok7ggqm_1_1 recid=17 stamp=678970203
deleted backup piece
backup piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0pk7ggqm_1_1 recid=18 stamp=678970207
deleted backup piece
backup piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0rk7ggqv_1_1 recid=19 stamp=678970209
deleted backup piece
backup piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090216_0qk7ggqv_1_1 recid=20 stamp=678970208
Deleted 15 objects


RMAN>


备份数据库
run {
 allocate channel c1 type disk;
 allocate channel c2 type disk;
 allocate channel c3 type disk;
 allocate channel c4 type disk;
 backup as backupset incremental level 0 format '/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_%d_%I_%T_%U' database;
 sql 'alter system archive log current';
 backup as backupset format '/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_%d_%I_%T_%U' archivelog all;
 release channel c1;
 release channel c2;
 release channel c3;
 release channel c4;
}
RMAN> run {
2>  allocate channel c1 type disk;
3>  allocate channel c2 type disk;
4>  allocate channel c3 type disk;
5>  allocate channel c4 type disk;
6>  backup as backupset incremental level 0 format '/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_%d_%I_%T_%U' database;
7>  sql 'alter system archive log current';
8>  backup as backupset format '/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_%d_%I_%T_%U' archivelog all;
9>  release channel c1;
10>  release channel c2;
11>  release channel c3;
12>  release channel c4;
13> }

released channel: ORA_DISK_1
allocated channel: c1
channel c1: sid=1632 devtype=DISK

allocated channel: c2
channel c2: sid=1644 devtype=DISK

allocated channel: c3
channel c3: sid=1623 devtype=DISK

allocated channel: c4
channel c4: sid=1629 devtype=DISK

Starting backup at 2009-02-17 03:02:54
channel c1: starting incremental level 0 datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00001 name=/home/oracle/app/oracle/oradata/test/system01.dbf
channel c1: starting piece 1 at 2009-02-17 03:02:55
channel c2: starting incremental level 0 datafile backupset
channel c2: specifying datafile(s) in backupset
input datafile fno=00002 name=/home/oracle/app/oracle/oradata/test/undotbs01.dbf
input datafile fno=00004 name=/home/oracle/app/oracle/oradata/test/users01.dbf
channel c2: starting piece 1 at 2009-02-17 03:02:55
channel c3: starting incremental level 0 datafile backupset
channel c3: specifying datafile(s) in backupset
input datafile fno=00003 name=/home/oracle/app/oracle/oradata/test/sysaux01.dbf
input datafile fno=00005 name=/home/oracle/app/oracle/oradata/test/ts_test01.dbf
channel c3: starting piece 1 at 2009-02-17 03:02:55
channel c4: starting incremental level 0 datafile backupset
channel c4: specifying datafile(s) in backupset
including current control file in backupset
channel c4: starting piece 1 at 2009-02-17 03:02:58
channel c2: finished piece 1 at 2009-02-17 03:03:01
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090217_0tk7i9qv_1_1 tag=TAG20090217T030254 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:06
channel c2: starting incremental level 0 datafile backupset
channel c2: specifying datafile(s) in backupset
channel c4: finished piece 1 at 2009-02-17 03:03:01
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090217_0vk7i9r0_1_1 tag=TAG20090217T030254 comment=NONE
channel c4: backup set complete, elapsed time: 00:00:05
channel c1: finished piece 1 at 2009-02-17 03:03:02
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090217_0sk7i9qv_1_1 tag=TAG20090217T030254 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:07
including current SPFILE in backupset
channel c2: starting piece 1 at 2009-02-17 03:03:02
channel c2: finished piece 1 at 2009-02-17 03:03:03
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090217_10k7i9r5_1_1 tag=TAG20090217T030254 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:02
channel c3: finished piece 1 at 2009-02-17 03:03:06
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090217_0uk7i9qv_1_1 tag=TAG20090217T030254 comment=NONE
channel c3: backup set complete, elapsed time: 00:00:11
Finished backup at 2009-02-17 03:03:06

sql statement: alter system archive log current

Starting backup at 2009-02-17 03:03:10
current log archived
channel c1: starting archive log backupset
channel c1: specifying archive log(s) in backup set
input archive log thread=1 sequence=1306 recid=1962 stamp=678970183
input archive log thread=1 sequence=1307 recid=1963 stamp=678971984
input archive log thread=1 sequence=1308 recid=1964 stamp=678973784
input archive log thread=1 sequence=1309 recid=1965 stamp=678975584
input archive log thread=1 sequence=1310 recid=1966 stamp=678977383
input archive log thread=1 sequence=1311 recid=1967 stamp=678979183
input archive log thread=1 sequence=1312 recid=1968 stamp=678980982
input archive log thread=1 sequence=1313 recid=1969 stamp=678982782
input archive log thread=1 sequence=1314 recid=1970 stamp=678984584
input archive log thread=1 sequence=1315 recid=1971 stamp=678986384
input archive log thread=1 sequence=1316 recid=1972 stamp=678988183
input archive log thread=1 sequence=1317 recid=1973 stamp=678989983
input archive log thread=1 sequence=1318 recid=1974 stamp=678991782
input archive log thread=1 sequence=1319 recid=1975 stamp=678993585
input archive log thread=1 sequence=1320 recid=1976 stamp=678995390
input archive log thread=1 sequence=1321 recid=1977 stamp=678997190
input archive log thread=1 sequence=1322 recid=1978 stamp=678998989
input archive log thread=1 sequence=1323 recid=1979 stamp=679000789
input archive log thread=1 sequence=1324 recid=1980 stamp=679002588
input archive log thread=1 sequence=1325 recid=1981 stamp=679004391
input archive log thread=1 sequence=1326 recid=1982 stamp=679006196
input archive log thread=1 sequence=1327 recid=1983 stamp=679007996
input archive log thread=1 sequence=1328 recid=1984 stamp=679009795
input archive log thread=1 sequence=1329 recid=1985 stamp=679011599
channel c1: starting piece 1 at 2009-02-17 03:03:13
channel c2: starting archive log backupset
channel c2: specifying archive log(s) in backup set
input archive log thread=1 sequence=1264 recid=1920 stamp=678902015
input archive log thread=1 sequence=1265 recid=1921 stamp=678903815
input archive log thread=1 sequence=1266 recid=1922 stamp=678905614
input archive log thread=1 sequence=1267 recid=1923 stamp=678907414
input archive log thread=1 sequence=1268 recid=1924 stamp=678909216
input archive log thread=1 sequence=1269 recid=1925 stamp=678911022
input archive log thread=1 sequence=1270 recid=1926 stamp=678912821
input archive log thread=1 sequence=1271 recid=1927 stamp=678914621
input archive log thread=1 sequence=1272 recid=1928 stamp=678916420
input archive log thread=1 sequence=1273 recid=1929 stamp=678918219
input archive log thread=1 sequence=1274 recid=1930 stamp=678920021
input archive log thread=1 sequence=1275 recid=1931 stamp=678921821
input archive log thread=1 sequence=1276 recid=1932 stamp=678923620
input archive log thread=1 sequence=1277 recid=1933 stamp=678925434
input archive log thread=1 sequence=1278 recid=1934 stamp=678927234
input archive log thread=1 sequence=1279 recid=1935 stamp=678929024
channel c2: starting piece 1 at 2009-02-17 03:03:13
channel c3: starting archive log backupset
channel c3: specifying archive log(s) in backup set
input archive log thread=1 sequence=1330 recid=1986 stamp=679013397
input archive log thread=1 sequence=1331 recid=1987 stamp=679015197
input archive log thread=1 sequence=1332 recid=1988 stamp=679016996
input archive log thread=1 sequence=1333 recid=1989 stamp=679018799
input archive log thread=1 sequence=1334 recid=1990 stamp=679020598
input archive log thread=1 sequence=1335 recid=1991 stamp=679022397
input archive log thread=1 sequence=1336 recid=1992 stamp=679024197
input archive log thread=1 sequence=1337 recid=1993 stamp=679025996
input archive log thread=1 sequence=1338 recid=1994 stamp=679027799
input archive log thread=1 sequence=1339 recid=1995 stamp=679028590
input archive log thread=1 sequence=1340 recid=1996 stamp=679028590
channel c3: starting piece 1 at 2009-02-17 03:03:13
channel c4: starting archive log backupset
channel c4: specifying archive log(s) in backup set
input archive log thread=1 sequence=1238 recid=1894 stamp=678855202
input archive log thread=1 sequence=1239 recid=1895 stamp=678857001
input archive log thread=1 sequence=1240 recid=1896 stamp=678858804
input archive log thread=1 sequence=1241 recid=1897 stamp=678860603
input archive log thread=1 sequence=1242 recid=1898 stamp=678862402
input archive log thread=1 sequence=1243 recid=1899 stamp=678864202
input archive log thread=1 sequence=1244 recid=1900 stamp=678866001
input archive log thread=1 sequence=1245 recid=1901 stamp=678867804
input archive log thread=1 sequence=1246 recid=1902 stamp=678869603
input archive log thread=1 sequence=1247 recid=1903 stamp=678871402
input archive log thread=1 sequence=1248 recid=1904 stamp=678873202
input archive log thread=1 sequence=1249 recid=1905 stamp=678875002
input archive log thread=1 sequence=1250 recid=1906 stamp=678876801
input archive log thread=1 sequence=1251 recid=1907 stamp=678878603
input archive log thread=1 sequence=1252 recid=1908 stamp=678880403
input archive log thread=1 sequence=1253 recid=1909 stamp=678882202
input archive log thread=1 sequence=1254 recid=1910 stamp=678884002
input archive log thread=1 sequence=1255 recid=1911 stamp=678885802
input archive log thread=1 sequence=1256 recid=1912 stamp=678887601
input archive log thread=1 sequence=1257 recid=1913 stamp=678889404
input archive log thread=1 sequence=1258 recid=1914 stamp=678891209
input archive log thread=1 sequence=1259 recid=1915 stamp=678893009
input archive log thread=1 sequence=1260 recid=1916 stamp=678894808
input archive log thread=1 sequence=1261 recid=1917 stamp=678896608
input archive log thread=1 sequence=1262 recid=1918 stamp=678898410
input archive log thread=1 sequence=1263 recid=1919 stamp=678900215
channel c4: starting piece 1 at 2009-02-17 03:03:14
channel c2: finished piece 1 at 2009-02-17 03:03:17
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090217_12k7i9rg_1_1 tag=TAG20090217T030310 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:05
channel c3: finished piece 1 at 2009-02-17 03:03:17
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090217_13k7i9rg_1_1 tag=TAG20090217T030310 comment=NONE
channel c3: backup set complete, elapsed time: 00:00:05
channel c4: finished piece 1 at 2009-02-17 03:03:17
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090217_14k7i9rg_1_1 tag=TAG20090217T030310 comment=NONE
channel c4: backup set complete, elapsed time: 00:00:05
channel c1: finished piece 1 at 2009-02-17 03:03:18
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090217_11k7i9rg_1_1 tag=TAG20090217T030310 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:06
channel c2: starting archive log backupset
channel c2: specifying archive log(s) in backup set
input archive log thread=1 sequence=1280 recid=1936 stamp=678930822
input archive log thread=1 sequence=1281 recid=1937 stamp=678932625
input archive log thread=1 sequence=1282 recid=1938 stamp=678934430
input archive log thread=1 sequence=1283 recid=1939 stamp=678936230
input archive log thread=1 sequence=1284 recid=1940 stamp=678938029
input archive log thread=1 sequence=1285 recid=1941 stamp=678939828
input archive log thread=1 sequence=1286 recid=1942 stamp=678941628
input archive log thread=1 sequence=1287 recid=1943 stamp=678943431
input archive log thread=1 sequence=1288 recid=1944 stamp=678945236
input archive log thread=1 sequence=1289 recid=1945 stamp=678947036
input archive log thread=1 sequence=1290 recid=1946 stamp=678948835
input archive log thread=1 sequence=1291 recid=1947 stamp=678950635
input archive log thread=1 sequence=1292 recid=1948 stamp=678952434
input archive log thread=1 sequence=1293 recid=1949 stamp=678954234
input archive log thread=1 sequence=1294 recid=1950 stamp=678956036
input archive log thread=1 sequence=1295 recid=1951 stamp=678957836
input archive log thread=1 sequence=1296 recid=1952 stamp=678959635
input archive log thread=1 sequence=1297 recid=1953 stamp=678961435
input archive log thread=1 sequence=1298 recid=1954 stamp=678963234
input archive log thread=1 sequence=1299 recid=1955 stamp=678965034
input archive log thread=1 sequence=1300 recid=1956 stamp=678966837
input archive log thread=1 sequence=1301 recid=1957 stamp=678968014
input archive log thread=1 sequence=1302 recid=1958 stamp=678968649
input archive log thread=1 sequence=1303 recid=1959 stamp=678969197
input archive log thread=1 sequence=1304 recid=1960 stamp=678969198
input archive log thread=1 sequence=1305 recid=1961 stamp=678970182
channel c2: starting piece 1 at 2009-02-17 03:03:18
channel c2: finished piece 1 at 2009-02-17 03:03:21
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090217_15k7i9rm_1_1 tag=TAG20090217T030310 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:03
Finished backup at 2009-02-17 03:03:21

released channel: c1

released channel: c2

released channel: c3

released channel: c4

RMAN>

ls -lrt /u01/software/oracle/backup/DEV-RPT-2/test/rman/
[oracle@DEV-RPT-2 ~]$ ls -lrt /u01/software/oracle/backup/DEV-RPT-2/test/rman/
total 413324
-rw-r--r--  1 oracle oinstall      1559 Feb 16 07:16 spbakcup.ora
-rw-r-----  1 oracle oinstall  25886720 Feb 17 03:03 data_TEST_1973292924_20090217_0tk7i9qv_1_1
-rw-r-----  1 oracle oinstall   9764864 Feb 17 03:03 data_TEST_1973292924_20090217_0vk7i9r0_1_1
-rw-r-----  1 oracle oinstall 151830528 Feb 17 03:03 data_TEST_1973292924_20090217_0sk7i9qv_1_1
-rw-r-----  1 oracle oinstall     98304 Feb 17 03:03 data_TEST_1973292924_20090217_10k7i9r5_1_1
-rw-r-----  1 oracle oinstall 143163392 Feb 17 03:03 data_TEST_1973292924_20090217_0uk7i9qv_1_1
-rw-r-----  1 oracle oinstall  11546112 Feb 17 03:03 arch_TEST_1973292924_20090217_13k7i9rg_1_1
-rw-r-----  1 oracle oinstall  23557120 Feb 17 03:03 arch_TEST_1973292924_20090217_12k7i9rg_1_1
-rw-r-----  1 oracle oinstall  30858240 Feb 17 03:03 arch_TEST_1973292924_20090217_11k7i9rg_1_1
-rw-r-----  1 oracle oinstall   8069120 Feb 17 03:03 arch_TEST_1973292924_20090217_14k7i9rg_1_1
-rw-r-----  1 oracle oinstall   7874560 Feb 17 03:03 arch_TEST_1973292924_20090217_15k7i9rm_1_1
-rw-r-----  1 oracle oinstall   9715712 Feb 17 03:10 cf4standby
[oracle@DEV-RPT-2 ~]$


7. 主库备份备用控制文件

用 backup 命令
backup current controlfile for standby format='/u01/software/oracle/backup/DEV-RPT-2/test/rman/cf4standby_%U';
或 copy
copy current controlfile for standby to '/u01/software/oracle/backup/dev-rpt-2/test/rman/cf4standby_cp';
或在备份数据库时
backup database ... include current controlfile for standby;

或 alter database create
sql "alter database create standby controlfile as ''/u01/software/oracle/backup/DEV-RPT-2/test/rman/cf4standby''";
catalog controlfilecopy '/u01/software/oracle/backup/DEV-RPT-2/test/rman/cf4standby';

因为后面用的是手工方式, 这里只要alter database create就可以了
sql "alter database create standby controlfile as ''/u01/software/oracle/backup/DEV-RPT-2/test/rman/cf4standby''";
RMAN> sql "alter database create standby controlfile as ''/u01/software/oracle/backup/DEV-RPT-2/test/rman/cf4standby''";

sql statement: alter database create standby controlfile as ''/u01/software/oracle/backup/DEV-RPT-2/test/rman/cf4standby''

RMAN>
告警日志:
Tue Feb 17 03:10:18 2009
alter database create standby controlfile as '/u01/software/oracle/backup/DEV-RPT-2/test/rman/cf4standby'
Tue Feb 17 03:10:18 2009
Clearing standby activation ID 1974762515 (0x75b47c13)
The primary database controlfile was created using the
'MAXLOGFILES 32' clause.
There is space for up to 29 standby redo logfiles
Use the following SQL commands on the standby database to create
standby redo logfiles that match the primary database:
ALTER DATABASE ADD STANDBY LOGFILE 'srl1.f' SIZE 104857600;
ALTER DATABASE ADD STANDBY LOGFILE 'srl2.f' SIZE 104857600;
ALTER DATABASE ADD STANDBY LOGFILE 'srl3.f' SIZE 104857600;
ALTER DATABASE ADD STANDBY LOGFILE 'srl4.f' SIZE 104857600;
Completed: alter database create standby controlfile as '/u01/software/oracle/backup/DEV-RPT-2/test/rman/cf4standby'


8. 备库复制或恢复备用控制文件

NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss';export NLS_DATE_FORMAT
rman target /
set dbid=1973292924;
restore standby controlfile from '/u01/software/oracle/backup/DEV-RPT-2/test/rman/cf4standby';
[oracle@DEV-pxy-1 ~]$ NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss';export NLS_DATE_FORMAT
[oracle@DEV-pxy-1 ~]$ rman target /

Recovery Manager: Release 10.2.0.4.0 - Production on Tue Feb 17 03:15:08 2009

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: test (not mounted)

RMAN> set dbid=1973292924;

executing command: SET DBID

RMAN> restore standby controlfile from '/u01/software/oracle/backup/DEV-RPT-2/test/rman/cf4standby';

Starting restore at 2009-02-17 03:16:56
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1641 devtype=DISK

channel ORA_DISK_1: copied control file copy
output filename=/home/oracle/app/oracle/oradata/test_s/control01.ctl
output filename=/home/oracle/app/oracle/oradata/test_s/control02.ctl
output filename=/home/oracle/app/oracle/oradata/test_s/control03.ctl
Finished restore at 2009-02-17 03:16:58

RMAN>


9. 挂载控制文件
sql 'alter database mount standby database';
RMAN> sql 'alter database mount standby database';

sql statement: alter database mount standby database
released channel: ORA_DISK_1

RMAN>
10g运行alter database mount好像也可以


10. 恢复数据文件

list backupset;
RMAN> list backupset;


List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
21      Incr 0  24.68M     DISK        00:00:04     2009-02-17 03:02:59
        BP Key: 21   Status: AVAILABLE  Compressed: NO  Tag: TAG20090217T030254
        Piece Name: /u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090217_0tk7i9qv_1_1
  List of Datafiles in backup set 21
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  2    0  Incr 1789174    2009-02-17 03:02:55 /home/oracle/app/oracle/oradata/test_s/undotbs01.dbf
  4    0  Incr 1789174    2009-02-17 03:02:55 /home/oracle/app/oracle/oradata/test_s/users01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
22      Incr 0  9.30M      DISK        00:00:04     2009-02-17 03:03:00
        BP Key: 22   Status: AVAILABLE  Compressed: NO  Tag: TAG20090217T030254
        Piece Name: /u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090217_0vk7i9r0_1_1
  Control File Included: Ckp SCN: 1789174      Ckp time: 2009-02-17 03:02:56

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
23      Incr 0  144.79M    DISK        00:00:07     2009-02-17 03:03:02
        BP Key: 23   Status: AVAILABLE  Compressed: NO  Tag: TAG20090217T030254
        Piece Name: /u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090217_0sk7i9qv_1_1
  List of Datafiles in backup set 23
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1    0  Incr 1789173    2009-02-17 03:02:55 /home/oracle/app/oracle/oradata/test_s/system01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
24      Incr 0  80.00K     DISK        00:00:02     2009-02-17 03:03:03
        BP Key: 24   Status: AVAILABLE  Compressed: NO  Tag: TAG20090217T030254
        Piece Name: /u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090217_10k7i9r5_1_1
  SPFILE Included: Modification time: 2009-02-16 22:01:48

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
25      Incr 0  136.52M    DISK        00:00:10     2009-02-17 03:03:05
        BP Key: 25   Status: AVAILABLE  Compressed: NO  Tag: TAG20090217T030254
        Piece Name: /u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090217_0uk7i9qv_1_1
  List of Datafiles in backup set 25
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  3    0  Incr 1789175    2009-02-17 03:02:56 /home/oracle/app/oracle/oradata/test_s/sysaux01.dbf
  5    0  Incr 1789175    2009-02-17 03:02:56 /home/oracle/app/oracle/oradata/test_s/ts_test01.dbf

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ -------------------
26      11.01M     DISK        00:00:03     2009-02-17 03:03:15
        BP Key: 26   Status: AVAILABLE  Compressed: NO  Tag: TAG20090217T030310
        Piece Name: /u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090217_13k7i9rg_1_1

  List of Archived Logs in backup set 26
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    1330    1780512    2009-02-16 22:19:58 1781131    2009-02-16 22:49:57
  1    1331    1781131    2009-02-16 22:49:57 1783830    2009-02-16 23:19:57
  1    1332    1783830    2009-02-16 23:19:57 1784641    2009-02-16 23:49:56
  1    1333    1784641    2009-02-16 23:49:56 1785441    2009-02-17 00:19:58
  1    1334    1785441    2009-02-17 00:19:58 1786057    2009-02-17 00:49:58
  1    1335    1786057    2009-02-17 00:49:58 1786801    2009-02-17 01:19:57
  1    1336    1786801    2009-02-17 01:19:57 1787413    2009-02-17 01:49:57
  1    1337    1787413    2009-02-17 01:49:57 1788162    2009-02-17 02:19:56
  1    1338    1788162    2009-02-17 02:19:56 1788773    2009-02-17 02:49:58
  1    1339    1788773    2009-02-17 02:49:58 1789189    2009-02-17 03:03:10
  1    1340    1789189    2009-02-17 03:03:10 1789194    2009-02-17 03:03:10

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ -------------------
27      22.47M     DISK        00:00:03     2009-02-17 03:03:15
        BP Key: 27   Status: AVAILABLE  Compressed: NO  Tag: TAG20090217T030310
        Piece Name: /u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090217_12k7i9rg_1_1

  List of Archived Logs in backup set 27
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    1264    1730698    2009-02-15 15:23:35 1731311    2009-02-15 15:53:35
  1    1265    1731311    2009-02-15 15:53:35 1732044    2009-02-15 16:23:34
  1    1266    1732044    2009-02-15 16:23:34 1732662    2009-02-15 16:53:34
  1    1267    1732662    2009-02-15 16:53:34 1733398    2009-02-15 17:23:33
  1    1268    1733398    2009-02-15 17:23:33 1734017    2009-02-15 17:53:36
  1    1269    1734017    2009-02-15 17:53:36 1734770    2009-02-15 18:23:42
  1    1270    1734770    2009-02-15 18:23:42 1735383    2009-02-15 18:53:41
  1    1271    1735383    2009-02-15 18:53:41 1736125    2009-02-15 19:23:41
  1    1272    1736125    2009-02-15 19:23:41 1736741    2009-02-15 19:53:40
  1    1273    1736741    2009-02-15 19:53:40 1737501    2009-02-15 20:23:39
  1    1274    1737501    2009-02-15 20:23:39 1738114    2009-02-15 20:53:41
  1    1275    1738114    2009-02-15 20:53:41 1738853    2009-02-15 21:23:41
  1    1276    1738853    2009-02-15 21:23:41 1739471    2009-02-15 21:53:40
  1    1277    1739471    2009-02-15 21:53:40 1740210    2009-02-15 22:23:54
  1    1278    1740210    2009-02-15 22:23:54 1740822    2009-02-15 22:53:53
  1    1279    1740822    2009-02-15 22:53:53 1744220    2009-02-15 23:23:43

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ -------------------
28      7.69M      DISK        00:00:04     2009-02-17 03:03:16
        BP Key: 28   Status: AVAILABLE  Compressed: NO  Tag: TAG20090217T030310
        Piece Name: /u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090217_14k7i9rg_1_1

  List of Archived Logs in backup set 28
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    1238    1712986    2009-02-15 02:23:22 1713601    2009-02-15 02:53:22
  1    1239    1713601    2009-02-15 02:53:22 1714376    2009-02-15 03:23:21
  1    1240    1714376    2009-02-15 03:23:21 1714992    2009-02-15 03:53:23
  1    1241    1714992    2009-02-15 03:53:23 1715737    2009-02-15 04:23:23
  1    1242    1715737    2009-02-15 04:23:23 1716349    2009-02-15 04:53:22
  1    1243    1716349    2009-02-15 04:53:22 1717102    2009-02-15 05:23:22
  1    1244    1717102    2009-02-15 05:23:22 1717719    2009-02-15 05:53:21
  1    1245    1717719    2009-02-15 05:53:21 1718451    2009-02-15 06:23:23
  1    1246    1718451    2009-02-15 06:23:23 1719065    2009-02-15 06:53:23
  1    1247    1719065    2009-02-15 06:53:23 1719801    2009-02-15 07:23:22
  1    1248    1719801    2009-02-15 07:23:22 1720417    2009-02-15 07:53:22
  1    1249    1720417    2009-02-15 07:53:22 1721148    2009-02-15 08:23:21
  1    1250    1721148    2009-02-15 08:23:21 1721763    2009-02-15 08:53:21
  1    1251    1721763    2009-02-15 08:53:21 1722520    2009-02-15 09:23:23
  1    1252    1722520    2009-02-15 09:23:23 1723135    2009-02-15 09:53:23
  1    1253    1723135    2009-02-15 09:53:23 1723892    2009-02-15 10:23:22
  1    1254    1723892    2009-02-15 10:23:22 1724505    2009-02-15 10:53:22
  1    1255    1724505    2009-02-15 10:53:22 1725250    2009-02-15 11:23:22
  1    1256    1725250    2009-02-15 11:23:22 1725859    2009-02-15 11:53:21
  1    1257    1725859    2009-02-15 11:53:21 1726616    2009-02-15 12:23:24
  1    1258    1726616    2009-02-15 12:23:24 1727224    2009-02-15 12:53:29
  1    1259    1727224    2009-02-15 12:53:29 1727954    2009-02-15 13:23:28
  1    1260    1727954    2009-02-15 13:23:28 1728569    2009-02-15 13:53:28
  1    1261    1728569    2009-02-15 13:53:28 1729311    2009-02-15 14:23:27
  1    1262    1729311    2009-02-15 14:23:27 1729929    2009-02-15 14:53:30
  1    1263    1729929    2009-02-15 14:53:30 1730698    2009-02-15 15:23:35

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ -------------------
29      29.43M     DISK        00:00:05     2009-02-17 03:03:17
        BP Key: 29   Status: AVAILABLE  Compressed: NO  Tag: TAG20090217T030310
        Piece Name: /u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090217_11k7i9rg_1_1

  List of Archived Logs in backup set 29
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    1306    1760387    2009-02-16 10:49:42 1760392    2009-02-16 10:49:42
  1    1307    1760392    2009-02-16 10:49:42 1761235    2009-02-16 11:19:44
  1    1308    1761235    2009-02-16 11:19:44 1761848    2009-02-16 11:49:44
  1    1309    1761848    2009-02-16 11:49:44 1762592    2009-02-16 12:19:43
  1    1310    1762592    2009-02-16 12:19:43 1763210    2009-02-16 12:49:43
  1    1311    1763210    2009-02-16 12:49:43 1763946    2009-02-16 13:19:43
  1    1312    1763946    2009-02-16 13:19:43 1764559    2009-02-16 13:49:42
  1    1313    1764559    2009-02-16 13:49:42 1765327    2009-02-16 14:19:42
  1    1314    1765327    2009-02-16 14:19:42 1765941    2009-02-16 14:49:44
  1    1315    1765941    2009-02-16 14:49:44 1766697    2009-02-16 15:19:44
  1    1316    1766697    2009-02-16 15:19:44 1767312    2009-02-16 15:49:43
  1    1317    1767312    2009-02-16 15:49:43 1768045    2009-02-16 16:19:43
  1    1318    1768045    2009-02-16 16:19:43 1768658    2009-02-16 16:49:42
  1    1319    1768658    2009-02-16 16:49:42 1769418    2009-02-16 17:19:44
  1    1320    1769418    2009-02-16 17:19:44 1770034    2009-02-16 17:49:50
  1    1321    1770034    2009-02-16 17:49:50 1770792    2009-02-16 18:19:49
  1    1322    1770792    2009-02-16 18:19:49 1771408    2009-02-16 18:49:49
  1    1323    1771408    2009-02-16 18:49:49 1772152    2009-02-16 19:19:48
  1    1324    1772152    2009-02-16 19:19:48 1772766    2009-02-16 19:49:48
  1    1325    1772766    2009-02-16 19:49:48 1773544    2009-02-16 20:19:50
  1    1326    1773544    2009-02-16 20:19:50 1774158    2009-02-16 20:49:56
  1    1327    1774158    2009-02-16 20:49:56 1774893    2009-02-16 21:19:56
  1    1328    1774893    2009-02-16 21:19:56 1775511    2009-02-16 21:49:55
  1    1329    1775511    2009-02-16 21:49:55 1780512    2009-02-16 22:19:58

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ -------------------
30      7.51M      DISK        00:00:00     2009-02-17 03:03:18
        BP Key: 30   Status: AVAILABLE  Compressed: NO  Tag: TAG20090217T030310
        Piece Name: /u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090217_15k7i9rm_1_1

  List of Archived Logs in backup set 30
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    1280    1744220    2009-02-15 23:23:43 1745038    2009-02-15 23:53:42
  1    1281    1745038    2009-02-15 23:53:42 1745841    2009-02-16 00:23:44
  1    1282    1745841    2009-02-16 00:23:44 1746458    2009-02-16 00:53:50
  1    1283    1746458    2009-02-16 00:53:50 1747202    2009-02-16 01:23:49
  1    1284    1747202    2009-02-16 01:23:49 1747817    2009-02-16 01:53:49
  1    1285    1747817    2009-02-16 01:53:49 1748555    2009-02-16 02:23:48
  1    1286    1748555    2009-02-16 02:23:48 1749167    2009-02-16 02:53:48
  1    1287    1749167    2009-02-16 02:53:48 1749931    2009-02-16 03:23:50
  1    1288    1749931    2009-02-16 03:23:50 1750550    2009-02-16 03:53:56
  1    1289    1750550    2009-02-16 03:53:56 1751295    2009-02-16 04:23:55
  1    1290    1751295    2009-02-16 04:23:55 1751908    2009-02-16 04:53:55
  1    1291    1751908    2009-02-16 04:53:55 1752656    2009-02-16 05:23:54
  1    1292    1752656    2009-02-16 05:23:54 1753305    2009-02-16 05:53:54
  1    1293    1753305    2009-02-16 05:53:54 1754051    2009-02-16 06:23:54
  1    1294    1754051    2009-02-16 06:23:54 1754676    2009-02-16 06:53:56
  1    1295    1754676    2009-02-16 06:53:56 1755463    2009-02-16 07:23:56
  1    1296    1755463    2009-02-16 07:23:56 1756080    2009-02-16 07:53:55
  1    1297    1756080    2009-02-16 07:53:55 1756820    2009-02-16 08:23:55
  1    1298    1756820    2009-02-16 08:23:55 1757515    2009-02-16 08:53:54
  1    1299    1757515    2009-02-16 08:53:54 1758273    2009-02-16 09:23:54
  1    1300    1758273    2009-02-16 09:23:54 1758888    2009-02-16 09:53:56
  1    1301    1758888    2009-02-16 09:53:56 1759428    2009-02-16 10:13:33
  1    1302    1759428    2009-02-16 10:13:33 1759666    2009-02-16 10:24:08
  1    1303    1759666    2009-02-16 10:24:08 1759918    2009-02-16 10:33:17
  1    1304    1759918    2009-02-16 10:33:17 1759923    2009-02-16 10:33:18
  1    1305    1759923    2009-02-16 10:33:18 1760387    2009-02-16 10:49:42

RMAN>

restore database;
RMAN> restore database;

Starting restore at 2009-02-17 03:28:44
Starting implicit crosscheck backup at 2009-02-17 03:28:44
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1640 devtype=DISK
Crosschecked 10 objects
Finished implicit crosscheck backup at 2009-02-17 03:28:46

Starting implicit crosscheck copy at 2009-02-17 03:28:46
using channel ORA_DISK_1
Finished implicit crosscheck copy at 2009-02-17 03:28:46

searching for all files in the recovery area
cataloging files...
no files cataloged

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /home/oracle/app/oracle/oradata/test_s/undotbs01.dbf
restoring datafile 00004 to /home/oracle/app/oracle/oradata/test_s/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090217_0tk7i9qv_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090217_0tk7i9qv_1_1 tag=TAG20090217T030254
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /home/oracle/app/oracle/oradata/test_s/system01.dbf
channel ORA_DISK_1: reading from backup piece /u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090217_0sk7i9qv_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090217_0sk7i9qv_1_1 tag=TAG20090217T030254
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00003 to /home/oracle/app/oracle/oradata/test_s/sysaux01.dbf
restoring datafile 00005 to /home/oracle/app/oracle/oradata/test_s/ts_test01.dbf
channel ORA_DISK_1: reading from backup piece /u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090217_0uk7i9qv_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090217_0uk7i9qv_1_1 tag=TAG20090217T030254
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 2009-02-17 03:29:08

RMAN>
告警日志:
Tue Feb 17 03:28:47 2009
Full restore complete of datafile 4 /home/oracle/app/oracle/oradata/test_s/users01.dbf.  Elapsed time: 0:00:00
  checkpoint is 1789174
Full restore complete of datafile 2 /home/oracle/app/oracle/oradata/test_s/undotbs01.dbf.  Elapsed time: 0:00:03
  checkpoint is 1789174
  last deallocation scn is 1785174
Tue Feb 17 03:28:59 2009
Full restore complete of datafile 1 /home/oracle/app/oracle/oradata/test_s/system01.dbf.  Elapsed time: 0:00:05
  checkpoint is 1789173
  last deallocation scn is 176822
Full restore complete of datafile 5 /home/oracle/app/oracle/oradata/test_s/ts_test01.dbf.  Elapsed time: 0:00:00
  checkpoint is 1789175
Full restore complete of datafile 3 /home/oracle/app/oracle/oradata/test_s/sysaux01.dbf.  Elapsed time: 0:00:03
  checkpoint is 1789175
  last deallocation scn is 1782338

11. 修复数据库
recover database;
RMAN> recover database;

Starting recover at 2009-02-17 03:35:31
using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 1341 is already on disk as file /home/oracle/app/oracle/oradata/test_s/archive/1_1341_676622925.arc
archive log thread 1 sequence 1342 is already on disk as file /home/oracle/app/oracle/oradata/test_s/archive/1_1342_676622925.arc
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=1339
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=1340
channel ORA_DISK_1: reading from backup piece /u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090217_13k7i9rg_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_TEST_1973292924_20090217_13k7i9rg_1_1 tag=TAG20090217T030310
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archive log filename=/home/oracle/app/oracle/oradata/test_s/archive/1_1339_676622925.arc thread=1 sequence=1339
archive log filename=/home/oracle/app/oracle/oradata/test_s/archive/1_1340_676622925.arc thread=1 sequence=1340
archive log filename=/home/oracle/app/oracle/oradata/test_s/archive/1_1341_676622925.arc thread=1 sequence=1341
archive log filename=/home/oracle/app/oracle/oradata/test_s/archive/1_1342_676622925.arc thread=1 sequence=1342
unable to find archive log
archive log thread=1 sequence=1343
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/17/2009 03:35:34
RMAN-06054: media recovery requesting unknown log: thread 1 seq 1343 lowscn 1789808

RMAN>
告警日志:
Tue Feb 17 03:35:32 2009
alter database recover datafile list clear
Tue Feb 17 03:35:32 2009
Completed: alter database recover datafile list clear
Tue Feb 17 03:35:32 2009
alter database recover datafile list
 1 , 2 , 3 , 4 , 5
Completed: alter database recover datafile list
 1 , 2 , 3 , 4 , 5
Tue Feb 17 03:35:32 2009
alter database recover if needed
 standby start
Media Recovery Start
Managed Standby Recovery not using Real Time Apply
 parallel recovery started with 2 processes
ORA-279 signalled during: alter database recover if needed
 standby start
...
Tue Feb 17 03:35:33 2009
Archivelog restore complete. Elapsed time: 0:00:00
Archivelog restore complete. Elapsed time: 0:00:00
Tue Feb 17 03:35:34 2009
alter database recover logfile '/home/oracle/app/oracle/oradata/test_s/archive/1_1339_676622925.arc'
Tue Feb 17 03:35:34 2009
Media Recovery Log /home/oracle/app/oracle/oradata/test_s/archive/1_1339_676622925.arc
ORA-279 signalled during: alter database recover logfile '/home/oracle/app/oracle/oradata/test_s/archive/1_1339_676622925.arc'...
Tue Feb 17 03:35:34 2009
alter database recover logfile '/home/oracle/app/oracle/oradata/test_s/archive/1_1340_676622925.arc'
Tue Feb 17 03:35:34 2009
Media Recovery Log /home/oracle/app/oracle/oradata/test_s/archive/1_1340_676622925.arc
ORA-279 signalled during: alter database recover logfile '/home/oracle/app/oracle/oradata/test_s/archive/1_1340_676622925.arc'...
Tue Feb 17 03:35:34 2009
alter database recover logfile '/home/oracle/app/oracle/oradata/test_s/archive/1_1341_676622925.arc'
Tue Feb 17 03:35:34 2009
Media Recovery Log /home/oracle/app/oracle/oradata/test_s/archive/1_1341_676622925.arc
ORA-279 signalled during: alter database recover logfile '/home/oracle/app/oracle/oradata/test_s/archive/1_1341_676622925.arc'...
Tue Feb 17 03:35:34 2009
alter database recover logfile '/home/oracle/app/oracle/oradata/test_s/archive/1_1342_676622925.arc'
Tue Feb 17 03:35:34 2009
Media Recovery Log /home/oracle/app/oracle/oradata/test_s/archive/1_1342_676622925.arc
ORA-279 signalled during: alter database recover logfile '/home/oracle/app/oracle/oradata/test_s/archive/1_1342_676622925.arc'...
Tue Feb 17 03:35:34 2009
alter database recover cancel
Tue Feb 17 03:35:37 2009
Media Recovery Canceled
Completed: alter database recover cancel


12. 自动恢复
sqlplus /nolog
conn / as sysdba
alter database recover managed standby database disconnect from session;
SQL> alter database recover managed standby database disconnect from session;

Database altered.

SQL>
告警日志:
Tue Feb 17 03:37:30 2009
alter database recover managed standby database disconnect from session
Tue Feb 17 03:37:30 2009
Attempt to start background Managed Standby Recovery process (test_s)
MRP0 started with pid=22, OS id=15363
Tue Feb 17 03:37:30 2009
MRP0: Background Managed Standby Recovery process started (test_s)
Managed Standby Recovery not using Real Time Apply
 parallel recovery started with 2 processes
Tue Feb 17 03:37:35 2009
Waiting for all non-current ORLs to be archived...
Tue Feb 17 03:37:35 2009
Errors in file /home/oracle/app/oracle/admin/test_s/bdump/test_s_mrp0_15363.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/home/oracle/app/oracle/oradata/test_s/redo01b.rdo'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 1 thread 1: '/home/oracle/app/oracle/oradata/test_s/redo01.rdo'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Tue Feb 17 03:37:35 2009
Errors in file /home/oracle/app/oracle/admin/test_s/bdump/test_s_mrp0_15363.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/home/oracle/app/oracle/oradata/test_s/redo01b.rdo'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 1 thread 1: '/home/oracle/app/oracle/oradata/test_s/redo01.rdo'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Clearing online redo logfile 1 /home/oracle/app/oracle/oradata/test_s/redo01.rdo
Clearing online log 1 of thread 1 sequence number 1342
Tue Feb 17 03:37:35 2009
Errors in file /home/oracle/app/oracle/admin/test_s/bdump/test_s_mrp0_15363.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/home/oracle/app/oracle/oradata/test_s/redo01b.rdo'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 1 thread 1: '/home/oracle/app/oracle/oradata/test_s/redo01.rdo'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Tue Feb 17 03:37:36 2009
Completed: alter database recover managed standby database disconnect from session
Tue Feb 17 03:37:41 2009
Clearing online redo logfile 1 complete
Tue Feb 17 03:37:41 2009
Errors in file /home/oracle/app/oracle/admin/test_s/bdump/test_s_mrp0_15363.trc:
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: '/home/oracle/app/oracle/oradata/test_s/redo02b.rdo'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 2 thread 1: '/home/oracle/app/oracle/oradata/test_s/redo02.rdo'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Tue Feb 17 03:37:41 2009
Errors in file /home/oracle/app/oracle/admin/test_s/bdump/test_s_mrp0_15363.trc:
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: '/home/oracle/app/oracle/oradata/test_s/redo02b.rdo'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 2 thread 1: '/home/oracle/app/oracle/oradata/test_s/redo02.rdo'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Clearing online redo logfile 2 /home/oracle/app/oracle/oradata/test_s/redo02.rdo
Clearing online log 2 of thread 1 sequence number 1343
Tue Feb 17 03:37:41 2009
Errors in file /home/oracle/app/oracle/admin/test_s/bdump/test_s_mrp0_15363.trc:
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: '/home/oracle/app/oracle/oradata/test_s/redo02b.rdo'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 2 thread 1: '/home/oracle/app/oracle/oradata/test_s/redo02.rdo'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Clearing online redo logfile 2 complete
Tue Feb 17 03:37:46 2009
Errors in file /home/oracle/app/oracle/admin/test_s/bdump/test_s_mrp0_15363.trc:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: '/home/oracle/app/oracle/oradata/test_s/redo03b.rdo'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 3 thread 1: '/home/oracle/app/oracle/oradata/test_s/redo03.rdo'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Tue Feb 17 03:37:46 2009
Errors in file /home/oracle/app/oracle/admin/test_s/bdump/test_s_mrp0_15363.trc:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: '/home/oracle/app/oracle/oradata/test_s/redo03b.rdo'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 3 thread 1: '/home/oracle/app/oracle/oradata/test_s/redo03.rdo'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Clearing online redo logfile 3 /home/oracle/app/oracle/oradata/test_s/redo03.rdo
Clearing online log 3 of thread 1 sequence number 1341
Tue Feb 17 03:37:46 2009
Errors in file /home/oracle/app/oracle/admin/test_s/bdump/test_s_mrp0_15363.trc:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: '/home/oracle/app/oracle/oradata/test_s/redo03b.rdo'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-00312: online log 3 thread 1: '/home/oracle/app/oracle/oradata/test_s/redo03.rdo'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Clearing online redo logfile 3 complete
Tue Feb 17 03:37:51 2009
Media Recovery Waiting for thread 1 sequence 1343
自动创建了在线重做日志文件



==================================================

用RMAN DUPLICATE创建备库

13. 备份主库
grep -q "&circ;rcat" $ORACLE_HOME/network/admin/tnsnames.ora || \
cat &gt;&gt;$ORACLE_HOME/network/admin/tnsnames.ora &lt;&lt;'EOF'
rcat =
  (DESCRIPTION =
    (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = DEV-DB-2)(PORT = 1531)))
    (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = rcat))
  )

EOF
rman catalog=rman/rman@rcat
create catalog tablespace "RMAN";
exit
rman target=/ catalog=rman/rman@rcat
register database;
crosscheck archivelog all;
delete noprompt expired archivelog all;
list backupset summary;
delete noprompt backupset;
exit

NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss';export NLS_DATE_FORMAT
rman target=/ catalog=rman/rman@rcat
run {
 allocate channel c1 type disk;
 allocate channel c2 type disk;
 allocate channel c3 type disk;
 allocate channel c4 type disk;
 backup as backupset incremental level 0 format '/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_%d_%I_%T_%U' database;
 sql 'alter system archive log current';
 #backup as backupset format '/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_%d_%I_%T_%U' archivelog all;
 release channel c1;
 release channel c2;
 release channel c3;
 release channel c4;
}
exit
[oracle@DEV-RPT-2 ~]$ NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss';export NLS_DATE_FORMAT
[oracle@DEV-RPT-2 ~]$ rman target=/ catalog=rman/rman@rcat

Recovery Manager: Release 10.2.0.4.0 - Production on Thu Feb 19 05:58:14 2009

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: TEST (DBID=1973292924)
connected to recovery catalog database

RMAN> run {
2>  allocate channel c1 type disk;
3>  allocate channel c2 type disk;
4>  allocate channel c3 type disk;
5>  allocate channel c4 type disk;
6>  backup as backupset incremental level 0 format '/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_%d_%I_%T_%U' database;
7>  sql 'alter system archive log current';
8>  #backup as backupset format '/u01/software/oracle/backup/DEV-RPT-2/test/rman/arch_%d_%I_%T_%U' archivelog all;
 release channel c1;
9> 10>  release channel c2;
11>  release channel c3;
12>  release channel c4;
13> }

allocated channel: c1
channel c1: sid=1632 devtype=DISK

allocated channel: c2
channel c2: sid=1622 devtype=DISK

allocated channel: c3
channel c3: sid=1628 devtype=DISK

allocated channel: c4
channel c4: sid=1633 devtype=DISK

Starting backup at 2009-02-19 05:58:26
channel c1: starting incremental level 0 datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00002 name=/home/oracle/app/oracle/oradata/test/undotbs01.dbf
input datafile fno=00005 name=/home/oracle/app/oracle/oradata/test/ts_test01.dbf
channel c1: starting piece 1 at 2009-02-19 05:58:27
channel c2: starting incremental level 0 datafile backupset
channel c2: specifying datafile(s) in backupset
input datafile fno=00001 name=/home/oracle/app/oracle/oradata/test/system01.dbf
channel c2: starting piece 1 at 2009-02-19 05:58:27
channel c3: starting incremental level 0 datafile backupset
channel c3: specifying datafile(s) in backupset
input datafile fno=00003 name=/home/oracle/app/oracle/oradata/test/sysaux01.dbf
input datafile fno=00004 name=/home/oracle/app/oracle/oradata/test/users01.dbf
channel c3: starting piece 1 at 2009-02-19 05:58:28
channel c4: starting incremental level 0 datafile backupset
channel c4: specifying datafile(s) in backupset
including current control file in backupset
channel c4: starting piece 1 at 2009-02-19 05:58:30
channel c4: finished piece 1 at 2009-02-19 05:58:33
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090219_1ek7nss4_1_1 tag=TAG20090219T055827 comment=NONE
channel c4: backup set complete, elapsed time: 00:00:05
channel c4: starting incremental level 0 datafile backupset
channel c4: specifying datafile(s) in backupset
including current SPFILE in backupset
channel c4: starting piece 1 at 2009-02-19 05:58:35
channel c4: finished piece 1 at 2009-02-19 05:58:36
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090219_1fk7nssa_1_1 tag=TAG20090219T055827 comment=NONE
channel c4: backup set complete, elapsed time: 00:00:02
channel c1: finished piece 1 at 2009-02-19 05:58:39
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090219_1bk7nss3_1_1 tag=TAG20090219T055827 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:12
channel c2: finished piece 1 at 2009-02-19 05:58:39
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090219_1ck7nss3_1_1 tag=TAG20090219T055827 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:12
channel c3: finished piece 1 at 2009-02-19 05:58:40
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090219_1dk7nss3_1_1 tag=TAG20090219T055827 comment=NONE
channel c3: backup set complete, elapsed time: 00:00:13
Finished backup at 2009-02-19 05:58:40

sql statement: alter system archive log current

released channel: c1

released channel: c2

released channel: c3

released channel: c4

RMAN> exit


Recovery Manager complete.
[oracle@DEV-RPT-2 ~]$


14. 主库备份控制文件
sqlplus /nolog
conn / as sysdba
host rm -f /u01/software/oracle/backup/DEV-RPT-2/test/rman/cf4standby
alter database create standby controlfile as '/u01/software/oracle/backup/DEV-RPT-2/test/rman/cf4standby';


15. 修改主库归档日志参数
alter system set log_archive_dest_2='service=test_s optional reopen=60';
alter system set log_archive_dest_state_2='defer';
exit


14. 重新做备库

备库上
删除备库
sqlplus /nolog
conn / as sysdba
--alter database recover managed standby database cancel;
shutdown immediate
exit
(cd $ORACLE_BASE/oradata/test_s/ && rm -f *.dbf *.rdo *.ctl)

启动备库NOMOUNT
sqlplus /nolog
conn / as sysdba
startup nomount
exit

复制备库
rman的target连接主库, auxiliary连接备库
NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss';export NLS_DATE_FORMAT
rman target=sys/change_on_install@test catalog=rman/rman@rcat auxiliary=/
run {
  allocate auxiliary channel dup1 type disk;
  allocate auxiliary channel dup2 type disk;
  allocate auxiliary channel dup3 type disk;
  allocate auxiliary channel dup4 type disk;
  duplicate target database for standby
    dorecover;
  release channel dup1;
  release channel dup2;
  release channel dup3;
  release channel dup4;
}
[oracle@DEV-pxy-1 ~]$ rman target=sys/change_on_install@test catalog=rman/rman@rcat auxiliary=/

Recovery Manager: Release 10.2.0.4.0 - Production on Thu Feb 19 06:17:01 2009

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: TEST (DBID=1973292924)
connected to recovery catalog database
connected to auxiliary database: TEST (not mounted)

RMAN> run {
2>   allocate auxiliary channel dup1 type disk;
  allocate auxiliary channel dup2 type disk;
3> 4>   allocate auxiliary channel dup3 type disk;
5>   allocate auxiliary channel dup4 type disk;
6>   duplicate target database for standby
    dorecover;
  release channel dup1;
7> 8>   release channel dup2;
9>   release channel dup3;
10> 11>   release channel dup4;
12> }

allocated channel: dup1
channel dup1: sid=1641 devtype=DISK

allocated channel: dup2
channel dup2: sid=1640 devtype=DISK

allocated channel: dup3
channel dup3: sid=1639 devtype=DISK

allocated channel: dup4
channel dup4: sid=1638 devtype=DISK

Starting Duplicate Db at 2009-02-19 06:17:20

contents of Memory Script:
{
   set until scn  1885189;
   restore clone standby controlfile;
   sql clone 'alter database mount standby database';
}
executing Memory Script

executing command: SET until clause

Starting restore at 2009-02-19 06:17:24

released channel: dup1
released channel: dup2
released channel: dup3
released channel: dup4
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 02/19/2009 06:17:24
RMAN-03015: error occurred in stored script Memory Script
RMAN-06026: some targets not found - aborting restore
RMAN-06024: no backup or copy of the control file found to restore

RMAN>
报错说找不到, 这是因为用alter database创建的控制文件备份, 没有登记在CATALOG


15. 登记控制文件备份
因为备库现在是NOMOUNT的, 所以RMAN必须连接主库, 进行登记
rman target=sys/change_on_install@test catalog=rman/rman@rcat
或直接在主库上运行
rman target=/ catalog=rman/rman@rcat
list copy of controlfile;
catalog controlfilecopy '/u01/software/oracle/backup/DEV-RPT-2/test/rman/cf4standby';
list copy of controlfile;
exit

[oracle@DEV-pxy-1 ~]$ rman target=sys/change_on_install@test catalog=rman/rman@rcat

Recovery Manager: Release 10.2.0.4.0 - Production on Thu Feb 19 06:31:37 2009

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: TEST (DBID=1973292924)
connected to recovery catalog database

RMAN> list copy of controlfile;


RMAN> catalog controlfilecopy '/u01/software/oracle/backup/DEV-RPT-2/test/rman/cf4standby';

cataloged control file copy
control file copy filename=/u01/software/oracle/backup/DEV-RPT-2/test/rman/cf4standby recid=5 stamp=679213903

RMAN> list copy of controlfile;


List of Control File Copies
Key     S Completion Time     Ckp SCN    Ckp Time            Name
------- - ------------------- ---------- ------------------- ----
2848    A 2009-02-19 06:31:43 1885235    2009-02-19 05:59:18 /u01/software/oracle/backup/DEV-RPT-2/test/rman/cf4standby

RMAN> exit


Recovery Manager complete.
[oracle@DEV-pxy-1 ~]$

注销使用:
change controlfilecopy '/u01/software/oracle/backup/DEV-RPT-2/test/rman/cf4standby' uncatalog;


16. 恢复备库
rman target=sys/change_on_install@test catalog=rman/rman@rcat auxiliary=/
run {
  allocate auxiliary channel dup1 type disk;
  allocate auxiliary channel dup2 type disk;
  allocate auxiliary channel dup3 type disk;
  allocate auxiliary channel dup4 type disk;
  duplicate target database for standby
    dorecover;
  release channel dup1;
  release channel dup2;
  release channel dup3;
  release channel dup4;
}
[oracle@DEV-pxy-1 ~]$ rman target=sys/change_on_install@test catalog=rman/rman@rcat auxiliary=/

Recovery Manager: Release 10.2.0.4.0 - Production on Thu Feb 19 06:33:23 2009

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: TEST (DBID=1973292924)
connected to recovery catalog database
connected to auxiliary database: TEST (not mounted)

RMAN> run {
2>   allocate auxiliary channel dup1 type disk;
3>   allocate auxiliary channel dup2 type disk;
  allocate auxiliary channel dup3 type disk;
4> 5>   allocate auxiliary channel dup4 type disk;
6>   duplicate target database for standby
7>     dorecover;
8>   release channel dup1;
9>   release channel dup2;
10>   release channel dup3;
11>   release channel dup4;
12> }

allocated channel: dup1
channel dup1: sid=1640 devtype=DISK

allocated channel: dup2
channel dup2: sid=1639 devtype=DISK

allocated channel: dup3
channel dup3: sid=1638 devtype=DISK

allocated channel: dup4
channel dup4: sid=1642 devtype=DISK

Starting Duplicate Db at 2009-02-19 06:33:34

contents of Memory Script:
{
   set until scn  1886308;
   restore clone standby controlfile;
   sql clone 'alter database mount standby database';
}
executing Memory Script

executing command: SET until clause

Starting restore at 2009-02-19 06:33:37

channel dup1: restoring control file
channel dup1: copied control file copy
input filename=/u01/software/oracle/backup/DEV-RPT-2/test/rman/cf4standby
output filename=/home/oracle/app/oracle/oradata/test_s/control01.ctl
output filename=/home/oracle/app/oracle/oradata/test_s/control02.ctl
output filename=/home/oracle/app/oracle/oradata/test_s/control03.ctl
Finished restore at 2009-02-19 06:33:40

sql statement: alter database mount standby database

contents of Memory Script:
{
   set until scn  1886308;
   set newname for tempfile  1 to
 "/home/oracle/app/oracle/oradata/test_s/temp01.dbf";
   set newname for tempfile  2 to
 "/home/oracle/app/oracle/oradata/test_s/ts_temp01.dbf";
   switch clone tempfile all;
   set newname for datafile  1 to
 "/home/oracle/app/oracle/oradata/test_s/system01.dbf";
   set newname for datafile  2 to
 "/home/oracle/app/oracle/oradata/test_s/undotbs01.dbf";
   set newname for datafile  3 to
 "/home/oracle/app/oracle/oradata/test_s/sysaux01.dbf";
   set newname for datafile  4 to
 "/home/oracle/app/oracle/oradata/test_s/users01.dbf";
   set newname for datafile  5 to
 "/home/oracle/app/oracle/oradata/test_s/ts_test01.dbf";
   restore
   check readonly
   clone database
   ;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

renamed temporary file 1 to /home/oracle/app/oracle/oradata/test_s/temp01.dbf in control file
renamed temporary file 2 to /home/oracle/app/oracle/oradata/test_s/ts_temp01.dbf in control file

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 2009-02-19 06:33:47

channel dup1: starting datafile backupset restore
channel dup1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /home/oracle/app/oracle/oradata/test_s/undotbs01.dbf
restoring datafile 00005 to /home/oracle/app/oracle/oradata/test_s/ts_test01.dbf
channel dup1: reading from backup piece /u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090219_1bk7nss3_1_1
channel dup2: starting datafile backupset restore
channel dup2: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /home/oracle/app/oracle/oradata/test_s/system01.dbf
channel dup2: reading from backup piece /u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090219_1ck7nss3_1_1
channel dup3: starting datafile backupset restore
channel dup3: specifying datafile(s) to restore from backup set
restoring datafile 00003 to /home/oracle/app/oracle/oradata/test_s/sysaux01.dbf
restoring datafile 00004 to /home/oracle/app/oracle/oradata/test_s/users01.dbf
channel dup3: reading from backup piece /u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090219_1dk7nss3_1_1
channel dup1: restored backup piece 1
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090219_1bk7nss3_1_1 tag=TAG20090219T055827
channel dup1: restore complete, elapsed time: 00:00:15
channel dup3: restored backup piece 1
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090219_1dk7nss3_1_1 tag=TAG20090219T055827
channel dup3: restore complete, elapsed time: 00:00:15
channel dup2: restored backup piece 1
piece handle=/u01/software/oracle/backup/DEV-RPT-2/test/rman/data_TEST_1973292924_20090219_1ck7nss3_1_1 tag=TAG20090219T055827
channel dup2: restore complete, elapsed time: 00:00:16
Finished restore at 2009-02-19 06:34:04

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy recid=7 stamp=679214044 filename=/home/oracle/app/oracle/oradata/test_s/system01.dbf
datafile 2 switched to datafile copy
input datafile copy recid=8 stamp=679214044 filename=/home/oracle/app/oracle/oradata/test_s/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=9 stamp=679214044 filename=/home/oracle/app/oracle/oradata/test_s/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=10 stamp=679214044 filename=/home/oracle/app/oracle/oradata/test_s/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=11 stamp=679214044 filename=/home/oracle/app/oracle/oradata/test_s/ts_test01.dbf

contents of Memory Script:
{
   set until scn  1886308;
   recover
   standby
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 2009-02-19 06:34:04

starting media recovery

Oracle Error:
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/home/oracle/app/oracle/oradata/test_s/system01.dbf'

released channel: dup1
released channel: dup2
released channel: dup3
released channel: dup4
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 02/19/2009 06:34:05
RMAN-03015: error occurred in stored script Memory Script
RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of log thread 1 seq 1446 lowscn 1885189 found to restore
RMAN-06025: no backup of log thread 1 seq 1445 lowscn 1884681 found to restore

RMAN>

告警日志:
Thu Feb 19 06:33:40 2009
alter database mount standby database
Thu Feb 19 06:33:44 2009
Setting recovery target incarnation to 2
ARCH: STARTING ARCH PROCESSES
ARC0 started with pid=19, OS id=29083
Thu Feb 19 06:33:44 2009
ARC0: Archival started
ARC1: Archival started
ARCH: STARTING ARCH PROCESSES COMPLETE
Thu Feb 19 06:33:44 2009
ARC0: Becoming the 'no FAL' ARCH
ARC0: Becoming the 'no SRL' ARCH
ARC0: Thread not mounted
ARC1 started with pid=20, OS id=29085
ARC1: Becoming the heartbeat ARCH
ARC1: Thread not mounted
Thu Feb 19 06:33:44 2009
Successful mount of redo thread 1, with mount id 1977316932
Thu Feb 19 06:33:44 2009
Physical Standby Database mounted.
Completed: alter database mount standby database
Thu Feb 19 06:33:49 2009
Full restore complete of datafile 4 /home/oracle/app/oracle/oradata/test_s/users01.dbf.  Elapsed time: 0:00:01
  checkpoint is 1885163
Full restore complete of datafile 3 /home/oracle/app/oracle/oradata/test_s/sysaux01.dbf.  Elapsed time: 0:00:09
  checkpoint is 1885163
  last deallocation scn is 1874683
Thu Feb 19 06:34:00 2009
Full restore complete of datafile 2 /home/oracle/app/oracle/oradata/test_s/undotbs01.dbf.  Elapsed time: 0:00:12
  checkpoint is 1885160
  last deallocation scn is 1880441
Full restore complete of datafile 5 /home/oracle/app/oracle/oradata/test_s/ts_test01.dbf.  Elapsed time: 0:00:15
  checkpoint is 1885160
  last deallocation scn is 1816179
Thu Feb 19 06:34:03 2009
Full restore complete of datafile 1 /home/oracle/app/oracle/oradata/test_s/system01.dbf.  Elapsed time: 0:00:15
  checkpoint is 1885161
  last deallocation scn is 1852843
Thu Feb 19 06:34:04 2009
Switch of datafile 1 complete to datafile copy
  checkpoint is 1885161
Switch of datafile 2 complete to datafile copy
  checkpoint is 1885160
Switch of datafile 3 complete to datafile copy
  checkpoint is 1885163
Switch of datafile 4 complete to datafile copy
  checkpoint is 1885163
Switch of datafile 5 complete to datafile copy
  checkpoint is 1885160
Thu Feb 19 06:34:05 2009
alter database recover datafile list clear
Completed: alter database recover datafile list clear
Thu Feb 19 06:34:05 2009
alter database recover datafile list
 1 , 2 , 3 , 4 , 5
Completed: alter database recover datafile list
 1 , 2 , 3 , 4 , 5
Thu Feb 19 06:34:05 2009
alter database recover if needed
 standby start until change 1886308
Media Recovery Start
Managed Standby Recovery not using Real Time Apply
 parallel recovery started with 2 processes
ORA-279 signalled during: alter database recover if needed
 standby start until change 1886308
...
Thu Feb 19 06:34:05 2009
alter database recover cancel
Signalling error 1152 for datafile 1!
ORA-1547 signalled during: alter database recover cancel...
Thu Feb 19 06:36:48 2009
db_recovery_file_dest_size of 2048 MB is 0.00% used. This is a
user-specified limit on the amount of space that will be used by this
database for recovery-related files, and does not reflect the amount of
space available in the underlying filesystem or ASM diskgroup.


17. 自动恢复
sqlplus /nolog
conn / as sysdba
alter database recover managed standby database disconnect from session;
exit


18. 主库恢复归档
alter system set log_archive_dest_2='service=test_s optional reopen=60';
alter system set log_archive_dest_state_2='enable';







外部链接:
Creating a Standby Database with Recovery Manager
Step by step guide on how to create a physical standby database using RMAN without using duplicate command
Creating a Standby Database using RMAN (Recovery Manager)




-fin-
Website Analytics

Followers