Oracle data guard 10g 搭建

1系统常规参数检查

硬盘

[root@localhost ~]# df -h

内核

[root@localhost ~]# uname -a

[root@localhost grs]# uname -a

版本

[root@localhost ~]# cat /etc/redhat-release

物理内存

[root@localhost ~]# grep MemTotal /proc/meminfo

虚拟内存

[root@localhost ~]# grep SwapTotal /proc/meminfo

主机名

[root@localhost ~]# hostname

ip地址

[root@localhost ~]# ifconfig

2.关闭防火墙服务iptables&SELinux安全策略&邮件服务 sendmail&时间同步服务 NTP

关闭防火墙服务

[root@localhost ~]# service iptables status

防火墙服务2345级别开机都启动

[root@localhost ~]#  chkconfig --list iptables

iptables        0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭

chkconfig iptables off                   关闭防火墙服务

关闭 SELinux安全策略

[root@localhost ~]# getenforce

a  永久关闭方法  –  需要重启服务器

修改/etc/selinux/config文件中设置 SELINUX=disabled  ,然后重启服务器

[root@localhost ~]# vi /etc/selinux/config

6 SELINUX=disabled

b  临时关闭方法  –  设置系统参数

使用命令 setenforce 0

setenforce 1  设置 SELinux  成为enforcing模式

setenforce 0  设置 SELinux  成为 permissive模式

[root@localhost ~]# setenforce 0

[root@localhost ~]# getenforce

Permissive

关闭邮件服务sendmail

[root@localhost ~]# service sendmail stop

service sendmail stop

chkconfig sendmail off

关闭 NTP时间同步服务

[root@localhost ~]# service ntpd status

ntpd is stopped

service ntpd stop

chkconfig --list ntpd

主库: ip:10.0.1.103

数据库sid:grs

Db_unique_name:grs

数据库安装路径:/u01/app/oracle/product/10.2.0/db_1

数据文件路径:/u01/app/oracle/oradata/grs/

本地归档路径:/u01/app/oracle/archivelog/

备库: ip:192.168.2.188

数据库sid:grsdg

Db_unique_name:grsdg

数据库安装路径:/mountdisk2/oracle/product/10.2.0/db_1

数据文件路径:/mountdisk2/oracle/oradata/grsdg/-----

/mountdisk2/oracle/oradata/grsdg

本地归档路径:/mountdisk2/oracle/archivelog/

2 准备工作

2.1 设置主库的force logging模式

SQL> conn /as sysdba

Connected.

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

alter database no force  logging

2.2确认主库的归档模式

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /u01/app/oracle/archivelog/

Oldest online log sequence     253

Next log sequence to archive   255

Current log sequence           255

如果是disable,需要启动到mount,

然后SQL> alter database archivelog;/noarchivelog

2.3创建主库密码文件(如果不存在的话)

[root@localhost ~]# cd /u01/app/oracle/product/10.2.0/db_1/dbs/

[root@localhost dbs]# ll

-rw-r----- 1 oracle oinstall    1536 03-24 15:55 orapwgrs

不存在就创建

orapwd file=orapwgrs password="987064" entries=10 force=y;

2.4配置主库standby redo log,并验证结果

SQL> alter database add standby logfile group 4 ('/u01/app/oracle/oradata/grs/redo04.log') size 100m;

Database altered.

--删除该日志组

SQL> alter database drop standby logfile group 4;

Database altered.

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

alter database add standby logfile group 4 ('/u01/app/oracle/oradata/grs/redo04.log') size 50m

*

ERROR at line 1:

ORA-00301: error in adding log file '/u01/app/oracle/oradata/grs/redo04.log' -

file cannot be created

ORA-27038: created file already exists

Additional information: 1

--需要物理删除

----保证主库与备库的日志大小一样

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

Database altered.

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

Database altered.

SQL> select group#, thread#, sequence#, archived, status from v$standby_log;

GROUP#    THREAD#  SEQUENCE# ARCHIV STATUS

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

4          0          0 YES    UNASSIGNED

5          0          0 YES    UNASSIGNED

SQL> select group#,type,member from v$logfile;

GROUP# TYPE

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

MEMBER

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

3 ONLINE

/u01/app/oracle/oradata/grs/redo03.log

2 ONLINE

/u01/app/oracle/oradata/grs/redo02.log

1 ONLINE

/u01/app/oracle/oradata/grs/redo01.log

GROUP# TYPE

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

MEMBER

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

4 STANDBY

/u01/app/oracle/oradata/grs/redo04.log

2.5配置主库初始化参数文件

SQL> create pfile ='/u01/app/oracle/pfile_20140504' from spfile;

File created.

[root@localhost oracle]# cat pfile_20140506

j2grs.__db_cache_size=1509949440

grs.__db_cache_size=1644167168

grs.__java_pool_size=16777216

