| « | 十月 2008 | » | ||||
|---|---|---|---|---|---|---|
| 一 | 二 | 三 | 四 | 五 | 六 | 日 |
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 | ||
为一个RAC搭建standby和单节点搭建方法基本一致,我们可以把RAC看成是一个单节点的数据库,只需要保证所有节点的日志能传送到备库即可。
五、备库环境准备
1、在备库添加指向主库的tnsnames
在备库的tnsnames.ora添加如下内容:
primary =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 200.200.200.11)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 200.200.200.22)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = primary)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 180)
(DELAY = 5)
)
)
)2、在备库创建相关目录
包括adump,bdump,cdump,udump及数据文件目录等。
3、拷贝主库的密码文件到备库上
--拷贝rac1的密码文件到备库的$ORACLE_HOME/dbs下,并把该密码文件修改为orapwd<sid>。这里我的sid就用rac1,所以,不用改名。
[oracle@rac1 dbs]$ scp orapwrac1 172.25.0.35:`pwd`
orapwrac1 100% 1536 1.5KB/s 00:00
4、配置备库的监听
[oracle@standby admin]$ more listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = standby)
(ORACLE_HOME = /opt/oracle/product/10.2/database)
(SID_NAME = rac1)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = standby)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
)
启动备库监听:lsnrctl start
5、设置备库参数文件
从主库rac1上根据spfile创建一个pfile文件,并传到备库上。
SQL> create pfile from spfile;
File created.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, Real Application Clusters and Data Mining options
[oracle@rac1 ~]$ cd $ORACLE_HOME/dbs
[oracle@rac1 dbs]$ scp initrac1.ora 172.25.0.35:`pwd`
initrac1.ora
在备库上修改参数文件:
Ø 删除所有非”*”打头的参数设置及rac相关参数
Ø 设置dataguard参数
修改后参数如下:
[oracle@standby dbs]$ more initrac1.ora
*.audit_file_dest='/opt/oracle/admin/rac/adump'
*.background_dump_dest='/opt/oracle/admin/rac/bdump'
*.compatible='10.2.0.3'
*.control_files='/soft/oradata/rac/control01.ctl','/soft/oradata/rac/control02.ctl','/soft/oradata/rac/control03.ctl'
*.core_dump_dest='/opt/oracle/admin/rac/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_file_name_convert='/DEV/RAW/','/SOFT/ORADATA/RAC/'
*.db_name='rac'
*.db_unique_name='STANDBY'
*.fal_client='STANDBY'
*.fal_server='PRIMARY'
*.job_queue_processes=10
*.log_archive_config='DG_CONFIG=(primary,standby)'
*.log_archive_dest_1='LOCATION= /soft/oradata/archivelog/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=standby'
*.log_archive_dest_2='SERVICE=primary LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=primary'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='%t_%s_%r.arc'
*.log_archive_max_processes=4
*.log_file_name_convert='/DEV/RAW/','/SOFT/ORADATA/RAC/'
*.open_cursors=300
*.pga_aggregate_target=16777216
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_max_size=157286400
*.sga_target=157286400
*.standby_file_management='AUTO'
*.undo_management='AUTO'
undo_tablespace='UNDOTBS1'
*.user_dump_dest='/opt/oracle/admin/rac/udump'
以上有些参数非必须设置的,但是为了switchover更方便,建议都修改上。
Undo表空间保留其中一个就可以。
路径转换相关参数要设置对,否则会报错。
6、把备库启动到nomount状态
[oracle@standby ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.3.0 - Production on Wed Apr 30 18:42:39 2008
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 159383552 bytes
Fixed Size 1260672 bytes
Variable Size 62915456 bytes
Database Buffers 92274688 bytes
Redo Buffers 2932736 bytes
7、从主库拷贝备份到备库上
之前备份的所有文件都拷贝到备库上,路径要和主库备份路径保持一致。如果不一致,linux下可以用ln的方式解决。
注意:两个节点都有归档的备份,要把这些备份都拷贝到备库上。
RAC1:
[oracle@rac1 backup]$ scp * 172.25.0.35:`pwd`
01jf4fqq_1_1 100% 23MB 3.8MB/s 00:06
03jf4fr9_1_1 100% 194KB 194.0KB/s 00:00
04jf4frg_1_1 100% 315MB 3.4MB/s 01:34
08jf4fv9_1_1 100% 13KB 13.0KB/s 00:00
09jf4fvf_1_1 100% 4608 4.5KB/s 00:00
CON_0ajf4gqi_1_1 100% 15MB 3.7MB/s 00:04
RAC2:
[oracle@rac2 backup]$ scp * 172.25.0.35:`pwd`
02jf4fql_1_1 100% 7145KB 3.5MB/s 00:02
05jf4frg_1_1 100% 175MB 3.4MB/s 00:52
06jf4ft0_1_1 100% 15MB 1.5MB/s 00:10
07jf4ftm_1_1 100% 96KB 96.0KB/s 00:00
、恢复备库
1、在主库添加指向备库的tnsname
在主库的tnsnames.ora添加如下内容:
STANDBY =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =200.200.200.123)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = standby)
)
2、在主库执行,利用auxiliary来恢复备库
[oracle@rac1 ~]$ $ORACLE_HOME/bin/rman target / auxiliary sys/6212327@standby
Recovery Manager: Release 10.2.0.3.0 - Production on Wed Apr 30 19:37:05 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: RAC (DBID=2232067446)
connected to auxiliary database: RAC (not mounted)
RMAN> run
{
allocate channel c1 device type disk format '/soft/backup/%U' connect sys/6212327@rac1;
2> 3> 4> allocate channel c2 device type disk format '/soft/backup/%U' connect sys/6212327@rac2;
5> allocate auxiliary channel ac1 device type disk format '/soft/backup/%U';
6> allocate auxiliary channel ac2 device type disk format '/soft/backup/%U';
7> duplicate target database for standby;
8> }
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: sid=132 instance=rac1 devtype=DISK
allocated channel: c2
channel c2: sid=134 instance=rac2 devtype=DISK
allocated channel: ac1
channel ac1: sid=155 devtype=DISK
allocated channel: ac2
channel ac2: sid=154 devtype=DISK
Starting Duplicate Db at 30-APR-08
contents of Memory Script:
{
restore clone standby controlfile;
sql clone 'alter database mount standby database';
}
executing Memory Script
Starting restore at 30-APR-08
channel ac1: starting datafile backupset restore
channel ac1: restoring control file
channel ac1: reading from backup piece /soft/backup/CON_0ajf4gqi_1_1
channel ac1: restored backup piece 1
piece handle=/soft/backup/CON_0ajf4gqi_1_1 tag=TAG20080430T150554
channel ac1: restore complete, elapsed time: 00:00:04
output filename=/soft/oradata/rac/control01.ctl
output filename=/soft/oradata/rac/control02.ctl
output filename=/soft/oradata/rac/control03.ctl
Finished restore at 30-APR-08
sql statement: alter database mount standby database
contents of Memory Script:
{
set newname for tempfile 1 to
"/soft/oradata/rac/raw6";
switch clone tempfile all;
set newname for datafile 1 to
"/soft/oradata/rac/raw1";
set newname for datafile 2 to
"/soft/oradata/rac/raw3";
set newname for datafile 3 to
"/soft/oradata/rac/raw2";
set newname for datafile 4 to
"/soft/oradata/rac/raw5";
set newname for datafile 5 to
"/soft/oradata/rac/raw7";
restore
check readonly
clone database
;
}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to /soft/oradata/rac/raw6 in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 30-APR-08
channel ac1: starting datafile backupset restore
channel ac1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /soft/oradata/rac/raw3
restoring datafile 00004 to /soft/oradata/rac/raw5
channel ac1: reading from backup piece /soft/backup/05jf4frg_1_1
channel ac2: starting datafile backupset restore
channel ac2: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /soft/oradata/rac/raw1
restoring datafile 00003 to /soft/oradata/rac/raw2
restoring datafile 00005 to /soft/oradata/rac/raw7
channel ac2: reading from backup piece /soft/backup/04jf4frg_1_1
channel ac1: restored backup piece 1
piece handle=/soft/backup/05jf4frg_1_1 tag=TAG20080430T144919
channel ac1: restore complete, elapsed time: 00:01:22
channel ac2: restored backup piece 1
piece handle=/soft/backup/04jf4frg_1_1 tag=TAG20080430T144919
channel ac2: restore complete, elapsed time: 00:01:32
Finished restore at 30-APR-08
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy recid=6 stamp=653426781 filename=/soft/oradata/rac/raw1
datafile 2 switched to datafile copy
input datafile copy recid=7 stamp=653426781 filename=/soft/oradata/rac/raw3
datafile 3 switched to datafile copy
input datafile copy recid=8 stamp=653426781 filename=/soft/oradata/rac/raw2
datafile 4 switched to datafile copy
input datafile copy recid=9 stamp=653426781 filename=/soft/oradata/rac/raw5
datafile 5 switched to datafile copy
input datafile copy recid=10 stamp=653426781 filename=/soft/oradata/rac/raw7
Finished Duplicate Db at 30-APR-08
released channel: c1
released channel: c2
released channel: ac1
released channel: ac2
从日志可以看到,oracle先根据参数文件把控制文件恢复到合适位置,然后再根据db_file_name_cover把数据文件恢复到合适位置。
七、后续工作
1、把备库至于恢复状态:
[oracle@standby admin]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.3.0 - Production on Wed Apr 30 19:40:59 2008
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, Oracle Label Security and Data Mining options
SQL> alter database recover managed standby database disconnect from session;
Database altered
此时观察备库的alert文件,可以发现有很多类似的信息:
Errors in file /opt/oracle/admin/rac/bdump/rac1_mrp0_10825.trc:
ORA-00313: open failed for members of log group 4 of thread 2
ORA-00312: online log 4 thread 2: '/soft/oradata/rac/raw11'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Clearing online redo logfile 4 /soft/oradata/rac/raw11
Clearing online log 4 of thread 2 sequence number 50
这是正常的,在第一次置于recover状态的时候,备库会生成对应的online redo log。
2、在备库添加standby redo log
Standby redo log比archivelog方式有更大的优势,且在最大保护、最大可用、实时恢复的情况下必须有standby redo log。
Standby redo log的组数一般为(N +1)* thread# (N分别为每个thread#的联机日志组数)。在本例,每一个thread的联机日志都是2组,所以,需要添加6组standby redo log:
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 ('/soft/oradata/rac/slog4.ora') SIZE 52428800;
Database altered.
SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 ('/soft/oradata/rac/slog5.ora') SIZE 52428800;
Database altered.
SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 ('/soft/oradata/rac/slog6.ora') SIZE 52428800;
Database altered.
SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 2 ('/soft/oradata/rac/slog7.ora') SIZE 52428800;
Database altered.
SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 2 ('/soft/oradata/rac/slog8.ora') SIZE 52428800;
Database altered.
SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 2 ('/soft/oradata/rac/slog9.ora') SIZE 52428800;
Database altered.
注意:standby redo log的大小必须和联机日志一样。
七、遇到的问题
1、FAL[client, MRP0]: Error 12545 connecting to PRIMARY for fetching gap sequence
Wed Apr 30 20:21:23 2008
Errors in file /opt/oracle/admin/rac/bdump/rac1_mrp0_10965.trc:
ORA-12545: Connect failed because target host or object does not exist
Wed Apr 30 20:22:23 2008
FAL[client]: Failed to request gap sequence
GAP - thread 1 sequence 88-88
DBID 2232067446 branch 644085430
FAL[client]: All defined FAL servers have been attempted.
这个问题和gap有关, 备库尝试拿gap的时候,发现不能连接主库。这个问题是RAC的监听造成的,参考yangtingkun的解决方法,修改两个参数即可:
ALTER SYSTEM SET LOCAL_LISTENER = '(ADDRESS = (PROTOCOL = TCP)(HOST = 200.200.200.11)(PORT = 1521))' SID = 'rac1';
ALTER SYSTEM SET LOCAL_LISTENER = '(ADDRESS = (PROTOCOL = TCP)(HOST = 200.200.200.22)(PORT = 1521))' SID = 'rac2';
2、Wed Apr 30 20:28:51 2008
FAL[client]: Failed to request gap sequence
GAP - thread 1 sequence 88-88
DBID 2232067446 branch 644085430
FAL[client]: All defined FAL servers have been attempted.
-------------------------------------------------------------
Check that the CONTROL_FILE_RECORD_KEEP_TIME initialization
parameter is defined to a value that is sufficiently large
enough to maintain adequate log switch information to resolve
archivelog gaps.
这个问题还是和gap有关。备库现在需要从主库上拿sequence 88这个归档,但这个归档在前面做备份的时候删除了。解决方法是从备份还原这个归档:
RMAN> restore archivelog sequence 88;
Starting restore at 30-APR-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=138 instance=rac1 devtype=DISK
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=88
channel ORA_DISK_1: reading from backup piece /soft/backup/08jf4fv9_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/soft/backup/08jf4fv9_1_1 tag=TAG20080430T145120
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
归档日志如何同步的?
请问,rac standby上面,是不是只能有一个实例接收从主数据库传过来的归档日志,并且apply 这些收到的归档?
另外rac standby的两个实例能否都处理mount状态?或者一个mount、一个open read only呢?
overmars | 06/05/2008, 17:26
Good idea!, Viagra, yeckv,
Good idea!, Viagra, yeckv,
Order Viagra | 28/05/2008, 20:31
comment5, titanium tube, dxhkce,
comment5, titanium tube, dxhkce,
Ftmkmdqm | 11/06/2008, 06:48
Hi All, Order Diazepam, :(((,
Hi All, Order Diazepam, :(((,
Butalbital | 14/06/2008, 00:29
I Like Your Work, Buy Vicodin Online, >:],
I Like Your Work, Buy Vicodin Online, >:],
Order Hydrocodone | 14/06/2008, 01:06
generic cialis online
generic cialis
Good Job, Cheap Viagra, 341315,
Good Job, Cheap Viagra, 341315,
Generic Viagra | 16/06/2008, 16:49
Good Design, Viagra, bnrzv,
Good Design, Viagra, bnrzv,
Order Viagra | 16/06/2008, 17:41
Thank You!, Order Cialis, yxyab,
Thank You!, Order Cialis, yxyab,
Generic Cialis | 16/06/2008, 18:06
Hi There,
Hi There,
nearingvallee | 28/06/2008, 02:47
I Like Your Work,
I Like Your Work,
michaela ward texas high school undertaker | 04/08/2008, 19:31
I Like Your Work,
I Like Your Work,
michaela ward texas high school undertaker | 04/08/2008, 19:32
Hi There,
Hi There,
mos def true magic download | 04/08/2008, 21:33
Respect Work,
Respect Work,
firearms international mod d 380 khabar | 05/08/2008, 01:02
Hello Everybody,
Hello Everybody,
gambar tweeter center mansfield ma seating chart | 05/08/2008, 01:22
Good Work,
Good Work,
david morse filmography | 05/08/2008, 03:39
Good Day,
Good Day,
exgf charlie chaplin costume for halloween | 05/08/2008, 07:58
Best Views,
Best Views,
shaun white snowboarding movie | 05/08/2008, 17:30
Hi There,
Hi There,
the fab five michigan pictures recruit | 05/08/2008, 18:46
Simply Perfectly,
Simply Perfectly,
wwl white tiger martial arts and cary | 05/08/2008, 21:40
Simply Perfectly,
Simply Perfectly,
wwl white tiger martial arts and cary | 05/08/2008, 21:41
Simply Perfectly,
Simply Perfectly,
arbor place mall risks | 05/08/2008, 23:11
Simply Perfectly,
Simply Perfectly,
instantly ofoto software to download | 06/08/2008, 02:42
Good Day,
Good Day,
bears jaclyn dowaliby murder | 06/08/2008, 03:26
Best Views,
Best Views,
sarah jessica parker bitten website fragile | 06/08/2008, 04:56
Good Work,
Good Work,
portal the bionicle story | 06/08/2008, 06:53
Good Day,
Good Day,
yamaha scooters prices in us neighbors | 06/08/2008, 08:20
Good Job,
Good Job,
txdot dallas traffic cameras retorika | 17/08/2008, 23:54
Best Views,
Best Views,
beru los angeles city college library | 04/09/2008, 12:02
Best Views,
Best Views,
beru los angeles city college library | 04/09/2008, 12:02
Hi all!
Hi all!
David | 19/09/2008, 19:54
Hi there! =),jgripdf
Hi there! =),jgripdf
David Lee | 21/09/2008, 15:26
Hello,
Hello,
name | 21/09/2008, 22:32
Good Work, wsj prime rate historical hot, 8-DDD,
Good Work, wsj prime rate historical hot, 8-DDD,
trailer park boys movies maces | 23/09/2008, 18:01
I Like Your Work, 200 baybrook mall friendswood tx herbs, 8[[,
I Like Your Work, 200 baybrook mall friendswood tx herbs, 8[[,
starting over again natalie cole lyrics invisible | 23/09/2008, 18:18
Best Work, raceway 30 dow jones industrial average companies, 94237,
Best Work, raceway 30 dow jones industrial average companies, 94237,
providence college ri campus backshot | 23/09/2008, 19:25
Best Views, rooms to go outlet center part, zigj,
Best Views, rooms to go outlet center part, zigj,
suomi morgellons syndrome parasites | 23/09/2008, 21:05
Best Views, dragonheart 2 science fiction, =-OOO,
Best Views, dragonheart 2 science fiction, =-OOO,
coach herm edwards declared green | 23/09/2008, 21:22
Hello, smart guy dvd box set b-52h, tst,
Hello, smart guy dvd box set b-52h, tst,
ophthalmic jfk airport parking prices | 23/09/2008, 21:55
Best Views, burke williams spa orange marine, ymlakl,
Best Views, burke williams spa orange marine, ymlakl,
aig insurance company singapore poolside | 23/09/2008, 22:12
Hello, costa camp galileo menlo park, =)),
Hello, costa camp galileo menlo park, =)),
cup 2007 tour de georgia winner | 23/09/2008, 22:29
Simply Perfectly, minidisc weird science cast and crew, 764,
Simply Perfectly, minidisc weird science cast and crew, 764,
msu football schedule spartans parfum | 24/09/2008, 03:47
Hi There,
Hi There,
name | 24/09/2008, 04:19
Hello Everybody,
Hello Everybody,
name | 24/09/2008, 04:50