1.oracle RAC11G 对单机ADG搭建详细文档


    
    
    
    
一个问题:rac对单机ADG搭建完成之后,rac是双节点,假设某一个节点发生故障done机了,或者是将一个节点关机了,然后
这个数据库再启动话是否还能起来???
起不来。因为一旦重启,之前修改的参数就生效了,启动的时候就会出现参数路径不一致的情况,就会导致这个节点无法启动。
有两个解决办法:
1.生成一个pfile文件,使用pfile文件启动,但是有弊端
2、重新编辑参数文件,清空路径不一致的参数,然后再启动。
生产库上如果不能立即重启使参数生效,那就等可以重启的时候在统一重启各个节点的数据库使参数生效就可以了。
备库:
  • standby 操作系统 oracle版本 db_name db_unique hostname oracle_sid
      rhel-server-6.5-x86_64 11.2.0.4 rac11g rac11gdg rac11gdg rac11gdg
主库:
RAC 操作系统 oracle版本 db_name db_unique hostname oracle_sid
节点1 rhel-server-6.5-x86_64 11.2.0.4 rac11g rac11g rac11g1 rac11g1
节点2 rhel-server-6.5-x86_64 11.2.0.4 rac11g rac11g rac11g2 rac11g2
1、创建物理备库的准备工作,首先保证rac数据库的状态都正常
 
1
[grid@rac11g1 ~]$ lsnrctl status 
2
3
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 06-APR-2017 17:00:55
Copyright (c) 1991, 2013, Oracle.  Allrightsreserved.
6
7
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
8
STATUS of the LISTENER
9
------------------------
10
Alias                     LISTENER
11
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
12
Start Date                06-APR-2017 16:05:29
13
Uptime                    0 days 0 hr. 55 min. 25 sec
14
Trace Level               off
15
Security                  ON: Local OS Authentication
16
SNMP                      OFF
17
Listener Parameter File   /u01/11.2.0/grid/network/admin/listener.ora
18
Listener Log File         /u01/app/oracle/diag/tnslsnr/rac11g1/listener/alert/log.xml
19
Listening Endpoints Summary...
20
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
21
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.10)(PORT=1521)))
22
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.26)(PORT=1521)))
23
Services Summary...
24
Service "+ASM" has 1 instance(s).
25
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
26
Service "rac11g" has 1 instance(s).
27
  Instance "rac11g1", status READY, has 1 handler(s) for this service...
28
Service "rac11gXDB" has 1 instance(s).
29
  Instance "rac11g1", status READY, has 1 handler(s) for this service...
30
The command completed successfully
31
[grid@rac11g1 ~]$ crsctl status resource -t
32
--------------------------------------------------------------------------------
33
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
34
--------------------------------------------------------------------------------
35
Local Resources
36
--------------------------------------------------------------------------------
37
ora.ARCHDG.dg
38
               ONLINE  ONLINE       rac11g1                                      
39
               ONLINE  ONLINE       rac11g2                                      
40
ora.DATADG.dg
41
               ONLINE  ONLINE       rac11g1                                      
42
               ONLINE  ONLINE       rac11g2                                      
43
ora.LISTENER.lsnr
44
               ONLINE  ONLINE       rac11g1                                      
45
               ONLINE  ONLINE       rac11g2                                      
46
ora.OCR_VOTE.dg
47
               ONLINE  ONLINE       rac11g1                                      
48
               ONLINE  ONLINE       rac11g2                                      
49
ora.asm
50
               ONLINE  ONLINE       rac11g1                  Started             
51
               ONLINE  ONLINE       rac11g2                  Started             
52
ora.gsd
53
               OFFLINE OFFLINE      rac11g1                                      
54
               OFFLINE OFFLINE      rac11g2                                      
55
ora.net1.network
56
               ONLINE  ONLINE       rac11g1                                      
57
               ONLINE  ONLINE       rac11g2                                      
58
ora.ons
59
               ONLINE  ONLINE       rac11g1                                      
60
               ONLINE  ONLINE       rac11g2                                      
61
ora.registry.acfs
62
               ONLINE  ONLINE       rac11g1                                      
63
               ONLINE  ONLINE       rac11g2                                      
64
--------------------------------------------------------------------------------
65
Cluster Resources
66
--------------------------------------------------------------------------------
67
ora.LISTENER_SCAN1.lsnr
68
      1        ONLINE  ONLINE       rac11g1                                      
69
ora.cvu
70
      1        ONLINE  ONLINE       rac11g1                                      
71
ora.oc4j
72
      1        ONLINE  ONLINE       rac11g1                                      
73
ora.rac11g.db
74
      1        ONLINE  ONLINE       rac11g1                  Open                
75
      2        ONLINE  ONLINE       rac11g2                  Open                
76
ora.rac11g1.vip
77
      1        ONLINE  ONLINE       rac11g1                                      
78
ora.rac11g2.vip
79
      1        ONLINE  ONLINE       rac11g2                                      
80
ora.scan1.vip
81
      1        ONLINE  ONLINE       rac11g1


10中的命令:
[grid@rac11g1 admin]$ crs_stat -tName           Type           Target    State     Host        ------------------------------------------------------------ora.ARCHDG.dg  ora....up.type ONLINE    ONLINE    rac11g1     ora.DATADG.dg  ora....up.type ONLINE    ONLINE    rac11g1     ora....ER.lsnr ora....er.type ONLINE    ONLINE    rac11g1     ora....N1.lsnr ora....er.type ONLINE    ONLINE    rac11g1     ora....VOTE.dg ora....up.type ONLINE    ONLINE    rac11g1     ora.asm        ora.asm.type   ONLINE    ONLINE    rac11g1     ora.cvu        ora.cvu.type   ONLINE    ONLINE    rac11g1     ora.gsd        ora.gsd.type   OFFLINE   OFFLINE               ora....network ora....rk.type ONLINE    ONLINE    rac11g1     ora.oc4j       ora.oc4j.type  ONLINE    ONLINE    rac11g1     ora.ons        ora.ons.type   ONLINE    ONLINE    rac11g1     ora.rac11g.db  ora....se.type ONLINE    ONLINE    rac11g1     ora....SM1.asm application    ONLINE    ONLINE    rac11g1     ora....G1.lsnr application    ONLINE    ONLINE    rac11g1     ora....1g1.gsd application    OFFLINE   OFFLINE               ora....1g1.ons application    ONLINE    ONLINE    rac11g1     ora....1g1.vip ora....t1.type ONLINE    ONLINE    rac11g1     ora....SM2.asm application    ONLINE    ONLINE    rac11g2     ora....G2.lsnr application    ONLINE    ONLINE    rac11g2     ora....1g2.gsd application    OFFLINE   OFFLINE               ora....1g2.ons application    ONLINE    ONLINE    rac11g2     ora....1g2.vip ora....t1.type ONLINE    ONLINE    rac11g2     ora....ry.acfs ora....fs.type ONLINE    ONLINE    rac11g1     ora.scan1.vip  ora....ip.type ONLINE    ONLINE    rac11g1 

1.1、 修改RAC数据库为FORCE LOGGING
 
1
SQL> select force_logging from v$database;
2
3
FOR
4
---
5
NO
6
7
SQL> alter database force logging;
8
9
Database altered.

1.2、查询online 的redo log 
 
1
注:通常我们设置生产库的每个redo大小为512M~2048M之间,并且大于等于三组
2
SQL> set linesize 150;
3
set pagesize 50;
4
column MB format a5;
5
column STATUS format a12;
6
column MEMBER format a50;
7
select l.GROUP#,l.THREAD#,l.BYTES/1024/1024||'MB' MB,l.STATUS, lf.TYPE,lf.MEMBER from v$log l,v$logfile lf where l.GROUP#=lf.GROUP#;
8
SQL> SQL> SQL> SQL> SQL> 
9
    GROUP#    THREAD# MB    STATUS TYPE MEMBER
10
---------- ---------- ----- ------------ ------- --------------------------------------------------
11
 1    1 512MB INACTIVE ONLINE  +DATADG/rac11g/onlinelog/group_1.263.940529009
12
 2    1 512MB INACTIVE ONLINE  +DATADG/rac11g/onlinelog/group_2.262.940529023
13
 3    1 512MB INACTIVE ONLINE  +DATADG/rac11g/onlinelog/group_3.261.940529039
14
 5    2 512MB INACTIVE ONLINE  +DATADG/rac11g/onlinelog/group_5.268.940259119
15
 6    2 512MB CURRENT ONLINE  +DATADG/rac11g/onlinelog/group_6.269.940259139
16
 7    2 512MB INACTIVE ONLINE  +DATADG/rac11g/onlinelog/group_7.270.940259155
17
 8    2 512MB INACTIVE ONLINE  +DATADG/rac11g/onlinelog/group_8.271.940259169
18
 4    1 512MB CURRENT ONLINE  +DATADG/rac11g/onlinelog/group_4.273.940529057
19
20
8 rows selected.

1.3、编辑hosts 文件主机名解析配置
 
