oracle 11g dg 部署rman方式要点记录

1、环境介绍

ip hostname sid db_name db_unique_name net service name
192.168.56.118 oraclep yunhaip yunhaip yunhaip yunhaip
192.168.56.117 oracles yunhaip yunhaip yunhais yunhais

2、修改hostname

hostnamectl set-hostname oraclep

3、db部署

主:创建库,从:不创建数据库
就是没有dbca那一步,网络和基础环境还是需要的

4、主库开启归档并设置强制日志 force logging

SQL> shutdown immediate

停止数据库操作

startup mount

启动到mount状态

alter database archivelog;

开启归档

alter database force logging;

强制记录日志,即对数据库中的所有操作都产生日志信息,并将该信息写入到联机重做日志文件。

alter database open;

打开数据库

archive log list;

想查看数据的归档模式

select force_logging from v$database;

确认是否为强制日志

5、主库添加standby redo log

select member from v$logfile;

查看redo和standby redo

select * from v$log;

查看redo情况

alter database add standby logfile group 21 ‘/u01/app/oradata/yunhaip/standby21.log‘ size 50M;
alter database add standby logfile group 22 ‘/u01/app/oradata/yunhaip/standby22.log‘ size 50M;
alter database add standby logfile group 23 ‘/u01/app/oradata/yunhaip/standby23.log‘ size 50M;
alter database add standby logfile group 24 ‘/u01/app/oradata/yunhaip/standby24.log‘ size 50M;

增一组大小为50M的standby redo,这里的group号不得与online redo重复,正式环境文件大小需要调整

6、配置文件修改
6.1、主库pfile创建,以便做出修改

SQL>create pfile from spfile;
SQL> host
[[email protected] ~]$ cd $ORACLE_HOME/dbs
[[email protected] dbs]$ pwd
/u01/app/oracle/product/11.2.0/db_1/dbs
cat >> /u01/app/oracle/product/11.2.0/db_1/dbs/inityunhaip.ora << "EOF"
*.db_unique_name=‘yunhaip‘
*.fal_server=‘yunhais‘
*.log_archive_config=‘dg_config=(yunhaip,yunhais)‘
*.log_archive_dest_1=‘location=use_db_recovery_file_dest valid_for=(all_logfiles, all_roles) db_unique_name=yunhaip‘
*.log_archive_dest_2=‘service=yunhais lgwr async valid_for=(online_logfile,primary_role) db_unique_name=yunhais‘
*.log_archive_dest_state_1=ENABLE
*.log_archive_dest_state_2=ENABLE
*.standby_file_management=‘AUTO‘
*.db_file_name_convert=‘/u01/app/oradata/yunhaip‘,‘/u01/app/oradata/yunhaip‘
*.log_file_name_convert=‘/u01/app/oradata/yunhaip‘,‘/u01/app/oradata/yunhaip‘
EOF

6.2、拷贝主库的pfile到从库,并修改如下内容:

[[email protected] dbs]$ pwd
/u01/app/oracle/product/11.2.0/db_1/dbs
[[email protected] dbs]$ scp inityunhaip.ora
192.168.56.117:/u01/app/oracle/product/11.2.0/db_1/dbs/

cat >> /u01/app/oracle/product/11.2.0/db_1/dbs/inityunhaip.ora << "EOF"
*.db_unique_name=‘yunhais‘
*.fal_server=‘yunhaip‘
*.log_archive_config=‘dg_config=(yunhaip,yunhais)‘
*.log_archive_dest_1=‘location=use_db_recovery_file_dest valid_for=(all_logfiles, all_roles) db_unique_name=yunhais‘
*.log_archive_dest_2=‘service=yunhaip lgwr async valid_for=(online_logfile,primary_role) db_unique_name=yunhaip‘
*.log_archive_dest_state_1=ENABLE
*.log_archive_dest_state_2=ENABLE
*.standby_file_management=‘AUTO‘
*.db_file_name_convert=‘/u01/app/oradata/yunhaip‘,‘/u01/app/oradata/yunhaip‘
*.log_file_name_convert=‘/u01/app/oradata/yunhaip‘,‘/u01/app/oradata/yunhaip‘
EOF

6.3、说明:

dg_config=(yunhaip,yunhais) 以外,其他情况主从的相关信息对调即可

6.4、创建新的主库spfile文件,并重新启动主库

SQL> shutdown immediate
SQL> create spfile from pfile;
SQL> startup
SQL> ALTER USER SYS IDENTIFIED BY sys;

修改sys密码为以后rman连接使用

