当前位置:  数据库>oracle

RedHat搭建物理Data Guard

    来源: 互联网  发布时间:2017-06-17

    本文导语: 我的搭建环境: 两台机器均为:Red Hat Enterprise Linux Server release 5.4 数据库版本为:Oracle10g10.2.0 primary机上装oracle软件并创建数据库orcl standby机上只装oralce软件,无需装数据库 基本配置: 源数据库: IP:10.37.1.1 数据库SID:orcl_p db_...

我的搭建环境:

两台机器均为:Red Hat Enterprise Linux Server release 5.4

数据库版本为:Oracle10g10.2.0

primary机上装oracle软件并创建数据库orcl

standby机上只装oralce软件,无需装数据库

基本配置:

源数据库:

IP:10.37.1.1

数据库SID:orcl_p

db_unique_name:orcl1

standby数据库:

IP:10.37.1.2

数据库SID:orcl_s

db_unique_name:orcl2

配置步骤:

1、配置primary数据库归档,并设置本地归档路径

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

Total System Global Area  167772160 bytes

Fixed Size                  1218316 bytes

Variable Size              83888372 bytes

Database Buffers          79691776 bytes

Redo Buffers                2973696 bytes

Database mounted.

SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.

SQL> alter system set log_archive_dest_1='location=/u01/arch';

System altered.

SQL> archive log list

Database log mode            Archive Mode

Automatic archival            Enabled

Archive destination            /u01/arch

Oldest online log sequence  2

Next log sequence to archive  4

Current log sequence  4

2、将primary数据库置于force logging模式

SQL> select force_logging from v$database;

FOR

---

NO

SQL> alter database force logging;

Database altered.

SQL> select force_logging from v$database;

FOR

---

YES

3、创建并修改primary数据库的初始化参数文件

SQL> create pfile='/u01/p_pfile.ora' from spfile;

File created.

[oracle@localhost ~]$ vi /u01/p_pfile.ora

修改如下内容:

*.db_unique_name=orcl1

*.log_archive_config='dg_config=(orcl1,orcl2)'

*.log_archive_dest_2='service=orcl_s.2_tns arch valid_for=(online_logfiles,primary_role)db_unique_name=orcl2'

*.log_archive_dest_state_2=defer

*.fal_server=orcl_s.2_tns

*.fal_client=orcl_p.1_tns

*.db_file_name_convert='/u01/app/oracle/oradata/orcl', '/u01/app/oracle/oradata/orcl_s'

*.log_file_name_convert='/u01/app/oracle/oradata/orcl', '/u01/app/oracle/oradata/orcl_s'

*.standby_file_management=auto

关闭数据库利用修改后的pfile创建spfile

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> !export ORACLE_SID=orcl_p

SQL> create spfile from pfile='/u01/p_pfile.ora';

File created.

SQL> startup

ORACLE instance started.

Total System Global Area  167772160 bytes

Fixed Size                  1218316 bytes

Variable Size              62916852 bytes

Database Buffers          100663296 bytes

Redo Buffers                2973696 bytes

Database mounted.

Database opened.

4、创建备份:

创建standby的控制文件:

SQL> alter database create standby controlfile as '/u01/orcl2control01.ctl';

Database altered.

创建所有的数据文件备份(此处仅以users表空间下的数据文件为例,其他数据文件均要备份)

SQL> alter tablespace users begin backup;

Tablespace altered.

SQL> !cp /u01/app/oracle/oradata/orcl/users01.dbf /u01

SQL> alter tablespace users end backup;

Tablespace altered.

5、配置primary监听和tns服务

[oracle@localhost ~]$ cd $ORACLE_HOME/network/admin

[oracle@localhost admin]$ vi listener.ora

配置内容如下:

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = orcl_p)

      (ORACLE_HOME = /u01/app/oracle/10.2.0/db_1)

      (GLOBAL_DBNAME = orcl_p)

    )

  )

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

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

    )

  )

配置tns

[oracle@localhost admin]$ vi tnsnames.ora

配置内容如下:

orcl_p.1_tns =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    ) 

    (CONNECT_DATA =

      (SID = orcl_p)

      (SERVER = DEDICATED)

    )

  )

orcl_s.2_tns =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    ) 

    (CONNECT_DATA =

      (SID = orcl_s)

      (SERVER = DEDICATED)

    )

  )

此时重启监听后,测试源数据库tns配置

[oracle@localhost admin]$ lsnrctl stop

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 26-FEB-2014 19:11:44

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.37.1.1)(PORT=1521)))

The command completed successfully

[oracle@localhost admin]$ lsnrctl start

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 26-FEB-2014 19:11:53

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

Starting /u01/app/oracle/10.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.1.0 - Production

System parameter file is /u01/app/oracle/10.2.0/db_1/network/admin/listener.ora

Log messages written to /u01/app/oracle/10.2.0/db_1/network/log/listener.log

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.37.1.1)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.37.1.1)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias                    LISTENER

Version                  TNSLSNR for Linux: Version 10.2.0.1.0 - Production

Start Date                26-FEB-2014 19:11:53

