脚踏实地、勇往直前!
全部博文(1005)
分类: Oracle
2014-01-24 11:06:30
---------------------------------------------rac主机部署-----------------------
1.设置主库为force logging模式(在其中一个节点执行即可)
SQL> alter database force logging;
2.配置两个节点上的tnsnames.ora
添加如下内容:
myrac1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.50.251)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = racdb)
)
)
myrac2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.50.252)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = racdb)
)
)
racbak =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.50.202)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = racbak)
)
)
myrac =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.50.251)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.50.252)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = racdb)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 180)
(DELAY = 5)
)
)
)
3.修改数据库参数
alter system set db_unique_name=racdb scope=spfile sid='*';
alter system set log_archive_config='dg_config=(racdb,racbak)' scope=both sid='*';
我的环境归档路径1和归档路径2都已经使用了,所以这里配置归档路径3
alter system set log_archive_dest_3= 'service=racbak async valid_for=(online_logfiles,primary_role) db_unique_name=racbak' scope=both sid='*';
alter system set log_archive_dest_state_3=enable scope=both sid='*';
alter system set standby_file_management=auto scope=both sid='*';
alter system set fal_server=racbak scope=both sid='*';
alter system set fal_client=myrac1 scope=both sid='racdb1';
alter system set fal_client=myrac2 scope=both sid='racdb2';
alter system set db_file_name_convert='/u01/app/oracle/oradata/racbak/','+DATA01/racdb/datafile/' scope=spfile sid='*';
alter system set log_file_name_convert='/u01/app/oracle/oradata/racbak/','+DATA01/racdb/onlinelog/' scope=spfile sid='*';
4.备份主库
在其中一个节点上运行,注意该节点需要能访问每个rac节点的归档日志
run{
allocate channel dup type disk;
backup format '/bak/rman_bak/df_t%t_s%s_p%p' database;
sql 'alter system archive log current';
backup format '/bak/rman_bak/archive_log_t%t_s%s_p%p' archivelog all;
backup spfile format '/bak/rman_bak/spfile_%u_%T.bak';
release channel dup;
}
6.生成standby控制文件
rman>copy current controlfile for standby to '/bak/rman_bak/standby.ctl';
7.将以上生成的备份集,密码文件传到备库
scp archive_log_t837368189_s53_p1 oracle@192.168.50.202:/bak
scp archive_log_t837368197_s54_p1 oracle@192.168.50.202:/bak
scp archive_log_t837368199_s55_p1 oracle@192.168.50.202:/bak
scp archive_log_t837368200_s56_p1 oracle@192.168.50.202:/bak
scp archive_log_t837368216_s57_p1 oracle@192.168.50.202:/bak
scp archive_log_t837368217_s58_p1 oracle@192.168.50.202:/bak
scp df_t837367891_s51_p1 oracle@192.168.50.202:/bak
scp df_t837368124_s52_p1 oracle@192.168.50.202:/bak
scp spfile_1rouiedf_20140120.bak oracle@192.168.50.202:/bak
scp standby.ctl oracle@192.168.50.202:/bak
scp orapwracdb1 oracle@192.168.50.202:/bak
scp tnsnames.ora oracle@192.168.50.202:/bak
--------------------------------------------备库上的操作------------------------------
1.从备份集恢复spfile
RMAN>set dbid 834465720 --在主库上获取数据的dbid:Select dbid From v$database
RMAN>startup nomount
RMAN>restore spfile to pfile '/u01/export/home/oracle/pfile.ora' from '/bak/spfile_1rouiedf_20140120.bak';
2.修改pfile,最后的内容如下
racbak.__java_pool_size=4194304
racbak.__large_pool_size=4194304
racbak.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
racbak.__pga_aggregate_target=209715200
racbak.__sga_target=213909504
racbak.__shared_io_pool_size=0
racbak.__shared_pool_size=138412032
racbak.__streams_pool_size=0
*.audit_file_dest='/u01/product/oracle/admin/racbak/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/oradata/racbak/control01.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='racdb'
*.db_unique_name='racbak'
*.diagnostic_dest='/u01/product/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=racbakXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='exclusive'
*.undo_tablespace='UNDOTBS1'
*.log_archive_config='dg_config=(racdb,racbak)'
*.log_archive_dest_1=
'location=/u01/archive_log/
valid_for=(all_logfiles,all_roles)
db_unique_name=racbak'
*.log_archive_dest_2=
'service=myrac1 async
valid_for=(online_logfiles,primary_role)
db_unique_name=racdb'
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.standby_file_management=auto
*.fal_server=myrac1,myrac2
*.fal_client=racbak
*.thread=1
*.db_file_name_convert='+DATA01/racdb/datafile/','/u01/app/oracle/oradata/racbak/'
*.log_file_name_convert='+DATA01/racdb/onlinelog/','/u01/app/oracle/oradata/racbak/','+FRA/racdb/onlinelog/','/u01/app/oracle/oradata/racbak/'
创建参数文件中定义的目录(仔细检查每个目录,没有创建的话需要创建)
mkdir -p /u01/product/oracle/admin/racbak/adump
mkdir -p /u01/app/oracle/oradata/racbak
3.将主库传过来的tnsnames文件,密码文件和standby控制文件传到指定目录
cp tnsnames.ora /u01/app/oracle/product/11.2.0/db_1/network/admin/
cp standby.ctl /u01/app/oracle/oradata/racbak/
cd cd /u01/app/oracle/oradata/racbak/
mv standby.ctl control01.ctl
cp orapwracdb1 /u01/app/oracle/product/11.2.0/db_1/dbs/
cd /u01/app/oracle/product/11.2.0/db_1/dbs/
mv orapwracdb1 orapwracbak
4.启动数据库到nomount状态
SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup nomount pfile=/u01/export/home/oracle/pfile.ora
ORACLE instance started.
Total System Global Area 497995776 bytes
Fixed Size 1337464 bytes
Variable Size 260048776 bytes
Database Buffers 230686720 bytes
Redo Buffers 5922816 bytes
5.启动到mount状态
SQL> alter database mount;
Database altered.
6.指定备份集路径,bak目录下是从主库传过来的备份集
rman>catalog start with '/bak/';
7.利用rman恢复出备库
set dbid 834465720
RMAN>
run{
set newname for datafile 1 to '/u01/app/oracle/oradata/racbak/system01.dbf';
set newname for datafile 2 to '/u01/app/oracle/oradata/racbak/sysaux01.dbf';
set newname for datafile 3 to '/u01/app/oracle/oradata/racbak/undotbs01.dbf';
set newname for datafile 4 to '/u01/app/oracle/oradata/racbak/users01.dbf';
set newname for datafile 5 to '/u01/app/oracle/oradata/racbak/undotbs02.dbf';
set newname for datafile 6 to '/u01/app/oracle/oradata/racbak/tps_hxl01.dbf';
set newname for tempfile 1 to '/u01/app/oracle/oradata/temp01.dbf';
restore database;
switch datafile all;
}
8.应用日志
SQL> alter database recover managed standby database using current logfile disconnect from session;
alter database recover managed standby database using current logfile disconnect from session
*
ERROR at line 1:
ORA-38500: USING CURRENT LOGFILE option not available without standby redo logs
9.添加standby日志组
Standby redo log的组数一般为(N +1)* thread# (N分别为每个thread#的联机日志组数).
在本例,每一个thread的联机日志都是3组,所以需要添加6组standby redo log:
alter database add standby logfile thread 1 group 7 ('/u01/app/oracle/oradata/racbak/stdbyredo_1_07.log') size 50m;
alter database add standby logfile thread 1 group 8 ('/u01/app/oracle/oradata/racbak/stdbyredo_1_08.log') size 50m;
alter database add standby logfile thread 1 group 9 ('/u01/app/oracle/oradata/racbak/stdbyredo_1_09.log') size 50m;
alter database add standby logfile thread 1 group 10 ('/u01/app/oracle/oradata/racbak/stdbyredo_1_10.log') size 50m;
alter database add standby logfile thread 2 group 11 ('/u01/app/oracle/oradata/racbak/stdbyredo_2_11.log') size 50m;
alter database add standby logfile thread 2 group 12 ('/u01/app/oracle/oradata/racbak/stdbyredo_2_12.log') size 50m;
alter database add standby logfile thread 2 group 13 ('/u01/app/oracle/oradata/racbak/stdbyredo_2_13.log') size 50m;
alter database add standby logfile thread 2 group 14 ('/u01/app/oracle/oradata/racbak/stdbyredo_1_14.log') size 50m;
9.重新应用日志
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
到这里整个dataguard环境部署完成 .
--------------------------------------------问题列表------------------------------
1.主库因某个日志文件没有传输到备份,导致日志无法应用
备库日志信息如下:
Archived Log entry 50 added for thread 2 sequence 36 ID 0x31c44f6e dest 1:
RFS[15]: Selected log 12 for thread 2 sequence 31 dbid 834465720 branch 837290977
CORRUPTION DETECTED: In redo blocks starting at block 1920count 977 for thread 2 sequence 31
Errors in file /u01/app/oracle/diag/rdbms/racbak/racbak/trace/racbak_rfs_6215.trc:
ORA-00272: error writing archive log /u01/app/oracle/oradata/racbak/stdbyredo_2_12.log
ORA-00354: corrupt redo log block header
在备库的归档目录没有发现thread 2 sequence 36对应的日志文件,不知道什么原因没有传输到备库.
手工传到备库:
scp 2_31_837290977.dbf oracle@192.168.50.202:/u01/archive_log/
手工注册:
alter database register physical logfile '/u01/archive_log/2_31_837290977.dbf';
查看备库日志 :
ALTER DATABASE REGISTER [PHYSICAL] LOGFILE
Completed: alter database register physical logfile '/u01/archive_log/2_31_837290977.dbf'
Tue Jan 21 23:19:35 2014
Media Recovery Log /u01/archive_log/2_31_837290977.dbf
Media Recovery Log /u01/archive_log/1_26_837290977.dbf
Media Recovery Log /u01/archive_log/2_32_837290977.dbf
Media Recovery Log /u01/archive_log/1_27_837290977.dbf
Media Recovery Log /u01/archive_log/2_33_837290977.dbf
Media Recovery Log /u01/archive_log/2_34_837290977.dbf
Media Recovery Log /u01/archive_log/1_28_837290977.dbf
Media Recovery Log /u01/archive_log/2_35_837290977.dbf
Media Recovery Log /u01/archive_log/1_29_837290977.dbf
Media Recovery Log /u01/archive_log/1_30_837290977.dbf
Media Recovery Log /u01/archive_log/1_31_837290977.dbf
Media Recovery Log /u01/archive_log/2_36_837290977.dbf
Media Recovery Log /u01/archive_log/2_37_837290977.dbf
Media Recovery Log /u01/archive_log/2_38_837290977.dbf
Media Recovery Waiting for thread 1 sequence 32 (in transit)
Recovery of Online Redo Log: Thread 1 Group 7 Seq 32 Reading mem 0
Mem# 0: /u01/app/oracle/oradata/racbak/stdbyredo_1_07.log
Media Recovery Waiting for thread 2 sequence 39
可以看到备库正常使用主库传过来的日志了 。
2.备库临时表空间对应的数据文件依然是asm的存储方式,导致备库用到临时表空间的会话报错误
备库日志文件错误:
Wed Jan 22 07:26:18 2014
Errors in file /u01/app/oracle/diag/rdbms/racbak/racbak/trace/racbak_dbw0_6048.trc:
ORA-01157: cannot identify/lock data file 201 - see DBWR trace file
ORA-01110: data file 201: '+DATA01/racdb/tempfile/temp.261.836849023'
ORA-17503: ksfdopn:2 Failed to open file +DATA01/racdb/tempfile/temp.261.836849023
ORA-15001: diskgroup "DATA01" does not exist or is not mounted
ORA-15077: could not locate ASM instance serving a required diskgroup
ORA-29701: unable to connect to Cluster Synchronization Service
Errors in file /u01/app/oracle/diag/rdbms/racbak/racbak/trace/racbak_dbw0_6048.trc:
ORA-01186: file 201 failed verification tests
ORA-01157: cannot identify/lock data file 201 - see DBWR trace file
ORA-01110: data file 201: '+DATA01/racdb/tempfile/temp.261.836849023'
File 201 not verified due to error ORA-01157
Successfully added datafile 7 to media recovery
Datafile #7: '/u01/app/oracle/oradata/racbak/tps_hxl02.278.837513931'
Wed Jan 22 07:32:56 2014
ERROR: slave communication error with ASM; terminating process 8121
Errors in file /u01/app/oracle/diag/rdbms/racbak/racbak/trace/racbak_ora_8121.trc:
解决办法:
为该临时数据文件对应的默认表空间添加另外一个数据文件
SQL>alter tablespace temp add tempfile '/u01/app/oracle/oradata/racbak/temp01.dbf' size 100m;
删除ASM的数据文件
SQL> alter database tempfile '+DATA01/racdb/tempfile/temp.261.836849023' drop;
3.rman过来的时候备库会自动生成rac每个节点的在线日志组, 因为是单实例的备库,只需要一个实例的在线日志组就可以了,如下将禁用实例2,同时可以删除实例2对应的在线日志组.
alter database disable thread 2;
alter database drop logfile group 2 thread 2;
alter database drop logfile group 4 thread 2;
alter database drop logfile group 6 thread 2;
-- The End --