1
编辑所有RAC节点的hosts文件:
2
[root@rac11g1 ~]# vim /etc/hosts  (节点1 同节点2 )
3
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
5
6
#rac11g Public IP
7
192.168.56.10         rac11g1
8
192.168.56.11         rac11g2
9
#rac11g Private IP
10
10.10.10.20           rac11g1-priv
11
10.10.10.21           rac11g2-priv
12
#rac11g VIP
13
192.168.56.26         rac11g1-vip
14
192.168.56.27         rac11g2-vip
15
#rac11g SCAN IP
16
192.168.56.29         rac11gscan
17
18
#ADG
19
192.168.56.70   db11g1    //备库的ip 以及主机名
20
21
编辑备库的hosts文件:(与rac中的hosts文件相同)
22
[root@db11g1 ~]# vim /etc/hosts
23
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
24
#public IP
25
192.168.56.10         rac11g1
26
192.168.56.11         rac11g2
27
#rac11g Private IP
28
10.10.10.20           rac11g1-priv
29
10.10.10.21           rac11g2-priv
30
#rac11g VIP
31
192.168.56.26         rac11g1-vip
32
192.168.56.27         rac11g2-vip
33
#rac11g SCAN IP
34
192.168.56.29         rac11gscan
35
36
#ADG
37
192.168.56.70   db11g1
38
39
40
修改完成之后在各个节点上ping 一下检查是否可以ping通
41
在rac的连个节点上ping一下备库:
42
[root@rac11g1 ~]# ping db11g1
43
PING db11g1 (192.168.56.70) 56(84) bytes of data.
44
64 bytes from db11g1 (192.168.56.70): icmp_seq=1 ttl=64 time=0.327 ms
45
64 bytes from db11g1 (192.168.56.70): icmp_seq=2 ttl=64 time=0.350 ms
46
64 bytes from db11g1 (192.168.56.70): icmp_seq=3 ttl=64 time=0.274 ms
47
48
[root@rac11g2 ~]# ping db11g1
49
PING db11g1 (192.168.56.70) 56(84) bytes of data.
50
64 bytes from db11g1 (192.168.56.70): icmp_seq=1 ttl=64 time=0.204 ms
51
64 bytes from db11g1 (192.168.56.70): icmp_seq=2 ttl=64 time=0.195 ms
52
64 bytes from db11g1 (192.168.56.70): icmp_seq=3 ttl=64 time=0.420 ms
53
64 bytes from db11g1 (192.168.56.70): icmp_seq=4 ttl=64 time=0.349 ms
54
55
56
57
在备库上ping一下rac的两个节点:
58
[root@db11g1 ~]# ping rac11g1
59
PING rac11g1 (192.168.56.10) 56(84) bytes of data.
60
64 bytes from rac11g1 (192.168.56.10): icmp_seq=1 ttl=64 time=1.64 ms
61
64 bytes from rac11g1 (192.168.56.10): icmp_seq=2 ttl=64 time=0.556 ms
62
64 bytes from rac11g1 (192.168.56.10): icmp_seq=3 ttl=64 time=0.243 ms
63
64 bytes from rac11g1 (192.168.56.10): icmp_seq=4 ttl=64 time=0.270 ms
64
^C
65
--- rac11g1 ping statistics ---
66
4 packets transmitted, 4 received, 0% packet loss, time 3187ms
67
rtt min/avg/max/mdev = 0.243/0.678/1.645/0.571 ms
68
[root@db11g1 ~]# 
69
[root@db11g1 ~]# ping rac11g2
70
PING rac11g2 (192.168.56.11) 56(84) bytes of data.
71
64 bytes from rac11g2 (192.168.56.11): icmp_seq=1 ttl=64 time=1.02 ms
72
64 bytes from rac11g2 (192.168.56.11): icmp_seq=2 ttl=64 time=0.269 ms
73
64 bytes from rac11g2 (192.168.56.11): icmp_seq=3 ttl=64 time=0.268 ms


1.4、配置备库的监听
 
1
[oracle@db11g1 admin]$ vim listener.ora
2
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
3
# Generated by Oracle configuration tools.
4
5
SID_LIST_LISTENER =
6
  (SID_LIST =
7
    (SID_DESC =
8
      (GLOBAL_DBNAME = rac11gdg)
9
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
10
      (SID_NAME = rac11gdg)
11
    )
12
  )
13
14
LISTENER =
15
  (DESCRIPTION_LIST =
16
    (DESCRIPTION =
17
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.70)(PORT = 1521))
18
    )
19
    (DESCRIPTION =
20
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
21
    )
22
  )
23
24
ADR_BASE_LISTENER = /u01/app/oracle
25
26
27
然后重启监听
28
[oracle@db11g1 admin]$ lsnrctl stop
29
[oracle@db11g1 admin]$ lsnrctl start
30
[oracle@db11g1 admin]$ lsnrctl status
31

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 17-SEP-2017 14:06:30Copyright (c) 1991, 2013, Oracle.  All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.70)(PORT=1521)))STATUS of the LISTENER------------------------Alias                     LISTENERVersion                   TNSLSNR for Linux: Version 11.2.0.4.0 - ProductionStart Date                17-SEP-2017 14:06:26Uptime                    0 days 0 hr. 0 min. 3 secTrace Level               offSecurity                  ON: Local OS AuthenticationSNMP                      OFFListener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.oraListener Log File         /u01/app/oracle/diag/tnslsnr/rac11gdg/listener/alert/log.xmlListening Endpoints Summary...  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.70)(PORT=1521)))  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))Services Summary...Service "rac11g" has 1 instance(s).  Instance "rac11gdg", status UNKNOWN, has 1 handler(s) for this service...The command completed successfully


1.5 配置所有的tnsname.ora 文件
 
1
节点1:
2
[root@rac11g1 ~]# su - oracle
3
[oracle@rac11g1 ~]$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin/
4
[oracle@rac11g1 admin]$ ls
5
samples  shrept.lst  tnsnames.ora
6
[oracle@rac11g1 admin]$ vim tnsnames.ora 
7
# tnsnames.ora.rac11g1 Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora.rac11g1
8
# Generated by Oracle configuration tools.
9
10
RAC11G =
11
  (DESCRIPTION =
12
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac11gscan)(PORT = 1521))
13
    (CONNECT_DATA =
14
      (SERVER = DEDICATED)
15
      (SERVICE_NAME = rac11g)
16
    )
17
  )
18
// 注:这里主机名写成rac11gscan ,可以解析两个节点
19
20
// 添加一个解析备库的解析地址
21
RACDG =
22
  (DESCRIPTION =
23
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.70)(PORT = 1521))
24
    (CONNECT_DATA =
25
      (SERVER = DEDICATED)
26
      (SERVICE_NAME = racdg)
27
    )
28
  )  
29
30
配置完成之后tnsping 一下
31
[oracle@rac11g1 admin]$ tnsping RACDG
32
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 06-APR-2017 18:22:19
33
Copyright (c) 1997, 2013, Oracle.  All rights reserved.
34
Used parameter files:
35
Used TNSNAMES adapter to resolve the alias
36
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.70)(PORT = 1521)) 
37
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = racdg)))
38
OK (10 msec)
39
40
[oracle@rac11g1 admin]$ tnsping RAC11G
41
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 06-APR-2017 18:22:27
42
Copyright (c) 1997, 2013, Oracle.  All rights reserved.
43
Used parameter files:
44
Used TNSNAMES adapter to resolve the alias
45
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = rac11gscan)(PORT = 1521)) (CONNECT_DATA =
46
 (SERVER = DEDICATED) (SERVICE_NAME = rac11g)))
47
OK (20 msec)
48
两个解析都可以ping通
49
50
节点2:
51
[oracle@rac11g2 admin]$ vim tnsnames.ora 
52
# tnsnames.ora.rac11g2 Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora.rac11g2
53
# Generated by Oracle configuration tools.
54
55
RAC11G =
56
  (DESCRIPTION =
57
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac11gscan)(PORT = 1521))
58
    (CONNECT_DATA =
59
      (SERVER = DEDICATED)
60
      (SERVICE_NAME = rac11g)
61
    )
62
  )
63
64
RACDG =
65
  (DESCRIPTION =
66
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.70)(PORT = 1521))
67
    (CONNECT_DATA =
68
      (SERVER = DEDICATED)
69
      (SERVICE_NAME = racdg)
70
    )
71
  )
72
73
ping一下:
74
[oracle@rac11g2 admin]$ tnsping rac11g
75
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 06-APR-2017 18:26:21
76
Copyright (c) 1997, 2013, Oracle.  All rights reserved.
77
Used parameter files:
78
79
Used TNSNAMES adapter to resolve the alias
80
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = rac11gscan)(PORT = 1521)) (CONNECT_DATA = 
81
(SERVER = DEDICATED) (SERVICE_NAME = rac11g)))
82
OK (0 msec)
83
84
[oracle@rac11g2 admin]$ tnsping racdg
85
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 06-APR-2017 18:26:24
86
Copyright (c) 1997, 2013, Oracle.  All rights reserved.
87
Used parameter files:
88
89
Used TNSNAMES adapter to resolve the alias
90
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.70)(PORT = 1521)) 
91
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = racdg)))
92
OK (10 msec)
93
94
也没有问题,都可以ping通
95
96
注意:tnsping能ping通不代表主库的日志可以通过它传到备库,也不代表备库的归档日志可以传到主库,只能说明你
97
            配置的这个解析串是可以ping通的,并不代表进程会通过这个解析串成功的把想要传输的东西传输过去
98
99
100
备库上就有点不一样了:
101
[oracle@db11g1 admin]$ vim tnsnames.ora
102
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
103
# Generated by Oracle configuration tools.
104
105
RACDG =
106
  (DESCRIPTION =
107
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.70)(PORT = 1521))
108
    (CONNECT_DATA =
109
      (SERVER = DEDICATED)
110
      (SERVICE_NAME = racdg)
111
    )
112
  )
113
114
RAC11G =
115
  (DESCRIPTION =
116
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.10)(PORT = 1521))
117
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.11)(PORT = 1521))
118
    (CONNECT_DATA =
119
      (SERVER = DEDICATED)
120
      (SERVICE_NAME = rac11g)
121
    )
122
  )
123
124
ping 一下:
125
[oracle@db11g1 admin]$ tnsping racdg
126
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 06-APR-2017 18:33:23
127
Copyright (c) 1997, 2013, Oracle.  All rights reserved.
128
Used parameter files:
129
130
Used TNSNAMES adapter to resolve the alias
131
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.70)(PORT = 1521)) (CONNECT_DATA = 
132
(SERVER = DEDICATED) (SERVICE_NAME = racdg)))
133
OK (10 msec)
134
[oracle@db11g1 admin]$ tnsping rac11g
135
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 06-APR-2017 18:33:30
136
Copyright (c) 1997, 2013, Oracle.  All rights reserved.
137
Used parameter files:
138
139
Used TNSNAMES adapter to resolve the alias
140
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.10)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)
141
(HOST = 192.168.56.11)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = rac11g)))
142
OK (0 msec)
143
也没有问题。
144
145
需要注意的是:在备库中不推荐使用(ADDRESS = (PROTOCOL = TCP)(HOST = rac11gscan)(PORT = 1521))  这种方式,因为
这样写的话将来备库连接主库的时候,无法保证归档日志是怎么传输的,因为他是随机分配的。所以还是写成具体的地址
2、主库初始化参数检查与设置
2.1、查看主库的  DB_NAME
 