Uptime                    0 days 0 hr. 0 min. 0 sec

Trace Level              off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File  /u01/app/oracle/10.2.0/db_1/network/admin/listener.ora

Listener Log File        /u01/app/oracle/10.2.0/db_1/network/log/listener.log

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.37.1.1)(PORT=1521)))

Services Summary...

Service "orcl_p" has 1 instance(s).

  Instance "orcl_P", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully

[oracle@localhost admin]$ tnsping orcl_p.1_tns

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 26-FEB-2014 19:12:38

Copyright (c) 1997, 2005, Oracle.  All rights reserved.

Used parameter files:

/u01/app/oracle/10.2.0/db_1/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.37.1.1)(PORT = 1521))) (CONNECT_DATA = (SID = orcl_p) (SERVER = DEDICATED)))

OK (0 msec)

6、standby数据库创建目录结构,并将源数据库的参数文件、备份的控制文件、创建的口令文件copy到相应的位置

7、

[oracle@localhost ~]$ mkdir -p /u01/arch2

[oracle@localhost u01]$ mkdir -p /u01/app/oracle/flash_recovery_area

[oracle@localhost ~]$ mkdir -p /u01/app/oracle/oradata/orcl_s

[oracle@localhost ~]$ mkdir -p /u01/app/oracle/admin/orcl_s/{a,b,c,u}dump