grs.__large_pool_size=16777216

grs.__shared_pool_size=452984832

grs.__streams_pool_size=0

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

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

*.compatible='10.2.0.1.0'

*.control_files='/u01/app/oracle/oradata/grs/control01.ctl','/u01/app/oracle/oradata/grs/control02.ctl','/u01/app/oracle/oradata/grs/control03.ctl'

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

*.db_domain=''

*.DB_FILE_NAME_CONVERT='/mountdisk2/oracle/oradata/grsdg','/u01/app/oradata/grs'

*.db_name='grs'

*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'

*.db_recovery_file_dest_size=2147483648

*.DB_UNIQUE_NAME='grs'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=grsXDB)'

*.FAL_CLIENT='grs'

*.FAL_SERVER='grsdg'

*.job_queue_processes=10

*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(grs,grsdg)'

*.LOG_ARCHIVE_DEST_1='LOCATION=/u01/app/oracle/archivelog/ arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=grs'

*.LOG_ARCHIVE_DEST_2='SERVICE=grsdg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=grsdg'

*.LOG_ARCHIVE_DEST_STATE_1='ENABLE'

*.log_archive_dest_state_2='DEFER'

*.LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'

*.LOG_ARCHIVE_MAX_PROCESSES=30

*.LOG_FILE_NAME_CONVERT='/mountdisk2/oracle/oradata/grsdg','/u01/app/oradata/grs'

*.open_cursors=300

*.pga_aggregate_target=1073741824

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_target=2147483648

*.STANDBY_FILE_MANAGEMENT='AUTO'

*.undo_management='AUTO'

*.undo_tablespace='UNDOTBS1'

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

Arch只支持最高性能模式,

如果standby数据库处于其他模式,就必须使用lgwr默认来传输redo数据

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> create spfile from pfile='/u01/app/oracle/pfile_20140504';

File created.

SQL> startup;

3 创建主库相关文件的备份

3.1创建主库数据文件的物理备份(这里采用tar方式)

建立目录

/u02/app/oracle/oradata/grs2

[oracle@localhost oradata]$ tar -cvf grs.tar grs/

grs/

3.2为备库创建控制文件

SQL> startup mount;

ORACLE instance started.

Total System Global Area 2147483648 bytes

Fixed Size                  2022144 bytes

Variable Size             486540544 bytes

Database Buffers         1644167168 bytes

Redo Buffers               14753792 bytes

Database mounted.

SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/u01/app/oracle/control01.ctl';

Database altered.

3.3为备库创建初始化参数文件

SQL> CREATE PFILE='/u01/oracle/backup/initgrs2.ora' FROM SPFILE;

File created.

3.4 将tar包以及主库控制文件和参数文件cp到备库

[root@localhost oradata]# scp -r /u01/app/oracle/oradata/grs oracle@192.168.2.188:/mountdisk2/oracle/oradata/

[root@localhost ~]# scp -r /u01/app/oracle/control01.ctl oracle@192.168.2.188:/mountdisk2/oracle/oradata/

4 设置备库

4.1解压主库数据文件到备库相应位置

[oracle@localhost oracle]$ tar -xvf grs.tar

grs/

grs/yhq_temp.dbf

grs/cmask01.dbf

grs/undotbs01.dbf

grs/exit

grs/backup

grs/rman_test.dbf

grs/redo04.log

grs/control_backup/

grs/control_backup/control01.ctl

grs/control_backup/control02.ctl

grs/control_backup/control03.ctl

grs/rman_catalog.dbf

[oracle@localhost ~]$ cd /mountdisk2/oracle/oradata/

[oracle@localhost oradata]$ ll

总计 6912

-rw-r----- 1 oracle oinstall 7061504 05-04 15:36 control01.ctl

drwxr-x--- 2 oracle oinstall    4096 05-04 14:31 grsdg

[oracle@localhost oradata]$ cp control01.ctl /mountdisk2/oracle/oradata/grsdg/control01.ctl

[oracle@localhost oradata]$ cd grsdg/

[root@localhost ~]# scp -r /u01/app/oracle/pfile_20140504 oracle@192.168.2.188:/mountdisk2/oracle/oradata/

oracle@192.168.2.188's password:

4.2创建相关没有的目录

[oracle@localhost oracle]$ mkdir -p archivelog/archivelog

[oracle@localhost oracle]$ mkdir -p /u02/app/oracle/flash_recovery_area/grs/onlinelog

[oracle@localhost oracle]$

[oracle@localhost oracle]$ pwd

/u02/app/oracle

QL> startup nomount;

ORA-09925: Unable to create audit trail file

Linux Error: 2: No such file or directory

Additional information: 9925

SQL> startup mount;

ORA-09925: Unable to create audit trail file

Linux Error: 2: No such file or directory

Additional information: 9925

