三、配置备库

  创建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搭建(二)的更多相关文章

  1. Oracle DataGuard搭建(一)

    第一次搭建oracle dataguard.学oracle很长时间,却没有完整的搭过dg,说起来让人笑.总得有第一次,而且第一次总是很痛苦的. 数据库版本: Oracle Database 11g E ...

  2. oracle(环境搭建二)

    Configuration oracle database Password file(非必要)        cd $ORACLE_HOME/dbs/ ls 查看是否有init.ora 创建密码文件 ...

  3. oracle dataguard搭建

    搭建前环境准备 1.查看主库的oracle的uid和gid并在备库创建用户 # 主库查看oracle $ id oracle uid=54321(oracle) gid=54321(oinstall) ...

  4. 9. Oracle DataGuard的介绍

    一. Oracle DataGuard简介 Oracle DataGuard:简称DG.是由一个Primary Database(主库)和一个或者多个Standby Database(备库)组成.对O ...

  5. Oracle DataGuard 物理Standby 搭建(上)

    物理standby database 环境搭建 Arch asysnc Oracle Dataguard host IP Oracle_sid DB_unique_name FAL_server FA ...

  6. Oracle 10gR2 Dataguard搭建(非duplicate方式)

    Oracle 10gR2 Dataguard搭建(非duplicate方式) 我的实验环境: 源生产库(主库): IP地址:192.168.1.30 Oracle 10.2.0.5 单实例 新DG库( ...

  7. 【Oracle】搭建DG(DataGuard)

    操作系统:OEL 5.6 Oracle 版本:11.2.0.4.0 DataGuard规划说明 DATABASE_ROLE DB_NAME IPADDR Primary lgr 192.168.10. ...

  8. oracle dataguard主从切换

    前言: 众所周知DataGuard一般的切换分成两种,一种是系统正常的情况下的切换这种方式为:switchover是无损切换,不会丢失数据:另外一种方式属于灾难情况下的切换,这种情况下一般主库已经启动 ...

  9. Oracle DataGuard故障转移(failover)后使用RMAN还原失败的主库

    (一)DG故障转移后切换为备库的方法 在DG执行故障转移之后,主库与从库的关系就被破坏了.这个时候如果要恢复主从关系,可以使用下面的3种方法: 将失败的主库重新搭建为备库,该方法比较耗时: 使用数据库 ...

随机推荐

  1. WordPress数据库研究 (转)

    该系列文章将会详细介绍WordPress数据总体的设计思路.详细介绍WordPress10个数据表的设计.并对WordPress系统中涉及的用户信息.分类信息.链接信息.文章信息.文章评论信息.基本设 ...

  2. hdu 3535 AreYouBusy

    // 混合背包// xiaoA想尽量多花时间做ACM,但老板要求他在T时间内做完n堆工作,每个工作耗时ac[i][j],// 幸福感ag[i][j],每堆工作有m[i]个工作,每堆工作都有一个性质,/ ...

  3. Spring学习之声明式事物管理

    public List<Student> selectStudent() { Student s = new Student(); s.setName("zhengbin&quo ...

  4. Android02--debug.keystore的注册信息

    1 -- 签名文件的密钥 默认签名文件的密码是:android 该文件的存放点是: 2 -- 签名文件的签名信息 keytool -list -v -keystore C:\Users\motadou ...

  5. 2、列表item_圆头像_信息提示

    import android.app.Activity; import android.os.Bundle; import android.view.LayoutInflater; import an ...

  6. HDU 5730 Shell Necklace cdq分治+FFT

    题意:一段长为 i 的项链有 a[i] 种装饰方式,问长度为n的相连共有多少种装饰方式 分析:采用dp做法,dp[i]=∑dp[j]*a[i-j]+a[i],(1<=j<=i-1) 然后对 ...

  7. Selenium用户扩展

    Selenium用户扩展 这很容易扩展Selenium IDE加入自定义操作,断言和定位,策略,这是通过添加方法,在JavaScript的帮助下Selenium 对象原型.在启动时,Selenium会 ...

  8. new trip

    离开YY已经快一周了,特别感谢以前的老大姚冬和朱云峰,从他俩身上学到了很多.这个决定也经过了很长的纠结,不想再做个犹豫不决的人,所以最后还是坚定了最初的信念,也算是对半年前自己的一个完好交代,以防将来 ...

  9. support vector regression与 kernel ridge regression

    前一篇,我们将SVM与logistic regression联系起来,这一次我们将SVM与ridge regression(之前的linear regression)联系起来. (一)kernel r ...

  10. pyinstaller使用小结

    安装pyinstaller pip install -U pyinstaller 生成控制台程序 pyinstaller ./example.py 在当前目录的dist文件夹内可以找到编译成功的程序 ...