手动搭建Dataguard步骤(同一服务器上physic standby)

(1)建立对应standby数据库的目录,如$ORACLE_BASE/admin,$ORACL_EBASE/oradata下的对应目录以及相关子目录,归档日志存放目录,闪回区存放路径等;创建密码文件。

mkdir /opt/oracle/admin/standby
cd /opt/oracle/admin/standby
mkdir adump bdump cdump udump dpdump

mkdir /opt/oracle/oradata/standby

mkdir /opt/oracle/oradata/standby/archivelog

 

orapwd file=$ORACLE_HOME/dbs/orapwstandby password=oracle force=y

 

(2) 开始主库的备份,备份包括数据文件和控制文件

alter database begin backup;

 cp /opt/oracle/oradata/ocp/system01.dbf /home/oracle/backup/
 cp /opt/oracle/oradata/ocp/undotbs01.dbf /home/oracle/backup/
 cp /opt/oracle/oradata/ocp/sysaux01.dbf /home/oracle/backup/
 cp /opt/oracle/oradata/ocp/users01.dbf /home/oracle/backup/
 cp /opt/oracle/oradata/ocp/perfstat01.dbf /home/oracle/backup/
 cp /opt/oracle/oradata/ocp/example01.dbf /home/oracle/backup/
 cp /opt/oracle/oradata/ocp/user01.dbf /home/oracle/backup/
 cp /opt/oracle/oradata/ocp/user02.dbf /home/oracle/backup/

alter database end backup;

alter system archive log current;

alter database create standby controlfile as '/home/oracle/backup/control01.ctl'; --这里要注意语法

 

(3) 修改主库的参数文件

create pfile from spfile

vim $ORACLE_HOME/dbs/initocp.ora

 

*.log_archive_config='dg_config=(demo,standby)'
*.fal_server=standby
*.fal_client=demo
*.standby_file_management=AUTO
*.db_unique_name=demo
*.log_archive_dest_1='LOCATION=/opt/oracle/oradata/ocp/archive/'
*.log_archive_dest_2='SERVICE=standby valid_for=(online_logfiles,primary_role) db_unique_name=standby'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'

 

(4)关闭主库,创建spfile

shutdown immediate;

create spfile from pfile;

 

(5)创建备库的参数文件

 

create pfile='?/dbs/initstandby.ora' from spfile;

 

改变其中的相关路径,设置如下对应参数:
*.log_archive_dest_1='LOCATION=/opt/oracle/oradata/standby/archive/'
*.log_archive_dest_2='SERVICE=ocp valid_for=(online_logfiles,primary_role) db_unique_name=ocp'
*.log_archive_config='dg_config=(ocp,standby)'
*.fal_server=ocp
*.fal_client=standby
*.standby_file_management=AUTO
*.db_unique_name=standby
*.db_file_name_convert='/opt/oracle/oradata/ocp','/opt/oracle/oradata/standby'
*.log_file_name_convert='/opt/oracle/oradata/ocp','/opt/oracle/oradata/standby'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'

修改pfile完成后,创建备库对应的spfile:

create spfile='?/dbs/spfilestandby.ora' from pfile='?/dbs/initstandby.ora';

 

(6) 配置监听,将对应的db_unique_name配置进去

vim $ORACLE_HOME/network/admin/tnsnames.ora

DEMO =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.102)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = demo)
    )
  )

STANDBY =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.102)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = standby)
    )
  )

重新启动监听。

 

(7)copy 主库数据文件和控制文件的备份到备库对应目录

cd  /home/oracle/backup/

cp * /opt/oracle/oradata/standby

 

(8)启动备库

export ORACLE_SID=standby

startup mount;

 

如果没有临时文件,记得增加临时文件,以备查询时排序的需要。

alter tablespace temp add tempfile '路径' size 20M;

 

(9)启动主库

export ORACLE_SID=demo

startup;

 

(10) 验证日志是否传送到备库

在主库切日志 alter system switch logfile; / /

主库查看 archive log list

 

备库查看 archive log list;

 

如果没有传送,请检查log_archive_dest_n的设置以及tnsnames的配置(用tnsping检验是否可以ping 通)

 

select process,status from v$managed_standby; --备库上看看有哪些进程,有没有RFS进程

 

select message_num,message from v$dataguard_status; --看看提示信息

 

 

 

 

 

 

你可能感兴趣的:(手动搭建Dataguard步骤(同一服务器上physic standby))