6.5、 复制主库的密码文件到备库

scp orapwyunhaip 192.168.56.117:/u01/app/oracle/product/11.2.0/db_1/dbs/

7、从库创建相关目录

strings spfileyunhaip.ora

获得目录,我观察的是主库的

mkdir -p /u01/app/oracle
mkdir -p /u01/app/admin/yunhaip/{a,b,c,d,u}dump
mkdir -p /u01/app/oradata/yunhaip/
mkdir -p /u01/app/fast_recovery_area/yunhaip/

8、创建tnsnames.ora ,主从一致即可

cat >> /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora << "EOF"
yunhaip =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.118)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = yunhaip)
)
)

yunhais =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.117)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = yunhais)
)
)
EOF

9、修改备份库的listener.ora

cat >> /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora << "EOF"
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = yunhais)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = yunhaip)
)
)

EOF

原因如下:
[[email protected] ~]$ rman target sys/[email protected] auxiliary sys/[email protected]
Recovery Manager: Release 11.2.0.3.0 - Production on Wed Jul 3 15:43:07 2019
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: YUNHAIP (DBID=665781658)
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: initialization of internal recovery manager package failed
RMAN-04006: error from auxiliary database: ORA-12528: TNS:listener: all appropriate instances are blocking new connections

10、尝试启动从库到nomount

SQL> create spfile from pfile;
SQL> startup nomount

11、RMAN复制主库到备库
11.1、首先RMAN连接到主数据库和备数据库

rman target sys/[email protected] auxiliary sys/[email protected]

如果有相关报错,请注意9,6.4步骤

11.2、使用RMAN的duplicate命令进行复制,两边目录结构相同,需要添加nofilenamecheck参数

duplicate target database for standby from active database nofilenamecheck;

12、复制完毕,对从库进行相关处理

select status from v$instance;

查询从库是否处于MOUNTED状态

alter database recover managed standby database using current logfile disconnect from session;

在备库开启实时日志应用

13、观察主从正确状态
13.1、观察主库alert日志

vim alert_yunhaip.log

Error 12154 received logging on to the standby发现这个错误

13.2、重启主库

SQL> shutdown immediate;
SQL> startup;

13.3观察主库状态:

SQL> select switchover_status,database_role from v$database;

SWITCHOVER_STATUS DATABASE_ROLE



TO STANDBY PRIMARY

13.4、观察从库状态

SQL> select switchover_status,database_role from v$database;

SWITCHOVER_STATUS DATABASE_ROLE



NOT ALLOWED PHYSICAL STANDBY

14、通过切换日志观察同步情况
14.1、主库切换

SQL> archive log list;
SQL> alter system switch logfile;
SQL> archive log list;

14.2、从库观察

SQL> archive log list;

15、从库open,以便用户能够读取

alter database recover managed standby database cancel;
alter database open;
alter database recover managed standby database using current logfile disconnect ;

[[email protected] ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Wed Jul 3 15:59:46 2019
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter database open;
Database altered.
SQL> alter database recover managed standby database using current logfile disconnect ;
Database altered.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

16、实验过程
16.1、观察从库现有数据

[[email protected] ~]$ sqlplus test/test
SQLPlus: Release 11.2.0.3.0 Production on Wed Jul 3 16:01:59 2019
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select
from test;
ID NUMS



1 2
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[[email protected] ~]$ exit
登出
Connection to 192.168.56.117 closed.

16.2、主库添加新数据

[[email protected] trace]$ sqlplus test/test
SQL*Plus: Release 11.2.0.3.0 Production on Wed Jul 3 16:02:19 2019
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> insert into test values(2,2);
1 row created.
SQL> commit;
Commit complete.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

16.3、从库观察新数据

[[email protected] trace]$ ssh 192.168.56.117
[email protected]‘s password:
Last login: Wed Jul 3 16:01:52 2019 from 192.168.56.118
[[email protected] ~]$ sqlplus test/test
SQLPlus: Release 11.2.0.3.0 Production on Wed Jul 3 16:02:36 2019
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select
from test;
ID NUMS



1 2
2 2

原文地址:https://blog.51cto.com/860143/2416732

时间: 2024-10-16 16:16:28

oracle 11g dg 部署rman方式要点记录的相关文章

Oracle 11g单实例RMAN恢复到Oracle 11g RAC

一.环境说明 操作系统版本: RHEL 6.5 x64 1. 源数据库服务器 Oracle版本: Oracle 11g 11.2.0.4 64位(单机)Oracle_SID: orcl db_name   : orcl 背景:一台生产oracle10g(10.2.0.5)数据库计划迁移到Oracle 11.2.0.4.0 RAC.1) 先oracle10g(10.2.0.5)升级到Oracle 11.2.0.4(过程略)2)再Oracle 11.2.0.4单实例迁移到Oracle 11.2.0.