1
SQL> set linesize 150;   
2
SQL> show parameter DB_NAME;
3
4
NAME     TYPE VALUE
5
------------------------------------ ----------- ------------------------------
6
db_name      string rac11g
2.2、查看数据库的唯一名和归档模式
 
1
SQL> show parameter db_unique_name;
2
3
NAME     TYPE VALUE
4
------------------------------------ ----------- ------------------------------
5
db_unique_name string rac11g
6
SQL> select db_unique_name,name,log_mode from v$database;
7
8
DB_UNIQUE_NAME       NAME LOG_MODE
9
------------------------------ --------- ------------
10
rac11g       RAC11G ARCHIVELOG
11
SQL> archive log list;
12
Database log mode       Archive Mode
13
Automatic archival       Enabled
14
Archive destination       +ARCHDG
15
Oldest online log sequence     15
16
Next log sequence to archive   18
17
Current log sequence       18
18
19
确认一下是否只有这一条归档路径:
20
SQL> show parameter archive;
21
22
NAME     TYPE VALUE
23
------------------------------------ ----------- ------------------------------
24
archive_lag_target     integer 0
25
log_archive_config     string
26
log_archive_dest     string
27
log_archive_dest_1     string LOCATION=+ARCHDG
28
log_archive_dest_10     string
29
log_archive_dest_11     string
2.3、查看 log_archive_config 参数并进行设置

 
1
SQL>  set linesize 150;
2
3
SQL> show parameters LOG_ARCHIVE_CONFIG
4
NAME     TYPE VALUE
5
------------------------------------ ----------- ------------------------------
6
log_archive_config     string
7
8
SQL> alter system set log_archive_config='dg_config=(racllg,racdg)';  // 这个写的是db_unique_name
9
10
System altered.
11
12
SQL> show parameters LOG_ARCHIVE_CONFIG;
13
14
NAME     TYPE VALUE
15
------------------------------------ ----------- ------------------------------
16
log_archive_config     string dg_config=(racllg,racdg)

 
2.4、查看一下控制文件的位置
 
1
SQL> show parameter control_files
2
3
NAME     TYPE VALUE
4
------------------------------------ ----------- ------------------------------
5
control_files     string +DATADG/rac11g/controlfile/cur
6
 rent.260.940258727
2.5、在所有节点查看并设置归档参数
 
1
主库:
2
SQL> show parameter log_archive_dest_1;
3
4
NAME     TYPE VALUE
5
------------------------------------ ----------- ------------------------------
6
log_archive_dest_1     string LOCATION=+ARCHDG
7
log_archive_dest_10     string
8
log_archive_dest_11     string
9
10
SQL> alter system set LOG_ARCHIVE_DEST_1='LOCATION=+ARCHDG  VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=rac11g';
11
12
System altered.
13
14
SQL> alter system set LOG_ARCHIVE_DEST_2='SERVICE=racdg ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=racdg';
15
16
System altered.
17
18
SQL> show parameter LOG_ARCHIVE_DEST_1   //第一条归档路径是本地+ARCHDG
19
20
NAME     TYPE VALUE
21
------------------------------------ ----------- ------------------------------
22
log_archive_dest_1     string LOCATION=+ARCHDG  VALID_FOR=(A
23
 LL_LOGFILES,ALL_ROLES) DB_UNIQ
24
 UE_NAME=rac11g
25
log_archive_dest_10     string
26
log_archive_dest_11     string
27
log_archive_dest_12     string
28
log_archive_dest_13     string
29
log_archive_dest_14     string
30
log_archive_dest_15     string
31
log_archive_dest_16     string
32
log_archive_dest_17     string
33
log_archive_dest_18     string
34
log_archive_dest_19     string
35
SQL> show parameters LOG_ARCHIVE_DEST_2  //第二条归档路径是远端 DB_UNIQUE_NAME=racdg
36
37
NAME     TYPE VALUE
38
------------------------------------ ----------- ------------------------------
39
log_archive_dest_2     string SERVICE=racdg ASYNC VALID_FOR=
40
 (ONLINE_LOGFILES,PRIMARY_ROLE)
41
  DB_UNIQUE_NAME=racdg