SQL> show parameter audit_file_dest

ORA-01034: ORACLE not available

[oracle@localhost oracle]$ mkdir admin

[oracle@localhost oracle]$ cd admin/

[oracle@localhost admin]$ mkdir grs2

[oracle@localhost admin]$ cd grs2/

[oracle@localhost grs2]$ mkdir adump bdump cdump udump

4.3 修改备库的参数文件

[oracle@localhost oradata]$ cp pfile_20140504 /u01/app/oracle/product/10.2.0/db_1/dbs

[root@localhost oradata]# cat pfile_20140506

j2grsdg.__db_cache_size=1509949440

grsdg.__db_cache_size=1644167168

grsdg.__java_pool_size=16777216

grsdg.__large_pool_size=16777216

grsdg.__shared_pool_size=452984832

grsdg.__streams_pool_size=0

*.audit_file_dest='/mountdisk2/oracle/admin/grsdg/adump'

*.background_dump_dest='/mountdisk2/oracle/admin/grsdg/bdump'

*.compatible='10.2.0.1.0'

*.control_files='/mountdisk2/oracle/oradata/grsdg/grsdgcontrol01.ctl','/mountdisk2/oracle/oradata/grsdg/grsdgcontrol02.ctl','/mountdisk2/oracle/oradata/grsdg/grsdgcontrol03.ctl'

*.core_dump_dest='/mountdisk2/oracle/admin/grsdg/cdump'

*.db_domain=''

*.DB_FILE_NAME_CONVERT='/u01/app/oradata/grs','/mountdisk2/oracle/oradata/grsdg'

*.db_name='grs'

*.db_recovery_file_dest='/mountdisk2/oracle/flash_recovery_area'

*.db_recovery_file_dest_size=2147483648

*.DB_UNIQUE_NAME='grsdg'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=grsXDB)'

*.FAL_CLIENT='grsdg'

*.FAL_SERVER='grs'

*.job_queue_processes=10

*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(grs,grsdg)'

*.LOG_ARCHIVE_DEST_1='LOCATION=/mountdisk2/oracle/archivelog/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=grsdg'

*.LOG_ARCHIVE_DEST_2='SERVICE=grs LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=grs'

*.LOG_ARCHIVE_DEST_STATE_1='ENABLE'

*.log_archive_dest_state_2='DEFER'

*.LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'

*.LOG_ARCHIVE_MAX_PROCESSES=30

*.LOG_FILE_NAME_CONVERT='/u01/app/oradata/grs','/mountdisk2/oracle/oradata/grsdg'

*.open_cursors=300

*.pga_aggregate_target=1073741824

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_target=2147483648

*.STANDBY_FILE_MANAGEMENT='AUTO'

*.undo_management='AUTO'

*.undo_tablespace='UNDOTBS1'

*.user_dump_dest='/mountdisk2/oracle/admin/grsdg/udump'

[root@localhost oradata]#

4.4创建备库密码文件

[root@localhost ~]# scp -r /u01/app/oracle/product/10.2.0/db_1/dbs/orapwgrs oracle@192.168.2.188:/mountdisk2/oracle/oradata/

复制密码文件到备库

[oracle@localhost oradata]$ mv orapwgrs /u01/app/oracle/product/10.2.0/db_1/dbs/orapwgrsdg

[oracle@localhost grs2]$  orapwd file=/u02/app/oracle/product/10.2.0/db_1/dbs/orapwgrs2 password="987064" entries=10 force=y;

5创建主备库监听及tnsnames文件

5.1创建文件

[oracle@localhost admin]$ cp -p /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora /u02/app/oracle/product/10.2.0/db_1/network/admin/

[oracle@localhost admin]$ cp -p /u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora /u02/app/oracle/product/10.2.0/db_1/network/admin/

修改监听文件

[oracle@localhost admin]$ vi listener.ora

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

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(SID_NAME = PLSExtProc)

(ORACLE_HOME = /u02/app/oracle/product/10.2.0/db_1)

(PROGRAM = extproc)

)

(SID_DESC =

(GLOBAL_DBNAME = Oracle8)

(ORACLE_HOME = /u02/app/oracle/product/10.2.0/db_1)

(SID_NAME = grs2)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

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

)

(DESCRIPTION =

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

)

)

[oracle@localhost admin]$ vi tnsnames.ora

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

# Generated by Oracle configuration tools.

GRS2 =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = grs2)

)

)

EXTPROC_CONNECTION_DATA =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

)

(CONNECT_DATA =

(SID = PLSExtProc)

(PRESENTATION = RO)

)

)

主库

[oracle@localhost ~]$ tnsping 192.168.2.188

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 04-MAY-2014 15:57:47

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

Used parameter files:

Used HOSTNAME adapter to resolve the alias

Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=192.168.2.188))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.2.188)(PORT=1521)))

