oracle 单实例 dataguard 搭建

环境说明:

   
   

源库:
单实例:
CPU:12
MEM:8G
操作系统:Linux 2.6.18-194.el5
IP地址:10.10.10.222
DB_NAME=orcl
db_unique_Name=orclpri

ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_6

DATAGUARD目标库:
单实例
CPU:4
MEM:6G
操作系统:Linux 2.6.18-194.el5
10.10.10.226
DB_NAME=oem
db_unique_name=dgtest
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_3 

配置步骤
一、源库设置强制归档:
alter database force logging;
二、源库设置初始化参数

alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(orclpri,orclstd)'scope=both;
alter system set LOG_ARCHIVE_DEST_1='LOCATION=/data/logarchive01/';
alter system set LOG_ARCHIVE_DEST_2='SERVICE=orclstd LGWR AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orclstd'scope=both;
alter system set log_archive_format='%t_%s_%r.arc'scope=spfile;
alter system set log_archive_max_processes=4 scope=both;
alter system set fal_server=orclstd scope=both;
alter system set DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/orclstd','/u01/app/oracle/oradataorcl/orcl' scope=spfile;

alter system set LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/orclstd','/u01/app/oracle/oradataorcl/orcl' scope=spfile
alter system set standby_file_management=AUTO scope=both;

 


三、重启源库,设置为归档模式

sqlplus / as sysdba
shutdown immediate
startup mount;
alter database archivelog;

 


四、源库建立standby redolog:

alter database add standby logfile  group 5 '/u01/app/oracle/oradataorcl/orcl/orclstandby_group_05.log' size 50m;
alter database add standby logfile  group 6 '/u01/app/oracle/oradataorcl/orcl/orclstandby_group_06.log' size 50m;
alter database add standby logfile  group 7 '/u01/app/oracle/oradataorcl/orcl/orclstandby_group_07.log' size 50m;
alter database add standby logfile  group 8 '/u01/app/oracle/oradataorcl/orcl/orclstandby_group_08.log' size 50m;

 

五、源库rman备份整个库:

run
{
sql "alter system switch logfile";
allocate channel ch1 type disk format '/dbfs_backup/Primary_for_DG_%U';
backup database;
backup current controlfile for standby;
sql "alter system archive log current";
}

 

用scp 将源库的备份复制到备库同样的目录下;

scp /dbfs_backup/*  10.10.10.226:$PWD
create pfile='/dbfs_backup/initorclstd.ora' from spfile;
scp /dbfs_backup/initorclstd.ora 10.10.10.226:/u01/app/oracle/product/11.2.0/dbhome_6/dbs

 


修改备库初始化参数文件如下 

*.audit_file_dest='/u01/app/oracle/admin/orclstd/adump'
*.control_files='/u01/app/oracle/oradata/orclstd/control01.ctl','/u01/app/oracle/fast_recovery_area/orclstd/control02.ctl'
*.db_file_name_convert='/u01/app/oracle/oradataorcl/orcl/','/u01/app/oracle/oradata/orclstd/'
*.db_name='orcl'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=14385144832
*.db_unique_name='orclstd'
*.FAL_CLIENT='orclstd'
*.fal_server='orclpri'
*.log_archive_config='DG_CONFIG=(orclpri,orclstd)'
*.log_archive_dest_1='LOCATION=/data/logarchive01/'
*.log_archive_dest_2='SERVICE=orclpri LGWR AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orclpri'
*.LOG_ARCHIVE_DEST_STATE_2='ENABLE'
*.log_archive_format='%t_%s_%r.arc'
*.log_file_name_convert='/u01/app/oracle/oradataorcl/orcl/','/u01/app/oracle/oradata/orclstd/'
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'

 

七、修改oracle的sys密码,保持源库和目标库一致:


 八、源库和目标库:修改的tnsnames.ora文件,添加源库和目标库的配置:

 1 orclpri =
 2   (DESCRIPTION =
 3      (ADDRESS_LIST =
 4        (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.222)(PORT = 1521))   
 5      )
 6      (CONNECT_DATA =
 7      (SERVER = DEDICATED)
 8      (SERVICE_NAME = orclpri)
 9   )
10 )
11 orclstd =
12   (DESCRIPTION =
13       (ADDRESS_LIST =
14          (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.226)(PORT = 1521))
15        )
16       (CONNECT_DATA =
17       (SERVER = DEDICATED)
18       (SERVICE_NAME = orclstd)
19   )

 

      九、目标库:配置监听,服务手动注册, 网络配置

vi  listener.ora

 

 1 LISTENER =
 2   (DESCRIPTION_LIST =
 3     (DESCRIPTION =
 4       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.226)(PORT = 1521))
 5       (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)))
 6   )
 7 SID_LIST_LISTENER =
 8   (SID_LIST =
 9     (SID_DESC =
10       (SID_NAME = orclstd)
11       (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_3)
12       (GLOBAL_DBNAME = orclstd)
13     )
14   )

 


启动监听器:lsnrctl start

十、目标库:创建audit 目录

mkdir /u01/app/oracle/admin/orclstd

cd  /u01/app/oracle/admin/orclstd

mkdir adump  dpdump  pfile  scripts

十一、目标库:nomount启动数据库:
       startup nomount
十二、源库端:rman建立dataguard数据库:
rman target / auxiliary sys/oracle@orclstd
DUPLICATE TARGET DATABASE FOR STANDBY NOFILENAMECHECK;
十三、目标库:创建spfile
      create spfile from pfile;     
十四、源库:设置为最大可用模式。
     alter database set standby database to maximize availability;
十五、目标库:启动日志应用,启用active standby data gurad:

alter database open read only;
alter database recover managed standby database disconnect from session;
十六、测试效果:

你可能感兴趣的:(oracle 单实例 dataguard 搭建)