备份与恢复

Oracle 11G 搭建Data Guard

时间:2013/10/28 12:44:13  作者:www.solgle.com  来源:说歌社区  查看:832  评论:1
内容摘要:1 安装环境在主机1上安装数据库软件,并建监听和实例,在主机2上安装数据库软件,并建监听,但不建实例。主机1 主机2 操作系统 redhat6.1 64位 redhat6.1 64位 主机名 dg1 db2 IP 192.168.132.3 192.168.132.4 数据库软件...

1 安装环境

在主机1上安装数据库软件,并建监听和实例,在主机2上安装数据库软件,并建监听,但不建实例。

 

 

主机1

主机2

操作系统

redhat6.1 64

redhat6.1 64

主机名

dg1

db2

IP

192.168.132.3

192.168.132.4

数据库软件版本

oracle 11.2.0.1.0

oracle 11.2.0.1.0

ORACLE_BASE

/oracle/app/oracle/

/oracle/app/oracle/

ORACLE_HOME

$ORACLE_BASE/product/11.2.0/db_1

$ORACLE_BASE/product/11.2.0/db_1

ORACLE_SID

dbtest

 

 

闪回区

4G

 

 

归档

开启

 

 

 

 

2 主数据库配置

2.1 设置数据库强制归档

sqlplus / as sysdba

SQL> ALTER DATABASE FORCE LOGGING;

SQL> select force_logging from v$database;

FOR

---

YES

2.2 添加STANDBY日志文件

SQL>alter database add standby logfile group 4 ('/oradata/dbtest/redo04.log') size 50m;

SQL>alter database add standby logfile group 5 ('/oradata/dbtest/redo05.log') size 50m;

SQL>alter database add standby logfile group 6 ('/oradata/dbtest/redo06.log') size 50m;

SQL>alter database add standby logfile group 7 ('/oradata/dbtest/redo07.log') size 50m;

SQL> select * from v$logfile order by 1;

 

2.3 修改参数文件

2.3.1 生成pfile

SQL>create pfile from spfile;

SQL>shutdown immediate;

2.3.2 修改pfile

vi $ORACLE_HOME/dbs/initdbtest.ora

在最后添加如下内容:

*.db_unique_name=dbtest1

*.fal_server='dbtest1'

*.fal_client='dbtest2'

*.standby_file_management=auto

*.db_file_name_convert='/oradata/dbtest/','/oradata/dbtest/'

*.log_file_name_convert='/oradata/dbtest/','/oradata/dbtest/'

*.log_archive_config='dg_config=(dbtest1,dbtest2)'

*.log_archive_dest_2='service=dbtest2 LGWR SYNC AFFIRM valid_for=(online_logfiles,primary_role) db_unique_name=dbtest2'

*.log_archive_dest_state_2='ENABLE'

2.3.3 生成spfile

SQL> create spfile from pfile;

File created.

2.4 修改监听配置文件

 

2.5 修改TNS配置文件

[oracle@dg1 admin]$ cat tnsnames.ora

# tnsnames.ora Network Configuration File: /oracle/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

 

 

DBTEST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.132.3)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = dbtest1)

)

)

DBTEST1 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.132.3)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = dbtest1)

)

)

DBTEST2 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.132.4)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = dbtest2)

)

)

EXTPROC_CONNECTION_DATA =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC2))

)

(CONNECT_DATA =

(SID = PLSExtProc)

(PRESENTATION = RO)

)

)

 

2.6 重启监听服务

lsnrctl stop

lsnrctl start

2.7 配置最大可用模式

SQL> startup

ORACLE instance started

SQL> alter database set standby database to maximize availability;

Database altered.

SQL> exit

2.8 备份数据库

[oracle@dg1 admin]$ rman target /

RMAN> backup database plus archivelog;

RMAN> backup current controlfile for standby;

RMAN> exit

备份完成后会在闪回区生产备份文件

 

 

3 备数据库配置

3.1 建立相应的文件目录

包括dump文件目录,闪回区,数据文件目录,可以通过 show parameter dest命令查看

mkdir -p /oracle/app/oracle/admin/dbtest/adump

mkdir -p /oracle/app/oracle/admin/dbtest/dpdump

mkdir -p /oracle/app/oracle/diag/rdbms/dbtest1/dbtest/trace

mkdir -p /oracle/app/oracle/diag/rdbms/dbtest1/dbtest/cdump

mkdir -p /oracle/app/oracle/flash_recovery_area

mkdir -p /oradata/dbtest

3.2 从主数据库服务器上拷贝文件

注意:下面命令在主数据库上执行

3.2.1 拷贝闪回区内容

[oracle@dg1 admin]$ cd /oracle/app/oracle/flash_recovery_area

scp -r ./* 192.168.132.4:/oracle/app/oracle/flash_recovery_area/

3.2.2 拷贝参数文件

[oracle@dg1 flash_recovery_area]$ cd $ORACLE_HOME/dbs

scp ./* 192.168.132.4:/oracle/app/oracle/product/11.2.0/db_1/dbs/

3.2.3 拷贝监听文件

[oracle@dg1 dbs]$ cd ../network/admin/

scp *.ora 192.168.132.4:/oracle/app/oracle/product/11.2.0/db_1/network/admin/

3.3 修改监听配置文件

修改ip地址

 

3.4 修改TNS配置文件

修改ip地址

 

3.5 重启监听服务

lsnrctl stop

lsnrctl start

3.6 恢复数据库

[oracle@dg2 admin]$ rman target sys/funo1234@dbtest1 auxiliary /

RMAN> duplicate target database for standby nofilenamecheck;

RMAN> exit

3.7 修改参数文件

[oracle@dg2 admin]$ sqlplus / as sysdba

SQL> shutdown immediate;

vi $ORACLE_HOME/dbs/initdbtest.ora

修改如下内容

*.db_unique_name=dbtest2

 

SQL> create spfile from pfile;

3.8 启动数据库

SQL> startup nomount;

SQL> alter database mount standby database;

SQL> alter database add standby logfile;

SQL> alter database add standby logfile;

SQL> alter database add standby logfile;

SQL> alter database add standby logfile;

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

3.9 验证

主库备库均执行如下命令:

SQL> archive log list;

主库

 

备库

 

如果最后一行数字相同,说明配置成功

3.10 切换到只读模式

SQL> alter database recover managed standby database cancel;

SQL> alter database open read only;

3.11 切换到同步模式

SQL> shutdown immediate;

SQL> startup nomount;

SQL> alter database mount standby database;

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


推介其他快捷方式:http://www.solgle.com/news/?216.html


标签:Oracle 11G 搭建Data Guard 

solgle.com 版权所有,欢迎分享!!!

相关评论
 img1 img2 img3 img4 img5 img6 img7 img8 img9 img10
评论者:      验证码:  点击获取验证码
   Copyright © 2013-2028 solgle.com,All rights reserved.[solgle.com] 公安机关备案号:51010802000219
Email:solgle@solgle.com; weixin:cd1008610000 ICP:蜀ICP备14011070号-1