Oracle 11g dataguard pyhsical standby创建步骤
Oracle 11g dataguard pyhsical standby创建步骤
 
主库:dcwhtest_std  192.168.128.40
备库:dcwhtest_dg   10.161.138.10
 
相关环境变量(主备库相同)
ORACLE_SID=dcwhtest
ORACLE_BASE=/home/oracle/product
ORACLE_HOME=/home/oracle/product/11203/db1
datafile目录:/lg/oradata
 
primary主库操作 
 
1.打开Forced Logging模式
$ sqlplus / as sysdba
SQL> alter database force logging;
 
2.确保主库为归档模式
SQL> archive log list;
如果没有开启归档 需要打开归档
SQL> shutdown immediate  
SQL> startup mount  
SQL> alter database archivelog;  
SQL> archive log list;
 
3.配置Standby redo log(以下为示例)
SQL> alter database add standby logfile group 5 (‘/lg/oradata/dcwhtest/rtdby_log05.log’) size 500M;
SQL> alter database add standby logfile group 6 (‘/lg/oradata/dcwhtest/rtdby_log06.log’) size 500M;
SQL> alter database add standby logfile group 7 (‘/lg/oradata/dcwhtest/rtdby_log07.log’) size 500M;
SQL> alter database add standby logfile group 8 (‘/lg/oradata/dcwhtest/rtdby_log08.log’) size 500M;
验证是否创建成功
SQL> SELECT GROUP#,THREAD#,SEQUENCE#,ARCHIVED,STATUS FROM V$STANDBY_LOG;
 
4.创建密码文件(如果不存在)
$ orapwd file=/home/oracle/product/11203/db1/dbs/orapwdcwhtest passwd=orapasswd
 
5.创建控制文件
SQL> alter database create standby controlfile as ‘/home/oracle/control01.ctl’;
 
6.配置监听
$ vim /home/oracle/product/11203/db1/network/admin/tnsnames.ora
 
dcwhtest_std =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.128.40)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dcwhtest)
    )
  )
 
dcwhtest_dg =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.161.138.10)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dcwhtest)
    )
  )
 
 
7.修改初始化参数
SQL> create pfile=’/home/oracle/initdcwhtest.ora’ from spfile;
$ vim /home/oracle/initdcwhtest.ora
*.db_name=’dcwhtest’
*.db_unique_name=’dcwhtest_std’
*.log_archive_config=’DG_CONFIG=(dcwhtest_dg,dcwhtest_std)’
*.log_archive_dest_1=’LOCATION=/lg/oradata/dcwhtest/arch’
*.log_archive_dest_state_2=’enable’
*.fal_client=’dcwhtest_std’
*.fal_server=’dcwhtest_dg’
*.log_file_name_convert=’/lg/oradata/dcwhtest’,’/lg/oradata/dcwhtest’
 
参数修改通过alter system在线修改,不用重启数据库,如下
SQL> alter system set log_archive_config=’DG_CONFIG=(dcwhtest_dg,dcwhtest_std)’ scope=both;
 
 
 
8.拷贝密码文件和pfile文件到备库
[oracle@wha0itdat001 lg]$ scp  initdcwhtest.ora orapwdcwhtest root@10.161.138.10:/lg/
 
 
 
standby备库操作
 
[oracle@wuhan-test-dg lg]$ cp /lg/orapwdcwhtest /home/oracle/product/11203/db1/dbs/
[oracle@wuhan-test-dg lg]$ cp /lg/ initdcwhtest.ora  /home/oracle/product/11203/db1/dbs/
 
1.配置和启动监听
[oracle@wuhan-test-dg admin]$ vim  /home/oracle/product/11203/db1/network/admin/listener.ora
 
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST =10.161.138.10)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )
 
SID_LIST_LISTENER =
 (SID_LIST =
    (SID_DESC =
      (ORACLE_HOME = /home/oracle/product/11203/db1)
      (SID_NAME = dcwhtest)
    )
)
 