OK (40 msec)

[oracle@localhost ~]$ tnsping grsdg

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 04-MAY-2014 17:49:16

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

Used parameter files:

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.188)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = grsdg)))

OK (10 msec)

备库

[oracle@localhost admin]$ tnsping 10.0.1.103

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 04-MAY-2014 15:56:57

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

Used parameter files:

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

Used HOSTNAME adapter to resolve the alias

Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=10.0.1.103))(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.1.103)(PORT=1521)))

OK (0 msec)

[oracle@localhost dbs]$ tnsping grs

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 04-MAY-2014 17:53:47

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

Used parameter files:

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

TNS-03505: Failed to resolve name

[oracle@localhost admin]$ vi tnsnames.ora

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

# Generated by Oracle configuration tools.

GRS =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = grs)

)

)

GRS2 =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = grsdg)

)

)

EXTPROC_CONNECTION_DATA =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

)

(CONNECT_DATA =

(SID = PLSExtProc)

(PRESENTATION = RO)

)

)

5.2分别启动主备库监听

为什么要先启动备库再启动主库呢?

DG 原理:主库启动后会主动探测备库,如果此时备库没有启动那么主库探测不到备库的存在,就会等待若干分钟之后再次探测,你会在 alert 日志中看到大量 ORA 报错引起恐慌,为了避免这种情况发生。可以先启动备库,此时备库会等待来自主库的日志,当备库启动之后主库再启动会在第一时间探测到备库存在,就不会看到大量报错信息了。

为什么在操作primary  standby 库时建议始终打开alert日志 这样可以实时监控数据库启动  关闭  切换  操作的状态,查看到日志是否应用,角色是否切换完毕,数据库是否read only 打开等,主要是为了方便我们监控主备库同步状态。

启动备库

备库的启动

[oracle@localhost admin]$ export ORACLE_SID=grsdg

[oracle@localhost dbs]$ cp initgrs2.ora /u01/app/oracle/product/10.2.0/db_1/dbs/initgrs2.ora

[oracle@localhost dbs]$ sqlplsu /nolog

-bash: sqlplsu: command not found

[oracle@localhost dbs]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Mar 31 17:16:24 2014

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

SQL> conn /as sysdba

Connected to an idle instance.

SQL> create spfile from pfile='/mountdisk2/oracle/oradata/pfile_20140504';

File created.

SQL> startup nomount;

ORA-01078: failure in processing system parameters

LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db_1/dbs/initgrsdg.ora'

[oracle@localhost dbs]$ cp pfile_20140504 initgrsdg.ora

SQL> startup nomount;

ORACLE instance started.

Total System Global Area  285212672 bytes

Fixed Size                  1218992 bytes

Variable Size              92276304 bytes

Database Buffers          188743680 bytes

Redo Buffers                2973696 bytes

SQL> alter database mount standby database;

Database altered.

SQL> show parameter convert;

NAME                                 TYPE        VALUE

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

db_file_name_convert                 string      /mountdisk2/oracle/oradata/grs

dg, /u01/app/oradata/grs

log_file_name_convert                string      /mountdisk2/oracle/oradata/grs

dg, /u01/app/oradata/grs

SQL> set linesize 1000

SQL> set pagesize 1000

SQL> select name from v$datafile;

NAME

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

/u01/app/oracle/oradata/grs/system01.dbf

/u01/app/oracle/oradata/grs/undotbs01.dbf

/u01/app/oracle/oradata/grs/sysaux01.dbf

/u01/app/oracle/oradata/grs/users01.dbf

/u01/app/oracle/oradata/grs/example01.dbf

/u01/app/oracle/oradata/grs/yyhhqq.dbf

/u01/app/oracle/oradata/grs/grsv501.dbf

/u01/app/oracle/oradata/grs/starhub.dbf

/u01/app/oracle/oradata/grs/starhub01.dbf

/u01/app/oracle/oradata/grs/starhub02.dbf

/u01/app/oracle/oradata/grs/starhub03.dbf

/u01/app/oracle/oradata/grs/starhub04.dbf

/u01/app/oracle/oradata/grs/starhub05.dbf

/u01/app/oracle/oradata/grs/cmask01.dbf

/u01/app/oracle/oradata/grs/ais01.dbf

/u01/app/oracle/oradata/grs/ais02.dbf

/u01/app/oracle/oradata/grs/ipfingo02.dbf

/u01/app/oracle/oradata/grs/ipfiingo01.dbf

/u01/app/oracle/oradata/grs/ipfingo03.dbf

/u01/app/oracle/oradata/grs/SPICEI2I02.dbf

切换到主库

SQL> alter system set LOG_ARCHIVE_DEST_STATE_2=ENABLE;

System altered  --开始打开远程的归档

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

Database altered.

6.主备库状态检查

1 主库