[oracle@localhost ~]$ scp 10.37.1.1:/u01/*.dbf /u01/app/oracle/oradata/orcl_s/

oracle@10.37.1.1's password: 

example01.dbf                                100%  100MB  20.0MB/s  00:05   

sysaux01.dbf                                  100%  240MB  16.0MB/s  00:15   

system01.dbf                                  100%  480MB  14.6MB/s  00:33   

undotbs01.dbf                                100%  30MB  15.0MB/s  00:02   

users01.dbf                                  100% 5128KB  5.0MB/s  00:01   

[oracle@localhost ~]$ scp 10.37.1.1:/u01/*.ctl /u01/app/oracle/oradata/orcl_s/

oracle@10.37.1.1's password: 

orcl2control01.ctl                            100% 6896KB  6.7MB/s  00:00   

[oracle@localhost ~]$ scp 10.37.1.1:/u01/p_pfile.ora /u01s_pfile.ora

oracle@10.37.1.1's password: 

p_pfile.ora                                  100% 1508    1.5KB/s  00:00 

[oracle@localhost ~]$ scp 10.37.1.1:/u01/app/oracle/10.2.0/db_1/dbs/orapworcl_p /u01/app/oracle/10.2.0/db_1/dbs/orapworcl_s

oracle@10.37.1.1's password: 

orapworcl_p                                  100% 5120    5.0KB/s  00:00

7、��改standby数据库的sid为orcl_s并配置copy来的参数文件

[root@localhost ~]# vi /u01/s_pfile.ora

需要修改的内容如下:(没必要照搬,可根据自己的实际情况自行修改,注意红色部分是重点修改的地方)

*.audit_file_dest='/u01/app/oracle/admin/orcl_s/adump'

*.background_dump_dest='/u01/app/oracle/admin/orcl_s/bdump'

*.control_files='/u01/app/oracle/oradata/orcl_s/orcl2control01.ctl','/u01/app/oracle/oradata/orcl_s/orcl2control02.ctl','/u01/app/oracle/oradata/orcl_s/orcl2control03.ctl'

*.core_dump_dest='/u01/app/oracle/admin/orcl_s/cdump'

*.user_dump_dest='/u01/app/oracle/admin/orcl_s/udump'

*.db_unique_name=orcl2

*.log_archive_dest_1='location=/u01/arch2'

*.log_archive_dest_2='service=orcl_p.1_tns arch valid_for=(online_logfiles, primary_ro

le) db_unique_name=orcl1'

*.log_archive_dest_state_2=enable

*.fal_server=orcl_p.1_tns

*.fal_client=orcl_s.2_tns

8、配置standby数据库的监听和服务名

[oracle@localhost admin]$ cd $ORACLE_HOME/network/admin

[oracle@localhost admin]$ vi listener.ora 

# listener.ora Network Configuration File: /u01/app/oracle/10.2.0/db_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = orcl_s)

      (ORACLE_HOME = /u01/app/oracle/10.2.0/db_1)

      (GLOBAL_DBNAME = orcl_s)

    )

  )

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

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

    )

  )

[oracle@localhost admin]$ vi tnsnames.ora 

# tnsnames.ora Network Configuration File: /u01/app/oracle/10.2.0/db_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

orcl_s.2_tns =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

      (SID = orcl_s)

      (SERVER = DEDICATED)

    )

  )

orcl_p.1_tns =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

      (SID = orcl_p)

      (SERVER = DEDICATED)

"tnsnames.ora" 36L, 764C 

配置完成后重启监听服务

[oracle@localhost admin]$ lsnrctl stop

[oracle@localhost admin]$ lsnrctl start

至此监听和服务配置完成,在primary和standby端用tnsping命令应该能ping都通两个服务,能远程登入两数据库视为配置成功

SQL> conn sys/oracle@orcl_p.1_tns as sysdba

Connected.

SQL> conn sys/oracle@orcl_s.2_tns as sysdba

Connected to an idle instance.

9、配置stanby数据库并启动到mount状态,并接受归档文件

任意终端连接到standby数据库

[oracle@localhost ~]$ sqlplus sys/oracle@orcl_s.2_tns as sysdba

利用s_pfile.ora常见standby的spfile

SQL> create spfile from pfile='/u01/s_pfile.ora';

File created.

SQL> startup mount

ORACLE instance started.

Total System Global Area  167772160 bytes

Fixed Size                  1218316 bytes

Variable Size              62916852 bytes

Database Buffers          100663296 bytes

Redo Buffers                2973696 bytes

Database mounted.

连接到primary数据库并设置远程归档路径开启

SQL> conn sys/oracle@orcl_p.1_tns as sysdba

Connected.

SQL> alter system set log_archive_dest_state_2=enable;

System altered.

查看归档接受情况

SQL> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)

--------------

            4

SQL> conn sys/oracle@orcl_s.2_tns as sysdba

Connected.

SQL> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)

--------------

            4

查看standby的归档路径下是否有源数据库传来的归档日志

SQL> !ls /u01/arch2

1_4_840520047.dbf

10、primary数据插入,测试standby数据库能否正常接受

primary端创建表并插入数据

SQL> conn scott/tiger

Connected.

SQL> create table DG_TEST(ID VARCHAR2(10));

Table created.

SQL> insert into DG_TEST 

  2  values ('DG_TEST')

  3  /

1 row created.

SQL> /

1 row created.

SQL> /

1 row created.

SQL> /

1 row created.

SQL> select * from DG_TEST;

ID

----------

DG_TEST

DG_TEST

DG_TEST

DG_TEST

SQL> commit;

Commit complete.

切换归档日志,使当前日志归档

SQL> conn / as sysdba

Connected.

SQL> alter system switch logfile;

System altered.

standby启动redo应用(这也正是物理standby的工作方法,等于是从获取的归档中执行恢复操作,来保持与源数据库一致)

SQL> alter database recover managed standby database disconnect from session;

Database altered.

打开数据库前必须停止redo应用

SQL> alter database recover managed standby database cancel;

Database altered.

打开standby数据,查看是否有源数据库新插入的数据

SQL> select * from scott.DG_TEST;

ID

----------

DG_TEST

DG_TEST

DG_TEST

DG_TEST

数据成功传入standby数据库,物理的DG搭建成功!

--------------------------------------分割线 --------------------------------------

Oracle Data Guard 重要配置参数

基于同一主机配置 Oracle 11g Data Guard

探索Oracle之11g DataGuard

Oracle Data Guard (RAC+DG) 归档删除策略及脚本

Oracle Data Guard 的角色转换

Oracle Data Guard的日志FAL gap问题

Oracle 11g Data Guard Error 16143 Heartbeat failed to connect to standby 处理方法

--------------------------------------分割线 --------------------------------------


    
 
 
 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • redhat/centos 常用信息查看命令整理
  • 请问redhat6.2或redhat7.0有没有汉化版本或汉化包。only redhat serial?
  • Linux/centos/redhat下各种压缩解压缩方式详解
  • 我机器上装了win98SE,win2000 Server,和Mandrake linux,我想再装个RedHat,可是到后来我发现RedHat没有认出ManDrake,我装上RedHat后,Lilo
  • Linux_centos_redhat下tar命令解压tgz文件方法
  • 不是说Liunx是免费发布的嘛,请问哪里可以下载RedHat 7.3或更高版本的redhat的完全安装版,请提供地址,我想装个redhat学学
  • redhat linux/CentOS 6/7 关闭防火墙(iptables)命令,作用:CentOS 防火墙不关行不行?
  • 三个问题,关于RedHat7.2和RedHat7.3的........
  • 根据文件大小查找文件的find命令举例(Linux,centos,redhat)
  • REDHAT8 比 REDHAT7.x要好多少? 是不是对硬件要求比较高? 另外
  • 红帽redhat下通过脚本和yum安装docker容器引擎的详细步骤
  • redhat13.8与redhat9有什么驱别?
  • Redhat/Centos下rpmbuild命令从spec文件或者tar包建立rpm
  • 求救!!安装redhat后,提示重启,但是没有没有redhat的启动选项
  • REDHAT8.0还是REDHAT9.0?
  • 请问:redhat 的桌面是gnome吗,我的redhat 9是默认安装的。
  • 请问如何做到redhat fedora core2和redhat linux enterprise 3 AS共存,谢谢
  • redhat 12与redhat 5.5有什么区别?不用序列号能不能用?
  • [RedHat9]RedHat9无法进入图形模式,疑是声卡问题,请教如何解决?
  • 菜鸟刚学redhat,redhat eth0 网卡怎么激活,在线等
  • 求Redhat9.0下载地址,Redhat9.0现在仍否允许免费下载?


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3