[oracle@wuhan-test-dg admin]$ vim  /home/oracle/product/11203/db1/network/admin/tnsnames.ora
 
dcwhtest_dg =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.161.138.10)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dcwhtest)
    )
  )
 
dcwhtest_std =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.128.40)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dcwhtest)
    )
  )
 
 
 启动和测试tns
[oracle@wuhan-test-dg oradata]$ lsnrctl start
[oracle@wuhan-test-dg ~]$ sqlplus sys/oracle@dcwhtest_std as sysdba
[oracle@wuhan-test-dg ~]$ sqlplus sys/oracle@dcwhtest_dg as sysdba
 
2.修改初始化参数
[oracle@wuhan-test-dg dbs]$ vim /lg/initdcwhtest.ora 
*.db_name=’dcwhtest’
*.db_unique_name=’dcwhtest_dg’
*.log_archive_config=’DG_CONFIG=(dcwhtest_dg,dcwhtest_std)’
*.log_archive_dest_1=’LOCATION=/lg/oradata/dcwhtest/arch’
*.log_archive_dest_state_2=’enable’
*.log_file_name_convert=’/lg/oradata/dcwhtest’,’/lg/oradata/dcwhtest’
 
 
3.启动数据库到nomount状态
 
[oracle@wuhan-test-dg lg]$ sqlplus / as sysdba
SQL> create spfile from pfile=’initdcwhtest.ora’;
SQL> startup nomount;
 
4.使用RMAN 来创建physical standby database
rman target sys/oracle@dcwhtest_std auxiliary sys/oracle@dcwhtest_dg   nocatalog

run {

allocate channel c1 type disk;

allocate channel c2 type disk;

allocate channel c3 type disk;

allocate auxiliary channel s1 type disk;

allocate auxiliary channel s2 type disk;

allocate auxiliary channel s3 type disk;

allocate auxiliary channel s4 type disk;

duplicate target database for standby from active database nofilenamecheck;

}

nofilenamecheck这个参数是主备库文件名称一样的时添加,否则会报错。
 
 
5.查看是否创建成功
 
SQL>  select instance_name from v$instance;
 
INSTANCE_NAME
—————-
dcwhtest
 
SQL>  select database_role from v$database;
 
DATABASE_ROLE
————————————————
PHYSICAL STANDBY
 
SQL>  select open_mode from v$database;
 
OPEN_MODE
————————————————————
MOUNTED
 
SQL> select dest_id,status from v$archive_dest;
 
   DEST_ID STATUS
———- ———
         1 VALID
         2 INACTIVE
         3 INACTIVE
         4 INACTIVE
 
 
6.打开数据库并应用同步
 
SQL>  alter database recover managed standby database disconnect;
 
Database altered.
 
SQL> select open_mode from v$database;
 
OPEN_MODE
————————————————————
MOUNTED
 
SQL>  alter database recover managed standby database cancel;
 
SQL> alter database open;
 
Database altered.
 
SQL> select open_mode from v$database;
 
OPEN_MODE
——————–
READ ONLY
 
 
SQL> alter database recover managed standby database using current logfile disconnect;
 
Database altered.
 
SQL> select open_mode from v$database;
 
OPEN_MODE
——————–
READ ONLY WITH APPLY
 
SQL> select open_mode from v$database;
 
OPEN_MODE
——————–
READ ONLY WITH APPLY
 
 
[oracle@wuhan-test-dg oradata]$ ora dgstats
 
NAME        VALUE     UNIT    TIME_COMPUTED   DATUM_TIME
—————————— ——————– —————————— —————————— ——————————
transport lag        +00 00:00:00     day(2) to second(0) interval   07/26/2013 17:26:42   07/26/2013 17:26:42
apply lag        +00 00:00:00     day(2) to second(0) interval   07/26/2013 17:26:42   07/26/2013 17:26:42
apply finish time        +00 00:00:00.000     day(2) to second(3) interval   07/26/2013 17:26:42
estimated startup time        12     second    07/26/2013 17:26:42
 
 
 
 
 
 
 

共有 0 条评论

Top