Oracle DataGuard搭建(二)
三、配置备库
创建catalog数据库
用dbca创建数据库,用oracle自带模板,不用em,启用归档,同一管理密码oracle,global name:dbcat1.node249.gewara,实例名:dbcat1
$export $ORACLE_SID=dbcat1
$sqlplus / as sysdba
SQL>create tablespace tbs_rman datafile '/u01/app/oracle/oradata/dbtest/tbs_rman01.dbf' size 500m autoextned on next 1m extent management local;
SQL>create user rman identified by rman default tablespace tbs_rman temporary tablespace temp;
SQL>grant connect,resource,recovery_catalog_owner to rman;
SQL>conn rman/rman
SQL>show user
创建catalog
$rman
RMAN>connect catalog rman/rman@dbcat1;
RMAN>create catalog;
创建密码文件,或者直接将主库的密码文件复制过来,放在$ORACLE_HOME/dbs/下,更改文件属住为oracle:oinstall
orapwd file=$ORACLE_HOME/dbs/orapwdbtest password=oracle entries=10
配置TNS,修改$ORACLE_HOME/netword/admin/tnsnames.ora
DBCAT1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.249)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dbcat1)
)
)
DBPRIMARY =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.248)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dbtest.node248.gewara)
(SID=dbtest)
)
)
DBSTANDBY =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.249)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dbtest.node249.gewara)
)
)
配置监听
修改$ORACLE_HOME/network/admin/listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/products/11.2/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = dbtest.node249.gewara)
(ORACLE_HOME = /u01/app/oracle/products/11.2/db_1)
(SID_NAME = dbtest)
)
(SID_DESC =
(GLOBAL_DBNAME = dbcat1)
(ORACLE_HOME = /u01/app/oracle/products/11.2/db_1)
(SID_NAME = dbcat1)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.2.249)( PORT = 1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
启动监听
$lsnrctl start
?测试tns是否配置成功
$tnsping dbprimary
$tnsping dbstandby
$tnsping dbcat1
为备库准备pfile
可以把之前为主库准备的pfile拷贝到node249上,做相应修改
# /tmp/initdbtest.ora
dbtest.__db_cache_size=671088640
dbtest.__java_pool_size=16777216
dbtest.__large_pool_size=16777216
dbtest.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
dbtest.__pga_aggregate_target=671088640
dbtest.__sga_target=973078528
dbtest.__shared_io_pool_size=0
dbtest.__shared_pool_size=251658240
dbtest.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/dbtest/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/oradata/dbtest/control01.ctl','/u01/app/oracle/flash_recovery_area/dbtest/control02.ctl'
*.db_block_size=8192
*.db_domain='node249.gewara'
*.db_name='dbtest'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4070572032
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=dbtestXDB)'
*.memory_target=1639972864
*.open_cursors=300
*.processes=150
*.undo_tablespace='UNDOTBS1'
*.DB_UNIQUE_NAME='db249'
*.FAL_CLIENT='dbstandby'
*.FAL_SERVER='dbprimary'
*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(db248,db249)'
*.log_archive_dest_1='LOCATION=/u01/app/oracle/archive/
VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=db249' #这里的DB_UNIQUE_NAME为备库的DB_UNIQUE_NAME
*.LOG_ARCHIVE_DEST_2='SERVICE=dbprimary LGWR ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=db248'
*.LOG_ARCHIVE_DEST_STATE_1='ENABLE'
*.LOG_ARCHIVE_DEST_STATE_2='ENABLE'
*.LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
按照pfile中指定的目录,在oracle用户下,用mkdir –p 命令,创建所有需要的文件夹,保证所有目录的属主为oracle:oinstall.
启动备库到nomount状态:
$export ORACLE_SID=dbtest
$echo $ORACLE_SID
$sqlplus / as sysdba
SQL>startup nomount pfile='/tmp/initdbtest.ora'
启动rman,用duplicate命令,建立备库
$rman
RMAN>connect catalog rman/rman@dbcat1
RMAN>connect target sys/oracle@dbprimary
RMAN>connect auxiliary sys/oracle@dbstandby
RMAN>register database;
RMAN>duplicate target database for standby from active database nofilenamecheck;
四、添加standby logfile
主库:
SQL>alter database add standby logfile group 4 ('/u01/app/oracle/oradata/dbtest/stdy_redo04.log') size 10m;
SQL>alter database add standby logfile group 5 ('/u01/app/oracle/oradata/dbtest/stdy_redo05.log') size 10m;
SQL>alter database add standby logfile group 6 ('/u01/app/oracle/oradata/dbtest/stdy_redo06.log') size 10m;
SQL>alter database add standby logfile group 7 ('/u01/app/oracle/oradata/dbtest/stdy_redo07.log') size 10m;
备库:
SQL>alter database add standby logfile group 4 ('/u01/app/oracle/oradata/dbtest/stdy_redo04.log') size 10m;
SQL>alter database add standby logfile group 5 ('/u01/app/oracle/oradata/dbtest/stdy_redo05.log') size 10m;
SQL>alter database add standby logfile group 6 ('/u01/app/oracle/oradata/dbtest/stdy_redo06.log') size 10m;
SQL>alter database add standby logfile group 7 ('/u01/app/oracle/oradata/dbtest/stdy_redo07.log') size 10m;
SQL>shutdown immediate
SQL>startup nomount;
SQL>alter database mount standby database;
五、datagurad管理
启用dataguard
SQL>startup nomount;
SQL>alter database mount standby database;
SQL>alter database recover managed standby database disconnect from session;
切换为readonly状态
SQL>alter database recover managed standby database concel;
SQL>alter database open read only;
SQL>select * from dual;
主备切换:
主库端:
SQL>alter database commit to switchover to physical standby database with session shutdown;
SQL>shutdown immediate;
SQL>startup nomount;
SQL>alter database mount standby database;
SQL>alter database recover managed standby database disconnect from session;
备库端:
SQL>alter database commit to switchover to primary with session shutdown;
SQL>shutdown immediate
SQL>startup
trouble shooting:
ora-00845:
$su – root
#mount –t tmpfs shmfs –o size=3g /dev/shm
Oracle DataGuard搭建(二)的更多相关文章
- Oracle DataGuard搭建(一)
第一次搭建oracle dataguard.学oracle很长时间,却没有完整的搭过dg,说起来让人笑.总得有第一次,而且第一次总是很痛苦的. 数据库版本: Oracle Database 11g E ...
- oracle(环境搭建二)
Configuration oracle database Password file(非必要) cd $ORACLE_HOME/dbs/ ls 查看是否有init.ora 创建密码文件 ...
- oracle dataguard搭建
搭建前环境准备 1.查看主库的oracle的uid和gid并在备库创建用户 # 主库查看oracle $ id oracle uid=54321(oracle) gid=54321(oinstall) ...
- 9. Oracle DataGuard的介绍
一. Oracle DataGuard简介 Oracle DataGuard:简称DG.是由一个Primary Database(主库)和一个或者多个Standby Database(备库)组成.对O ...
- Oracle DataGuard 物理Standby 搭建(上)
物理standby database 环境搭建 Arch asysnc Oracle Dataguard host IP Oracle_sid DB_unique_name FAL_server FA ...
- Oracle 10gR2 Dataguard搭建(非duplicate方式)
Oracle 10gR2 Dataguard搭建(非duplicate方式) 我的实验环境: 源生产库(主库): IP地址:192.168.1.30 Oracle 10.2.0.5 单实例 新DG库( ...
- 【Oracle】搭建DG(DataGuard)
操作系统:OEL 5.6 Oracle 版本:11.2.0.4.0 DataGuard规划说明 DATABASE_ROLE DB_NAME IPADDR Primary lgr 192.168.10. ...
- oracle dataguard主从切换
前言: 众所周知DataGuard一般的切换分成两种,一种是系统正常的情况下的切换这种方式为:switchover是无损切换,不会丢失数据:另外一种方式属于灾难情况下的切换,这种情况下一般主库已经启动 ...
- Oracle DataGuard故障转移(failover)后使用RMAN还原失败的主库
(一)DG故障转移后切换为备库的方法 在DG执行故障转移之后,主库与从库的关系就被破坏了.这个时候如果要恢复主从关系,可以使用下面的3种方法: 将失败的主库重新搭建为备库,该方法比较耗时: 使用数据库 ...
随机推荐
- substring函数——sql
--substring( expression, start, length ) expression待截取的文字 start 截取位置的起始下标 length 要截取的长度 --左边第一个字符的下标 ...
- 对于随机变量的标准差standard deviation、样本标准差sample standard deviation、标准误差standard error的解释
参考:http://blog.csdn.net/ysuncn/article/details/1749729
- Java [Leetcode 125]Valid Palindrome
题目描述: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ...
- U1 - A 留在电脑里的字体
U1系列新篇章,实战派!说说常用的字体! U1系列新篇章,实战派!更多干货更多关于软件的使用等即将放出,大家敬请期待!!
- 我的web前端之路 分享些前端的好书(转)
WEB前端研发工程师,在国内算是一个朝阳职业,这个领域没有学校的正规教育,大多数人都是靠自己自学成才.本文主要介绍自己从事web开发以来 (从大二至今)看过的书籍和自己的成长过程,目的是给想了解Jav ...
- 利用ioctl()获取无线速率
其实对于自己装了网卡驱动的来说,应该从最根本的驱动中获取速率. 但是用ioctl()也可以,其实实现和iwconfig命令相同. 仅仅获取速率这部分: #include <stdio.h> ...
- 在stm32上移植wpa_supplicant(一)
wifi芯片为88w8686,已经写好了驱动,用的是SPI方式,接下来准备移植wpa_supplicant.参考的资料为一篇论文----<基于微控制器的WPA技术研究与应用>. wpa_s ...
- [转] AE中如何由IFeature 如何获取所对应的FeatureClass
转载的原文 AE中如何由IFeature 如何获取所对应的FeatureClass 先获取FeatureClass,然后遍历Map中所有的FeatureLayer,然后比较 FeatureClas ...
- <转>Python运行的17个时新手常见错误小结
1)忘记在 if , elif , else , for , while , class ,def 声明末尾添加 :(导致 “SyntaxError :invalid syntax”) 该错误将发生在 ...
- Apriori学习笔记
Apriori算法是一种挖掘关联规则的频繁项集算法,是由Rakesh Agrawal和Ramakrishnan Srikant两位在1994年提出的布尔关联规则的频繁项集挖掘算法.算法的名字" ...