select db_unique_name,open_mode,database_role,switchover_status,

dataguard_broker,protection_mode,remote_archive,guard_status from

v$database;

grs READ WRITE PRIMARY SESSIONS ACTIVE DISABLED MAXIMUM PERFORMANCE ENABLED NONE

主库:可读写   没有启动broker   主库角色

主库:

SQL> select group#,bytes,status from v$standby_log;

GROUP#      BYTES STATUS

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

4   52428800 UNASSIGNED

5   52428800 UNASSIGNED

主库的 standby_log没有使用

SQL> select * from v$archive_gap;

no rows selected

主库没有遗漏

SQL> col standby_dest for a12

SQL> col archived for a10

SQL> col applied for a10

SQL> col status for a10

SQL> select sequence#,standby_dest,archived,applied,status from v$archived_log;

SEQUENCE# STANDBY_DEST ARCHIVED   APPLIED    STATUS

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

245 NO           YES        NO         X

246 NO           YES        NO         X

247 NO           YES        NO         X

248 NO           YES        NO         X

249 NO           YES        NO         A

250 NO           YES        NO         A

251 NO           YES        NO         A

252 NO           YES        NO         A

253 NO           YES        NO         A

254 NO           YES        NO         A

255 NO           YES        NO         A

SEQUENCE# STANDBY_DEST ARCHIVED   APPLIED    STATUS

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

256 NO           YES        NO         A

257 NO           YES        NO         A

257 YES          YES        NO         A

258 NO           YES        NO         A

258 YES          YES        NO         A

260 NO           YES        NO         A

261 NO           YES        NO         A

262 NO           YES        NO         A

262 YES          YES        NO         A

20 rows selected.

一共有20个归档日志, 257 257 262 传输到standby

全部归档,全部未应用,状态A

A - Available

D - Deleted

U - Unavailable

X - Expired

select dest_name,database_mode,recovery_mode,archived_seq#,applied_seq# from

v$archive_dest_status;

LOG_ARCHIVE_DEST_1 OPEN IDLE 262 0

LOG_ARCHIVE_DEST_2 UNKNOWN UNKNOWN 262 261

LOG_ARCHIVE_DEST_3 OPEN IDLE 0 0

SQL> select process,status,sequence#,delay_mins from v$managed_standby;

ARCH               CONNECTED           0          0

ARCH               CONNECTED           0          0

ARCH               CONNECTED           0          0

LNS                WRITING           263          0

备库状态

SQL> conn /as sysdba

Connected.

SQL> select db_unique_name,open_mode,database_role,switchover_status,

2  dataguard_broker,protection_mode,remote_archive,guard_status from

3  v$database;

DB_UNIQUE_NAME

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

OPEN_MODE            DATABASE_ROLE

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

SWITCHOVER_STATUS                        DATAGUARD_BROKER

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

PROTECTION_MODE                          REMOTE_ARCHIVE   GUARD_STATUS

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

grsdg

MOUNTED              PHYSICAL STANDBY

RECOVERY NEEDED                          DISABLED

MAXIMUM PERFORMANCE                      ENABLED          NONE

SQL> select group#,bytes,status from v$standby_log;

no rows selected

SQL> select * from v$archive_gap;

no rows selected

SQL> col standby_dest for a12

SQL> col archived for a10

SQL> col applied for a10

SQL> col status for a10

SQL> select sequence#,standby_dest,archived,applied,status from v$archived_log;

SEQUENCE# STANDBY_DEST ARCHIVED   APPLIED    STATUS

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

262 NO           YES        NO         A

select dest_name,database_mode,recovery_mode,archived_seq#,applied_seq# from v$archive_dest_status;

SQL> select process,status,sequence#,delay_mins from v$managed_standby;

ARCH               CONNECTED           0          0

ARCH               CONNECTED           0          0

ARCH               CONNECTED           0          0

ARCH               CONNECTED           0          0

ARCH               CONNECTED           0          0

ARCH               CONNECTED           0          0

ARCH               CONNECTED           0          0

ARCH               CONNECTED           0          0

RFS                IDLE              263          0

RFS                IDLE                0          0

7 .日志应用与切换

7 验证归档文件的情况

1 通过数据字典视图验证

--主库执行

[oracle@localhost ~]$  export ORACLE_SID=grs

[oracle@localhost ~]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Mar 31 17:07:31 2014

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

SQL> conn /as sysdba

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area  285212672 bytes

Fixed Size                  1218992 bytes

Variable Size              96470608 bytes

Database Buffers          184549376 bytes

Redo Buffers                2973696 bytes

Database mounted.

Database opened.

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup;

ORACLE instance started.

Total System Global Area  285212672 bytes

Fixed Size                  1218992 bytes

Variable Size             100664912 bytes

Database Buffers          180355072 bytes

Redo Buffers                2973696 bytes