Linux平台 Oracle 11g DG测试环境快速搭建参考

环境现状: 两台虚拟主机A和B: 1. A机器已安装ASM存储的Oracle 11g 实例 参考:http://www.cnblogs.com/jyzhao/p/4332410.html 2. B机器已安装系统,配置以及目录结构均和A机器保持一致 /u01 + 3块ASM盘 DG部署规划:   primary standby 主机 JY-DB JY-DBS db_name jyzhao jyzhao db_unique_name jyzhao jyzhao_s instance_name jyz

Oracle 11g R2 RAC RMAN备份脚本示例

一.将RAC切换成归档模式 1. 修改数据库的归档模式,通常在安装RAC的时候都会配置归档并且使用闪回区,已经配置过归档下面的方式可以略过. SQL> alter system set cluster_database=false scope=spfile sid='*'; 2. 关闭所有实例(两边都要shutdown) SQL> shutdown immediate 或直接关闭所有实例   $ srvctl stop database -d orcl 3. 在任意一个实例上将数据库启动到mo

Oracle 11G R2利用RMAN搭建DataGuard环境

环境: 角色 机器名 操作系统 IP 备注 主库 db1 CentOS 5.11 x86_64 192.168.2.241 安装Oracle,创建数据库 备库 db2 CentOS 5.11 x86_64 192.168.2.242 只安装Oracle 准备工作: 在db1的/etc/hosts里增加 127.0.0.1       db1 192.168.2.242    db2 在db2的/etc/hosts里增加 127.0.0.1       db2 192.168.2.241    d

oracle 11g r2 使用rman进行迁移rac到rac

源端服务器主机名 rac05 rac06公共IP地址(eth0) 10.15.8.15 10.15.8.16 虚拟IP地址(eth0) 10.15.8.17 10.15.8.18私有IP地址(eth1) 1.1.1.9 1.1.1.10ORACLE RAC SID bol1 bol2集群实例名称 bolSCAN IP 10.15.8.19 操作系统 CentOS 6.5(vm)存储 ASM(vm)ORACLE 11.2.0.4 目标端(实例已安装运行)服务器主机名 rac01 rac02公共IP

oracle 11g DG 搭建

groupadd oinstall groupadd dba groupadd oper groupadd asmadmin groupadd asmdba groupadd asmoper useradd -g oinstall -G dba,asmdba,asmadmin,asmoper grid useradd -g oinstall -G dba,oper,asmdba oracle passwd  grid passwd  oracle mkdir -p /u01/app/11.2.0

Oracle 11g rac 生产环境部署详录

作者:田逸([email protected]) 基本规划 ◎设备选型 1.服务器:Dell R620 两台.cpu 8 core,内存64G,600G 15000转sas硬盘,双电源,hba卡一块,连接存储线缆一根(连接hba卡和共享存储). 2.存储:dell MD3200 一台.双控制器,12块600G 15000转sas硬盘.为追求最高可用性,使用的raid级别是raid10. 3.交换机:华为3com两台,型号为h3c S5048E.注意:网络端口最好是全千兆. 4.网线:2-3米机制

Oracle 11g R2 Rman、数据泵、闪回备份与恢复

Oracle 11g R2 Rman备份备份与恢复的定义及分类 备份的定义及分类: 备份就是把数据库复制到转储设备的过程.其中,转储设备是指用于放置数据库副本的磁带或磁盘.通常也将存放于转储设备中的数据库的副本称为原数据库的备份或转储.备份是一份数据副本,从不同的角度分类如下: 从物理与逻辑的角度来分类: 从物理与逻辑的,备份可以分为物理备份和逻辑备份. 物理备份:对数据库操作系统的物理文件(数据文件,控制文件和日志文件)的备份.物理备份又可以分为脱机备份(冷备份)和联机备份(热备份),前者是在

Linux平台oracle 11g单实例 安装部署配置 快速参考

1.重建主机的Oracle用户 组 统一规范 uid gid 以保证共享存储挂接或其他需求的权限规范 userdel -r oracle groupadd -g 500 oinstall groupadd -g 501 dba useradd -g oinstall -G dba -u 500 oracle #id oracle uid=500(oracle) gid=500(oinstall) 组=500(oinstall),501(dba) 2.安装好Oracle 需要的rpm包.安装rpm