您好,登錄后才能下訂單哦!
這篇文章主要介紹“Oracle Data Guard部署方法是什么”,在日常操作中,相信很多人在Oracle Data Guard部署方法是什么問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”O(jiān)racle Data Guard部署方法是什么”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!
本實施方案主要對Oracle DataGuard實施部署作相應(yīng)的說明。以便能根據(jù)當(dāng)前業(yè)務(wù)特點,規(guī)劃、建設(shè)符合高可用、高可靠的數(shù)據(jù)庫集群系統(tǒng)。
數(shù)據(jù)庫服務(wù)器采用Data Guard災(zāi)備模式,可以滿足對可用性有特殊需求的應(yīng)用,具備以下特點:
1. 需要冗余的服務(wù)器設(shè)備,該模式需要有冗余的服務(wù)器硬件,硬件成本較高。
2. 需要冗余的存儲設(shè)備,主機和備機都需要同樣的存儲空間,成本較高。
3. 安裝配置比較復(fù)雜,該模式比單節(jié)點、單實例的模式配置復(fù)雜一些,需要更多的配置步驟。
4. 管理維護成本高,該模式對維護人員的要求較高,維護成本高。
5. 具備一定的容災(zāi)特性。當(dāng)主機整個數(shù)據(jù)庫系統(tǒng)不可用并短期內(nèi)無法恢復(fù)時,可以把數(shù)據(jù)庫系統(tǒng)切換到備機上,具備容災(zāi)的功能。
6. 備機可以用作只讀查詢,備機可以切換到只讀狀態(tài)供報表之類的查詢操作,減輕主機的壓力。
主機1 | 主機2 | 主機3 | |
操作系統(tǒng) | Oracle Linux Server release 6.5 | Oracle Linux Server release 6.5 | Oracle Linux Server release 6.5 |
主機名 | test1.us.oracle.com | test2.us.oracle.com | test5.us.oracle.com |
IP | 192.168.1.2 | 192.168.1.3 | 192.168.1.6 |
數(shù)據(jù)庫軟件版本 | 11.2.0.4.0 | 11.2.0.4.0 | 11.2.0.4.0 |
ORACLE_BASE | /u01/app/oracle | /u01/app/oracle | /u01/app/oracle |
ORACLE_HOME | /u01/app/oracle/product/11.2.0/db_1 | /u01/app/oracle/product/11.2.0/db_1 | /u01/app/oracle/product/11.2.0/db_1 |
ORACLE_SID | PROD1 | PROD2 | PROD5 |
閃回區(qū)路徑 | /home/oracle/flash | ||
閃回區(qū)大小 | 4G | ||
歸檔 | archovelog | ||
主從關(guān)系 | Primiry | Standby | Standby |
強制日志 | logging force | ||
閃回 | flashbackdatabase | ||
是否開啟監(jiān)聽 | start | start | start |
是否建立實例 | setup | no setup | no setup |
1. 設(shè)置數(shù)據(jù)庫歸檔
[oracle@test1 dbs]$ export ORACLE_SID=PROD1 [oracle@test1 dbs]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Sun Mar 3 08:07:15 2019 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to an idle instance. SQL> startup mount; ORACLE instance started. Total System Global Area 1219260416 bytes Fixed Size 2252744 bytes Variable Size 788529208 bytes Database Buffers 419430400 bytes Redo Buffers 9048064 bytes Database mounted. SQL> alter system set db_recovery_file_dest='/home/oracle/flash'; System altered. SQL> alter system set db_recovery_file_dest_size=4G; System altered. SQL> alter database archivelog; Database altered. SQL> alter database open; Database altered.
2. 設(shè)置數(shù)據(jù)庫閃回
SQL> select flashback_on from v$database; FLASHBACK_ON ------------------------------------ NO SQL> alter system set db_recovery_file_dest='/home/oracle/flash'; System altered. SQL> alter system set db_recovery_file_dest_size='5G'; System altered. SQL> shutdown immediate; ORA-01109: database not open Database dismounted. ORACLE instance shut down. SQL> startup mount; ORACLE instance started. Total System Global Area 1219260416 bytes Fixed Size 2252744 bytes Variable Size 788529208 bytes Database Buffers 419430400 bytes Redo Buffers 9048064 bytes Database mounted. SQL> alter database flashback on; Database altered. SQL> alter database open; Database altered. SQL> select flashback_on from v$database; FLASHBACK_ON ------------------------------------ YES
3. 設(shè)置數(shù)據(jù)庫強制歸檔
SQL> select force_logging from v$database; FORCE_ ------ NO SQL> alter database force logging; Database altered. SQL> select force_logging from v$database; FORCE_ ------ YES
4. 添加Standby日志文件
在備庫,當(dāng)RFS進程接受到日志后,就將其寫入Standby日志文件里,備庫的Standby日志文件可以看做是主庫在線日志文件的一個鏡像,當(dāng)主庫做日志切換時,備庫的Standby日志也做相應(yīng)的切換,切換后的Standby日志由備庫的ARCH進程歸檔。
Oracle規(guī)定備庫的Standby日志文件大小不能小于主庫在線日志文件最大的一個,一般情況下,為了管理方便,最好把所有的在線日志和Standby日志大小設(shè)為一樣。
通過下面語句可以查詢主庫在線日志的大小和組數(shù):
SQL> select group#,bytes/1024/1024 from v$log; GROUP# BYTES/1024/1024 ---------- --------------- 1 50 2 50 3 50 SQL> select group#,bytes/1024/1024 from v$standby_log; no rows selected SQL> alter database add standby logfile group 4 '/home/oracle/s1.log' size 50M; Database altered. SQL> alter database add standby logfile group 5 '/home/oracle/s2.log' size 50M; Database altered. SQL> alter database add standby logfile group 6 '/home/oracle/s3.log' size 50M; Database altered. SQL> alter database add standby logfile group 7 '/home/oracle/s4.log' size 50M; Database altered. SQL> select group#,bytes/1024/1024 from v$standby_log; GROUP# BYTES/1024/1024 ---------- --------------- 4 50 5 50 6 50 7 50
5. 修改參數(shù)文件
SQL> create pfile from spfile; File created. SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options [oracle@test1 dbs]$ ls hc_PROD1.dat init.ora initPROD1.ora lkPROD1 orapwPROD1 spfilePROD1.ora [oracle@test1 dbs]$ cat initPROD1.ora PROD1.__db_cache_size=419430400 PROD1.__java_pool_size=16777216 PROD1.__large_pool_size=83886080 PROD1.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment PROD1.__pga_aggregate_target=503316480 PROD1.__sga_target=721420288 PROD1.__shared_io_pool_size=0 PROD1.__shared_pool_size=184549376 PROD1.__streams_pool_size=0 *.audit_file_dest='/u01/app/oracle/admin/PROD1/adump' *.audit_trail='db' *.compatible='11.2.0.4.0' *.control_files='/u01/app/oracle/oradata/PROD1/control01.ctl','/u01/app/oracle/fast_recovery_area/PROD1/control02.ctl' *.db_block_size=8192 *.db_domain='' *.db_name='PROD1' *.db_recovery_file_dest='/home/oracle/flash' *.db_recovery_file_dest_size=4294967296 *.diagnostic_dest='/u01/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=PROD1XDB)' *.undo_tablespace='UNDOTBS1' *.processes=150 *.open_cursors=300 *.memory_target=1211105280 *.DB_UNIQUE_NAME='PROD1' *.LOG_ARCHIVE_CONFIG='DG_CONFIG=(PROD1,PROD2,PROD5)' *.LOG_ARCHIVE_DEST_1='LOCATION=/home/oracle/flash VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=PROD1' *.LOG_ARCHIVE_DEST_2='SERVICE=PROD1_2 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PROD2' *.LOG_ARCHIVE_DEST_3='SERVICE=PROD1_5 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PROD5' *.LOG_ARCHIVE_DEST_STATE_1='ENABLE' *.LOG_ARCHIVE_DEST_STATE_2='ENABLE' *.LOG_ARCHIVE_DEST_STATE_3='ENABLE' *.LOG_ARCHIVE_FORMAT='%t_%s_%r.arc' *.LOG_ARCHIVE_MAX_PROCESSES=30 *.REMOTE_LOGIN_PASSWORDFILE='EXCLUSIVE' *.FAL_CLIENT='PROD2,PROD5' *.FAL_SERVER='PROD1'
注意:上面修改的參數(shù)有的需要重啟數(shù)據(jù)庫才能生效
6. 修改監(jiān)聽配置文件
[oracle@test1 ~]$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin/ [oracle@test1 admin]$ cat listener.ora # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora # Generated by Oracle configuration tools. LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = test1.us.oracle.com)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) ) ADR_BASE_LISTENER = /u01/app/oracle SID_LIST_LISTENER= (SID_LIST= (SID_DESC= (GLOBAL_DBNAME=PROD1) (ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1) (SID_NAME=PROD1)) )
7. 修改TNS配置文件
[oracle@test1 admin]$ cat tnsnames.ora # tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora # Generated by Oracle configuration tools. PROD1_5 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = test5.us.oracle.com)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = PROD5) ) ) PROD1_2 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = test2.us.oracle.com)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = PROD2) ) ) PROD1_1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = test1.us.oracle.com)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = PROD1) ) )
8. 重啟監(jiān)聽服務(wù),測試服務(wù)名的連通情況
[oracle@test1 dbs]$ lsnrctl stop [oracle@test1 dbs]$ lsnrctl start
9. 拷貝參數(shù)文件
[oracle@test1 dbs]$ scp initPROD1.ora oracle@test2:/u01/app/oracle/product/11.2.0/db_1/dbs/ oracle@test2's password: initPROD1.ora 100% 1519 1.5KB/s 00:00 [oracle@test1 dbs]$ scp initPROD1.ora oracle@test5:/u01/app/oracle/product/11.2.0/db_1/dbs/ oracle@test5's password: initPROD1.ora 100% 1519 1.5KB/s 00:00
10. 拷貝密碼文件
[oracle@test1 dbs]$ scp orapwPROD1 oracle@test2:/u01/app/oracle/product/11.2.0/db_1/dbs/ oracle@test2's password: orapwPROD1 100% 1536 1.5KB/s 00:00 [oracle@test1 dbs]$ scp orapwPROD1 oracle@test5:/u01/app/oracle/product/11.2.0/db_1/dbs/ oracle@test5's password: orapwPROD1 100% 1536 1.5KB/s 00:00
1. 修改參數(shù)文件
[oracle@test2 dbs]$ cat initPROD1.ora PROD2.__db_cache_size=419430400 PROD2.__java_pool_size=16777216 PROD2.__large_pool_size=83886080 PROD2.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment PROD2.__pga_aggregate_target=503316480 PROD2.__sga_target=721420288 PROD2.__shared_io_pool_size=0 PROD2.__shared_pool_size=184549376 PROD2.__streams_pool_size=0 *.audit_file_dest='/u01/app/oracle/admin/PROD1/adump' *.audit_trail='db' *.compatible='11.2.0.4.0' *.control_files='/u01/app/oracle/oradata/PROD1/control01.ctl','/u01/app/oracle/fast_recovery_area/PROD1/control02.ctl' *.db_block_size=8192 *.db_domain='' *.db_name='PROD1' *.db_recovery_file_dest='/home/oracle/flash' *.db_recovery_file_dest_size=4294967296 *.diagnostic_dest='/u01/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=PROD1XDB)' *.undo_tablespace='UNDOTBS1' *.processes=150 *.open_cursors=300 *.memory_target=1211105280 *.DB_UNIQUE_NAME='PROD2' *.LOG_ARCHIVE_CONFIG='DG_CONFIG=(PROD2,PROD1,PROD5)' *.LOG_ARCHIVE_DEST_1='LOCATION=/home/oracle/flash VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=PROD2' *.LOG_ARCHIVE_DEST_2='SERVICE=PROD1_1 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PROD1' *.LOG_ARCHIVE_DEST_3='SERVICE=PROD1_5 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PROD5' *.LOG_ARCHIVE_DEST_STATE_1='ENABLE' *.LOG_ARCHIVE_DEST_STATE_2='ENABLE' *.LOG_ARCHIVE_DEST_STATE_3='ENABLE' *.LOG_ARCHIVE_FORMAT='%t_%s_%r.arc' *.LOG_ARCHIVE_MAX_PROCESSES=30 *.REMOTE_LOGIN_PASSWORDFILE='EXCLUSIVE' *.FAL_CLIENT='PROD2,PROD5' *.FAL_SERVER='PROD1'
[oracle@test5 dbs]$ cat initPROD1.ora PROD5.__db_cache_size=469762048 PROD5.__java_pool_size=16777216 PROD5.__large_pool_size=33554432 PROD5.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment PROD5.__pga_aggregate_target=503316480 PROD5.__sga_target=721420288 PROD5.__shared_io_pool_size=0 PROD5.__shared_pool_size=184549376 PROD5.__streams_pool_size=0 *.audit_file_dest='/u01/app/oracle/admin/PROD1/adump' *.audit_trail='db' *.compatible='11.2.0.4.0' *.control_files='/u01/app/oracle/oradata/PROD1/control01.ctl','/u01/app/oracle/fast_recovery_area/PROD1/control02.ctl' *.db_block_size=8192 *.db_domain='' *.db_name='PROD1' *.db_recovery_file_dest='/home/oracle/flash' *.db_recovery_file_dest_size=4294967296 *.diagnostic_dest='/u01/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=PROD1XDB)' *.memory_target=1211105280 *.open_cursors=300 *.processes=150 *.remote_login_passwordfile='EXCLUSIVE' *.undo_tablespace='UNDOTBS1' DB_UNIQUE_NAME=PROD5 LOG_ARCHIVE_CONFIG='DG_CONFIG=(PROD5,PROD1,PROD2)' LOG_ARCHIVE_DEST_1= 'LOCATION=/home/oracle/flash VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=PROD5' LOG_ARCHIVE_DEST_2= 'SERVICE=PROD1_2 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PROD2' LOG_ARCHIVE_DEST_3= 'SERVICE=PROD1_1 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PROD1' LOG_ARCHIVE_DEST_STATE_1=ENABLE LOG_ARCHIVE_DEST_STATE_2=ENABLE LOG_ARCHIVE_DEST_STATE_3=ENABLE REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE LOG_ARCHIVE_FORMAT=%t_%s_%r.arc LOG_ARCHIVE_MAX_PROCESSES=30 FAL_SERVER=PROD1 FAL_CLIENT=PROD2,PROD5 STANDBY_FILE_MANAGEMENT=AUTO
2. 修改密碼文件創(chuàng)建相應(yīng)的文件目錄
根據(jù)上面修改的參數(shù)文件,為備庫創(chuàng)建相應(yīng)的文件目錄
[oracle@test2 dbs]$ mv orapwPROD1 orapwPROD2 [oracle@test2 dbs]$ mv initPROD1.ora initPROD2.ora [oracle@test2 dbs]$ mkdir -p /u01/app/oracle/admin/PROD1/adump [oracle@test2 dbs]$ mkdir -p /u01/app/oracle/oradata/PROD1 [oracle@test2 dbs]$ mkdir -p /u01/app/oracle/fast_recovery_area/PROD1 [oracle@test2 dbs]$ mkdir -p /home/oracle/flash [oracle@test5 dbs]$ mv orapwPROD1 orapwPROD5 [oracle@test5 dbs]$ mv initPROD1.ora initPROD5.ora [oracle@test5 dbs]$ mkdir -p /u01/app/oracle/admin/PROD1/adump [oracle@test5 dbs]$ mkdir -p /u01/app/oracle/oradata/PROD1 [oracle@test5 dbs]$ mkdir -p /u01/app/oracle/fast_recovery_area/PROD1 [oracle@test5 dbs]$ mkdir -p /home/oracle/flash
3. 修改監(jiān)聽配置文件
[oracle@test2 admin]$ cat listener.ora # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora # Generated by Oracle configuration tools. LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = test2.us.oracle.com)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) ) ADR_BASE_LISTENER = /u01/app/oracle SID_LIST_LISTENER= (SID_LIST= (SID_DESC= (GLOBAL_DBNAME=PROD2) (ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1) (SID_NAME=PROD2)) )
[oracle@test5 admin]$ cat listener.ora # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora # Generated by Oracle configuration tools. LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = test5.us.oracle.com)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) ) ADR_BASE_LISTENER = /u01/app/oracle SID_LIST_LISTENER= (SID_LIST= (SID_DESC= (GLOBAL_DBNAME=PROD5) (ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1) (SID_NAME=PROD5)) )
4. 修改TNS配置文件
兩備庫的TNS配置文件與主庫相同
[oracle@test2 admin]$ cat tnsnames.ora # tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora # Generated by Oracle configuration tools. PROD1_1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.2)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = PROD1) ) ) PROD1_2 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = test2.us.oracle.com)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = PROD2) ) ) PROD1_5 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = test5.us.oracle.com)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = PROD5) ) )
5. 重啟監(jiān)聽服務(wù)
[oracle@test2 dbs]$ lsnrctl stop [oracle@test2 dbs]$ lsnrctl start [oracle@test5 dbs]$ lsnrctl stop [oracle@test5 dbs]$ lsnrctl start
6. 啟動數(shù)據(jù)庫到nomonunt狀態(tài)
[oracle@test2 dbs]$ export ORACLE_SID=PROD2 [oracle@test2 dbs]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Sun Mar 3 08:04:27 2019 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to an idle instance. SQL> startup nomount; ORACLE instance started. Total System Global Area 1219260416 bytes Fixed Size 2252744 bytes Variable Size 788529208 bytes Database Buffers 419430400 bytes Redo Buffers 9048064 bytes
[oracle@test5 dbs]$ export ORACLE_SID=PROD5 [oracle@test5 dbs]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Sun Mar 3 08:04:47 2019 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to an idle instance. SQL> startup nomount; ORACLE instance started. Total System Global Area 1219260416 bytes Fixed Size 2252744 bytes Variable Size 788529208 bytes Database Buffers 419430400 bytes Redo Buffers 9048064 bytes
7. 驗證監(jiān)聽和TNS配置
主備庫上都需要驗證
[oracle@test1 dbs]$ sqlplus sys/oracle@PROD1_1 as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Sun Mar 3 05:35:15 2019 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> quit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options [oracle@test1 dbs]$ sqlplus sys/oracle@PROD1_2 as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Sun Mar 3 05:35:54 2019 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> quit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options [oracle@test1 dbs]$ sqlplus sys/oracle@PROD1_5 as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Sun Mar 3 05:36:02 2019 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> quit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
注意:該步驟一定要在主備庫上都能通過才能執(zhí)行下面步驟
[oracle@test1 ~]$ rman target sys/oracle@prod1_1 auxiliary sys/oracle@prod1_2 Recovery Manager: Release 11.2.0.4.0 - Production on Sat Mar 2 16:03:55 2019 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: PROD1 (DBID=2223201576) connected to auxiliary database: PROD1 (not mounted) RMAN> duplicate target database for standby from active database nofilenamecheck; Starting Duplicate Db at 2019-03-02 16:04:03 using target database control file instead of recovery catalog allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=10 device type=DISK contents of Memory Script: { backup as copy reuse targetfile '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwPROD1' auxiliary format '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwPROD2' ; } executing Memory Script Starting backup at 2019-03-02 16:04:03 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=144 device type=DISK Finished backup at 2019-03-02 16:04:04 contents of Memory Script: { backup as copy current controlfile for standby auxiliary format '/u01/app/oracle/oradata/PROD1/control01.ctl'; restore clone controlfile to '/u01/app/oracle/fast_recovery_area/PROD1/control02.ctl' from '/u01/app/oracle/oradata/PROD1/control01.ctl'; } executing Memory Script Starting backup at 2019-03-02 16:04:04 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile copy copying standby control file output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_PROD1.f tag=TAG20190302T160404 RECID=6 STAMP=1001865845 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03 Finished backup at 2019-03-02 16:04:08 Starting restore at 2019-03-02 16:04:08 using channel ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: copied control file copy Finished restore at 2019-03-02 16:04:09 contents of Memory Script: { sql clone 'alter database mount standby database'; } executing Memory Script sql statement: alter database mount standby database contents of Memory Script: { set newname for tempfile 1 to "/u01/app/oracle/oradata/PROD1/temp01.dbf"; switch clone tempfile all; set newname for datafile 1 to "/u01/app/oracle/oradata/PROD1/system01.dbf"; set newname for datafile 2 to "/u01/app/oracle/oradata/PROD1/sysaux01.dbf"; set newname for datafile 3 to "/u01/app/oracle/oradata/PROD1/undotbs01.dbf"; set newname for datafile 4 to "/u01/app/oracle/oradata/PROD1/users01.dbf"; set newname for datafile 5 to "/u01/app/oracle/oradata/PROD1/example01.dbf"; backup as copy reuse datafile 1 auxiliary format "/u01/app/oracle/oradata/PROD1/system01.dbf" datafile 2 auxiliary format "/u01/app/oracle/oradata/PROD1/sysaux01.dbf" datafile 3 auxiliary format "/u01/app/oracle/oradata/PROD1/undotbs01.dbf" datafile 4 auxiliary format "/u01/app/oracle/oradata/PROD1/users01.dbf" datafile 5 auxiliary format "/u01/app/oracle/oradata/PROD1/example01.dbf" ; sql 'alter system archive log current'; } executing Memory Script executing command: SET NEWNAME renamed tempfile 1 to /u01/app/oracle/oradata/PROD1/temp01.dbf in control file executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME Starting backup at 2019-03-02 16:04:14 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile copy input datafile file number=00001 name=/u01/app/oracle/oradata/PROD1/system01.dbf output file name=/u01/app/oracle/oradata/PROD1/system01.dbf tag=TAG20190302T160414 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25 channel ORA_DISK_1: starting datafile copy input datafile file number=00002 name=/u01/app/oracle/oradata/PROD1/sysaux01.dbf output file name=/u01/app/oracle/oradata/PROD1/sysaux01.dbf tag=TAG20190302T160414 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15 channel ORA_DISK_1: starting datafile copy input datafile file number=00005 name=/u01/app/oracle/oradata/PROD1/example01.dbf output file name=/u01/app/oracle/oradata/PROD1/example01.dbf tag=TAG20190302T160414 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15 channel ORA_DISK_1: starting datafile copy input datafile file number=00003 name=/u01/app/oracle/oradata/PROD1/undotbs01.dbf output file name=/u01/app/oracle/oradata/PROD1/undotbs01.dbf tag=TAG20190302T160414 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03 channel ORA_DISK_1: starting datafile copy input datafile file number=00004 name=/u01/app/oracle/oradata/PROD1/users01.dbf output file name=/u01/app/oracle/oradata/PROD1/users01.dbf tag=TAG20190302T160414 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01 Finished backup at 2019-03-02 16:05:14 sql statement: alter system archive log current contents of Memory Script: { switch clone datafile all; } executing Memory Script datafile 1 switched to datafile copy input datafile copy RECID=6 STAMP=1001878035 file name=/u01/app/oracle/oradata/PROD1/system01.dbf datafile 2 switched to datafile copy input datafile copy RECID=7 STAMP=1001878035 file name=/u01/app/oracle/oradata/PROD1/sysaux01.dbf datafile 3 switched to datafile copy input datafile copy RECID=8 STAMP=1001878035 file name=/u01/app/oracle/oradata/PROD1/undotbs01.dbf datafile 4 switched to datafile copy input datafile copy RECID=9 STAMP=1001878035 file name=/u01/app/oracle/oradata/PROD1/users01.dbf datafile 5 switched to datafile copy input datafile copy RECID=10 STAMP=1001878035 file name=/u01/app/oracle/oradata/PROD1/example01.dbf Finished Duplicate Db at 2019-03-02 16:05:21
[oracle@test1 ~]$ rman target sys/oracle@prod1_1 auxiliary sys/oracle@prod1_5 Recovery Manager: Release 11.2.0.4.0 - Production on Sat Mar 2 16:05:39 2019 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: PROD1 (DBID=2223201576) connected to auxiliary database: PROD1 (not mounted) RMAN> duplicate target database for standby from active database nofilenamecheck; Starting Duplicate Db at 2019-03-02 16:05:42 using target database control file instead of recovery catalog allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=10 device type=DISK contents of Memory Script: { backup as copy reuse targetfile '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwPROD1' auxiliary format '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwPROD5' ; } executing Memory Script Starting backup at 2019-03-02 16:05:42 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=125 device type=DISK Finished backup at 2019-03-02 16:05:43 contents of Memory Script: { backup as copy current controlfile for standby auxiliary format '/u01/app/oracle/oradata/PROD1/control01.ctl'; restore clone controlfile to '/u01/app/oracle/fast_recovery_area/PROD1/control02.ctl' from '/u01/app/oracle/oradata/PROD1/control01.ctl'; } executing Memory Script Starting backup at 2019-03-02 16:05:43 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile copy copying standby control file output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_PROD1.f tag=TAG20190302T160543 RECID=7 STAMP=1001865944 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01 Finished backup at 2019-03-02 16:05:44 Starting restore at 2019-03-02 16:05:44 using channel ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: copied control file copy Finished restore at 2019-03-02 16:05:46 contents of Memory Script: { sql clone 'alter database mount standby database'; } executing Memory Script sql statement: alter database mount standby database contents of Memory Script: { set newname for tempfile 1 to "/u01/app/oracle/oradata/PROD1/temp01.dbf"; switch clone tempfile all; set newname for datafile 1 to "/u01/app/oracle/oradata/PROD1/system01.dbf"; set newname for datafile 2 to "/u01/app/oracle/oradata/PROD1/sysaux01.dbf"; set newname for datafile 3 to "/u01/app/oracle/oradata/PROD1/undotbs01.dbf"; set newname for datafile 4 to "/u01/app/oracle/oradata/PROD1/users01.dbf"; set newname for datafile 5 to "/u01/app/oracle/oradata/PROD1/example01.dbf"; backup as copy reuse datafile 1 auxiliary format "/u01/app/oracle/oradata/PROD1/system01.dbf" datafile 2 auxiliary format "/u01/app/oracle/oradata/PROD1/sysaux01.dbf" datafile 3 auxiliary format "/u01/app/oracle/oradata/PROD1/undotbs01.dbf" datafile 4 auxiliary format "/u01/app/oracle/oradata/PROD1/users01.dbf" datafile 5 auxiliary format "/u01/app/oracle/oradata/PROD1/example01.dbf" ; sql 'alter system archive log current'; } executing Memory Script executing command: SET NEWNAME renamed tempfile 1 to /u01/app/oracle/oradata/PROD1/temp01.dbf in control file executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME Starting backup at 2019-03-02 16:05:51 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile copy input datafile file number=00001 name=/u01/app/oracle/oradata/PROD1/system01.dbf output file name=/u01/app/oracle/oradata/PROD1/system01.dbf tag=TAG20190302T160551 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25 channel ORA_DISK_1: starting datafile copy input datafile file number=00002 name=/u01/app/oracle/oradata/PROD1/sysaux01.dbf output file name=/u01/app/oracle/oradata/PROD1/sysaux01.dbf tag=TAG20190302T160551 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15 channel ORA_DISK_1: starting datafile copy input datafile file number=00005 name=/u01/app/oracle/oradata/PROD1/example01.dbf output file name=/u01/app/oracle/oradata/PROD1/example01.dbf tag=TAG20190302T160551 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15 channel ORA_DISK_1: starting datafile copy input datafile file number=00003 name=/u01/app/oracle/oradata/PROD1/undotbs01.dbf output file name=/u01/app/oracle/oradata/PROD1/undotbs01.dbf tag=TAG20190302T160551 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03 channel ORA_DISK_1: starting datafile copy input datafile file number=00004 name=/u01/app/oracle/oradata/PROD1/users01.dbf output file name=/u01/app/oracle/oradata/PROD1/users01.dbf tag=TAG20190302T160551 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01 Finished backup at 2019-03-02 16:06:50 sql statement: alter system archive log current contents of Memory Script: { switch clone datafile all; } executing Memory Script datafile 1 switched to datafile copy input datafile copy RECID=7 STAMP=1001878132 file name=/u01/app/oracle/oradata/PROD1/system01.dbf datafile 2 switched to datafile copy input datafile copy RECID=8 STAMP=1001878132 file name=/u01/app/oracle/oradata/PROD1/sysaux01.dbf datafile 3 switched to datafile copy input datafile copy RECID=9 STAMP=1001878132 file name=/u01/app/oracle/oradata/PROD1/undotbs01.dbf datafile 4 switched to datafile copy input datafile copy RECID=10 STAMP=1001878132 file name=/u01/app/oracle/oradata/PROD1/users01.dbf datafile 5 switched to datafile copy input datafile copy RECID=11 STAMP=1001878132 file name=/u01/app/oracle/oradata/PROD1/example01.dbf Finished Duplicate Db at 2019-03-02 16:06:58
test2&test5: SQL> alter database open; Database altered. SQL> recover managed standby database using current logfile disconnect from session; Media recovery complete.
test2&test5: SQL> alter database recover managed standby database cancel; Database altered. SQL> shutdown immediate ; Database closed. Database dismounted. ORACLE instance shut down. SQL> startup mount ; ORACLE instance started. Total System Global Area 1219260416 bytes Fixed Size 2252744 bytes Variable Size 788529208 bytes Database Buffers 419430400 bytes Redo Buffers 9048064 bytes Database mounted. SQL> alter database flashback on; Database altered. SQL> alter database open; Database altered. SQL> alter database recover managed standby database using current logfile disconnect from session; Database altered.
上面已經(jīng)把Data Gurad搭建完,下面介紹如何驗證Data Guard是否能實時同步:
1. 通過查看archive_log_dest_2、archive_log_dest_3列是否有error報錯,如果有報錯,則需要先根據(jù)報錯內(nèi)容解決問題:
test1: SQL> set linesize 150 SQL> col dest_name format a30 SQL> col error format a20 SQL> select dest_name,error from v$archive_dest; DEST_NAME ERROR ------------------------------ -------------------- LOG_ARCHIVE_DEST_1 LOG_ARCHIVE_DEST_2 LOG_ARCHIVE_DEST_3 LOG_ARCHIVE_DEST_4 LOG_ARCHIVE_DEST_5 LOG_ARCHIVE_DEST_6 LOG_ARCHIVE_DEST_7 LOG_ARCHIVE_DEST_8 LOG_ARCHIVE_DEST_9 LOG_ARCHIVE_DEST_10 LOG_ARCHIVE_DEST_11 DEST_NAME ERROR ------------------------------ -------------------- LOG_ARCHIVE_DEST_12 LOG_ARCHIVE_DEST_13 LOG_ARCHIVE_DEST_14 LOG_ARCHIVE_DEST_15 LOG_ARCHIVE_DEST_16 LOG_ARCHIVE_DEST_17 LOG_ARCHIVE_DEST_18 LOG_ARCHIVE_DEST_19 LOG_ARCHIVE_DEST_20 LOG_ARCHIVE_DEST_21 LOG_ARCHIVE_DEST_22 DEST_NAME ERROR ------------------------------ -------------------- LOG_ARCHIVE_DEST_23 LOG_ARCHIVE_DEST_24 LOG_ARCHIVE_DEST_25 LOG_ARCHIVE_DEST_26 LOG_ARCHIVE_DEST_27 LOG_ARCHIVE_DEST_28 LOG_ARCHIVE_DEST_29 LOG_ARCHIVE_DEST_30 LOG_ARCHIVE_DEST_31 31 rows selected.
注意:上面顯示沒有報錯
2. 查詢主庫最大歸檔序號,一致即歸檔同步成功。
test1: SQL> select max(sequence#) from v$archived_log; MAX(SEQUENCE#) -------------- 26 test2&test5: SQL> select max(sequence#) from v$archived_log; MAX(SEQUENCE#) -------------- 26 test1: SQL> alter system archive log current; System altered. SQL> select max(sequence#) from v$archived_log; MAX(SEQUENCE#) -------------- 27 test2&test5: SQL> select max(sequence#) from v$archived_log; MAX(SEQUENCE#) -------------- 27
3. 查看主備庫狀態(tài)
test1: SQL> select open_mode,database_role,switchover_status from v$database; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS ---------------- ----------------- -------------------- READ WRITE PRIMARY TO STANDBY test2&test5: SQL> select open_mode,database_role,switchover_status from v$database; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS ------------------------ -------------------- --------------- READ ONLY WITH APPLY PHYSICAL STANDBY NOT ALLOWED
4. 在test1上創(chuàng)建一個table測試
test1: SQL> create table dg(id number); Table created. SQL> insert into dg values(1); 1 row created. SQL> commit; Commit complete. SQL> select * from dg; ID ---------- 1 test2&test5: SQL> select * from dg; ID ---------- 1
我們配置DG的目的就是為了在主庫出現(xiàn)故障時,備庫能夠提供服務(wù),保證業(yè)務(wù)的正常運行。DG的故障切換分為switchover和failover兩種:
switchover是用戶有計劃的進行停機切換,能夠保證不丟失數(shù)據(jù)。以下是具體操作:
1. switchover1
SQL> select open_mode,database_role,switchover_status from v$database; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS -------------------- --------------------- --------------------- READ WRITE PRIMARY SESSIONS ACTIVE
注意:上面查詢結(jié)果為TO STANDBY 或 SESSIONS ACTIVE表明可以進行切換
SQL> alter database commit to switchover to physical standby; Database altered. SQL> conn / as sysdba; Connected to an idle instance. SQL> startup ORACLE instance started. Total System Global Area 1219260416 bytes Fixed Size 2252744 bytes Variable Size 939524152 bytes Database Buffers 268435456 bytes Redo Buffers 9048064 bytes Database mounted. Database opened. SQL> set linesize 150 SQL> select open_mode,database_role,switchover_status from v$database; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS --------------------- ------------------------ -------------------- READ ONLY PHYSICAL STANDBY TO PRIMARY test5: SQL> recover managed standby database cancel; Media recovery complete. SQL> select open_mode,database_role,switchover_status from v$database; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS -------------------- ------------------------- -------------------- READ ONLY PHYSICAL STANDBY TO PRIMARY SQL> alter database commit to switchover to primary; Database altered. SQL> select open_mode,database_role,switchover_status from v$database; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS -------------------- --------------------- -------------------- MOUNTED PRIMARY NOT ALLOWED SQL> alter database open; Database altered. SQL> insert into t1 values (1); 1 row created. SQL> commit; Commit complete. SQL> select * from t1; ID ---------- 1 test1: SQL> select * from t1; no rows selected SQL> recover managed standby database using current logfile disconnect from session; Media recovery complete. SQL> select * from t1; ID ---------- 1 test2: SQL> recover managed standby database cancel; Media recovery complete. SQL> select open_mode,database_role,switchover_status from v$database; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS -------------------- ------------------------- -------------------- READ ONLY PHYSICAL STANDBY TO PRIMARY SQL> recover managed standby database using current logfile disconnect from session; Media recovery complete. SQL> select * from t1; ID ---------- 1 1. switchover1 test5: SQL> alter database commit to switchover to physical standby; Database altered. SQL> conn / as sysdba; Connected to an idle instance. SQL> startup ORACLE instance started. Total System Global Area 1219260416 bytes Fixed Size 2252744 bytes Variable Size 788529208 bytes Database Buffers 419430400 bytes Redo Buffers 9048064 bytes Database mounted. Database opened. SQL> select open_mode,database_role,switchover_status from v$database; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS -------------------- ------------------------- ------------------ READ ONLY PHYSICAL STANDBY TO PRIMARY test2: SQL> recover managed standby database cancel; Media recovery complete. SQL> select open_mode,database_role,switchover_status from v$database; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS -------------------- ------------------------- ------------------- READ ONLY PHYSICAL STANDBY TO PRIMARY SQL> alter database commit to switchover to primary; Database altered. SQL> select open_mode,database_role,switchover_status from v$database; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS --------------------- -------------------- ------------------- MOUNTED PRIMARY NOT ALLOWED SQL> alter database open; Database altered. SQL> insert into t1 values (2); 1 row created. SQL> commit; Commit complete. SQL> select * from t1; ID ---------- 1 2 test5: SQL> select * from t1; ID ---------- 1 SQL> recover managed standby database using current logfile disconnect from session; Media recovery complete. SQL> select * from t1; ID ---------- 1 2 SQL> select open_mode,database_role,switchover_status from v$database; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS ------------------------ ------------------------- -------------------- READ ONLY WITH APPLY PHYSICAL STANDBY NOT ALLOWED test1: SQL> recover managed standby database cancel; Media recovery complete. SQL> select open_mode,database_role,switchover_status from v$database; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS -------------------- ------------------------- ------------------- READ ONLY PHYSICAL STANDBY TO PRIMARY SQL> select * from t1; ID ---------- 1 SQL> recover managed standby database using current logfile disconnect from session; Media recovery complete. SQL> select * from t1; ID ---------- 1 2 SQL> select open_mode,database_role,switchover_status from v$database; OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS ------------------------ ------------------------- ------------------- READ ONLY WITH APPLY PHYSICAL STANDBY NOT ALLOWED
到此DG switover切換完成,驗證方法同上。
到此DG switover切換完成,驗證方法同上。
failover是當(dāng)主庫真正出現(xiàn)嚴重系統(tǒng)故障,如數(shù)據(jù)庫宕機,軟硬件故障導(dǎo)致主庫不能支持服務(wù),從而進行的切換動作。
注意:為了能夠在failover后能夠恢復(fù)DG,需要在主庫上開啟flashback,如果不開啟flashback的話,DG就可能需要重新搭建。
由于主庫已經(jīng)不可訪問,下面所有的操作都在備庫完成:
上面提到了failover,這種情形是當(dāng)主庫真正出現(xiàn)異常之后,才會執(zhí)行的操作,那么我們執(zhí)行過failover 之后,如何再重新構(gòu)建DG,這里我們利用flashback database來重構(gòu),具體方法如下:
到此,關(guān)于“Oracle Data Guard部署方法是什么”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注億速云網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。