Database mounted.

Database opened.

SQL> select sequence#, first_time, next_time, applied, fal from v$archived_log order by sequence#;

SEQUENCE# FIRST_TIME         NEXT_TIME          APP FAL

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

1 25-MAR-14          25-MAR-14          NO  NO

1 25-MAR-14          25-MAR-14          NO  YES

2 25-MAR-14          26-MAR-14          NO  NO

2 25-MAR-14          26-MAR-14          NO  YES

3 26-MAR-14          26-MAR-14          NO  YES

3 26-MAR-14          26-MAR-14          NO  NO

4 26-MAR-14          27-MAR-14          NO  NO

4 26-MAR-14          27-MAR-14          NO  YES

5 27-MAR-14          27-MAR-14          NO  NO

5 27-MAR-14          27-MAR-14          NO  YES

6 27-MAR-14          27-MAR-14          NO  NO

SEQUENCE# FIRST_TIME         NEXT_TIME          APP FAL

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

6 27-MAR-14          27-MAR-14          NO  YES

6 24-MAR-14          24-MAR-14          NO  NO

7 27-MAR-14          27-MAR-14          NO  YES

7 27-MAR-14          27-MAR-14          NO  NO

7 24-MAR-14          24-MAR-14          NO  NO

7 24-MAR-14          24-MAR-14          NO  NO

8 24-MAR-14          25-MAR-14          NO  NO

8 27-MAR-14          28-MAR-14          NO  NO

8 27-MAR-14          28-MAR-14          NO  YES

9 28-MAR-14          31-MAR-14          NO  NO

9 25-MAR-14          25-MAR-14          NO  NO

SEQUENCE# FIRST_TIME         NEXT_TIME          APP FAL

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

9 28-MAR-14          31-MAR-14          YES YES

10 31-MAR-14          31-MAR-14          NO  NO

10 25-MAR-14          25-MAR-14          NO  NO

10 31-MAR-14          31-MAR-14          NO  YES

11 31-MAR-14          31-MAR-14          NO  YES

11 25-MAR-14          25-MAR-14          NO  NO

11 31-MAR-14          31-MAR-14          NO  NO

12 31-MAR-14          31-MAR-14          NO  NO

12 31-MAR-14          31-MAR-14          NO  YES

12 25-MAR-14          25-MAR-14          NO  NO

32 rows selected.

2 查看告警日志文件

--备库上有类似的信息

[oracle@localhost bdump]$ tail -f -n 100  /u02/app/oracle/admin/grs2/bdump/alert_grs2.log

Errors in file /u02/app/oracle/admin/grs2/bdump/grs2_mrp0_25231.trc:

ORA-01110: data file 1: '/u01/app/oracle/oradata/grs/system01.dbf'

Errors in file /u02/app/oracle/admin/grs2/bdump/grs2_mrp0_25231.trc:

ORA-01110: data file 1: '/u01/app/oracle/oradata/grs/system01.dbf'

ORA-01157: cannot identify/lock data file 1 - see DBWR trace file

ORA-01110: data file 1: '/u01/app/oracle/oradata/grs/system01.dbf'

Mon Mar 31 17:17:35 2014

MRP0: Background Media Recovery process shutdown (grs2)

Mon Mar 31 17:17:36 2014

Completed: alter database recover managed standby database disconnect from session

Mon Mar 31 17:18:14 2014

Redo Shipping Client Connected as PUBLIC

-- Connected User is Valid

RFS[3]: Assigned to RFS process 25253

RFS[3]: Identified database type as 'physical standby'

Mon Mar 31 17:18:17 2014

Redo Shipping Client Connected as PUBLIC

主库

1 主库上建测试表

SQL> conn

Enter user-name: scott

Enter password:

Connected.

SQL> create table randy (id number);

Table created.

SQL>  insert into randy values(1);

1 row created.

SQL> /

1 row created.

SQL> /

1 row created.

SQL> /

1 row created.

SQL> commit;

Commit complete.

SQL> select * from randy;

ID

----------

1

1

1

1

2 主库上模拟日志切换

SQL> alter system archive log current;

备库上的日志

db_recovery_file_dest_size of 2048 MB is 0.00% used. This is a

user-specified limit on the amount of space that will be used by this

database for recovery-related files, and does not reflect the amount of

space available in the underlying filesystem or ASM diskgroup.

Mon Mar 31 17:43:20 2014

RFS[2]: Possible network disconnect with primary database

Redo Shipping Client Connected as PUBLIC

-- Connected User is Valid

RFS[15]: Assigned to RFS process 26201

RFS[15]: Identified database type as 'physical standby'

Primary database is in MAXIMUM PERFORMANCE mode

Primary database is in MAXIMUM PERFORMANCE mode

RFS[15]: Successfully opened standby log 4: '/u01/app/oracle/oradata/grs/redo04.log'