42
log_archive_dest_20     string
43
log_archive_dest_21     string
44
log_archive_dest_22     string
45
log_archive_dest_23     string
46
log_archive_dest_24     string
47
log_archive_dest_25     string
48
log_archive_dest_26     string
49
log_archive_dest_27     string
50
log_archive_dest_28     string
51
log_archive_dest_29     string
52
SQL> 
注意的问题:

 
1
1、注:搭建DG后,若发现主库无法解析LOG_ARCHIVE_DEST_2中备库的service名,修改LOG_ARCHIVE_DEST_2参数,直接指定tns连接字符串,绕过tnsnames.ora文件的解析。
3
例:
4
SQL> alter system set log_archive_dest_2='service="(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 172.17.0.14)(PORT = 1521))
5
(CONNECT_DATA =(SERVER = DEDICATED) (SERVICE_NAME = orcldg)))" ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) 
6
DB_UNIQUE_NAME=orcldg' scope=both;
7
8
System altered.
9
10
11
2、注:若是10g数据库,必须采用归档模式,即:
12
alter system set log_archive_dest_2='service="(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)
13
(HOST = 172.17.0.14)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED) (SERVICE_NAME = orcldg)))" ARCH VALID_FOR=
14
(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcldg' scope=both;
15
16
如果不采用这种方式,一旦备库done机,主库也一定会夯住

2.6确认LOG_ARCHIVE_DEST_STATE_1LOG_ARCHIVE_DEST_STATE_2参数为" enable "

 
1
SQL> show parameters LOG_ARCHIVE_DEST_STATE
2
3
NAME     TYPE VALUE
4
------------------------------------ ----------- ------------------------------
5
log_archive_dest_state_1     string enable
6
log_archive_dest_state_10     string enable
7
log_archive_dest_state_11     string enable
8
log_archive_dest_state_12     string enable
9
log_archive_dest_state_13     string enable
10
log_archive_dest_state_14     string enable
11
log_archive_dest_state_15     string enable
12
log_archive_dest_state_16     string enable
13
log_archive_dest_state_17     string enable
14
log_archive_dest_state_18     string enable
15
log_archive_dest_state_19     string enable
16
log_archive_dest_state_2     string enable
17
18
归档路径启用方法:
19
SQL> alter system set log_archive_dest_state_2=ENABLE;
20
System altered.
21
SQL>
22
23
归档路径禁用方法:
24
SQL> alter system set log_archive_dest_state_2=defer;
25
System altered.


2.7 、确认REMOTE_LOGIN_PASSWORDFILE参数为"EXCLUSIVE"
 
1
SQL> show parameters REMOTE_LOGIN_PASSWORDFILE
2
3
NAME     TYPE VALUE
4
------------------------------------ ----------- ------------------------------
5
remote_login_passwordfile     string EXCLUSIVE
6
7
查看并设置LOG_ARCHIVE_MAX_PROCESSES参,4个或者5个都行
8
SQL> show parameters LOG_ARCHIVE_MAX_PROCESSES
9
10
NAME     TYPE VALUE
11
------------------------------------ ----------- ------------------------------
12
log_archive_max_processes     integer 4
13
14
SQL> alter system set LOG_ARCHIVE_MAX_PROCESSES=5;
15
System altered.


2.8、设置switch over参数FAL_SERVERFAL_CLIENT
 
1
注:主库的服务端是备库,客户端是主库;备库的服务端是主库,客户端是备库;不要混淆。
2
3
只在一个节点上执行就可以:
4
SQL> alter system set FAL_SERVER=racdg;  //备库的tns解析名
5
6
System altered.
7
8
SQL> alter system set FAL_CLIENT=rac11g; //主库的tns解析名
9
10
System altered.
11
12
SQL> show parameters FAL_
13
14
NAME     TYPE VALUE
15
------------------------------------ ----------- ------------------------------
16
fal_client     string RAC11G
17
fal_server     string RACDG

2.9、 设置数据文件名,redo log 文件名转换参数(这个是以后做主备库切换的时候用到)
 
1
注:当为备库角色时,上面两个参数对数据文件、redo log 文件名做转换;若主备库的数据库物理结构完全一致,忽略该步骤
2
3
从asmdg转换到文件系统
4
SQL> select name from v$datafile;                                                     
5
NAME
6
--------------------------------------------------------------------------------------------------------------------------
7
+DATADG/rac11g/datafile/system.256.940258647
8
+DATADG/rac11g/datafile/sysaux.257.940258647
9
+DATADG/rac11g/datafile/undotbs1.258.940529005
10
+DATADG/rac11g/datafile/users.259.940258647
11
+DATADG/rac11g/datafile/example.266.940258813
12
+DATADG/rac11g/datafile/undotbs2.267.940258987
13
+DATADG/rac11g/datafile/undotbs1_1.264.940524699
14
15
7 rows selected.
16
17
SQL> select member from v$logfile;
18
19
MEMBER
20
--------------------------------------------------
21
+DATADG/rac11g/onlinelog/group_1.263.940529009
22
+DATADG/rac11g/onlinelog/group_2.262.940529023
23
+DATADG/rac11g/onlinelog/group_3.261.940529039
24
+DATADG/rac11g/onlinelog/group_5.268.940259119
25
+DATADG/rac11g/onlinelog/group_6.269.940259139
26
+DATADG/rac11g/onlinelog/group_7.270.940259155
27
+DATADG/rac11g/onlinelog/group_8.271.940259169
28
+DATADG/rac11g/onlinelog/group_4.273.940529057
29
30
8 rows selected.
31
32
设置数据文件路径:
33
SQL> alter system set DB_FILE_NAME_CONVERT='/oradata/rac11g/','+DATADG/RAC/' scope=spfile;
34
35
System altered.
36
37
设置归档日志路径:
38
SQL> alter system set LOG_FILE_NAME_CONVERT='/oradata/rac11g/onlinelog/','+DATADG/RAC/onlinelog' scope=spfile;
39
40
System altered.

2.10 设置备用文件管理方式:
 
1
SQL>  show parameters STANDBY_FILE_MANAGEMENT
2
3
NAME     TYPE VALUE
4
------------------------------------ ----------- ------------------------------
5
standby_file_management      string MANUAL
6
SQL> alter system set STANDBY_FILE_MANAGEMENT=AUTO;
7
8
System altered.
9
10
SQL> show parameters STANDBY_FILE_MANAGEMENT
11
12
NAME     TYPE VALUE
13
------------------------------------ ----------- ------------------------------
14
standby_file_management      string AUTO

2.11 重启所有节点的数据库实例,使修改的参数生效(生产库按具体情况选择重启或者忽略

 
1
注:关闭数据库前,严格检查数据库信息
2
3
确认当前主机:hostname
4
确认当前实例:echo $ORACLE_SID
5
确认当前数据库唯一名:show parameter db_un
6
7
确认无误后
8
关闭所有节点数据库实例:
9
SQL> shutdown immediate
10
Database closed.
11
Database dismounted.
12
ORACLE instance shut down.
13
14
15
启动所有节点实例:
16
SQL> startup
17
18
ORACLE instance started.
19
Total System Global Area 5.3447E+10 bytes
20
Fixed Size                  2265864 bytes
21
Variable Size            1.3556E+10 bytes
22
Database Buffers         3.9863E+10 bytes
23
Redo Buffers               26480640 bytes
24
Database mounted.
25
Database opened.

3、对数据库进行全备,并将备份scp到备库
 
1
创建备份目录(主备库目录一致):
2
主库:
3
[root@rac11g1 ~]# mkdir /home/oracle/backup/
4
[root@rac11g1 ~]# ll /home/oracle/
5
total 804
6
-rw-r--r-- 1 oracle oinstall  40304 Sep  1 11:36 ashrpt_1_0901_1135.html
7
-rw-r--r-- 1 oracle oinstall 725903 Sep  1 09:41 awrrpt_1_43_47.html
8
drwxr-xr-x 2 root   root       4096 Sep  8 00:33 backup
9
-rw-r--r-- 1 oracle oinstall  40847 Sep  3 05:22 cis_sequence.txt
10
drwxr-xr-x 3 oracle oinstall   4096 Aug 28 16:16 oradiag_oracle
11
[root@rac11g1 ~]# chown oracle:oinstall /home/oracle/backup/
12
[root@rac11g1 ~]# ll /home/oracle/
13
total 804
14
-rw-r--r-- 1 oracle oinstall  40304 Sep  1 11:36 ashrpt_1_0901_1135.html
15
-rw-r--r-- 1 oracle oinstall 725903 Sep  1 09:41 awrrpt_1_43_47.html
16
drwxr-xr-x 2 oracle oinstall   4096 Sep  8 00:33 backup
17
-rw-r--r-- 1 oracle oinstall  40847 Sep  3 05:22 cis_sequence.txt
18
drwxr-xr-x 3 oracle oinstall   4096 Aug 28 16:16 oradiag_oracle
19
备库:
20
[root@rac11gdg ~]# mkdir /home/oracle/backup/
21
[root@rac11gdg ~]# ll /home/oracle/
22
total 4
23
drwxr-xr-x 2 root root 4096 Sep  8 20:25 backup
24
[root@rac11gdg ~]# chown oracle:oinstall /home/oracle/backup/
25
[root@rac11gdg ~]# ll /home/oracle/
26
total 4
27
drwxr-xr-x 2 oracle oinstall 4096 Sep  8 20:25 backup
28
29
[oracle@rac11g1 ~]$ vim backup.sh
30

#!/bin/bash
31
32
ORACLE_BASE=/u01/app/oracle
33
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
34
PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
35
ORACLE_UNQNAME=rac11g
36
export ORACLE_BASE ORACLE_HOME PATH ORACLE_UNQNAME
37
38
/u01/app/oracle/product/11.2.0/db_1/bin/rman target sys/oracle  <
39
run{ 
40
allocate channel c1 type disk;
41
allocate channel c2 type disk;
42
allocate channel c3 type disk;
43
backup database format '/home/oracle/backup/%d_%T_%s_%p.dbf';
44
sql 'alter system archive log current';
45
sql 'alter system archive log current';
46
sql 'alter system archive log current';
47
backup archivelog all format '/home/oracle/backup/%d_%T_%s_%p.arch';
48
backup spfile format '/home/oracle/backup/%d_%T_%s_%p.spf';
49
backup current controlfile format '/home/oracle/backup/%d_%T_%s_%p.ctl';
50
release channel c1;
51
release channel c2;
52
release channel c3;
53
}
54
report obsolete;
55
delete obsolete;
56
yes
57
58
exit
59
eof

[oracle@rac11g1 ~]$ chmod +x backup.sh

查看一下备份:
[oracle@rac11g1 backup]$ ll -htotal 1.7G-rw-r----- 1 oracle asmadmin  32K Sep 17 15:37 RAC11G_20170917_10_1.arch-rw-r----- 1 oracle asmadmin  96K Sep 17 15:37 RAC11G_20170917_11_1.spf-rw-r----- 1 oracle asmadmin 642M Sep 17 15:35 RAC11G_20170917_1_1.dbf-rw-r----- 1 oracle asmadmin 114M Sep 17 15:38 RAC11G_20170917_12_1.ctl-rw-r----- 1 oracle asmadmin 461M Sep 17 15:35 RAC11G_20170917_2_1.dbf-rw-r----- 1 oracle asmadmin 6.7M Sep 17 15:34 RAC11G_20170917_3_1.dbf-rw-r----- 1 oracle asmadmin 114M Sep 17 15:36 RAC11G_20170917_4_1.dbf-rw-r----- 1 oracle asmadmin  96K Sep 17 15:36 RAC11G_20170917_5_1.dbf-rw-r----- 1 oracle asmadmin 141M Sep 17 15:37 RAC11G_20170917_6_1.arch-rw-r----- 1 oracle asmadmin  35M Sep 17 15:37 RAC11G_20170917_7_1.arch-rw-r----- 1 oracle asmadmin 172M Sep 17 15:37 RAC11G_20170917_8_1.arch-rw-r----- 1 oracle asmadmin  34M Sep 17 15:37 RAC11G_20170917_9_1.arch
 
                      
把备份传到备库:
[oracle@rac11g1 backup]$ scp * 192.168.56.70:/home/oracle/backup/

oracle@192.168.56.70's password: 

ctrback: not a regular file

RAC11G_20170407_18_1.dbf                                                                       100%  641MB  18.9MB/s   00:34    

RAC11G_20170407_19_1.dbf                                                                       100%  464MB  16.0MB/s   00:29    

RAC11G_20170407_20_1.dbf                                                                       100%   75MB  24.9MB/s   00:03    
RAC11G_20170407_26_1.arch                                                                      100%   72MB  14.4MB/s   00:05    
RAC11G_20170407_27_1.spf                                                                       100%   96KB  96.0KB/s   00:00    

RAC11G_20170407_28_1.ctl                                                                       100%  114MB  12.6MB/s   00:09  

72
备份一下最新的控制文件:(standby模式的控制文件)
73
RMAN> backup current controlfile for standby format '/home/oracle/backup/new_controlfile.bak';
74
75
Starting backup at 07-APR-17
76
using target database control file instead of recovery catalog
77
allocated channel: ORA_DISK_1
78
channel ORA_DISK_1: SID=941 instance=rac11g1 device type=DISK
79
channel ORA_DISK_1: starting full datafile backup set
80
channel ORA_DISK_1: specifying datafile(s) in backup set
81
including standby control file in backup set
82
channel ORA_DISK_1: starting piece 1 at 07-APR-17
83
channel ORA_DISK_1: finished piece 1 at 07-APR-17
84
piece handle=/home/oracle/backup/new_controlfile.bak tag=TAG20170407T210126 comment=NONE
85
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
86
Finished backup at 07-APR-17  
87
88
将备份的控制文件scp到备库
89
[oracle@rac11g1 backup]$ scp new_controlfile.bak 192.168.56.70:/home/oracle/backup/
90
[email protected]'s password: 
91
new_controlfile.bak                                              100%  114MB  22.8MB/s   00:05 
4、物理备库的创建
 
1
[oracle@db11g admin]$ rman target / auxiliary sys/oracle@orcldg
2
RMAN> duplicate target database for standby from active database nofilenamecheck;

4.1 配置物理备库 oracle 的环境变量
 
1
[oracle@db11g1 ~]$ vim .bash_profile 
2
# .bash_profile
3
4
# Get the aliases and functions
5
if [ -f ~/.bashrc ]; then
6
        . ~/.bashrc
7
fi
8
9
# User specific environment and startup programs
10
11
PATH=$PATH:$HOME/bin
12
13
export PATH
14
export ORACLE_SID=orcl
15
ORACLE_BASE=/u01/app/oracle
16
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
17
PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
18
ORACLE_UNQNAME=racdg
19
export ORACLE_BASE ORACLE_HOME PATH ORACLE_UNQNAME

4.2 在备库中恢复参数文件:
 
1
11g 中密码区分大小写
2
3
在rman 中启动到DUMMY实例:
4
[oracle@db11g1 dbs]$ rman target / nocatalog
5
6
Recovery Manager: Release 11.2.0.4.0 - Production on Fri Apr 7 19:51:11 2017
7
8
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
9
10
connected to target database: DUMMY (not mounted)
11
using target database control file instead of recovery catalog
12
13
RMAN> restore spfile from '/home/oracle/backup/RAC11G_20170407_27_1.spf';
14
15
Starting restore at 07-APR-17
16
using channel ORA_DISK_1
17
18
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /home/oracle/backup/RAC11G_20170407_27_1.spf
19
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
20
Finished restore at 07-APR-17


4.3生成init.ora 文件,并编辑init.ora文件

补充:
SQL> create pfile='/home/oracle/initbak.ora' from spfile='+datadg/rac11g/spfilerac11g.ora';
4
5
File created.
6
7
SQL> create spfile='+datadg/rac11g/spfilerac11g.ora' from pfile='/home/oracle/initb
8
9
File created.

[oracle@db11g1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Apr 7 20:16:14 2017

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

Connected to an idle instance.

SQL> create spfile from pfile;

[oracle@rac11gdg ~]$ cd $ORACLE_HOME/dbs
[oracle@rac11gdg dbs]$ ls
hc_rac11gdg.dat  init.ora  initrac11gdg.ora  lkDUMMY  spfilerac11gdg.ora
[oracle@rac11gdg dbs]$ vim initrac11gdg.ora
rac11g2.__db_cache_size=738197504
rac11g1.__db_cache_size=754974720
rac11g2.__java_pool_size=16777216
rac11g1.__java_pool_size=16777216
rac11g2.__large_pool_size=33554432
rac11g1.__large_pool_size=33554432
rac11g2.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
rac11g1.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
rac11g2.__pga_aggregate_target=402653184
rac11g1.__pga_aggregate_target=402653184
rac11g2.__sga_target=1207959552
rac11g1.__sga_target=1207959552
rac11g2.__shared_io_pool_size=0
rac11g1.__shared_io_pool_size=0
rac11g2.__shared_pool_size=402653184
rac11g1.__shared_pool_size=385875968
rac11g2.__streams_pool_size=0
rac11g1.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/racdg/adump'        //确认这些目录有没有,权限对不对
*.audit_trail='db'    //再确认一下 
*.cluster_database=false
*.compatible='11.2.0.4.0'
*.control_files='/oradata/racdg/current.260.940258727'
*.db_block_size=8192
*.db_create_file_dest='/oradata/'
*.db_domain=''
*.db_file_name_convert='+DATADG/RAC11G/','/oradata/rac11g/'
*.db_name='rac11g'
*.db_unique_name='RACDG'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=rac11gXDB)'
*.fal_client='racdg'
*.fal_server='rac11g'
rac11g2.instance_number=2
rac11g1.instance_number=1
*.log_archive_config='dg_config=(racllg,racdg)'
*.log_archive_dest_1='LOCATION=/oradata/arch'
*.log_archive_dest_2='SERVICE=rac11g ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)   DB_UNIQUE_NAME=rac11g'
*.log_archive_format='racdg_%t_%s_%r.dbf'
*.log_file_name_convert='+DATADG/RAC11G/onlinelog','/oradata/racdg/onlinelog'
*.open_cursors=300
*.pga_aggregate_target=400556032
*.processes=1200
*.remote_login_passwordfile='exclusive'
*.sessions=1325
*.sga_max_size=1000M
*.sga_target=900M
*.standby_file_management='AUTO'
rac11g2.thread=2
rac11g1.thread=1
rac11g2.undo_tablespace='UNDOTBS2'
rac11g1.undo_tablespace='UNDOTBS1'

必须删除 监听参数,注释不管用

4.4 重新生成spfile 并启动到nomount
 
1
[oracle@db11g1 ~]$ sqlplus / as sysdba
2
3
SQL*Plus: Release 11.2.0.4.0 Production on Fri Apr 7 20:54:28 2017
4
5
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
6
7
Connected to an idle instance.
8
9
SQL> create spfile from pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initorcl.ora';
10
11
File created.
12
13
SQL> startup nomount
14
ORACLE instance started.
15
16
Total System Global Area 1043886080 bytes
17
Fixed Size    2259840 bytes
18
Variable Size  822084736 bytes
19
Database Buffers  213909504 bytes
20
Redo Buffers    5632000 bytes

4.5 恢复standby模式控制文件
 
1
[oracle@db11g1 ~]$ rman target /
2
3
Recovery Manager: Release 11.2.0.4.0 - Production on Sat Apr 8 15:14:58 2017
4
5
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
6
7
connected to target database: RAC11G (not mounted)
8
9
RMAN> restore standby controlfile from '/home/oracle/backup/new_controlfile.bak';
10
11
Starting restore at 08-APR-17
12
using target database control file instead of recovery catalog
13
allocated channel: ORA_DISK_1
14
channel ORA_DISK_1: SID=10 device type=DISK
15
16
channel ORA_DISK_1: restoring control file
17
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
18
output file name=/oradata/racdg/current.260.940258727
19
Finished restore at 08-APR-17



 
1
恢复出来之后查看一下恢复的路径:
2
RMAN> report schema;
3
4
RMAN-06139: WARNING: control file is not current for REPORT SCHEMA
5
Report of database schema for database with db_unique_name RACDG
6
7
List of Permanent Datafiles
8
===========================
9
File Size(MB) Tablespace           RB segs Datafile Name
10
---- -------- -------------------- ------- ------------------------
11
1    0        SYSTEM               ***     /oradata/rac11g/datafile/system.256.940258647
12
2    0        SYSAUX               ***     /oradata/rac11g/datafile/sysaux.257.940258647
13
3    0        UNDOTBS1             ***     /oradata/rac11g/datafile/undotbs1.258.940529005
14
4    0        USERS                ***     /oradata/rac11g/datafile/users.259.940258647
15
5    0        EXAMPLE              ***     /oradata/rac11g/datafile/example.266.940258813
16
6    0        UNDOTBS2             ***     /oradata/rac11g/datafile/undotbs2.267.940258987
17
7    0        UNDOTBS1_1           ***     /oradata/rac11g/datafile/undotbs1_1.264.940524699
18
19
List of Temporary Files
20
=======================
21
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
22
---- -------- -------------------- ----------- --------------------
23
1    20       TEMP                 32767       /oradata/rac11g/tempfile/temp.265.940258797



 
1
然后查看一下redo 的恢复路径:
2
SQL> select member from v$logfile;
3
4
MEMBER
5
--------------------------------------------------------------------------------
6
/oradata/racdg/onlinelog/group_1.263.940529009
7
/oradata/racdg/onlinelog/group_2.262.940529023
8
/oradata/racdg/onlinelog/group_3.261.940529039
9
/oradata/racdg/onlinelog/group_5.268.940259119
10
/oradata/racdg/onlinelog/group_6.269.940259139
11
/oradata/racdg/onlinelog/group_7.270.940259155
12
/oradata/racdg/onlinelog/group_8.271.940259169
13
/oradata/racdg/onlinelog/group_4.273.940529057
14
15
8 rows selected.

adrci 可以查看各种日志:(生产库不要使用这种方法,这种方法相当于vi,如果日志很大会消耗大量内存)
 
4.6 恢复数据文件
 
1
忽略此部分:
记得将主库的口令文件传送到备库上
2
编写脚本(脚本不好用,直接手动restore 、recover)
3
[oracle@db11g1 backup]$ vim restore.sh
4
#!/bin/sh
5
source ~/.bash_profile
6
7
rman target /   <
8
run {
9
allocate channel c1 device type disk;
10
restore databse;
11
recover database until scn 1309123;   //这个值在下面查询出来
12
release channel c1;
13
14
[oracle@db11g1 backup]$ chmod +x restore.sh   // 添加可执行权限
15
[oracle@db11g1 backup]$ ll
16
total 1515192
17
-rw-r----- 1 oracle oinstall 119275520 Apr  8 16:26 new_controlfile.bak
18
-rw-r----- 1 oracle oinstall 672022528 Apr  7 19:49 RAC11G_20170407_18_1.dbf
19
-rw-r----- 1 oracle oinstall 486940672 Apr  7 19:49 RAC11G_20170407_19_1.dbf
20
-rw-r----- 1 oracle oinstall  78209024 Apr  7 19:49 RAC11G_20170407_20_1.dbf
21
-rw-r----- 1 oracle oinstall  75715072 Apr  7 19:49 RAC11G_20170407_26_1.arch
22
-rw-r----- 1 oracle oinstall     98304 Apr  7 19:49 RAC11G_20170407_27_1.spf
23
-rw-r----- 1 oracle oinstall 119275520 Apr  7 19:49 RAC11G_20170407_28_1.ctl
24
-rwxr-xr-x 1 oracle oinstall       171 Apr  817:38 restore.sh
25
[oracle@db11g1 backup]$ 

查询scn:
 
1
[oracle@db11g1 ~]$ rman target /
2
3
Recovery Manager: Release 11.2.0.4.0 - Production on Sat Apr 8 17:33:27 2017
4
5
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
6
7
connected to target database: RAC11G (DBID=1992506470, not open)
8
9
10
RMAN> list backup of archivelog all;
11
12
using target database control file instead of recovery catalog
13
14
List of Backup Sets
15
===================
16
17
18
BS Key  Size       Device Type Elapsed Time Completion Time
19
------- ---------- ----------- ------------ ---------------
20
25      72.21M     DISK        00:00:14     07-APR-17      
21
        BP Key: 25   Status: AVAILABLE  Compressed: NO  Tag: TAG20170407T194438
22
        Piece Name: /home/oracle/backup/RAC11G_20170407_26_1.arch
23
24
  List of Archived Logs in backup set 25
25
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
26
  ---- ------- ---------- --------- ---------- ---------
27
  1    23      1237492    06-APR-17 1237508    06-APR-17
28
  1    24      1237508    06-APR-17 1241004    07-APR-17
29
  1    25      1241004    07-APR-17 1241483    07-APR-17
30
  1    26      1286888    07-APR-17 1286893    07-APR-17
31
  1    27      1286893    07-APR-17 1287267    07-APR-17
32
  1    28      1287267    07-APR-17 1309070    07-APR-17
33
  1    29      1309070    07-APR-17 1309082    07-APR-17
34
  1    30      1309082    07-APR-17 1309101    07-APR-17
35
  1    31      1309101    07-APR-17 1309123   07-APR-17
36
  2    18      1237477    06-APR-17 1237489    06-APR-17
37
  2    19      1237489    06-APR-17 1237514    06-APR-17
38
  2    20      1237514    06-APR-17 1241001    07-APR-17
39
  2    21      1241001    07-APR-17 1241067    07-APR-17
40
  2    22      1241067    07-APR-17 1287533    07-APR-17
41
  2    23      1287533    07-APR-17 1309067    07-APR-17
42
  2    24      1309067    07-APR-17 1309086    07-APR-17
43
  2    25      1309086    07-APR-17 1309104    07-APR-17
44
  2    26      1309104    07-APR-171309126    07-APR-17
45
46
47
取这两个值中较小的一个 1309123 

检查一下备份和归档有没有过期的:
 
1
[oracle@db11g1 ~]$ rman target /
2
3
Recovery Manager: Release 11.2.0.4.0 - Production on Sat Apr 8 17:42:28 2017
4
5
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
6
7
connected to target database: RAC11G (DBID=1992506470, not open)
8
9
RMAN> crosscheck backup;
10
11
using target database control file instead of recovery catalog
12
allocated channel: ORA_DISK_1
13
channel ORA_DISK_1: SID=11 device type=DISK
14
crosschecked backup piece: found to be 'AVAILABLE'
15
backup piece handle=/home/oracle/backup/RAC11G_20170407_20_1.dbf RECID=17 STAMP=940707789
16
crosschecked backup piece: found to be 'AVAILABLE'
17
backup piece handle=/home/oracle/backup/RAC11G_20170407_18_1.dbf RECID=18 STAMP=940707787
18
crosschecked backup piece: found to be 'AVAILABLE'
19
backup piece handle=/home/oracle/backup/RAC11G_20170407_19_1.dbf RECID=19 STAMP=940707789
20
crosschecked backup piece: found to be 'AVAILABLE'
21
backup piece handle=/home/oracle/backup/RAC11G_20170407_26_1.arch RECID=25 STAMP=940707903
22
crosschecked backup piece: found to be 'AVAILABLE'
23
backup piece handle=/home/oracle/backup/RAC11G_20170407_27_1.spf RECID=26 STAMP=940707910
24
crosschecked backup piece: found to be 'AVAILABLE'
25
backup piece handle=/home/oracle/backup/RAC11G_20170407_28_1.ctl RECID=27 STAMP=940707918
26
crosschecked backup piece: found to be 'EXPIRED'
27
backup piece handle=/home/oracle/backup/new_controlfile.bak RECID=28 STAMP=940712501
28
Crosschecked 7 objects
29
30
31
RMAN> delete expired backup;
32
33
using channel ORA_DISK_1
34
35
List of Backup Pieces
36
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
37
------- ------- --- --- ----------- ----------- ----------
38
28      28      1   1   EXPIRED     DISK        /home/oracle/backup/new_controlfile.bak
39
40
Do you really want to delete the above objects (enter YES or NO)? yes
41
deleted backup piece
42
backup piece handle=/home/oracle/backup/new_controlfile.bak RECID=28 STAMP=940712501
43
Deleted 1 EXPIRED objects
44
45
46
RMAN> crosscheck archivelog all;
47
48
released channel: ORA_DISK_1
49
allocated channel: ORA_DISK_1
50
channel ORA_DISK_1: SID=11 device type=DISK
51
specification does not match any archived log in the repository
52
53
RMAN> delete expired archivelog all;
54
55
released channel: ORA_DISK_1
56
allocated channel: ORA_DISK_1
57
channel ORA_DISK_1: SID=11 device type=DISK
58
specification does not match any archived log in the repository
59
60
61
[oracle@db11g1 ~]$ rman target /
62
63
Recovery Manager: Release 11.2.0.4.0 - Production on Sat Apr 8 19:04:17 2017
64
65
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
66
67
connected to target database: RAC11G (DBID=1992506470, not open)
68
69
RMAN> restore database;
70
71
Starting restore at 08-APR-17
72
using target database control file instead of recovery catalog
73
allocated channel: ORA_DISK_1
74
channel ORA_DISK_1: SID=11 device type=DISK
75
76
channel ORA_DISK_1: starting datafile backup set restore
77
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
78
channel ORA_DISK_1: restoring datafile 00001 to /oradata/rac11g/datafile/system.256.940258647
79
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/RAC11G_20170407_18_1.dbf
80
channel ORA_DISK_1: piece handle=/home/oracle/backup/RAC11G_20170407_18_1.dbf tag=TAG20170407T194306
81
channel ORA_DISK_1: restored backup piece 1
82
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16
83
channel ORA_DISK_1: starting datafile backup set restore
84
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
85
channel ORA_DISK_1: restoring datafile 00002 to /oradata/rac11g/datafile/sysaux.257.940258647
86
channel ORA_DISK_1: restoring datafile 00004 to /oradata/rac11g/datafile/users.259.940258647
87
channel ORA_DISK_1: restoring datafile 00007 to /oradata/rac11g/datafile/undotbs1_1.264.940524699
88
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/RAC11G_20170407_19_1.dbf
89
channel ORA_DISK_1: piece handle=/home/oracle/backup/RAC11G_20170407_19_1.dbf tag=TAG20170407T194306
90
channel ORA_DISK_1: restored backup piece 1
91
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
92
channel ORA_DISK_1: starting datafile backup set restore
93
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
94
channel ORA_DISK_1: restoring datafile 00003 to /oradata/rac11g/datafile/undotbs1.258.940529005
95
channel ORA_DISK_1: restoring datafile 00005 to /oradata/rac11g/datafile/example.266.940258813
96
channel ORA_DISK_1: restoring datafile 00006 to /oradata/rac11g/datafile/undotbs2.267.940258987
97
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/RAC11G_20170407_20_1.dbf
98
channel ORA_DISK_1: piece handle=/home/oracle/backup/RAC11G_20170407_20_1.dbf tag=TAG20170407T194306
99
channel ORA_DISK_1: restored backup piece 1
100
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
101
Finished restore at 08-APR-17
102
103
RMAN> recover database until scn 1309123;
104
105
Starting recover at 08-APR-17
106
using channel ORA_DISK_1
107
108
starting media recovery
109
110
channel ORA_DISK_1: starting archived log restore to default destination
111
channel ORA_DISK_1: restoring archived log
112
archived log thread=1 sequence=28
113
channel ORA_DISK_1: restoring archived log
114
archived log thread=2 sequence=23
115
channel ORA_DISK_1: restoring archived log
116
archived log thread=2 sequence=24
117
channel ORA_DISK_1: restoring archived log
118
archived log thread=1 sequence=29
119
channel ORA_DISK_1: restoring archived log
120
archived log thread=1 sequence=30
121
channel ORA_DISK_1: restoring archived log
122
archived log thread=2 sequence=25
123
channel ORA_DISK_1: restoring archived log
124
archived log thread=1 sequence=31
125
channel ORA_DISK_1: restoring archived log
126
archived log thread=2 sequence=26
127
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/RAC11G_20170407_26_1.arch
128
channel ORA_DISK_1: piece handle=/home/oracle/backup/RAC11G_20170407_26_1.arch tag=TAG20170407T194438
129
channel ORA_DISK_1: restored backup piece 1
130
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
131
archived log file name=/oradata/arch/racdg_1_28_940258729.dbf thread=1 sequence=28
132
archived log file name=/oradata/arch/racdg_2_23_940258729.dbf thread=2 sequence=23
133
archived log file name=/oradata/arch/racdg_2_24_940258729.dbf thread=2 sequence=24
134
archived log file name=/oradata/arch/racdg_1_29_940258729.dbf thread=1 sequence=29
135
archived log file name=/oradata/arch/racdg_1_30_940258729.dbf thread=1 sequence=30
136
archived log file name=/oradata/arch/racdg_2_25_940258729.dbf thread=2 sequence=25
137
archived log file name=/oradata/arch/racdg_1_31_940258729.dbf thread=1 sequence=31
138
archived log file name=/oradata/arch/racdg_2_26_940258729.dbf thread=2 sequence=26
139
Oracle Error: 
140
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
141
ORA-01152: file 1 was not restored from a sufficiently old backup 
142
ORA-01110: data file 1: '/oradata/rac11g/datafile/system.256.940258647'
143
144
media recovery complete, elapsed time: 00:00:03
145
Finished recover at 08-APR-17


恢复完成,查看一下数据文件和归档日志
 
1
[oracle@db11g1 datafile]$ ll
2
total 1795268
3
-rw-r----- 1 oracle oinstall 328343552 Apr  8 19:07 example.266.940258813
4
-rw-r----- 1 oracle oinstall 639639552 Apr  8 19:07 sysaux.257.940258647
5
-rw-r----- 1 oracle oinstall 786440192 Apr  8 19:07 system.256.940258647
6
-rw-r----- 1 oracle oinstall  26222592 Apr  8 19:07 undotbs1_1.264.940524699
7
-rw-r----- 1 oracle oinstall  26222592 Apr  8 19:07 undotbs1.258.940529005
8
-rw-r----- 1 oracle oinstall  26222592 Apr  8 19:07 undotbs2.267.940258987
9
-rw-r----- 1 oracle oinstall   5251072 Apr  8 19:07 users.259.940258647
10
[oracle@db11g1 arch]$ ll
11
total 19924
12
-rw-r----- 1 oracle oinstall  9034752 Apr  8 19:07 racdg_1_28_940258729.dbf
13
-rw-r----- 1 oracle oinstall     1536 Apr  8 19:07 racdg_1_29_940258729.dbf
14
-rw-r----- 1 oracle oinstall     3072 Apr  8 19:07 racdg_1_30_940258729.dbf
15
-rw-r----- 1 oracle oinstall     5632 Apr  8 19:07 racdg_1_31_940258729.dbf
16
-rw-r----- 1 oracle oinstall 11331072 Apr  8 19:07 racdg_2_23_940258729.dbf
17
-rw-r----- 1 oracle oinstall     2560 Apr  8 19:07 racdg_2_24_940258729.dbf
18
-rw-r----- 1 oracle oinstall     2048 Apr  8 19:07 racdg_2_25_940258729.dbf
19
-rw-r----- 1 oracle oinstall     6144 Apr  8 19:07 racdg_2_26_940258729.dbf
20
[oracle@db11g1 arch]$ pwd
21
/oradata/arch

4.7 主备库添加standby redo 
 
1
查看一下备库的redo:
2
SQL> select group#,thread#,sequence#,status,bytes/1024/1024 from v$log;
3
4
    GROUP#    THREAD#  SEQUENCE# STATUS       BYTES/1024/1024
5
---------- ---------- ---------- ------------ ---------------
6
 1    1      35 INACTIVE  512
7
 2    1      36 INACTIVE  512
8
 3    1      37 INACTIVE  512
9
 4    1      38 CURRENT  512
10
 5    2      29 INACTIVE  512
11
 6    2      26 INACTIVE  512
12
 7    2      27 INACTIVE  512
13
 8    2      28 INACTIVE  512
14
15
8 rows selected.
16
【这里我们看到有8组redo,我们的备库是一个单机,将来备库切换成主库的话,他只用thread1 的redo ,也就是4组,
17
所以我们的rac 要添加4+1 组standby redo 。而现在这个单机要为 rac添加(4+1)*2=10组 standby redo,每个节点5组】

在备库上添加主库的standby redo 
 
1
SQL> select open_mode from v$database;
2
3
OPEN_MODE
4
--------------------
5
MOUNTED
6
7
SQL> alter database add standby logfile thread 1 group 21 '/oradata/racdg/srl/srl21.log' size 520M;
8
9
Database altered.
10
11
SQL> c/21/22
12
  1* alter database add standby logfile thread 1 group 22 '/oradata/racdg/srl/srl21.log' size 520M
13
SQL> c/l21/l22
14
  1* alter database add standby logfile thread 1 group 22 '/oradata/racdg/srl/srl22.log' size 520M
15
SQL> /
16
17
Database altered.
18
19
SQL> c/22/23
20
  1* alter database add standby logfile thread 1 group 23 '/oradata/racdg/srl/srl22.log' size 520M
21
SQL> c/l22/l23
22
  1* alter database add standby logfile thread 1 group 23 '/oradata/racdg/srl/srl23.log' size 520M
23
SQL> /
24
25
Database altered.
26
27
SQL> c/21/22
28
SP2-0023: String not found.
29
SQL> c/23/24
30
  1* alter database add standby logfile thread 1 group 24 '/oradata/racdg/srl/srl23.log' size 520M
31
SQL> c/l23/l24
32
  1* alter database add standby logfile thread 1 group 24 '/oradata/racdg/srl/srl24.log' size 520M
33
SQL> /
34
35
Database altered.
36
37
SQL> c/24/25
38
  1* alter database add standby logfile thread 1 group 25 '/oradata/racdg/srl/srl24.log' size 520M
39
SQL> c/l24/l25
40
  1* alter database add standby logfile thread 1 group 25 '/oradata/racdg/srl/srl25.log' size 520M
41
SQL> /
42
43
Database altered.
44
45
SQL> 
46
SQL> alter database add standby logfile thread 2 group 26 '/oradata/racdg/srl/srl26.log' size 520M;
47
48
Database altered.
49
50
SQL> c/26/27
51
  1* alter database add standby logfile thread 2 group 27 '/oradata/racdg/srl/srl26.log' size 520M
52
SQL> c/l26/l27
53
  1* alter database add standby logfile thread 2 group 27 '/oradata/racdg/srl/srl27.log' size 520M
54
SQL> /
55
56
Database altered.
57
58
SQL> c/27/28
59
  1* alter database add standby logfile thread 2 group 28 '/oradata/racdg/srl/srl27.log' size 520M
60
SQL> c/l27/l28
61
  1* alter database add standby logfile thread 2 group 28 '/oradata/racdg/srl/srl28.log' size 520M
62
SQL> /
63
64
Database altered.
65
66
SQL> c/28/29
67
  1* alter database add standby logfile thread 2 group 29 '/oradata/racdg/srl/srl28.log' size 520M
68
SQL> c/l28/l29
69
  1* alter database add standby logfile thread 2 group 29 '/oradata/racdg/srl/srl29.log' size 520M
70
SQL> /
71
72
Database altered.
73
74
SQL> c/29/30
75
  1* alter database add standby logfile thread 2 group 30 '/oradata/racdg/srl/srl29.log' size 520M
76
SQL> c/l29/l30
77
  1* alter database add standby logfile thread 2 group 30 '/oradata/racdg/srl/srl30.log' size 520M
78
SQL> /
79
80
Database altered.
81
82
SQL> set linesize 150;
83
set pagesize 50;
84
column MB format a5;
85
column STATUS format a12;
86
column MEMBER format a50;
87
select sl.GROUP#,sl.THREAD#,sl.BYTES/1024/1024||'MB' MB,sl.STATUS, lf.TYPE,lf.MEMBER from v$standby_log sl,v$logfile lf where sl.GROUP#=lf.GROUP#;
88
SQL> SQL> SQL> SQL> SQL> 
89
    GROUP#    THREAD# MB    STATUS TYPE MEMBER
90
---------- ---------- ----- ------------ ------- --------------------------------------------------
91
21    1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl21.log
92
22    1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl22.log
93
23    1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl23.log
94
24    1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl24.log
95
25    1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl25.log
96
26    2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl26.log
97
27    2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl27.log
98
28    2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl28.log
99
29    2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl29.log
100
30    2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl30.log
101
102
10 rows selected.




在主库上添加standby redo 
 
1
SQL> alter database add standby logfile thread 1 group 21 '+datadg' size 520m;
2
3
Database altered.
4
5
SQL> c/21/22
6
  1* alter database add standby logfile thread 1 group 22 '+datadg' size 520m
7
SQL> /   
8
9
Database altered.
10
11
SQL> c/22/23
12
  1* alter database add standby logfile thread 1 group 23 '+datadg' size 520m
13
SQL> /
14
15
Database altered.
16
17
SQL> c/23/24
18
  1* alter database add standby logfile thread 1 group 24 '+datadg' size 520m
19
SQL> /
20
21
Database altered.
22
23
SQL> c/24/25
24
  1* alter database add standby logfile thread 1 group 25 '+datadg' size 520m
25
SQL> /
26
27
Database altered.


查看一下:
 
1
SQL> set linesize 150;
2
set pagesize 50;
3
column MB format a5;
4
column STATUS format a12;
5
column MEMBER format a50;
6
select sl.GROUP#,sl.THREAD#,sl.BYTES/1024/1024||'MB' MB,sl.STATUS, lf.TYPE,lf.MEMBER from v$standby_log sl,v$logfile lf where sl.GROUP#=lf.GROUP#;
7
SQL> SQL> SQL> SQL> SQL> 
8
    GROUP#    THREAD# MB    STATUS TYPE MEMBER
9
---------- ---------- ----- ------------ ------- --------------------------------------------------
10
21    1 520MB UNASSIGNED STANDBY +DATADG/rac11g/onlinelog/group_21.274.940794577
11
22    1 520MB UNASSIGNED STANDBY +DATADG/rac11g/onlinelog/group_22.275.940794669
12
23    1 520MB UNASSIGNED STANDBY +DATADG/rac11g/onlinelog/group_23.276.940794723
13
24    1 520MB UNASSIGNED STANDBY +DATADG/rac11g/onlinelog/group_24.277.940794751
14
25    1 520MB UNASSIGNED STANDBY +DATADG/rac11g/onlinelog/group_25.278.940794773
15
16
SQL> 

4.8 现在备库就可以启动了
 
1
如果启动的时候报错
2
SQL> alter database open;
3
alter database open
4
*
5
ERROR at line 1:
6
ORA-10458: standby database requires recovery
7
ORA-01152: file 1 was not restored from a sufficiently old backup
8
ORA-01110: data file 1: '/oradata/rac11g/datafile/system.256.940258647'
9
 就将主库的归档日志重新备份scp到备库上,然后一定要catalog一下保证元数据一致,然后recover。在启动就ok
10
当然具体情况具体分析
11
12
SQL> alter database open;
13
14
Database altered.
15
16
然后开启备库日志应用进程
17
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
18
19
Database altered.
20
21
备库察看 RFS(Remote File Service) 接收日志情况和 MRP 应用日志同步主库况
22
SQL>  select process,client_process,sequence#,status from v$managed_standby;
23
24
PROCESS   CLIENT_P  SEQUENCE# STATUS
25
--------- -------- ---------- ------------
26
ARCH  ARCH    0 CONNECTED
27
ARCH  ARCH    0 CONNECTED
28
ARCH  ARCH    0 CONNECTED
29
ARCH  ARCH    0 CONNECTED
30
MRP0  N/A   44 WAIT_FOR_LOG
31
32
看一下alert 日:
33
Additional information: 3
34
Clearing online redo logfile 8 /oradata/racdg/onlinelog/group_8.271.940259169
35
Clearing online log 8 of thread 2 sequence number 28
36
Errors in file /u01/app/oracle/diag/rdbms/racdg/orcl/trace/orcl_mrp0_3672.trc:
37
ORA-00313: open failed for members of log group 8 of thread 2
38
ORA-00312: online log 8 thread 2: '/oradata/racdg/onlinelog/group_8.271.940259169'
39
ORA-27037: unable to obtain file status
40
Linux-x86_64 Error: 2: No such file or directory
41
Additional information: 3
42
Errors in file /u01/app/oracle/diag/rdbms/racdg/orcl/trace/orcl_mrp0_3672.trc:
43
ORA-00313: open failed for members of log group 8 of thread 2
44
ORA-00312: online log 8 thread 2: '/oradata/racdg/onlinelog/group_8.271.940259169'
45
ORA-27037: unable to obtain file status
46
Linux-x86_64 Error: 2: No such file or directory
47
Additional information: 3
48
Clearing online redo logfile 8 complete
49
Sat Apr 08 20:29:34 2017
50
Media Recovery Waiting for thread 1 sequence 44   //这里显示正在等待1节点的44 ,我们去节点1 查看一下归档日志的情况

节点1:
 
1
SQL> archive log list;
2
Database log mode       Archive Mode
3
Automatic archival       Enabled
4
Archive destination       +ARCHDG
5
Oldest online log sequence     41
6
Next log sequence to archive   44
7
Current log sequence       44
8
SQL> select group#,thread#,sequence#,status,bytes/1024/1024 from v$log;
9
10
    GROUP#    THREAD#  SEQUENCE# STATUS       BYTES/1024/1024
11
---------- ---------- ---------- ------------ ---------------
12
 1    1      43 INACTIVE  512
13
 2    1      44 CURRENT  512
14
 3    1      41 INACTIVE  512
15
 4    1      42 INACTIVE  512
16
 5    2      33 INACTIVE  512
17
 6    2      34 INACTIVE  512
18
 7    2      35 CURRENT  512
19
 8    2      32 INACTIVE  512
20
21
8 rows selected.
22
没问题,节点1 的44 是current,表示一切正常!!!!!!!

再看一下备库的redo:
 
1
SQL> set linesize 150;
2
set pagesize 50;
3
column MB format a5;
4
column STATUS format a12;
5
column MEMBER format a50;
6
select sl.GROUP#,sl.THREAD#,sl.BYTES/1024/1024||'MB' MB,sl.STATUS, lf.TYPE,lf.MEMBER from v$standby_log sl,v$logfile lf where 
7
sl.GROUP#=lf.GROUP#;
8
9
    GROUP#    THREAD# MB    STATUS TYPE MEMBER
10
---------- ---------- ----- ------------ ------- --------------------------------------------------
11
21    1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl21.log
12
23    1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl23.log
13
24    1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl24.log
14
25    1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl25.log
15
22    1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl22.log
16
26    2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl26.log
17
27    2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl27.log
18
28    2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl28.log
19
29    2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl29.log
20
30    2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl30.log
21
22
10 rows selected.
23
24
发现都是UNASSIGNED ,因为主库没有进行日志切换,所以备库的日志没有激活。
25
然后我们去节点1 切换一下日志:
26
SQL> alter system archive log current;
27
28
System altered.
29
(这里虽然只是在节点上切换了日志,但是节点1 和节点2 都会发生切换)

再看备库的redo 状态:
 
1
SQL> set linesize 150;
2
set pagesize 50;
3
column MB format a5;
4
column STATUS format a12;
5
column MEMBER format a50;
6
select sl.GROUP#,sl.THREAD#,sl.BYTES/1024/1024||'MB' MB,sl.STATUS, lf.TYPE,lf.MEMBER from v$standby_log sl,v$logfile lf where 
7
sl.GROUP#=lf.GROUP#;SQL> SQL> SQL> SQL> SQL> 
8
9
    GROUP#    THREAD# MB    STATUS TYPE MEMBER
10
---------- ---------- ----- ------------ ------- --------------------------------------------------
11
21    1 520MB ACTIVE STANDBY /oradata/racdg/srl/srl21.log
12
23    1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl23.log
13
24    1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl24.log
14
25    1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl25.log
15
22    1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl22.log
16
26    2 520MB ACTIVE STANDBY /oradata/racdg/srl/srl26.log
17
27    2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl27.log
18
28    2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl28.log
19
29    2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl29.log
20
30    2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl30.log
21
22
10 rows selected.
23
现在就成了active
24
25
26
SQL>  select process,client_process,sequence#,status from v$managed_standby;
27
28
PROCESS   CLIENT_P  SEQUENCE# STATUS
29
--------- -------- ---------- ------------
30
ARCH  ARCH   63 CLOSING
31
ARCH  ARCH    0 CONNECTED
32
ARCH  ARCH    0 CONNECTED
33
ARCH  ARCH   75 CLOSING
34
RFS  LGWR   76 IDLE
35
RFS  UNKNOWN    0 IDLE
36
RFS  UNKNOWN    0 IDLE
37
RFS  LGWR   64 IDLE
38
RFS  UNKNOWN    0 IDLE
39
RFS  UNKNOWN    0 IDLE
40
RFS  UNKNOWN    0 IDLE
41
42
PROCESS   CLIENT_P  SEQUENCE# STATUS
43
--------- -------- ---------- ------------
44
RFS  UNKNOWN    0 IDLE
45
MRP0  N/A57 APPLYING_LOG

查看一下备库日志应用延迟:
 
1
SQL> set linesize 150;
2
set pagesize 20;
3
column name format a13;
4
column value format a20;
5
column unit format a30;
6
column TIME_COMPUTED format a30;
7
select name,value,unit,time_computed from v$dataguard_stats where name in ('transport lag','apply lag');
8
9
SQL> SQL> SQL> SQL> SQL> SQL> 
10
NAME      VALUE   UNIT   TIME_COMPUTED
11
------------- -------------------- ------------------------------ ------------------------------
12
transport lag +00 00:00:00   day(2) to second(0) interval   04/09/2017 10:14:14
13
apply lag     +00 00:00:00   day(2) to second(0) interval   04/09/2017 10:14:14



心跳出现问题:
查看alert日志的时候,出现tns的报错
首先查看/etc/host文件,ping一下备库的解析名称,如果可以ping通说明物理通信之间没有问题
然后再看一下备库的监听状态,如果不是解析的问题,基本就是监听的问题。可能监听未启动。配置问题

heartspeed 心跳问题
有可能是口令文件有问题,可以将两个节点 的口令文件cp过去
也有可能是tnsname.ora 解析的配置问题

3、备库应用延迟values为空,查看一下备库监听是否启动,监看备库日志应用是否开启。
                  
                 
                 
                 
  1. SQL> select process,client_process,sequence#,status from v$managed_standby;
  2. PROCESS   CLIENT_P  SEQUENCE# STATUS
  3. ---------------------------------------
  4. ARCH  ARCH    0 CONNECTED
  5. ARCH  ARCH    0 CONNECTED
  6. ARCH  ARCH    0 CONNECTED
  7. ARCH  ARCH    0 CONNECTED
  8. ARCH  ARCH    0 CONNECTED
  9. MRP0  N/A   42 APPLYING_LOG
  10. 6 rows selected.
  11. SQL>set linesize 150;
  12. set pagesize 20;
  13. column name format a13;
  14. column value format a20;
  15. column unit format a30;
  16. column TIME_COMPUTED format a30;
  17. select name,value,unit,time_computed from v$dataguard_stats where name in ('transport lag','apply lag');
  18. NAME      VALUE   UNIT  TIME_COMPUTED
  19. ---------------------------------------------------------------------------------------------
  20. transport lag   day(2) to second(0) interval   10/10/201711:48:06
  21. apply lag   day(2) to second(0) interval   10/10/201711:48:06
  22. [oracle@rac11gdg ~]$ lsnrctl status
  23. LSNRCTL forLinux:Version11.2.0.4.0-Production on 10-OCT-201711:49:25
  24. Copyright(c)1991,2013,Oracle.  All rights reserved.
  25. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.70)(PORT=1521)))
  26. TNS-12541: TNS:no listener
  27.  TNS-12560: TNS:protocol adapter error
  28.   TNS-00511:No listener
  29.    LinuxError:111:Connection refused
  30. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
  31. TNS-12541: TNS:no listener
  32.  TNS-12560: TNS:protocol adapter error
  33.   TNS-00511:No listener
  34.    LinuxError:111:Connection refused
  35. [oracle@rac11gdg ~]$ lsnrctl start
  36. LSNRCTL forLinux:Version11.2.0.4.0-Production on 10-OCT-201711:49:32
  37. Copyright(c)1991,2013,Oracle.  All rights reserved.
  38. Starting/u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...
  39. TNSLSNR forLinux:Version11.2.0.4.0-Production
  40. System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
  41. Log messages written to /u01/app/oracle/diag/tnslsnr/rac11gdg/listener/alert/log.xml
  42. Listening on:(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.70)(PORT=1521)))
  43. Listening on:(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  44. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.70)(PORT=1521)))
  45. STATUS of the LISTENER
  46. ------------------------
  47. Alias                     LISTENER
  48. Version                   TNSLSNR forLinux:Version11.2.0.4.0-Production
  49. StartDate                10-OCT-201711:49:34
  50. Uptime                    0 days 0 hr.0 min.0 sec
  51. TraceLevel               off
  52. Security                  ON:Local OS Authentication
  53. SNMP                      OFF
  54. ListenerParameterFile   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
  55. ListenerLogFile         /u01/app/oracle/diag/tnslsnr/rac11gdg/listener/alert/log.xml
  56. ListeningEndpointsSummary...
  57.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.70)(PORT=1521)))
  58.   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  59. ServicesSummary...
  60. Service"rac11g" has 1 instance(s).
  61.   Instance"rac11gdg", status UNKNOWN, has 1 handler(s)forthis service...
  62. The command completed successfully
  63. [oracle@rac11gdg ~]$ lsnrctl status
  64. LSNRCTL forLinux:Version11.2.0.4.0-Production on 10-OCT-201711:49:37
  65. Copyright(c)1991,2013,Oracle.  All rights reserved.
  66. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.70)(PORT=1521)))
  67. STATUS of the LISTENER
  68. ------------------------
  69. Alias                     LISTENER
  70. Version                   TNSLSNR forLinux:Version11.2.0.4.0-Production
  71. StartDate                10-OCT-201711:49:34
  72. Uptime                    0 days 0 hr.0 min.3 sec
  73. TraceLevel               off
  74. Security                  ON:Local OS Authentication
  75. SNMP                      OFF
  76. ListenerParameterFile   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
  77. ListenerLogFile         /u01/app/oracle/diag/tnslsnr/rac11gdg/listener/alert/log.xml
  78. ListeningEndpointsSummary...
  79.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.70)(PORT=1521)))
  80.   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  81. ServicesSummary...
  82. Service"rac11g" has 1 instance(s).
  83.   Instance"rac11gdg", status UNKNOWN, has 1 handler(s)forthis service...
  84. The command completed successfully
  85. SQL>set linesize 150;
  86. SQL>set pagesize 20;
  87. SQL> column name format a13;
  88. SQL> column value format a20;
  89. SQL> column unit format a30;
  90. SQL> column TIME_COMPUTED format a30;
  91. SQL> select name,value,unit,time_computed from v$dataguard_stats where name in ('transport lag','apply lag');
  92. NAME          VALUE                UNIT                           TIME_COMPUTED
  93. ---------------------------------------------------------------------------------------------
  94. transport lag +0000:00:00         day(2) to second(0) interval   10/10/201711:54:46
  95. apply lag     +0000:00:00         day(2) to second(0) interval   10/10/201711:54:46

 
             
 
            

你可能感兴趣的:(Oracle)