博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
30分钟创建一个Oracle11g DataGuard物理备库的步骤
阅读量:6803 次
发布时间:2019-06-26

本文共 5833 字,大约阅读时间需要 19 分钟。

hot3.png

30分钟创建一个Oracle11g DataGuard物理备库的步骤:

主库主机名:prmy

备库主机名:sby1
主库ip:192.168.1.1
备库ip:192.168.1.2 
主库dbname:prmy
备库dbname:sby1
主库db_unique_name=prmy
备库db_unique_name=sby1
主库listener.ora:prmy
备库listener.ora:sby1
主库备库tnsnames.ora:prmy,sby1

概述:

1.准备主库

2.设置物理备库上的参数

3.配置oracle 网络服务

4.启动备份实例

5.执行RMAN 命令:DUPLICATE TARGET DATABASE FOR

STANDBY FROM ACTIVE DATABASE

6.开启redo的传输和应用

准备主库:

    在数据库层面启用FORCE LOGGING

    如果需要的话创建一个密码文件
    创建备份日志组(standby redo log)
    设置初始化参数

SHUTDOWN IMMEDIATE;

STARTUP MOUNT;
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE OPEN;
alter database force logging;
select log_mode,force_logging from v$database;

scp orapwprmy oracle@192.168.76.134:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwsby1

ALTER DATABASE ADD STANDBY LOGFILE('/u01/app/oracle/oradata/prmy/srl01.log') SIZE 50M;

ALTER DATABASE ADD STANDBY LOGFILE('/u01/app/oracle/oradata/prmy/srl02.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE('/u01/app/oracle/oradata/prmy/srl03.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE('/u01/app/oracle/oradata/prmy/srl04.log') SIZE 50M;

select group#,type,member from v$logfile where type='STANDBY';

select group#,dbid,thread#,sequence#,status from v$standby_log;

(1)alter system set log_archive_config='dg_config=(prmy,sby1)'; 

show parameter log_ARCHIVE_CONFIG;

select * from v$dataguard_config;

(2)ALTER SYSTEM SET log_archive_dest_1='location=use_db_recovery_file_dest valid_for=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=prmy';
show parameter log_archive_dest_1;

(3)ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=sby1 NOAFFIRM ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=sby1';

show parameter LOG_ARCHIVE_DEST_2;

show parameter log_archive_dest_state_2

(4)alter system set log_archive_format='%t_%s_%r.arc' scope=spfile;

show parameter log_archive_format;

(5)alter system set log_archive_max_processes=10;

show parameter log_archive_max_processes;

show parameter remote_login_passwordfile;

(6)alter system set fal_server=sby1;

show parameter fal_server

(7)alter system set standby_file_management=auto;

show parameter standby_file_management

(8)alter system set db_file_name_convert='/u01/app/oracle/oradata/sby1/','/u01/app/oracle/oradata/prmy/' scope=spfile;

(9)alter system set log_file_name_convert='/u01/app/oracle/oradata/sby1/','/u01/app/oracle/oradata/prmy/'scope=spfile;

为物理备库创建一个参数文件

cat dg.ora

DB_NAME=prmy

DB_UNIQUE_NAME=sby1

DB_BLOCK_SIZE=8192

为物理备库创建目录

mkdir -p /u01/app/oracle/oradata/sby1

mkdir -p /u01/app/oracle/fast_recovery_area/sby1

mkdir -p /u01/app/oracle/fast_recovery_area/SBY1

mkdir -p /u01/app/oracle/admin/sby1/adump

启动物理备库

export ORACLE_SID=sby1

sqlplus /nolog

connect /as sysdba
startup nomount pfile='$ORACLE_HOME/dbs/dg.ora';  

select instance_name,host_name from v$instance;

select name from v$database;

为主库及物理备库创建网络服务名
prmy:
cat listener.ora 
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = prmy)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
      (SID_NAME = prmy)
    )
  )

LISTENER =

  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = prmy)(PORT = 1521))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

 cat tnsnames.ora 
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

PRMY =

  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = prmy)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = prmy)
    )
  )

SBY1 =

  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = sby1)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = sby1)
    )
  )

sby1:

 cat listener.ora 

# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = sby1)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
      (SID_NAME = sby1)
    )
  )

LISTENER =

  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = sby1)(PORT = 1521))
  )

ADR_BASE_LISTENER = /u01/app/oracle

 cat tnsnames.ora 
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

PRMY =

  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = prmy)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = prmy)
    )
  )

SBY1 =

  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = sby1)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = sby1)
    )
  )

tnsping prmy
tnsping sby1

使用RMAN脚本来创建物理备库

 cat du.rmn 

run{
allocate channel prmy1 type disk;

allocate channel prmy2 type disk;

allocate channel prmy3 type disk;

allocate channel prmy4 type disk;

allocate auxiliary channel stby type disk;

duplicate target database for standby from active database

spfile

 parameter_value_convert 'prmy','sby1'

 set db_unique_name='sby1'

 set db_file_name_convert='/u01/app/oracle/oradata/prmy/','/u01/app/oracle/oradata/sby1/'

 set log_file_name_convert='/u01/app/oracle/oradata/prmy/','/u01/app/oracle/oradata/sby1/'

 set control_files='/u01/app/oracle/oradata/sby1/control01.ctl', '/u01/app/oracle/fast_recovery_area/sby1/control02.ctl'

 set log_archive_max_processes='10'

 set fal_server='prmy'

 set standby_file_management='AUTO'

 set log_archive_config='dg_config=(prmy,sby1)'

 set log_archive_dest_2='service=prmy ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=prmy';

}

rman target sys/sys@prmy auxiliary sys/sys@sby1

@du.rmn

开启实时应用

alter database open;

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

archvie log list;

alter system switch logfile;

 

转载于:https://my.oschina.net/rootliu/blog/1559964

你可能感兴趣的文章
linux进程管理、任务管理
查看>>
VMware出现的问题(网络)
查看>>
大话数据库编程规范
查看>>
我的友情链接
查看>>
自己收集的golang书籍
查看>>
RCP 文件路径问题
查看>>
python中的自定义函数
查看>>
ELK日志分析平台(一)ELK简介、ElasticSearch集群
查看>>
View 4.6连接异常 求助~~~~~!
查看>>
动态内表及动态ALV显示
查看>>
Xtrabackup备份恢复常用命令与压缩测试
查看>>
Xtrabackup备份恢复常用命令与压缩测试
查看>>
linux运维面试题(一)
查看>>
TFS2008安装图解(详细版本)
查看>>
王家林每日大数据语录Spark篇0016(2015.11.6于南宁)
查看>>
android HOME点击事件的获取
查看>>
2.23——2.25find命令(上中下);2.26 文件名后缀
查看>>
华为服务器的中国梦-当梦想照进现实
查看>>
源码编译安装:隐藏nginx的版本信息
查看>>
python爬虫的常见方式
查看>>