环境:
主库和备库:
操作系统:Liunx6.5
数据库版本: 11.2.0.4
创建步骤:
一.主库配置
1.
设置为 force logging 模式
SQL> alter database force logging;
验证
SQL> select force_logging fromv$database;
FOR
---
YES
2.
主库添加standby redo日志文件
selectgroup#,thread#,members,status,bytes/1024/1024 m from v$log;
select group#,type,member from v$logfile order by 2;
添加原则:大小和 online redo 相同,比 online redo group 多一组。
alter database add standbylogfile thread 1 group 7 ('+DATA') size 521M;
alter database add standby logfile thread 1 group 8 ('+DATA') size 521M;
alter database add standby logfile thread 1 group 9 ('+DATA') size 521M;
alter database add standby logfile thread 1 group 10 ('+DATA') size 521M;
alter database add standby logfile thread 2 group 31('+DATA') size 521M;
alter database add standby logfile thread 2 group 32('+DATA') size 521M;
alter database add standby logfile thread 2 group 11 ('+DATA') size 521M;
alter database add standby logfile thread 2 group 12 ('+DATA') size 521M;
alter database add standby logfile thread 2 group 13 ('+DATA') size 521M;
alter database add standby logfile thread 2 group 14 ('+DATA') size 521M;
3.
添加监听及网络别名
在rac 中listener.ora 没有做配置。
只对tnsname.ora 做了配置,并且使用的是scanip
RACDB=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =
192.168.2.79)(PORT = 1521)) ---s
canip
地址
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = racdb)
)
)
RACDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.77)(PORT= 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = racdb)
)
)
RACDB2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.78)(PORT= 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = racdb)
)
)
racdg =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.90)(PORT= 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = racdg)
)
)
4.
参数修改
alter system set log_archive_config='dg_config=(racdb,racdg)';
alter system setlog_archive_dest_1='location=+data/arch valid_for=(all_logfiles,all_roles)db_unique_name=racdb' scope=both sid='*' ; ;
alter system setlog_archive_dest_2='service=racdg sync valid_for=(online_logfiles,primary_role)db_unique_name=racdg' scope=bothsid='*' ;
alter system setlog_archive_dest_state_1=enable;
alter system setlog_archive_dest_state_2=enable;
alter system setFAL_SERVER='racdg';
alter system setfal_client='racdb';
alter system setstandby_file_management=auto;
二:配置standby库
1.
添加监听及网络别名
Lister.ora
SID_LIST_listener=
(SID_LIST=
(SID_DESC=
(SID_NAME=ptsdg)
(ORACLE_HOME=/u01/oracle/product/11.0.2.4)))
Tnsname.ora
同上
2.
修改参数
把节点一的参数文件scp到stadby库
把带有RACDB1 RACDB2 参书删除.
把节点一的参数文件scp到stadby库
db_unique_name=racdg
log_archive_format=%t_%s_%r.arc
log_archive_config='dg_config=(racdb,racdg)'
log_archive_dest_1='location=/data/archvalid_for=(all_logfiles,all_roles) db_unique_name=racdg'
log_archive_dest_2='service=racdb sync valid_for=(online_logfiles,primary_role)db_unique_name=racdb'
log_archive_dest_state_1=enable
log_archive_dest_state_2=enable
#remote_login_passwordfile=exclusive
fal_server=racdb
fal_client=racdg
standby_file_management=auto
db_file_name_convert='+DATA/racdb/datafile','/data/racdg/','+DATA/racdb/TEMPFILE/','/data/racdg'
log_file_name_convert='+DATA/racdb/onlinelog/','/data/racdg','
+data/arch
/','data/arch/'
3.
重建密码文件:(非常重要)(一般scp某个节点的密码文件,但是一般有问题)
orapwd file=orawpracdgpassword=sys ignorecase=y force=y
如果不这样做的话会导致alter报ORA-16191 and ORA-1017/ORA-1031
4.
创建目录
mkdir -p /u01/app/oracle/diag/rdbms/racdg/racdg /trace
mkdir -p /u01/app/oracle/diag/rdbms/ racdg/ racdg /cdump
mkdir -p /u01/app/oracle/admin/ racdg/adump
5.
启动数据库到nomount
Export ORACLE_SID=racdg
Sql>startup nomount pfile=’/home/oracle/pfile.ora’
6.
创建standby
rman target sys/oracle@
RACDB1 auxiliarysys/oracle@
RACDG
duplicate target database for standby fromactive database;
7.
应用日志及验证
alter database open;
recover managed standbydatabase using current logfile disconnect from session;
主库
create table T ( ID int);
insert into ID values(1);
commit;
standby:
SQL> select * from T;
设置主库参数
配置归档删除策略
CONFIGURE ARCHIVELOG DELETION POLICY toapplied on all standby;---
至此adg 配置完成。