Mon Mar 31 17:43:39 2014

Redo Shipping Client Connected as PUBLIC

-- Connected User is Valid

RFS[16]: Assigned to RFS process 26211

RFS[16]: Identified database type as 'physical standby'

RFS[16]: No standby redo logfiles of size 6761 blocks available

RFS[16]: Archived Log: '/u02/app/oracle/archivelog/archivelog/1_13_843150133.arc'

以只读模式打开备库,验证数据

SQL> alter database recover managed standby database cancel;

同一台机器上进行dg

主库的参数文件

[oracle@localhost backup]$ vi initgrs.ora

grs.__db_cache_size=184549376

grs.__java_pool_size=4194304

grs.__large_pool_size=4194304

grs.__shared_pool_size=83886080

grs.__streams_pool_size=4194304

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

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

*.compatible='10.2.0.1.0'

*.control_files='/u01/app/oracle/oradata/grs/control01.ctl','/u01/app/oracle/oradata/grs/control02.ctl','/u01/app/oracle/oradata/grs/control03.ctl'

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

*.db_block_size=8192

*.db_domain=''

*.db_file_multiblock_read_count=16

*.DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/grs','/u02/app/oracle/oradata/grs2'

*.db_name='grs'

*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'

*.db_recovery_file_dest_size=2147483648

*.DB_UNIQUE_NAME='grs'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=grsXDB)'

*.FAL_CLIENT='grs2'

*.FAL_SERVER='grs'

*.job_queue_processes=10

*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(grs,grs2)'

*.LOG_ARCHIVE_DEST_1='LOCATION=/u01/app/oracle/archivelog/archivelog/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=grs'

*.LOG_ARCHIVE_DEST_2='SERVICE=grs2 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=grs2'

*.LOG_ARCHIVE_DEST_STATE_1='ENABLE'

*.LOG_ARCHIVE_DEST_STATE_2='ENABLE'

*.LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'

*.LOG_ARCHIVE_MAX_PROCESSES=30

*.LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/grs','/u02/app/oracle/oradata/grs2'

*.open_cursors=300

*.pga_aggregate_target=94371840

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_target=285212672

*.STANDBY_FILE_MANAGEMENT='AUTO'

*.undo_management='AUTO'

*.undo_tablespace='UNDOTBS1'

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

备库的参数文件

[oracle@localhost dbs]$ vi initgrs2.ora

grs.__db_cache_size=184549376

grs.__java_pool_size=4194304

grs.__large_pool_size=4194304

grs.__shared_pool_size=83886080

grs.__streams_pool_size=4194304

*.audit_file_dest='/u02/app/oracle/admin/grs2/adump'

*.background_dump_dest='/u02/app/oracle/admin/grs2/bdump'

*.compatible='10.2.0.1.0'

*.control_files='/u02/app/oracle/oradata/grs2/control01.ctl','/u02/app/oracle/oradata/grs2/control02.ctl','/u02/app/oracle/oradata/grs2/control03.ctl'

*.core_dump_dest='/u02/app/oracle/admin/grs2/cdump'

*.db_block_size=8192

*.db_domain=''

*.db_file_multiblock_read_count=16

*.DB_FILE_NAME_CONVERT='/u02/app/oracle/oradata/grs2','/u01/app/oracle/oradata/grs'

*.db_name='grs'

*.db_recovery_file_dest='/u02/app/oracle/flash_recovery_area'

*.db_recovery_file_dest_size=2147483648

*.DB_UNIQUE_NAME='grs2'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=grsXDB)'

*.FAL_CLIENT='grs'

*.FAL_SERVER='grs2'

*.job_queue_processes=10

*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(grs,grs2)'

*.LOG_ARCHIVE_DEST_1='LOCATION=/u02/app/oracle/archivelog/archivelog/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=grs2'

*.LOG_ARCHIVE_DEST_2='SERVICE=grs LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=grs'

*.LOG_ARCHIVE_DEST_STATE_1='ENABLE'

*.LOG_ARCHIVE_DEST_STATE_2='ENABLE'

*.LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'

*.LOG_ARCHIVE_MAX_PROCESSES=30

*.LOG_FILE_NAME_CONVERT='/u02/app/oracle/oradata/grs2','/u01/app/oracle/oradata/grs'

*.open_cursors=300

*.pga_aggregate_target=94371840

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_target=285212672

*.STANDBY_FILE_MANAGEMENT='AUTO'

*.undo_management='AUTO'

*.undo_tablespace='UNDOTBS1'

*.user_dump_dest='/u02/app/oracle/admin/grs2/udump'

