一个问题: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数据库的状态都正常
[grid@rac11g1 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 06-APR-2017 17:00:55
Copyright (c) 1991, 2013, Oracle. Allrightsreserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 06-APR-2017 16:05:29
Uptime 0 days 0 hr. 55 min. 25 sec
Security ON: Local OS Authentication
Listener Parameter File /u01/11.2.0/grid/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/rac11g1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.10)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.26)(PORT=1521)))
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "rac11g" has 1 instance(s).
Instance "rac11g1", status READY, has 1 handler(s) for this service...
Service "rac11gXDB" has 1 instance(s).
Instance "rac11g1", status READY, has 1 handler(s) for this service...
The command completed successfully
[grid@rac11g1 ~]$ crsctl status resource -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
ONLINE ONLINE rac11g1 Started
ONLINE ONLINE rac11g2 Started
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
1 ONLINE ONLINE rac11g1 Open
2 ONLINE ONLINE rac11g2 Open
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
SQL> select force_logging from v$database;
SQL> alter database force logging;
注:通常我们设置生产库的每个redo大小为512M~2048M之间,并且大于等于三组
column STATUS format a12;
column MEMBER format a50;
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#;
GROUP# THREAD# MB STATUS TYPE MEMBER
---------- ---------- ----- ------------ ------- --------------------------------------------------
1 1 512MB INACTIVE ONLINE +DATADG/rac11g/onlinelog/group_1.263.940529009
2 1 512MB INACTIVE ONLINE +DATADG/rac11g/onlinelog/group_2.262.940529023
3 1 512MB INACTIVE ONLINE +DATADG/rac11g/onlinelog/group_3.261.940529039
5 2 512MB INACTIVE ONLINE +DATADG/rac11g/onlinelog/group_5.268.940259119
6 2 512MB CURRENT ONLINE +DATADG/rac11g/onlinelog/group_6.269.940259139
7 2 512MB INACTIVE ONLINE +DATADG/rac11g/onlinelog/group_7.270.940259155
8 2 512MB INACTIVE ONLINE +DATADG/rac11g/onlinelog/group_8.271.940259169
4 1 512MB CURRENT ONLINE +DATADG/rac11g/onlinelog/group_4.273.940529057
[root@rac11g1 ~]# vim /etc/hosts (节点1 同节点2 )
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.26 rac11g1-vip
192.168.56.27 rac11g2-vip
192.168.56.70 db11g1 //备库的ip 以及主机名
编辑备库的hosts文件:(与rac中的hosts文件相同)
[root@db11g1 ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
192.168.56.26 rac11g1-vip
192.168.56.27 rac11g2-vip
修改完成之后在各个节点上ping 一下检查是否可以ping通
[root@rac11g1 ~]# ping db11g1
PING db11g1 (192.168.56.70) 56(84) bytes of data.
64 bytes from db11g1 (192.168.56.70): icmp_seq=1 ttl=64 time=0.327 ms
64 bytes from db11g1 (192.168.56.70): icmp_seq=2 ttl=64 time=0.350 ms
64 bytes from db11g1 (192.168.56.70): icmp_seq=3 ttl=64 time=0.274 ms
[root@rac11g2 ~]# ping db11g1
PING db11g1 (192.168.56.70) 56(84) bytes of data.
64 bytes from db11g1 (192.168.56.70): icmp_seq=1 ttl=64 time=0.204 ms
64 bytes from db11g1 (192.168.56.70): icmp_seq=2 ttl=64 time=0.195 ms
64 bytes from db11g1 (192.168.56.70): icmp_seq=3 ttl=64 time=0.420 ms
64 bytes from db11g1 (192.168.56.70): icmp_seq=4 ttl=64 time=0.349 ms
[root@db11g1 ~]# ping rac11g1
PING rac11g1 (192.168.56.10) 56(84) bytes of data.
64 bytes from rac11g1 (192.168.56.10): icmp_seq=1 ttl=64 time=1.64 ms
64 bytes from rac11g1 (192.168.56.10): icmp_seq=2 ttl=64 time=0.556 ms
64 bytes from rac11g1 (192.168.56.10): icmp_seq=3 ttl=64 time=0.243 ms
64 bytes from rac11g1 (192.168.56.10): icmp_seq=4 ttl=64 time=0.270 ms
--- rac11g1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3187ms
rtt min/avg/max/mdev = 0.243/0.678/1.645/0.571 ms
[root@db11g1 ~]# ping rac11g2
PING rac11g2 (192.168.56.11) 56(84) bytes of data.
64 bytes from rac11g2 (192.168.56.11): icmp_seq=1 ttl=64 time=1.02 ms
64 bytes from rac11g2 (192.168.56.11): icmp_seq=2 ttl=64 time=0.269 ms
64 bytes from rac11g2 (192.168.56.11): icmp_seq=3 ttl=64 time=0.268 ms
[oracle@db11g1 admin]$ vim listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
(GLOBAL_DBNAME = rac11gdg)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.70)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
ADR_BASE_LISTENER = /u01/app/oracle
[oracle@db11g1 admin]$ lsnrctl stop
[oracle@db11g1 admin]$ lsnrctl start
[oracle@db11g1 admin]$ lsnrctl status
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
[root@rac11g1 ~]# su - oracle
[oracle@rac11g1 ~]$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin/
[oracle@rac11g1 admin]$ ls
samples shrept.lst tnsnames.ora
[oracle@rac11g1 admin]$ vim tnsnames.ora
# tnsnames.ora.rac11g1 Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora.rac11g1
# Generated by Oracle configuration tools.
(ADDRESS = (PROTOCOL = TCP)(HOST = rac11gscan)(PORT = 1521))
// 注:这里主机名写成rac11gscan ,可以解析两个节点
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.70)(PORT = 1521))
[oracle@rac11g1 admin]$ tnsping RACDG
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 06-APR-2017 18:22:19
Copyright (c) 1997, 2013, Oracle. All rights reserved.
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.70)(PORT = 1521))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = racdg)))
[oracle@rac11g1 admin]$ tnsping RAC11G
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 06-APR-2017 18:22:27
Copyright (c) 1997, 2013, Oracle. All rights reserved.
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = rac11gscan)(PORT = 1521)) (CONNECT_DATA =
(SERVER = DEDICATED) (SERVICE_NAME = rac11g)))
[oracle@rac11g2 admin]$ vim tnsnames.ora
# tnsnames.ora.rac11g2 Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora.rac11g2
# Generated by Oracle configuration tools.
(ADDRESS = (PROTOCOL = TCP)(HOST = rac11gscan)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.70)(PORT = 1521))
[oracle@rac11g2 admin]$ tnsping rac11g
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 06-APR-2017 18:26:21
Copyright (c) 1997, 2013, Oracle. All rights reserved.
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = rac11gscan)(PORT = 1521)) (CONNECT_DATA =
(SERVER = DEDICATED) (SERVICE_NAME = rac11g)))
[oracle@rac11g2 admin]$ tnsping racdg
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 06-APR-2017 18:26:24
Copyright (c) 1997, 2013, Oracle. All rights reserved.
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.70)(PORT = 1521))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = racdg)))
注意:tnsping能ping通不代表主库的日志可以通过它传到备库,也不代表备库的归档日志可以传到主库,只能说明你
配置的这个解析串是可以ping通的,并不代表进程会通过这个解析串成功的把想要传输的东西传输过去
[oracle@db11g1 admin]$ vim tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.70)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.10)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.11)(PORT = 1521))
[oracle@db11g1 admin]$ tnsping racdg
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 06-APR-2017 18:33:23
Copyright (c) 1997, 2013, Oracle. All rights reserved.
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.70)(PORT = 1521)) (CONNECT_DATA =
(SERVER = DEDICATED) (SERVICE_NAME = racdg)))
[oracle@db11g1 admin]$ tnsping rac11g
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 06-APR-2017 18:33:30
Copyright (c) 1997, 2013, Oracle. All rights reserved.
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.10)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)
(HOST = 192.168.56.11)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = rac11g)))
需要注意的是:在备库中不推荐使用(ADDRESS = (PROTOCOL = TCP)(HOST = rac11gscan)(PORT = 1521)) 这种方式,因为
这样写的话将来备库连接主库的时候,无法保证归档日志是怎么传输的,因为他是随机分配的。所以还是写成具体的地址
2、主库初始化参数检查与设置
2.1、查看主库的 DB_NAME
SQL> show parameter DB_NAME;
------------------------------------ ----------- ------------------------------
SQL> show parameter db_unique_name;
------------------------------------ ----------- ------------------------------
db_unique_name string rac11g
SQL> select db_unique_name,name,log_mode from v$database;
DB_UNIQUE_NAME NAME LOG_MODE
------------------------------ --------- ------------
Database log mode Archive Mode
Automatic archival Enabled
Archive destination +ARCHDG
Oldest online log sequence 15
Next log sequence to archive 18
SQL> show parameter archive;
------------------------------------ ----------- ------------------------------
archive_lag_target integer 0
log_archive_config string
log_archive_dest_1 string LOCATION=+ARCHDG
log_archive_dest_10 string
log_archive_dest_11 string
2.3、查看 log_archive_config 参数并进行设置
SQL> show parameters LOG_ARCHIVE_CONFIG
------------------------------------ ----------- ------------------------------
log_archive_config string
SQL> alter system set log_archive_config='dg_config=(racllg,racdg)'; // 这个写的是db_unique_name
SQL> show parameters LOG_ARCHIVE_CONFIG;
------------------------------------ ----------- ------------------------------
log_archive_config string dg_config=(racllg,racdg)
SQL> show parameter control_files
------------------------------------ ----------- ------------------------------
control_files string +DATADG/rac11g/controlfile/cur
2.5、在所有节点查看并设置归档参数
SQL> show parameter log_archive_dest_1;
------------------------------------ ----------- ------------------------------
log_archive_dest_1 string LOCATION=+ARCHDG
log_archive_dest_10 string
log_archive_dest_11 string
SQL> alter system set LOG_ARCHIVE_DEST_1='LOCATION=+ARCHDG VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=rac11g';
SQL> alter system set LOG_ARCHIVE_DEST_2='SERVICE=racdg ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=racdg';
SQL> show parameter LOG_ARCHIVE_DEST_1 //第一条归档路径是本地+ARCHDG
------------------------------------ ----------- ------------------------------
log_archive_dest_1 string LOCATION=+ARCHDG VALID_FOR=(A
LL_LOGFILES,ALL_ROLES) DB_UNIQ
log_archive_dest_10 string
log_archive_dest_11 string
log_archive_dest_12 string
log_archive_dest_13 string
log_archive_dest_14 string
log_archive_dest_15 string
log_archive_dest_16 string
log_archive_dest_17 string
log_archive_dest_18 string
log_archive_dest_19 string
SQL> show parameters LOG_ARCHIVE_DEST_2 //第二条归档路径是远端 DB_UNIQUE_NAME=racdg
------------------------------------ ----------- ------------------------------
log_archive_dest_2 string SERVICE=racdg ASYNC VALID_FOR=
(ONLINE_LOGFILES,PRIMARY_ROLE)
log_archive_dest_20 string
log_archive_dest_21 string
log_archive_dest_22 string
log_archive_dest_23 string
log_archive_dest_24 string
log_archive_dest_25 string
log_archive_dest_26 string
log_archive_dest_27 string
log_archive_dest_28 string
log_archive_dest_29 string
1、注:搭建DG后,若发现主库无法解析LOG_ARCHIVE_DEST_2中备库的service名,修改LOG_ARCHIVE_DEST_2参数,直接指定tns连接字符串,绕过tnsnames.ora文件的解析。
SQL> alter system set log_archive_dest_2='service="(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 172.17.0.14)(PORT = 1521))
(CONNECT_DATA =(SERVER = DEDICATED) (SERVICE_NAME = orcldg)))" ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=orcldg' scope=both;
alter system set log_archive_dest_2='service="(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)
(HOST = 172.17.0.14)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED) (SERVICE_NAME = orcldg)))" ARCH VALID_FOR=
(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcldg' scope=both;
如果不采用这种方式,一旦备库done机,主库也一定会夯住
2.6确认LOG_ARCHIVE_DEST_STATE_1与LOG_ARCHIVE_DEST_STATE_2参数为" enable "
SQL> show parameters LOG_ARCHIVE_DEST_STATE
------------------------------------ ----------- ------------------------------
log_archive_dest_state_1 string enable
log_archive_dest_state_10 string enable
log_archive_dest_state_11 string enable
log_archive_dest_state_12 string enable
log_archive_dest_state_13 string enable
log_archive_dest_state_14 string enable
log_archive_dest_state_15 string enable
log_archive_dest_state_16 string enable
log_archive_dest_state_17 string enable
log_archive_dest_state_18 string enable
log_archive_dest_state_19 string enable
log_archive_dest_state_2 string enable
SQL> alter system set log_archive_dest_state_2=ENABLE;
SQL> alter system set log_archive_dest_state_2=defer;
2.7 、确认REMOTE_LOGIN_PASSWORDFILE参数为"EXCLUSIVE"
SQL> show parameters REMOTE_LOGIN_PASSWORDFILE
------------------------------------ ----------- ------------------------------
remote_login_passwordfile string EXCLUSIVE
查看并设置LOG_ARCHIVE_MAX_PROCESSES参,4个或者5个都行
SQL> show parameters LOG_ARCHIVE_MAX_PROCESSES
------------------------------------ ----------- ------------------------------
log_archive_max_processes integer 4
SQL> alter system set LOG_ARCHIVE_MAX_PROCESSES=5;
2.8、设置switch over参数FAL_SERVER,FAL_CLIENT
注:主库的服务端是备库,客户端是主库;备库的服务端是主库,客户端是备库;不要混淆。
SQL> alter system set FAL_SERVER=racdg; //备库的tns解析名
SQL> alter system set FAL_CLIENT=rac11g; //主库的tns解析名
SQL> show parameters FAL_
------------------------------------ ----------- ------------------------------
2.9、 设置数据文件名,redo log 文件名转换参数(这个是以后做主备库切换的时候用到)
注:当为备库角色时,上面两个参数对数据文件、redo log 文件名做转换;若主备库的数据库物理结构完全一致,忽略该步骤
SQL> select name from v$datafile;
--------------------------------------------------------------------------------------------------------------------------
+DATADG/rac11g/datafile/system.256.940258647
+DATADG/rac11g/datafile/sysaux.257.940258647
+DATADG/rac11g/datafile/undotbs1.258.940529005
+DATADG/rac11g/datafile/users.259.940258647
+DATADG/rac11g/datafile/example.266.940258813
+DATADG/rac11g/datafile/undotbs2.267.940258987
+DATADG/rac11g/datafile/undotbs1_1.264.940524699
SQL> select member from v$logfile;
--------------------------------------------------
+DATADG/rac11g/onlinelog/group_1.263.940529009
+DATADG/rac11g/onlinelog/group_2.262.940529023
+DATADG/rac11g/onlinelog/group_3.261.940529039
+DATADG/rac11g/onlinelog/group_5.268.940259119
+DATADG/rac11g/onlinelog/group_6.269.940259139
+DATADG/rac11g/onlinelog/group_7.270.940259155
+DATADG/rac11g/onlinelog/group_8.271.940259169
+DATADG/rac11g/onlinelog/group_4.273.940529057
SQL> alter system set DB_FILE_NAME_CONVERT='/oradata/rac11g/','+DATADG/RAC/' scope=spfile;
SQL> alter system set LOG_FILE_NAME_CONVERT='/oradata/rac11g/onlinelog/','+DATADG/RAC/onlinelog' scope=spfile;
SQL> show parameters STANDBY_FILE_MANAGEMENT
------------------------------------ ----------- ------------------------------
standby_file_management string MANUAL
SQL> alter system set STANDBY_FILE_MANAGEMENT=AUTO;
SQL> show parameters STANDBY_FILE_MANAGEMENT
------------------------------------ ----------- ------------------------------
standby_file_management string AUTO
2.11 重启所有节点的数据库实例,使修改的参数生效(生产库按具体情况选择重启或者忽略)
确认当前数据库唯一名:show parameter db_un
ORACLE instance shut down.
Total System Global Area 5.3447E+10 bytes
Variable Size 1.3556E+10 bytes
Database Buffers 3.9863E+10 bytes
Redo Buffers 26480640 bytes
[root@rac11g1 ~]# mkdir /home/oracle/backup/
[root@rac11g1 ~]# ll /home/oracle/
-rw-r--r-- 1 oracle oinstall 40304 Sep 1 11:36 ashrpt_1_0901_1135.html
-rw-r--r-- 1 oracle oinstall 725903 Sep 1 09:41 awrrpt_1_43_47.html
drwxr-xr-x 2 root root 4096 Sep 8 00:33 backup
-rw-r--r-- 1 oracle oinstall 40847 Sep 3 05:22 cis_sequence.txt
drwxr-xr-x 3 oracle oinstall 4096 Aug 28 16:16 oradiag_oracle
[root@rac11g1 ~]# chown oracle:oinstall /home/oracle/backup/
[root@rac11g1 ~]# ll /home/oracle/
-rw-r--r-- 1 oracle oinstall 40304 Sep 1 11:36 ashrpt_1_0901_1135.html
-rw-r--r-- 1 oracle oinstall 725903 Sep 1 09:41 awrrpt_1_43_47.html
drwxr-xr-x 2 oracle oinstall 4096 Sep 8 00:33 backup
-rw-r--r-- 1 oracle oinstall 40847 Sep 3 05:22 cis_sequence.txt
drwxr-xr-x 3 oracle oinstall 4096 Aug 28 16:16 oradiag_oracle
[root@rac11gdg ~]# mkdir /home/oracle/backup/
[root@rac11gdg ~]# ll /home/oracle/
drwxr-xr-x 2 root root 4096 Sep 8 20:25 backup
[root@rac11gdg ~]# chown oracle:oinstall /home/oracle/backup/
[root@rac11gdg ~]# ll /home/oracle/
drwxr-xr-x 2 oracle oinstall 4096 Sep 8 20:25 backup
[oracle@rac11g1 ~]$ vim backup.sh
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
export ORACLE_BASE ORACLE_HOME PATH ORACLE_UNQNAME
/u01/app/oracle/product/11.2.0/db_1/bin/rman target sys/oracle <
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup database format '/home/oracle/backup/%d_%T_%s_%p.dbf';
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup archivelog all format '/home/oracle/backup/%d_%T_%s_%p.arch';
backup spfile format '/home/oracle/backup/%d_%T_%s_%p.spf';
backup current controlfile format '/home/oracle/backup/%d_%T_%s_%p.ctl';
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
备份一下最新的控制文件:(standby模式的控制文件)
RMAN> backup current controlfile for standby format '/home/oracle/backup/new_controlfile.bak';
Starting backup at 07-APR-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=941 instance=rac11g1 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including standby control file in backup set
channel ORA_DISK_1: starting piece 1 at 07-APR-17
channel ORA_DISK_1: finished piece 1 at 07-APR-17
piece handle=/home/oracle/backup/new_controlfile.bak tag=TAG20170407T210126 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 07-APR-17
[oracle@rac11g1 backup]$ scp new_controlfile.bak 192.168.56.70:/home/oracle/backup/
new_controlfile.bak 100% 114MB 22.8MB/s 00:05
[oracle@db11g admin]$ rman target / auxiliary sys/oracle@orcldg
RMAN> duplicate target database for standby from active database nofilenamecheck;
[oracle@db11g1 ~]$ vim .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
# User specific environment and startup programs
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
export ORACLE_BASE ORACLE_HOME PATH ORACLE_UNQNAME
[oracle@db11g1 dbs]$ rman target / nocatalog
Recovery Manager: Release 11.2.0.4.0 - Production on Fri Apr 7 19:51:11 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: DUMMY (not mounted)
using target database control file instead of recovery catalog
RMAN> restore spfile from '/home/oracle/backup/RAC11G_20170407_27_1.spf';
Starting restore at 07-APR-17
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /home/oracle/backup/RAC11G_20170407_27_1.spf
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
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';
SQL> create spfile='+datadg/rac11g/spfilerac11g.ora' from pfile='/home/oracle/initb
[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
[oracle@db11g1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Fri Apr 7 20:54:28 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL> create spfile from pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initorcl.ora';
Total System Global Area 1043886080 bytes
Variable Size 822084736 bytes
Database Buffers 213909504 bytes
Redo Buffers 5632000 bytes
[oracle@db11g1 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sat Apr 8 15:14:58 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: RAC11G (not mounted)
RMAN> restore standby controlfile from '/home/oracle/backup/new_controlfile.bak';
Starting restore at 08-APR-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
output file name=/oradata/racdg/current.260.940258727
Finished restore at 08-APR-17
RMAN-06139: WARNING: control file is not current for REPORT SCHEMA
Report of database schema for database with db_unique_name RACDG
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 0 SYSTEM *** /oradata/rac11g/datafile/system.256.940258647
2 0 SYSAUX *** /oradata/rac11g/datafile/sysaux.257.940258647
3 0 UNDOTBS1 *** /oradata/rac11g/datafile/undotbs1.258.940529005
4 0 USERS *** /oradata/rac11g/datafile/users.259.940258647
5 0 EXAMPLE *** /oradata/rac11g/datafile/example.266.940258813
6 0 UNDOTBS2 *** /oradata/rac11g/datafile/undotbs2.267.940258987
7 0 UNDOTBS1_1 *** /oradata/rac11g/datafile/undotbs1_1.264.940524699
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 20 TEMP 32767 /oradata/rac11g/tempfile/temp.265.940258797
SQL> select member from v$logfile;
--------------------------------------------------------------------------------
/oradata/racdg/onlinelog/group_1.263.940529009
/oradata/racdg/onlinelog/group_2.262.940529023
/oradata/racdg/onlinelog/group_3.261.940529039
/oradata/racdg/onlinelog/group_5.268.940259119
/oradata/racdg/onlinelog/group_6.269.940259139
/oradata/racdg/onlinelog/group_7.270.940259155
/oradata/racdg/onlinelog/group_8.271.940259169
/oradata/racdg/onlinelog/group_4.273.940529057
adrci 可以查看各种日志:(生产库不要使用这种方法,这种方法相当于vi,如果日志很大会消耗大量内存)
4.6 恢复数据文件
编写脚本(脚本不好用,直接手动restore 、recover)
[oracle@db11g1 backup]$ vim restore.sh
allocate channel c1 device type disk;
recover database until scn 1309123; //这个值在下面查询出来
[oracle@db11g1 backup]$ chmod +x restore.sh // 添加可执行权限
[oracle@db11g1 backup]$ ll
-rw-r----- 1 oracle oinstall 119275520 Apr 8 16:26 new_controlfile.bak
-rw-r----- 1 oracle oinstall 672022528 Apr 7 19:49 RAC11G_20170407_18_1.dbf
-rw-r----- 1 oracle oinstall 486940672 Apr 7 19:49 RAC11G_20170407_19_1.dbf
-rw-r----- 1 oracle oinstall 78209024 Apr 7 19:49 RAC11G_20170407_20_1.dbf
-rw-r----- 1 oracle oinstall 75715072 Apr 7 19:49 RAC11G_20170407_26_1.arch
-rw-r----- 1 oracle oinstall 98304 Apr 7 19:49 RAC11G_20170407_27_1.spf
-rw-r----- 1 oracle oinstall 119275520 Apr 7 19:49 RAC11G_20170407_28_1.ctl
-rwxr-xr-x 1 oracle oinstall 171 Apr 817:38 restore.sh
[oracle@db11g1 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sat Apr 8 17:33:27 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: RAC11G (DBID=1992506470, not open)
RMAN> list backup of archivelog all;
using target database control file instead of recovery catalog
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
25 72.21M DISK 00:00:14 07-APR-17
BP Key: 25 Status: AVAILABLE Compressed: NO Tag: TAG20170407T194438
Piece Name: /home/oracle/backup/RAC11G_20170407_26_1.arch
List of Archived Logs in backup set 25
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 23 1237492 06-APR-17 1237508 06-APR-17
1 24 1237508 06-APR-17 1241004 07-APR-17
1 25 1241004 07-APR-17 1241483 07-APR-17
1 26 1286888 07-APR-17 1286893 07-APR-17
1 27 1286893 07-APR-17 1287267 07-APR-17
1 28 1287267 07-APR-17 1309070 07-APR-17
1 29 1309070 07-APR-17 1309082 07-APR-17
1 30 1309082 07-APR-17 1309101 07-APR-17
1 31 1309101 07-APR-17 1309123 07-APR-17
2 18 1237477 06-APR-17 1237489 06-APR-17
2 19 1237489 06-APR-17 1237514 06-APR-17
2 20 1237514 06-APR-17 1241001 07-APR-17
2 21 1241001 07-APR-17 1241067 07-APR-17
2 22 1241067 07-APR-17 1287533 07-APR-17
2 23 1287533 07-APR-17 1309067 07-APR-17
2 24 1309067 07-APR-17 1309086 07-APR-17
2 25 1309086 07-APR-17 1309104 07-APR-17
2 26 1309104 07-APR-171309126 07-APR-17
[oracle@db11g1 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sat Apr 8 17:42:28 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: RAC11G (DBID=1992506470, not open)
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=11 device type=DISK
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/home/oracle/backup/RAC11G_20170407_20_1.dbf RECID=17 STAMP=940707789
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/home/oracle/backup/RAC11G_20170407_18_1.dbf RECID=18 STAMP=940707787
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/home/oracle/backup/RAC11G_20170407_19_1.dbf RECID=19 STAMP=940707789
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/home/oracle/backup/RAC11G_20170407_26_1.arch RECID=25 STAMP=940707903
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/home/oracle/backup/RAC11G_20170407_27_1.spf RECID=26 STAMP=940707910
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/home/oracle/backup/RAC11G_20170407_28_1.ctl RECID=27 STAMP=940707918
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/home/oracle/backup/new_controlfile.bak RECID=28 STAMP=940712501
RMAN> delete expired backup;
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
28 28 1 1 EXPIRED DISK /home/oracle/backup/new_controlfile.bak
Do you really want to delete the above objects (enter YES or NO)? yes
backup piece handle=/home/oracle/backup/new_controlfile.bak RECID=28 STAMP=940712501
Deleted 1 EXPIRED objects
RMAN> crosscheck archivelog all;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=11 device type=DISK
specification does not match any archived log in the repository
RMAN> delete expired archivelog all;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=11 device type=DISK
specification does not match any archived log in the repository
[oracle@db11g1 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sat Apr 8 19:04:17 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: RAC11G (DBID=1992506470, not open)
Starting restore at 08-APR-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=11 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /oradata/rac11g/datafile/system.256.940258647
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/RAC11G_20170407_18_1.dbf
channel ORA_DISK_1: piece handle=/home/oracle/backup/RAC11G_20170407_18_1.dbf tag=TAG20170407T194306
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00002 to /oradata/rac11g/datafile/sysaux.257.940258647
channel ORA_DISK_1: restoring datafile 00004 to /oradata/rac11g/datafile/users.259.940258647
channel ORA_DISK_1: restoring datafile 00007 to /oradata/rac11g/datafile/undotbs1_1.264.940524699
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/RAC11G_20170407_19_1.dbf
channel ORA_DISK_1: piece handle=/home/oracle/backup/RAC11G_20170407_19_1.dbf tag=TAG20170407T194306
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00003 to /oradata/rac11g/datafile/undotbs1.258.940529005
channel ORA_DISK_1: restoring datafile 00005 to /oradata/rac11g/datafile/example.266.940258813
channel ORA_DISK_1: restoring datafile 00006 to /oradata/rac11g/datafile/undotbs2.267.940258987
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/RAC11G_20170407_20_1.dbf
channel ORA_DISK_1: piece handle=/home/oracle/backup/RAC11G_20170407_20_1.dbf tag=TAG20170407T194306
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 08-APR-17
RMAN> recover database until scn 1309123;
Starting recover at 08-APR-17
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=28
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=23
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=24
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=29
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=30
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=25
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=31
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=26
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/RAC11G_20170407_26_1.arch
channel ORA_DISK_1: piece handle=/home/oracle/backup/RAC11G_20170407_26_1.arch tag=TAG20170407T194438
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/oradata/arch/racdg_1_28_940258729.dbf thread=1 sequence=28
archived log file name=/oradata/arch/racdg_2_23_940258729.dbf thread=2 sequence=23
archived log file name=/oradata/arch/racdg_2_24_940258729.dbf thread=2 sequence=24
archived log file name=/oradata/arch/racdg_1_29_940258729.dbf thread=1 sequence=29
archived log file name=/oradata/arch/racdg_1_30_940258729.dbf thread=1 sequence=30
archived log file name=/oradata/arch/racdg_2_25_940258729.dbf thread=2 sequence=25
archived log file name=/oradata/arch/racdg_1_31_940258729.dbf thread=1 sequence=31
archived log file name=/oradata/arch/racdg_2_26_940258729.dbf thread=2 sequence=26
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: '/oradata/rac11g/datafile/system.256.940258647'
media recovery complete, elapsed time: 00:00:03
Finished recover at 08-APR-17
[oracle@db11g1 datafile]$ ll
-rw-r----- 1 oracle oinstall 328343552 Apr 8 19:07 example.266.940258813
-rw-r----- 1 oracle oinstall 639639552 Apr 8 19:07 sysaux.257.940258647
-rw-r----- 1 oracle oinstall 786440192 Apr 8 19:07 system.256.940258647
-rw-r----- 1 oracle oinstall 26222592 Apr 8 19:07 undotbs1_1.264.940524699
-rw-r----- 1 oracle oinstall 26222592 Apr 8 19:07 undotbs1.258.940529005
-rw-r----- 1 oracle oinstall 26222592 Apr 8 19:07 undotbs2.267.940258987
-rw-r----- 1 oracle oinstall 5251072 Apr 8 19:07 users.259.940258647
-rw-r----- 1 oracle oinstall 9034752 Apr 8 19:07 racdg_1_28_940258729.dbf
-rw-r----- 1 oracle oinstall 1536 Apr 8 19:07 racdg_1_29_940258729.dbf
-rw-r----- 1 oracle oinstall 3072 Apr 8 19:07 racdg_1_30_940258729.dbf
-rw-r----- 1 oracle oinstall 5632 Apr 8 19:07 racdg_1_31_940258729.dbf
-rw-r----- 1 oracle oinstall 11331072 Apr 8 19:07 racdg_2_23_940258729.dbf
-rw-r----- 1 oracle oinstall 2560 Apr 8 19:07 racdg_2_24_940258729.dbf
-rw-r----- 1 oracle oinstall 2048 Apr 8 19:07 racdg_2_25_940258729.dbf
-rw-r----- 1 oracle oinstall 6144 Apr 8 19:07 racdg_2_26_940258729.dbf
[oracle@db11g1 arch]$ pwd
SQL> select group#,thread#,sequence#,status,bytes/1024/1024 from v$log;
GROUP# THREAD# SEQUENCE# STATUS BYTES/1024/1024
---------- ---------- ---------- ------------ ---------------
【这里我们看到有8组redo,我们的备库是一个单机,将来备库切换成主库的话,他只用thread1 的redo ,也就是4组,
所以我们的rac 要添加4+1 组standby redo 。而现在这个单机要为 rac添加(4+1)*2=10组 standby redo,每个节点5组】
SQL> select open_mode from v$database;
SQL> alter database add standby logfile thread 1 group 21 '/oradata/racdg/srl/srl21.log' size 520M;
1* alter database add standby logfile thread 1 group 22 '/oradata/racdg/srl/srl21.log' size 520M
1* alter database add standby logfile thread 1 group 22 '/oradata/racdg/srl/srl22.log' size 520M
1* alter database add standby logfile thread 1 group 23 '/oradata/racdg/srl/srl22.log' size 520M
1* alter database add standby logfile thread 1 group 23 '/oradata/racdg/srl/srl23.log' size 520M
SP2-0023: String not found.
1* alter database add standby logfile thread 1 group 24 '/oradata/racdg/srl/srl23.log' size 520M
1* alter database add standby logfile thread 1 group 24 '/oradata/racdg/srl/srl24.log' size 520M
1* alter database add standby logfile thread 1 group 25 '/oradata/racdg/srl/srl24.log' size 520M
1* alter database add standby logfile thread 1 group 25 '/oradata/racdg/srl/srl25.log' size 520M
SQL> alter database add standby logfile thread 2 group 26 '/oradata/racdg/srl/srl26.log' size 520M;
1* alter database add standby logfile thread 2 group 27 '/oradata/racdg/srl/srl26.log' size 520M
1* alter database add standby logfile thread 2 group 27 '/oradata/racdg/srl/srl27.log' size 520M
1* alter database add standby logfile thread 2 group 28 '/oradata/racdg/srl/srl27.log' size 520M
1* alter database add standby logfile thread 2 group 28 '/oradata/racdg/srl/srl28.log' size 520M
1* alter database add standby logfile thread 2 group 29 '/oradata/racdg/srl/srl28.log' size 520M
1* alter database add standby logfile thread 2 group 29 '/oradata/racdg/srl/srl29.log' size 520M
1* alter database add standby logfile thread 2 group 30 '/oradata/racdg/srl/srl29.log' size 520M
1* alter database add standby logfile thread 2 group 30 '/oradata/racdg/srl/srl30.log' size 520M
column STATUS format a12;
column MEMBER format a50;
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#;
GROUP# THREAD# MB STATUS TYPE MEMBER
---------- ---------- ----- ------------ ------- --------------------------------------------------
21 1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl21.log
22 1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl22.log
23 1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl23.log
24 1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl24.log
25 1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl25.log
26 2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl26.log
27 2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl27.log
28 2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl28.log
29 2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl29.log
30 2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl30.log
SQL> alter database add standby logfile thread 1 group 21 '+datadg' size 520m;
1* alter database add standby logfile thread 1 group 22 '+datadg' size 520m
1* alter database add standby logfile thread 1 group 23 '+datadg' size 520m
1* alter database add standby logfile thread 1 group 24 '+datadg' size 520m
1* alter database add standby logfile thread 1 group 25 '+datadg' size 520m
column STATUS format a12;
column MEMBER format a50;
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#;
GROUP# THREAD# MB STATUS TYPE MEMBER
---------- ---------- ----- ------------ ------- --------------------------------------------------
21 1 520MB UNASSIGNED STANDBY +DATADG/rac11g/onlinelog/group_21.274.940794577
22 1 520MB UNASSIGNED STANDBY +DATADG/rac11g/onlinelog/group_22.275.940794669
23 1 520MB UNASSIGNED STANDBY +DATADG/rac11g/onlinelog/group_23.276.940794723
24 1 520MB UNASSIGNED STANDBY +DATADG/rac11g/onlinelog/group_24.277.940794751
25 1 520MB UNASSIGNED STANDBY +DATADG/rac11g/onlinelog/group_25.278.940794773
SQL> alter database open;
ORA-10458: standby database requires recovery
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/oradata/rac11g/datafile/system.256.940258647'
就将主库的归档日志重新备份scp到备库上,然后一定要catalog一下保证元数据一致,然后recover。在启动就ok
SQL> alter database open;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
备库察看 RFS(Remote File Service) 接收日志情况和 MRP 应用日志同步主库况
SQL> select process,client_process,sequence#,status from v$managed_standby;
PROCESS CLIENT_P SEQUENCE# STATUS
--------- -------- ---------- ------------
Additional information: 3
Clearing online redo logfile 8 /oradata/racdg/onlinelog/group_8.271.940259169
Clearing online log 8 of thread 2 sequence number 28
Errors in file /u01/app/oracle/diag/rdbms/racdg/orcl/trace/orcl_mrp0_3672.trc:
ORA-00313: open failed for members of log group 8 of thread 2
ORA-00312: online log 8 thread 2: '/oradata/racdg/onlinelog/group_8.271.940259169'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/racdg/orcl/trace/orcl_mrp0_3672.trc:
ORA-00313: open failed for members of log group 8 of thread 2
ORA-00312: online log 8 thread 2: '/oradata/racdg/onlinelog/group_8.271.940259169'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Clearing online redo logfile 8 complete
Media Recovery Waiting for thread 1 sequence 44 //这里显示正在等待1节点的44 ,我们去节点1 查看一下归档日志的情况
Database log mode Archive Mode
Automatic archival Enabled
Archive destination +ARCHDG
Oldest online log sequence 41
Next log sequence to archive 44
SQL> select group#,thread#,sequence#,status,bytes/1024/1024 from v$log;
GROUP# THREAD# SEQUENCE# STATUS BYTES/1024/1024
---------- ---------- ---------- ------------ ---------------
没问题,节点1 的44 是current,表示一切正常!!!!!!!
column STATUS format a12;
column MEMBER format a50;
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
GROUP# THREAD# MB STATUS TYPE MEMBER
---------- ---------- ----- ------------ ------- --------------------------------------------------
21 1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl21.log
23 1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl23.log
24 1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl24.log
25 1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl25.log
22 1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl22.log
26 2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl26.log
27 2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl27.log
28 2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl28.log
29 2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl29.log
30 2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl30.log
发现都是UNASSIGNED ,因为主库没有进行日志切换,所以备库的日志没有激活。
SQL> alter system archive log current;
(这里虽然只是在节点上切换了日志,但是节点1 和节点2 都会发生切换)
column STATUS format a12;
column MEMBER format a50;
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#;SQL> SQL> SQL> SQL> SQL>
GROUP# THREAD# MB STATUS TYPE MEMBER
---------- ---------- ----- ------------ ------- --------------------------------------------------
21 1 520MB ACTIVE STANDBY /oradata/racdg/srl/srl21.log
23 1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl23.log
24 1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl24.log
25 1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl25.log
22 1 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl22.log
26 2 520MB ACTIVE STANDBY /oradata/racdg/srl/srl26.log
27 2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl27.log
28 2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl28.log
29 2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl29.log
30 2 520MB UNASSIGNED STANDBY /oradata/racdg/srl/srl30.log
SQL> select process,client_process,sequence#,status from v$managed_standby;
PROCESS CLIENT_P SEQUENCE# STATUS
--------- -------- ---------- ------------
PROCESS CLIENT_P SEQUENCE# STATUS
--------- -------- ---------- ------------
column TIME_COMPUTED format a30;
select name,value,unit,time_computed from v$dataguard_stats where name in ('transport lag','apply lag');
SQL> SQL> SQL> SQL> SQL> SQL>
NAME VALUE UNIT TIME_COMPUTED
------------- -------------------- ------------------------------ ------------------------------
transport lag +00 00:00:00 day(2) to second(0) interval 04/09/2017 10:14:14
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为空,查看一下备库监听是否启动,监看备库日志应用是否开启。
SQL> select process,client_process,sequence#,status from v$managed_standby;
PROCESS CLIENT_P SEQUENCE# STATUS
---------------------------------------
ARCH ARCH 0 CONNECTED
ARCH ARCH 0 CONNECTED
ARCH ARCH 0 CONNECTED
ARCH ARCH 0 CONNECTED
ARCH ARCH 0 CONNECTED
MRP0 N/A 42 APPLYING_LOG
6 rows selected.
SQL>set linesize 150;
set pagesize 20;
column name format a13;
column value format a20;
column unit format a30;
column TIME_COMPUTED format a30;
select name,value,unit,time_computed from v$dataguard_stats where name in ('transport lag','apply lag');
NAME VALUE UNIT TIME_COMPUTED
---------------------------------------------------------------------------------------------
transport lag day(2) to second(0) interval 10/10/201711:48:06
apply lag day(2) to second(0) interval 10/10/201711:48:06
[oracle@rac11gdg ~]$ lsnrctl status
LSNRCTL forLinux:Version11.2.0.4.0-Production on 10-OCT-201711:49:25
Copyright(c)1991,2013,Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.70)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511:No listener
LinuxError:111:Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511:No listener
LinuxError:111:Connection refused
[oracle@rac11gdg ~]$ lsnrctl start
LSNRCTL forLinux:Version11.2.0.4.0-Production on 10-OCT-201711:49:32
Copyright(c)1991,2013,Oracle. All rights reserved.
Starting/u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR forLinux:Version11.2.0.4.0-Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/rac11gdg/listener/alert/log.xml
Listening on:(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.70)(PORT=1521)))
Listening on:(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.70)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR forLinux:Version11.2.0.4.0-Production
StartDate 10-OCT-201711:49:34
Uptime 0 days 0 hr.0 min.0 sec
TraceLevel off
Security ON:Local OS Authentication
SNMP OFF
ListenerParameterFile /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
ListenerLogFile /u01/app/oracle/diag/tnslsnr/rac11gdg/listener/alert/log.xml
ListeningEndpointsSummary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.70)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
ServicesSummary...
Service"rac11g" has 1 instance(s).
Instance"rac11gdg", status UNKNOWN, has 1 handler(s)forthis service...
The command completed successfully
[oracle@rac11gdg ~]$ lsnrctl status
LSNRCTL forLinux:Version11.2.0.4.0-Production on 10-OCT-201711:49:37
Copyright(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 LISTENER
Version TNSLSNR forLinux:Version11.2.0.4.0-Production
StartDate 10-OCT-201711:49:34
Uptime 0 days 0 hr.0 min.3 sec
TraceLevel off
Security ON:Local OS Authentication
SNMP OFF
ListenerParameterFile /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
ListenerLogFile /u01/app/oracle/diag/tnslsnr/rac11gdg/listener/alert/log.xml
ListeningEndpointsSummary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.70)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
ServicesSummary...
Service"rac11g" has 1 instance(s).
Instance"rac11gdg", status UNKNOWN, has 1 handler(s)forthis service...
The command completed successfully
SQL>set linesize 150;
SQL>set pagesize 20;
SQL> column name format a13;
SQL> column value format a20;
SQL> column unit format a30;
SQL> column TIME_COMPUTED format a30;
SQL> select name,value,unit,time_computed from v$dataguard_stats where name in ('transport lag','apply lag');
NAME VALUE UNIT TIME_COMPUTED
---------------------------------------------------------------------------------------------
transport lag +0000:00:00 day(2) to second(0) interval 10/10/201711:54:46
apply lag +0000:00:00 day(2) to second(0) interval 10/10/201711:54:46