rhel6.3_oracle11R2的DG搭建安装
2016-03-04 14:06
501 查看
安装环境:rhel6.3 oracle11gR2
主库: ip:192.168.38.38 hostname:pri
备库: ip:192.168.38.138 hostname:sty
主库安装oracle软件,安装数据库, 备库只安装oracle软件,没有安装数据库
在主库开启归档:
在主库设置force logging模式
在主库 创建备库的控制文件
在主库查看数据文件,控制文件,日志文件
关闭主库的数据库
在主库拷贝数据,控制,日志文件到备库中
重新启动主库的数据库
在主库修改参数文件
以下是添加的参数
在主库 用上面修改pfile再创建spfile,并重启数据库
创建口令文件
拷贝主库的参数和口令文件到备库中
备库中修改相应的pfile参数文件
主库修改监听文件
在备库修改监听文件
在主库测试是否连接到备库
在备库测试是否连接到主库
启动备库
在主库测试
备库查看,和主库一直,无问题
附:
主库: ip:192.168.38.38 hostname:pri
备库: ip:192.168.38.138 hostname:sty
主库安装oracle软件,安装数据库, 备库只安装oracle软件,没有安装数据库
在主库开启归档:
SQL> archive log list; Database log mode No Archive Mode Automatic archival Disabled Archive destination /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch Oldest online log sequence 13 Current log sequence 15 SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> startup mount ORACLE instance started. Total System Global Area 830930944 bytes Fixed Size 2257800 bytes Variable Size 490736760 bytes Database Buffers 335544320 bytes Redo Buffers 2392064 bytes Database mounted. SQL> alter database archivelog; Database altered. SQL> archive log list Database log mode Archive Mode Automatic archival Enabled Archive destination /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch Oldest online log sequence 13 Next log sequence to archive 15 Current log sequence 15 SQL> alter database open; Database altered.
在主库设置force logging模式
SQL> alter database force logging; Database altered.
在主库 创建备库的控制文件
SQL> alter database create standby controlfile as '/u01/app/oracle/oradata/orclpri/standby.ctl'; Database altered.
在主库查看数据文件,控制文件,日志文件
SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- /u01/app/oracle/oradata/orclpri/system01.dbf /u01/app/oracle/oradata/orclpri/sysaux01.dbf /u01/app/oracle/oradata/orclpri/undotbs01.dbf /u01/app/oracle/oradata/orclpri/users01.dbf SQL> show parameter control_files; NAME TYPE VALUE ----------------------------------------------- ------------------------------ control_files string /u01/app/oracle/oradata/orclpr i/control01.ctl, /u01/app/orac le/oradata/orclpri/control02.c tl SQL> select group#,member from v$logfile; GROUP# MEMBER -------------------------------------------------------------------------------- 1 /u01/app/oracle/oradata/orclpri/redo01.log 2 /u01/app/oracle/oradata/orclpri/redo02.log 3 /u01/app/oracle/oradata/orclpri/redo03.log
关闭主库的数据库
SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> quit Disconnected from Oracle Database 11gEnterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Miningand Real Application Testing options
在主库拷贝数据,控制,日志文件到备库中
[oracle@pri oradata]$ cd /u01/app/oracle/oradata/ [oracle@pri oradata]$ scp -r orclpri/ oracle@192.168.38.138:/u01/app/oracle/oradata oracle@192.168.38.138's password: control01.ctl 100% 9520KB 9.3MB/s 00:00 redo02.log 100% 50MB 25.0MB/s 00:02 standby.ctl 100% 9520KB 9.3MB/s 00:01 system01.dbf 100% 700MB 18.9MB/s 00:37 sysaux01.dbf 100% 600MB 17.7MB/s 00:34 redo01.log 100% 50MB 50.0MB/s 00:01 control02.ctl 100% 9520KB 9.3MB/s 00:00 undotbs01.dbf 100% 200MB 16.7MB/s 00:12 temp01.dbf 100% 20MB 20.0MB/s 00:01 users01.dbf 100% 5128KB 5.0MB/s 00:00 redo03.log 100% 50MB 25.0MB/s 00:02
重新启动主库的数据库
[oracle@pri oradata]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production onTue Mar 1 09:11:12 2016 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to an idle instance. SQL> startup ORACLE instance started. Total System Global Area 830930944 bytes Fixed Size 2257800 bytes Variable Size 490736760 bytes Database Buffers 335544320 bytes Redo Buffers 2392064 bytes Database mounted. Database opened.
在主库修改参数文件
SQL> create pfile from spfile; File created.
以下是添加的参数
[oracle@pri dbs]$ vi initorclpri.ora *.db_unique_name=orclpri *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclpriXDB)' *.fal_client='orclpri' *.fal_server='orclsty' *.local_listener='LISTENER_orclpri' *.log_archive_config='DG_CONFIG=(orclpri,orclsty)' *.log_archive_dest_1='LOCATION=/u01/app/oracle/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orclpri' *.log_archive_dest_2='SERVICE=orclsty OPTIONAL LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orclsty' *.log_archive_dest_state_1='ENABLE' *.log_archive_dest_state_2='ENABLE' *.log_archive_format='%t_%s_%r.arc'
在主库 用上面修改pfile再创建spfile,并重启数据库
SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> create spfile from pfile; File created. SQL> startup ORACLE instance started. Total System Global Area 830930944 bytes Fixed Size 2257800 bytes Variable Size 536874104 bytes Database Buffers 289406976 bytes Redo Buffers 2392064 bytes Database mounted. Database opened.
创建口令文件
[oracle@pri dbs]$ orapwd file=orapworclpri password=sys force=y ignorecase=y
拷贝主库的参数和口令文件到备库中
[oracle@pri dbs]$ scp -r orapworclpri initorclpri.ora 192.168.38.138:/u01/app/oracle/product/11.2.0/dbhome_1/dbs oracle@192.168.38.138's password: orapworclpri 100% 1536 1.5KB/s 00:00 initorclpri.ora 100% 1359 1.3KB/s 00:00
备库中修改相应的pfile参数文件
[oracle@sty dbs]$ cat initorclpri.ora 这个需要在备库建立相应路径 *.audit_file_dest='/u01/app/oracle/admin/orclpri/adump' 修改控制文件 *.control_files='/u01/app/oracle/oradata/orclpri/standby.ctl' 以下是添加的参数 *.db_unique_name=orclsty *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclpriXDB)' *.fal_client='orclpri' *.fal_server='orclsty' *.db_file_name_convert='/u01/app/oracle/oradata','/u01/app/oracle/oradata' *.log_file_name_convert='/u01/app/oracle/oradata','/u01/app/oracle/oradata' *.local_listener='LISTENER_orclsty' *.log_archive_config='DG_CONFIG=(orclpri,orclsty)' *.log_archive_dest_1='LOCATION=/u01/app/oracle/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orclsty' *.log_archive_dest_2='SERVICE=orclpri OPTIONAL LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orclpri' *.log_archive_dest_state_1='ENABLE' *.log_archive_dest_state_2='ENABLE' *.log_archive_format='%t_%s_%r.arc'
主库修改监听文件
[oracle@prisamples]$ pwd /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/samples [oracle@prisamples]$ cat listener.ora SID_LIST_LISTENER= (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1) (PROGRAM = extproc) ) (SID_DESC = (GLOBAL_DBNAME= orclpri) (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1) (SID_NAME=orclpri) ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY =EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST =pri)(PORT = 1521)) ) ) ADR_BASE_LISTENER = /u01/app/oracle [oracle@priadmin]$ pwd /u01/app/oracle/product/11.2.0/dbhome_1/network/admin [oracle@prisamples]$ cat tnsnames.ora orclpri = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.38.38)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orclpri) ) ) orclsty = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.38.138)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orclsty) ) ) EXTPROC_CONNECTION_DATA= (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL =TPC)(KEY = EXTPROCO)) ) (CONNECT_DATA = (SID = PLSExtProc) (PRESENTATION = RO) ) )
在备库修改监听文件
[oracle@stysamples]$ pwd /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/samples [oracle@stysamples]$ cat listener.ora SID_LIST_LISTENER= (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME =/u01/app/oracle/product/11.2.0/dbhome_1) (PROGRAM = extproc) ) (SID_DESC = (GLOBAL_DBNAME= orclpri) (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1) (SID_NAME=orclsty) ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY =EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST =sty)(PORT = 1521)) ) ) [oracle@styadmin]$ pwd /u01/app/oracle/product/11.2.0/dbhome_1/network/admin [oracle@stysamples]$ cat tnsnames.ora orclpri = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.38.38)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orclpri) ) ) orclsty = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.38.138)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = orclsty) ) ) EXTPROC_CONNECTION_DATA= (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL =TPC)(KEY = EXTPROCO)) ) (CONNECT_DATA = (SID = PLSExtProc) (PRESENTATION = RO) ) )
在主库测试是否连接到备库
[oracle@pri admin]$ sqlplus sys/system@orclsty as sysdba SQL*Plus: Release 11.2.0.4.0 Production onWed Mar 2 12:21:12 2016 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise EditionRelease 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Miningand Real Application Testing options SQL>
在备库测试是否连接到主库
[oracle@sty ~]$ sqlplus sys/system@orclpri as sysdba SQL*Plus: Release 11.2.0.4.0 Production onWed Mar 2 10:57:54 2016 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise EditionRelease 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Miningand Real Application Testing options SQL>
启动备库
已从主库拷贝来的pfile创建spfile来启动数据库 SQL> create spfile from pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorclpri.ora'; File created. SQL> startup nomount; ORACLE instance started. Total System Global Area 830930944 bytes Fixed Size 2257800 bytes Variable Size 536874104 bytes Database Buffers 289406976 bytes Redo Buffers 2392064 bytes Mount数据库 SQL> alter database mount standby database; Database altered. 应用redo SQL> alter database recover managed standby database disconnect from session; Database altered. 查看数据库角色 SQL> select database_role from v$database; DATABASE_ROLE ---------------- PHYSICAL STANDBY 查看归档日志scn SQL> select max(sequence#) from v$archived_log; MAX(SEQUENCE#) -------------- 19
在主库测试
SQL> alter system switch logfile; System altered. SQL> select max(sequence#) from v$archived_log; MAX(SEQUENCE#) -------------- 20
备库查看,和主库一直,无问题
SQL> select max(sequence#) from v$archived_log; MAX(SEQUENCE#) -------------- 20
附:
取消redo应用,但还是会接受redo的 SQL> alter database recover managed standby database cancel; Database altered. 以只读模式打开数据库 SQL> alter database open read only;
相关文章推荐
- Oracle手边常用70则脚本知识汇总
- Oracle - 数据库字符集的查询
- Oracle - 常用命令
- ORACLE的基础培训
- 一个Oracle GeoSQL性能问题解决过程
- oracle的alert日志迁移
- oracle的trace日志迁移
- oracle--游标
- Oracle手边常用命令及操作语句
- Oracle In-Memory database cache --TimesTen
- Like模糊查询与带有关键字Reverse的索引应用学习
- oracle优化:避免全表扫描
- oracle限制用户登陆
- oracle的sequence创建修改
- oracle 函数 WMSYS.WM_CONCAT 的用法 与 mysql 函数GROUP_CONCAT的用法
- Oracle--视图,序列及索引
- oracle删除数据文件
- oracle 查看表空间大小
- 深入理解ORACLE启动过程
- oracle的日期函数:last_day