Oracle data guard 10g 搭建的更多相关文章

  1. 一步一步搭建 Oracle Data Guard

    前言 为什么要写前言,因为我要吐槽一下.作为一个Java后端,搭建Oracle Data Guard真的是一件,嗯,既不专业也不擅长的事情,然而,为什么还是要我来弄? 因为DBA出差了,我们这边急着要 ...

  2. Oracle Data Guard

    DG 是 Oracle Data Guard 的简称.也就是Oracle11g的 数据卫士. 由于在工作中 Oracle和 SQL SERVER2008 同时都需要维护管理.给我的感觉这里的 DG 其 ...

  3. Oracle Data Guard 重要配置参数

    Oracle Data Guard主要是通过为生产数据库提供一个或多个备用数据库(是产生数据库的一个副本),以保证在主库不可用或异常时数据不丢失并通过备用数据库继续提供服务.对于Oracle DG的配 ...

  4. Oracle data guard学习

    Oracle data guard学习:三思笔记 Data guard 1data guard结构: data guard是一个集合,由一个primary数据库(生产数据库)和一个或多个standby ...

  5. Oracle Data Guard的配置

    概述 Oracle Data Guard 是针对企业数据库的最有效和最全面的数据可用性.数据保护和灾难恢复解决方案.它提供管理.监视和自动化软件基础架构来创建和维护一个或多个同步备用数据库,从而保护数 ...

  6. 【原】Configuring Oracle Data Guard In Physical Standby Database

    作者:david_zhang@sh [转载时请以超链接形式标明文章] http://www.cnblogs.com/david-zhang-index/p/5042640.html参照文档:https ...

  7. (转)Oracle Data Guard学习

    一.Data Guard提供如下三种数据保护模式: 1)最高保护模式(Maximum Protection) 这里的”最高保护“是指最大限度的保护数据不丢失,也就是至少有一个standby和prima ...

  8. Oracle Data Guard配置

    Oracle Data Guard 的配置在网上有很多资料,但是没有一个完整的,配置下来多少有些问题.在踩了各种坑之后,自己终于配置成功,就想把这过程记录下来. 1   测试环境 主数据库:windo ...

  9. Oracle Data Guard Protection Modes

    Maximum Availability This protection mode provides the highest level of data protection that is poss ...

随机推荐

  1. Luogu-4248 [AHOI2013]差异

    \(\sum_{i<j}len(i)+len(j)\)比较简单,稍微想想就出来了,问题在于怎么求任意两个后缀的\(lcp\)长度之和 因为求\(lcp\)实际上就是一个对\(h\)数组求区间最小 ...

  2. graphlab 安装好后的导入配置

    本以为下好了的结果... 然后等个十几二十分钟... 关掉这个页面重新打开,再重新导入graphlab 貌似好了...但是,,, 发现是自己的文件放错盘了...在F盘... 然后就好啦~

  3. STL视频_01

    ZC:这里视频里面有一个调试小技巧,VS08/VS2010开始,控制台程序会自动退出(不像VC6),那么可以在 函数退出的最后一句语句上设置断点,然后查看控制台打印出来的信息.ZC:这一讲,给我的感觉 ...

  4. GreenDao 多表事务操作

    场景:Android APP多表操作事务管理 使用Android自带的sql操作类操作的时候需要手动处理事务,使用GreenDao的时候不用管了,啥都处理好了.但是,如果是多表操作的话,怎么统一管理事 ...

  5. 03-dotnet core创建区域[Areas]及后台搭建

    熟悉MVC的人都知道从MVC4开始引入了区域的机制,区域的创建可以协助你在架构较大的项目中,让独立性较高的部分功能作为一个单独的子MVC系统,降低网站与网站之间的耦合度,也可以通过area切割,让多个 ...

  6. WPF中如何在文本外面加虚线外框

    WPF中如何在文本外面加虚线外框 昨天突然被问到如何在wpf里面给一段文本加个虚线外框,由于有一段时间没玩wpf了,一时还真没想出来,虽然大概有个思路,但是也不保证正确.今天回到家,闲着没事情也就随便 ...

  7. gym强化学习入门demo——随机选取动作 其实有了这些动作和反馈值以后就可以用来训练DNN网络了

    # -*- coding: utf-8 -*- import gym import time env = gym.make('CartPole-v0') observation = env.reset ...

  8. Object.assign()与深拷贝(一)

    深拷贝与浅拷贝 所谓深拷贝与浅拷贝,是围绕引用类型变量的拷贝进行的讨论. 在ECMAScript中,变量分为基本类型和引用类型两种.其本质区别是不可变性,基本类型是不可变的,而引用类型是可变的. 所谓 ...

  9. ubuntu设置开机启动命令行模式

    1.命令: sudo gedit /etc/default/grub 找到这一行 GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" (ubuntu ...

  10. DB21019E An error occurred while accessing the directory "/root".

    如果是在Linux上刚装完DB2即刻建立database,可能会遇到错误DB21019E An error occurred while accessing the directory "/ ...