同一服务器配置DataGuard
实验环境:
1.虚拟机VMware Server 1.0.6
2.操作系统:
ora10g@linux5 /home/oracle$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.1 (Tikanga)
3.数据库环境(OMF管理的数据库):
sys@ora10g> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
一.Primary 数据库配置及相关操作
1.确认primary库处于归档模式
sys@ora10g> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 33
Next log sequence to archive 35
Current log sequence 35
2.将primary库置为FORCE LOGGING 模式
sys@ora10g> alter database force logging;
Database altered.
3.在primary库创建standby数据库控制文件
sys@ora10g> alter database create standby controlfile as '/home/oracle/backup/ora10gdg.ctl';
Database altered.
4.创建primary库客户端初始化参数文件
1).创建主库中的pfile
sys@ora10g> create pfile from spfile;
File created.
2).备份到backup目录用于创建备库的pfile
sys@ora10g> ! cp /oracle/u01/app/oracle/product/10.2.0/db_1/dbs/initora10g.ora /home/oracle/backup/initora10gdg.ora
3).修改后主库pfile中内容如下:
ora10gdg@linux5 /oracle/u01/app/oracle/product/10.2.0/db_1/dbs$ cat initora10g.ora
ora10g.__db_cache_size=20971520
ora10g.__java_pool_size=4194304
ora10g.__large_pool_size=4194304
ora10g.__shared_pool_size=71303168
ora10g.__streams_pool_size=0
*.audit_file_dest='/oracle/u01/app/oracle/admin/ora10g/adump'
*.background_dump_dest='/oracle/u01/app/oracle/admin/ora10g/bdump'
*.compatible='10.2.0.3.0'
*.control_files='/oracle/u02/oradata/ORA10G/controlfile/o1_mf_4srph8fv_.ctl','/oracle/u01/app/oracle/flash_recovery_area/ORA10G/controlfile/o1_mf_4srph96b_.ctl'
*.core_dump_dest='/oracle/u01/app/oracle/admin/ora10g/cdump'
*.cursor_sharing='EXACT'
*.db_block_size=8192
*.db_create_file_dest='/oracle/u02/oradata'
*.db_create_online_log_dest_1='/oracle/u01'
*.db_create_online_log_dest_2='/oracle/u02'
*.db_create_online_log_dest_3='/oracle/u02'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='ora10g'
*.db_recovery_file_dest='/oracle/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4294967296
*.job_queue_processes=10
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=16777216
*.processes=500
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_max_size=104857600
*.sga_target=104857600
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/oracle/u01/app/oracle/admin/ora10g/udump'
#################################################################
#Parameters for Primary Database.
#################################################################
*.DB_NAME='ora10g'
*.DB_UNIQUE_NAME=ora10g
*.LOG_ARCHIVE_FORMAT=log%t_%s_%r.arc
*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(ora10g,ora10gdg)'
*.LOG_ARCHIVE_DEST_1='LOCATION=/oracle/u02/oradata/ORA10G VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ora10g'
*.LOG_ARCHIVE_DEST_2='SERVICE=ora10gdg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ora10gdg'
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
#################################################################
#Parameters which using for switch over from Primary to Standby.
#################################################################
*.FAL_SERVER=ora10gdg
*.FAL_CLIENT=ora10g
*.DB_FILE_NAME_CONVERT='/oracle/u02/oradata/ORA10GDG/datafile','/oracle/u02/oradata/ORA10G/datafile'
*.LOG_FILE_NAME_CONVERT='/oracle/u02/oradata/ORA10GDG/onlinelog','/oracle/u02/oradata/ORA10G/onlinelog'
*.STANDBY_FILE_MANAGEMENT=AUTO
*.STANDBY_ARCHIVE_DEST='/ora10g_arch'
4).通过pfile 重建spfile
sys@ora10g> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
NotConnected@> create spfile from pfile='initora10g.ora';
File created.
5.配置tnsnames.ora文件
ora10g@linux5 /oracle/u01/app/oracle/product/10.2.0/db_1/network/admin$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /oracle/u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORA10G =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = linux5)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ora10g)
)
)
ORA10GDG =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = linux5)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ora10gdg)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
ora10g@linux5 /oracle/u02/oradata/ORA10GDG/controlfile$ tnsping ora10g
TNS Ping Utility for Linux: Version 10.2.0.4.0 - Production on 25-MAR-2009 03:03:10
Copyright (c) 1997, 2007, Oracle. All rights reserved.
Used parameter files:
/oracle/u01/app/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = linux5)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ora10g)))
OK (50 msec)
ora10g@linux5 /oracle/u02/oradata/ORA10GDG/controlfile$ tnsping ora10gdg
TNS Ping Utility for Linux: Version 10.2.0.4.0 - Production on 25-MAR-2009 03:03:17
Copyright (c) 1997, 2007, Oracle. All rights reserved.
Used parameter files:
/oracle/u01/app/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = linux5)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ora10gdg)))
OK (10 msec)
二.Standby数据库配置及相关操作
1.创建密码文件,注意保持sys 密码与primary 数据库一致
ora10g@linux5 /oracle/u01/app/oracle/product/10.2.0/db_1/dbs$ orapwd file=orapwora10gdg password=sys entries=30
2.创建所需目录(注意OMF管理的文件)
ora10g@linux5 /home/oracle$ cd $ORACLE_BASE/admin
ora10g@linux5 /oracle/u01/app/oracle/admin$ mkdir ora10gdg
ora10g@linux5 /oracle/u01/app/oracle/admin$ cd ora10gdg
ora10g@linux5 /oracle/u01/app/oracle/admin/ora10gdg$ mkdir dpdump
ora10g@linux5 /oracle/u01/app/oracle/admin/ora10gdg$ mkdir cdump
ora10g@linux5 /oracle/u01/app/oracle/admin/ora10gdg$ mkdir pfile
ora10g@linux5 /oracle/u01/app/oracle/admin/ora10gdg$ mkdir bdump
ora10g@linux5 /oracle/u01/app/oracle/admin/ora10gdg$ mkdir udump
ora10g@linux5 /oracle/u01/app/oracle/admin/ora10gdg$ mkdir adump
ora10g@linux5 /oracle/u01/app/oracle/flash_recovery_area$ mkdir ORA10GDG
ora10g@linux5 /oracle/u01/app/oracle/flash_recovery_area$ cd ORA10GDG
ora10g@linux5 /oracle/u01/app/oracle/flash_recovery_area/ORA10GDG$ mkdir controlfile
ora10g@linux5 /oracle/u01/app/oracle/flash_recovery_area/ORA10GDG$ mkdir onlinelog
ora10g@linux5 /oracle/u01/app/oracle/flash_recovery_area/ORA10GDG$ mkdir backupset
ora10g@linux5 /oracle/u01/app/oracle/flash_recovery_area/ORA10GDG$ mkdir autobackup
ora10g@linux5 /oracle/u01/app/oracle/flash_recovery_area/ORA10GDG$ mkdir archivelog
3.复制数据文件到standby库对应的目录(datafile,log,controlfiles)
1).拷贝数据文件
$ cp -R /oracle/u02/oradata/ORA10G/datafile /oracle/u02/oradata/ORA10GDG
2).拷贝日志文件,注意是OMF管理的
$ cp -R /oracle/u02/oradata/ORA10G/onlinelog /oracle/u02/oradata/ORA10GDG
$ cp -R /oracle/u01/app/oracle/flash_recovery_area/ORA10G/onlinelog /oracle/u01/app/oracle/flash_recovery_area/ORA10GDG
3).拷贝主库生成的控制文件,注意是OMF管理的
$ cp /home/oracle/backup/ora10gdg.ctl /oracle/u02/oradata/ORA10GDG/controlfile/o1_mf_4srph8fv_.ctl
$ cp /home/oracle/backup/ora10gdg.ctl /oracle/u01/app/oracle/flash_recovery_area/ORA10GDG/controlfile/o1_mf_4srph96b_.ctl
4.修改standby初始化参数文件
1).standby的初始化参数如下
ora10gdg@linux5 /oracle/u01/app/oracle/product/10.2.0/db_1/dbs$ cat initora10gdg.ora
ora10g.__db_cache_size=20971520
ora10g.__java_pool_size=4194304
ora10g.__large_pool_size=4194304
ora10g.__shared_pool_size=71303168
ora10g.__streams_pool_size=0
*.audit_file_dest='/oracle/u01/app/oracle/admin/ora10gdg/adump'
*.background_dump_dest='/oracle/u01/app/oracle/admin/ora10gdg/bdump'
*.compatible='10.2.0.3.0'
*.control_files='/oracle/u02/oradata/ORA10GDG/controlfile/o1_mf_4srph8fv_.ctl','/oracle/u01/app/oracle/flash_recovery_area/ORA10GDG/controlfile/o1_mf_4srph96b_.ctl'
*.core_dump_dest='/oracle/u01/app/oracle/admin/ora10gdg/cdump'
*.cursor_sharing='EXACT'
*.db_block_size=8192
*.db_create_file_dest='/oracle/u02/oradata'
*.db_create_online_log_dest_1='/oracle/u01'
*.db_create_online_log_dest_2='/oracle/u02'
*.db_create_online_log_dest_3='/oracle/u02'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='ora10g'
*.db_recovery_file_dest='/oracle/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4294967296
*.job_queue_processes=10
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=16777216
*.processes=500
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_max_size=104857600
*.sga_target=104857600
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/oracle/u01/app/oracle/admin/ora10gdg/udump'
#################################################################
#Parameters for Standby Database.
#################################################################
*.DB_NAME='ora10g'
*.DB_UNIQUE_NAME=ora10gdg
*.LOG_ARCHIVE_FORMAT=log%t_%s_%r.arc
*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(ora10g,ora10gdg)'
*.DB_FILE_NAME_CONVERT='/oracle/u02/oradata/ORA10G/datafile','/oracle/u02/oradata/ORA10GDG/datafile'
*.LOG_FILE_NAME_CONVERT='/oracle/u02/oradata/ORA10G/onlinelog','/oracle/u02/oradata/ORA10GDG/onlinelog'
*.STANDBY_ARCHIVE_DEST='/ora10gdg_arch'
*.FAL_SERVER=ora10g
*.FAL_CLIENT=ora10gdg
*.STANDBY_FILE_MANAGEMENT=AUTO
#################################################################
#Parameters which using for switch over from Standby to Primary.
#################################################################
*.LOG_ARCHIVE_DEST_1='LOCATION=/oracle/u02/oradata/ORA10GDG VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ora10gdg'
*.LOG_ARCHIVE_DEST_2='SERVICE=ora10g LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ora10g'
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
2).通过该pfile 创建spfile
NotConnected@> create spfile from pfile= 'initora10gdg.ora';
File created.
5.启动standby 到mount
NotConnected@> startup mount;
ORACLE instance started.
Total System Global Area 104857600 bytes
Fixed Size 1266056 bytes
Variable Size 79695480 bytes
Database Buffers 20971520 bytes
Redo Buffers 2924544 bytes
Database mounted.
6.启动redo 应用
NotConnected@> alter database recover managed standby database disconnect from session;
Database altered.
7.查看同步情况
首先连接到primary 数据库
sys@ora10g> select instance_name,host_name,version,status from v$instance;
INSTANCE_NAME HOST_NAME VERSION STATUS
---------------- -------------------- ----------------- ------------
ora10g linux5 10.2.0.4.0 OPEN
sys@ora10g> alter system switch logfile;
System altered.
sys@ora10g> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
36
连接到standby 数据库
NotConnected@> select instance_name,host_name,version,status from v$instance;
INSTANCE_NAME HOST_NAME VERSION STATUS
---------------- -------------------- ----------------- ------------
ora10gdg linux5 10.2.0.4.0 MOUNTED
NotConnected@> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
36
8.暂停redo 应用
NotConnected@>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
三.验证standby数据库正确性
1.primary在sec用户创建一个表
sec@ora10g> create table test_dg (a int);
Table created.
sec@ora10g> conn / as sysdba
Connected.
sys@ora10g> alter system switch logfile;
System altered.
sys@ora10g> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
38
2.查看standby是否存在该表
NotConnected@> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
38
NotConnected@> alter database recover managed standby database cancel;
Database altered.
NotConnected@> alter database open read only;
Database altered.
sys@ora10gdg> conn sec/sec
Connected.
sec@ora10gdg> desc test_dg;
Name Null? Type
---------- -------- ---------------
A NUMBER(38)
OK,成功。
同一服务器配置DataGuard的更多相关文章
- Oracle Grid control 11g及Active DataGuard 11g安装部署
Oracle Grid control 11g及Active DataGuard 11g安装部署(一) 原贴 http://blog.csdn.net/lichangzai/article/detai ...
- 使用Oracle 11g新特性 Active Database Duplication 搭建Dataguard环境
Duplication Database 介绍 Duplicate database可以按照用途分为2种: duplicate database(复制出一个数据库) duplicate standby ...
- Oracle 11.2.0.4 DataGuard 环境打PSU,OJVM PSU补丁快速参考
环境:RHEL6.5 + Oracle 11.2.0.4 DataGuard physical standby 主库和备库都是单节点. 需求:主备库同时应用160719的PSU和OJVM PSU补丁. ...
- Linux服务器配置之加载硬盘
Linux服务器配置之加载硬盘 1.修改密码 passwd 2.测试密码是否成功 3.查看硬盘信息 fdisk –l 4.格式化分区 fdisk /dev/vdb 5.查看分区 6.快速格式化/dev ...
- Windows Server 2008 R2 WEB服务器配置系列文章索引
最近这段时间趁天翼云1元主机活动,购买了一个1元主机,主要是为了写一些服务器配置的教程. 已经完成如下几篇文章,送给大家. 国内云主机比较 天翼云/阿里云/腾讯云 Windows Server 200 ...
- Window下python2.7+Apache+mod_wsgi+Django服务器配置
前言:试着使用python搭建一个网页,分别在windows下和linux下,本篇文章主要讲解Window下python+Apache+mod_wsgi+Django服务器配置过程中遇见的问题和解决方 ...
- Samba服务器配置
Samba服务器配置流程: (1)安装samba服务器先用#rpm -ivh samba-列出与samba有关的rpm包然后选择第一个包,用tab键补齐文件名 (2)创建新用户和其密码#useradd ...
- 给11gR2 Dataguard打psu补丁的步骤及注意事项
参考文档278641.1 0.备份备主备库的spfile备份主库的数据 1.在主库上暂停向备库传日志alter system set log_archive_dest_state_X=defer sc ...
- dataguard不同步问题ora-16191解决
公司的11g的dataguard主备不同步,检查步骤如下: Primary:查询主库的最大日志 SQL> select max(sequence#) from v$archived_log;SQ ...
随机推荐
- Codeforces 710 D. Two Arithmetic Progressions
Description \(x=a_1k+b_1=a_2l+b_2,L\leqslant x \leqslant R\) 求满足这样条件的 \(x\) 的个数. Sol 扩展欧几里得+中国剩余定理. ...
- 分布式架构 Hadoop 2.7.X 安装和配置
一.安装环境 硬件:虚拟机 操作系统:Ubuntu 14 32位 IP:59.77.132.28主机名:admin安装用户:root 二.安装JDK 安装JDK1.7或者以上版本.这里安装jdk1.7 ...
- python操作memcached以及分布式
memcached 是以 LiveJournal 旗下 Danga Interactive 公司的 Brad Fitzpatric 为首开发的一款软件.现在已成为 mixi.Facebook.Live ...
- 解决maven项目移动
解决使用maven的工程移动到另一台电脑(电脑无法访问maven中央仓库问题) 移动后出现下述结果: Publishing failedPublishing failed with multiple ...
- minigui移植到arm linux开发板上无法执行
要保证目录下有该文件 /etc/MiniGUI.cfg 复制过程使用cp –af 强制复制
- JNative library not loaded, sorry ! win7 64位系统
java调用动态链接库时,使用myeclipse或者其他IDE工具时,针对于web程序,会报这样的错误: java.lang.IllegalStateException: JNative librar ...
- 阿里云ecs云服务器安装wdcp控制面板教程
以前就听说服务器非常的难,而且我也不懂代码,不懂英文,我怕自己学不会就买了一个月的.开始我都不知道啥样的服务器,还是我的一位哥们给我远程买的,他说这个镜像最稳定了. 服务器买好后我便开始研究,可是怎么 ...
- MySQL高可用性之Keepalived+MySQL(双主热备)
环境描述:OS:CentOS6.5_X64MASTER:192.168.0.202BACKUP:192.168.0.203VIP:192.168.0.204 1.配置两台Mysql主主同步[root@ ...
- ssh免密码登陆设置
服务器端 CentOS 6.5下编辑/etc/ssh/sshd_config MacOSx下编辑/etc/sshd_config #开启公钥验证 RSAAuthentication yes Pubke ...
- HttpServletRequest中得到各种信息
1.获得domain: StringBuffer url = request.getRequestURL(); String domain = url.delete(url.length() - re ...