openPower伺服器搭建Oracle 19c adg
建立使用者與組
建立組(在各個主機上執行)
mkgroup -'A' id='501' adms='root' oinstall mkgroup -'A' id='502' adms='root' asmdba mkgroup -'A' id='503' adms='root' asmoper mkgroup -'A' id='504' adms='root' dba mkgroup -'A' id='505' adms='root' oper mkgroup -'A' id='506' adms='root' backdba mkgroup -'A' id='507' adms='root' dgdba mkgroup -'A' id='508' adms='root' racdba mkgroup -'A' id='509' adms='root' kmdba
建立使用者(在各個主機上執行)
mkuser id=601 pgrp=oinstall groups=dba,asmdba,oper,asmoper,backdba,dgdba,racdba,kmdba home=/home/oracle oracle
建立安裝目錄
mkdir -p /u01/app/oraInventory mkdir -p /u01/app/oracle/product/19.3/db mkdir -p /u01/temp chown -R oracle:oinstall /u01 chmod -R 775 /u01
設定使用者環境變數(用oracle使用者來編輯.profile)
umask 022 export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=/u01/app/oracle/product/19.3/db export ORACLE_SID=hxsy export ORACLE_UNQNAME=hxsy export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK export NLS_DATE_FORMAT="yyyy-mm-dd hh24:mi:ss" export PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin export PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin export PATH=${PATH}:$ORACLE_BASE/common/oracle/bin export ORACLE_PATH=${PATH}:$ORACLE_BASE/common/oracle/sql:.:$ORACLE_HOME/rdbms/admin export ORACLE_TERM=xterm export TNS_ADMIN=$ORACLE_HOME/network/admin export LD_LIBRARY_PATH=$ORACLE_HOME/lib export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib export CLASSPATH=$ORACLE_HOME/JRE export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib export THREADS_FLAG=native export TEMP=/u01/tmp export TMPDIR=/u01/tmp export PS1=`hostname`:'$PWD'"$"
使用如下命令檢視虛擬記憶體管理引數
vmo -L minperm% vmo -L maxperm% vmo -L maxclient% vmo -L lru_file_repage vmo -L strict_maxclient vmo -L strict_maxperm
如果設定不合適,使用如下命令修改:
vmo -p -o minperm%=3 vmo -p -o maxperm%=90 vmo -p -o maxclient%=90 vmo -p -o lru_file_repage=0 vmo -p -o strict_maxclient=1 vmo -p -o strict_maxperm=0
檢查網路引數設定
ephemeral引數:
使用命令no -a |fgrep ephemeral可以檢視當前系統ephemeral引數設定,建議的引數設定如下
tcp_ephemeral_high = 65500 tcp_ephemeral_low = 9000 udp_ephemeral_high= 65500 udp_ephemeral_low = 9000
如果系統中引數設定和上述值不一樣,使用命令修改:
#no -p -o tcp_ephemeral_low=9000 -o tcp_ephemeral_high=65500 #no -p -o udp_ephemeral_low=9000 -o udp_ephemeral_high=65500
使用如下命令修改網路可調整引數:
#no -p -o rfc1323=1 #no -r -o ipqmaxlen=512 #no -p -o ipqmaxlen=512 #no -p -o sb_max=4194304 #no -p -o tcp_recvspace=65536 #no -p -o tcp_sendspace=65536 #no -p -o udp_recvspace=1351680 該值是udp_sendspace的10倍,但須小於sb_max #no -p -o udp_sendspace=135168
備註:-r表示reboot後生效,-p表示即刻生效.
檢查核心引數maxuproc(建議16384)和ncargs(至少128)
#lsattr -E -l sys0 -a ncargs #lsattr -E -l sys0 -a maxuproc
如果設定不合適使用如下命令修改:
#chdev -l sys0 -a ncargs=256 #chdev -l sys0 -a maxuproc=16384
解壓資料庫軟體
aix1:/u01/soft$unzip -q AIX.PPC64_193000_db_home.zip -d $ORACLE_HOME
安裝資料庫軟體
在$ORACLE_HOME/install/response目錄中有一個安裝rsp檔案示例
配置響應檔案
[oracle@ora19c ~]$ vi 19c_dbinstall.rsp oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v19.0.0 oracle.install.option=INSTALL_DB_SWONLY UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/u01/app/oraInventory ORACLE_BASE=/u01/app/oracle ORACLE_HOME=/u01/app/oracle/product/19.3/db oracle.install.db.InstallEdition=EE oracle.install.db.OSDBA_GROUP=dba oracle.install.db.OSOPER_GROUP=oper oracle.install.db.OSBACKUPDBA_GROUP=backdba oracle.install.db.OSDGDBA_GROUP=dgdba oracle.install.db.OSKMDBA_GROUP=kmdba oracle.install.db.OSRACDBA_GROUP=racdba oracle.install.db.rootconfig.executeRootScript=true oracle.install.db.rootconfig.configMethod=ROOT
執行安裝
openaix1:/home/oracle$$ORACLE_HOME/runInstaller -silent -force -noconfig -ignorePrereq -responseFile /home/oracle/19c_dbinstall.rsp ******************************************************************************** Your platform requires the root user to perform certain pre-installation OS preparation. The root user should run the shell script 'rootpre.sh' before you proceed with Oracle installation. The rootpre.sh script can be found at: /u01/app/oracle/product/19.3/db/clone/rootpre.sh Answer 'y' if root has run 'rootpre.sh' so you can proceed with Oracle installation. Answer 'n' to abort installation and then ask root to run 'rootpre.sh'. ******************************************************************************** Has 'rootpre.sh' been run by root in this machine? [y/n] (n) y Launching Oracle Database Setup Wizard... Enter password for 'root' user: [WARNING] [INS-13014] Target environment does not meet some optional requirements. CAUSE: Some of the optional prerequisites are not met. See logs for details. installActions2020-11-17_01-49-09AM.log ACTION: Identify the list of failed prerequisite checks from the log: installActions2020-11-17_01-49-09AM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually. The response file for this session can be found at: /u01/app/oracle/product/19.3/db/install/response/db_2020-11-17_01-49-09AM.rsp You can find the log of this install session at: /u01/tmp/InstallActions2020-11-17_01-49-09AM/installActions2020-11-17_01-49-09AM.log Successfully Setup Software with warning(s). Moved the install session logs to: /u01/app/oraInventory/logs/InstallActions2020-11-17_01-49-09AM
配置監聽
建立配置監聽的響應檔案
在/u01/app/oracle/product/19.3/db/assistants/netca/目錄有一個示例檔案
aix1:/home/oracle$vi 19c_netca.rsp "19c_netca.rsp" [New file] [GENERAL] RESPONSEFILE_VERSION="19.0" CREATE_TYPE="CUSTOM" [oracle.net.ca] INSTALLED_COMPONENTS={"server","net8","javavm"} INSTALL_TYPE=""typical"" LISTENER_NUMBER=1 LISTENER_NAMES={"LISTENER"} LISTENER_PROTOCOLS={"TCP;1521"} LISTENER_START=""LISTENER"" NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"} NSN_NUMBER=1 NSN_NAMES={"EXTPROC_CONNECTION_DATA"} NSN_SERVICE={"PLSExtProc"} NSN_PROTOCOLS={"TCP;HOSTNAME;1521"} aix1:/home/oracle$netca /silent /responsefile /home/oracle/19c_netca.rsp UnsatisfiedLinkError exception loading native library: njni19 java.lang.UnsatisfiedLinkError: njni19 (Not found in java.library.path) java.lang.UnsatisfiedLinkError: oracle/net/common/NetGetEnv.jniGetOracleHome()Ljava/lang/String; at oracle.net.common.NetGetEnv.getOracleHome(Unknown Source) at oracle.net.ca.NetCALogger.getOracleHome(NetCALogger.java:230) at oracle.net.ca.NetCALogger.initOracleParameters(NetCALogger.java:215) at oracle.net.ca.NetCALogger.initLogger(NetCALogger.java:130) at oracle.net.ca.NetCA.main(NetCA.java:459) Error: oracle/net/common/NetGetEnv.jniGetOracleHome()Ljava/lang/String; Oracle Net Services configuration failed. The exit code is 1 # lsdev | grep iocp iocp0 Defined I/O Completion Ports # smitty iocp # lsdev | grep iocp iocp0 Available I/O Completion Ports aix1:/home/oracle$$ORACLE_HOME/bin/relink all writing relink log to: /u01/app/oracle/product/19.3/db/install/relinkActions2020-11-16_11-17-27PM.log aix1:/home/oracle$netca /silent /responsefile /home/oracle/19c_netca.rsp Parsing command line arguments: Parameter "silent" = true Parameter "responsefile" = /home/oracle/19c_netca.rsp Done parsing command line arguments. Oracle Net Services Configuration: Profile configuration complete. Oracle Net Listener Startup: Running Listener Control: /u01/app/oracle/product/19.3/db/bin/lsnrctl start LISTENER Listener Control complete. Listener started successfully. Listener configuration complete. Oracle Net Services configuration successful. The exit code is 0 aix1:/home/oracle$lsnrctl status LSNRCTL for IBM/AIX RISC System/6000: Version 19.0.0.0.0 - Production on 16-NOV-2020 23:24:53 Copyright (c) 1991, 2019, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=aix1)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for IBM/AIX RISC System/6000: Version 19.0.0.0.0 - Production Start Date 16-NOV-2020 23:23:28 Uptime 0 days 0 hr. 1 min. 27 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/19.3/db/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/aix1/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=aix1)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) The listener supports no services The command completed successfully
建立資料庫
建立配置資料庫的響應檔案
在/u01/app/oracle/product/19.3/db/assistants/dbca/目錄中有一個示例檔案
[oracle@ora19c install]$ cat /u01/app/oracle/product/19.3/db/assistants/dbca/dbca.rsp aix1:/home/oracle$vi 19c_dbca.rsp automaticMemoryManagement=TRUE responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v19.0.0 templateName=General_Purpose.dbc gdbName=hxsy sid=hxsy databaseConfigType=SI createAsContainerDatabase=TRUE numberOfPDBs=1 pdbName=hxsy1 useLocalUndoForPDBs=TRUE pdbAdminPassword=hxsy_123456 sysPassword=hxsy_123456 systemPassword=hxsy_123456 storageType=FS characterSet=ZHS16GBK nationalCharacterSet=AL16UTF16 listeners=LISTENER sampleSchema=TRUE totalMemory 2048 databaseType=MULTIPURPOSE automaticMemoryManagement=FALSE totalMemory=4096
建立資料庫
aix1:/home/oracle$dbca -silent -createDatabase -responseFile /home/oracle/19c_dbca.rsp [WARNING] [DBT-06208] The 'SYS' password entered does not conform to the Oracle recommended standards. CAUSE: a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. b.The password entered is a keyword that Oracle does not recommend to be used as password ACTION: Specify a strong password. If required refer Oracle documentation for guidelines. [WARNING] [DBT-06208] The 'SYSTEM' password entered does not conform to the Oracle recommended standards. CAUSE: a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. b.The password entered is a keyword that Oracle does not recommend to be used as password ACTION: Specify a strong password. If required refer Oracle documentation for guidelines. [WARNING] [DBT-06208] The 'PDBADMIN' password entered does not conform to the Oracle recommended standards. CAUSE: a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. b.The password entered is a keyword that Oracle does not recommend to be used as password ACTION: Specify a strong password. If required refer Oracle documentation for guidelines. Prepare for db operation 8% complete Copying database files 31% complete Creating and starting Oracle instance 32% complete 36% complete 40% complete 43% complete 46% complete Completing Database Creation 51% complete 53% complete 54% complete Creating Pluggable Databases 58% complete 77% complete Executing Post Configuration Actions 100% complete Database creation complete. For details check the logfiles at: /u01/app/oracle/cfgtoollogs/dbca/hxsy. Database Information: Global Database Name:hxsy System Identifier(SID):hxsy Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/hxsy/hxsy.log" for further details.
給主庫配置歸檔
SQL> archive log list Database log mode No Archive Mode Automatic archival Disabled Archive destination /u01/app/oracle/product/19.3/db/dbs/arch Oldest online log sequence 5 Current log sequence 7 SQL> alter system set log_archive_dest_1='location=/u01/app/oracle/arch' scope=both sid='*'; System altered. SQL> show parameter log_archive_for NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ log_archive_format string %t_%s_%r.dbf SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. aix1:/u01/app/oracle/product/19.3/db/dbs$sqlplus / as sysdba SQL*Plus: Release 19.0.0.0.0 - Production on Mon Nov 16 16:32:33 2020 Version 19.3.0.0.0 Copyright (c) 1982, 2019, Oracle. All rights reserved. Connected to an idle instance. SQL> startup mount ORACLE instance started. Total System Global Area 3221222936 bytes Fixed Size 9303576 bytes Variable Size 956301312 bytes Database Buffers 2231369728 bytes Redo Buffers 24248320 bytes Database mounted. SQL> alter database archivelog; Database altered. SQL> alter database open; Database altered. SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 HXSY1 MOUNTED SQL> alter pluggable database hxsy1 open; Pluggable database altered. SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 HXSY1 READ WRITE NO
這裡主庫已經啟用了歸檔
啟用force logging
SQL> alter database force logging; Database altered. SQL> select force_logging from v$database; FORCE_LOGGING --------------------------------------- YES
給備庫建立密碼檔案
這裡透過複製主庫的密碼檔案來建立備庫密碼檔案
openaix1:/u01/app/oracle/product/19.3/db/dbs$scp oracle@aix1:/u01/app/oracle/product/19.3/db/dbs/orapwhxsy /u01/app/oracle/product/19.3/db/dbs/ oracle@aix1's password: orapwhxsy 100% 2048 199.4KB/s 00:00 openaix1:/u01/app/oracle/product/19.3/db/dbs$ls -lrt total 16 -rw-r--r-- 1 oracle oinstall 3079 May 16 2015 init.ora -rw-r----- 1 oracle oinstall 2048 Nov 17 16:40 orapwhxsy
給備庫建立引數檔案
使用主庫的引數檔案進行建立
SQL> create pfile from spfile; File created. aix1:/u01/app/oracle/product/19.3/db/dbs$cat inithxsy.ora *.audit_file_dest='/u01/app/oracle/admin/hxsy/adump' *.audit_trail='db' *.compatible='19.0.0' *.control_files='/u01/app/oracle/oradata/HXSY_DG/control01.ctl','/u01/app/oracle/oradata/HXSY_DG/control02.ctl' *.db_block_size=8192 *.db_name='hxsy' *.db_unique_name='hxsy_dg' *.diagnostic_dest='/u01/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=hxsyXDB)' *.enable_pluggable_database=true *.local_listener='LISTENER_HXSY' *.log_archive_dest_1='location=/u01/app/oracle/arch valid_for=(ALL_LOGFILES,ALL_ROLES) db_unique_name=hxsy_dg' *.log_archive_dest_2='service=hxsy LGWR ASYNC valid_for=(online_logfiles,primary_role) db_unique_name=hxsy' *.log_archive_config='DG_CONFIG=(hxsy,hxsy_dg)' *.nls_language='AMERICAN' *.nls_territory='AMERICA' *.open_cursors=300 *.pga_aggregate_target=1024m *.processes=2560 *.remote_login_passwordfile='EXCLUSIVE' *.sga_target=3072m *.undo_tablespace='UNDOTBS1' --備庫以備庫角色執行時需要設定的引數 *.db_file_name_convert='/u01/app/oracle/oradata/HXSY','/u01/app/oracle/oradata/HXSY_DG' *.fal_client='hxsy_dg' *.fal_server='hxsy' *.log_file_name_convert='/u01/app/oracle/oradata/HXSY','/u01/app/oracle/oradata/HXSY_DG' *.standby_file_management='auto'
在備庫主機上建立引數檔案
openaix1:/u01/app/oracle/product/19.3/db/dbs$vi inithxsy.ora "inithxsy.ora" [New file] *.audit_file_dest='/u01/app/oracle/admin/hxsy/adump' *.audit_trail='db' *.compatible='19.0.0' *.control_files='/u01/app/oracle/oradata/HXSY_DG/control01.ctl','/u01/app/oracle/oradata/HXSY_DG/control02.ctl' *.db_block_size=8192 *.db_name='hxsy' *.db_unique_name='hxsy_dg' *.diagnostic_dest='/u01/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=hxsyXDB)' *.enable_pluggable_database=true *.local_listener='LISTENER_HXSY' *.log_archive_dest_1='location=/u01/app/oracle/arch valid_for=(ALL_LOGFILES,ALL_ROLES) db_unique_name=hxsy_dg' *.log_archive_dest_2='service=hxsy LGWR ASYNC valid_for=(online_logfiles,primary_role) db_unique_name=hxsy' *.log_archive_config='DG_CONFIG=(hxsy,hxsy_dg)' *.nls_language='AMERICAN' *.nls_territory='AMERICA' *.open_cursors=300 *.pga_aggregate_target=1024m *.processes=2560 *.remote_login_passwordfile='EXCLUSIVE' *.sga_target=3072m *.undo_tablespace='UNDOTBS1' *.db_file_name_convert='/u01/app/oracle/oradata/HXSY','/u01/app/oracle/oradata/HXSY_DG' *.fal_client='hxsy_dg' *.fal_server='hxsy' *.log_file_name_convert='/u01/app/oracle/oradata/HXSY','/u01/app/oracle/oradata/HXSY_DG' *.standby_file_management='auto'
為主庫和備庫配置監聽
主庫
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = hxsy) (ORACLE_HOME =/u01/app/oracle/product/19.3/db) (GLOBAL_DBNAME=hxsy) ) )
備庫
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = hxsy) (ORACLE_HOME =/u01/app/oracle/product/19.3/db) (GLOBAL_DBNAME=hxsy_dg) ) )
重啟主庫和備庫的監聽
主庫:
aix1:/u01/app/oracle/product/19.3/db/network/admin$lsnrctl status LSNRCTL for IBM/AIX RISC System/6000: Version 19.0.0.0.0 - Production on 16-NOV-2020 16:58:45 Copyright (c) 1991, 2019, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=aix1)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for IBM/AIX RISC System/6000: Version 19.0.0.0.0 - Production Start Date 16-NOV-2020 16:58:06 Uptime 0 days 0 hr. 0 min. 39 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/19.3/db/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/aix1/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=aix1)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Services Summary... Service "hxsy" has 1 instance(s). Instance "hxsy", status UNKNOWN, has 1 handler(s) for this service... The command completed successfully
備庫:
openaix1:/home/oracle$lsnrctl start LSNRCTL for IBM/AIX RISC System/6000: Version 19.0.0.0.0 - Production on 17-NOV-2020 17:01:03 Copyright (c) 1991, 2019, Oracle. All rights reserved. Starting /u01/app/oracle/product/19.3/db/bin/tnslsnr: please wait... TNSLSNR for IBM/AIX RISC System/6000: Version 19.0.0.0.0 - Production System parameter file is /u01/app/oracle/product/19.3/db/network/admin/listener.ora Log messages written to /u01/app/oracle/diag/tnslsnr/openaix1/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=openaix1)(PORT=1521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=openaix1)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for IBM/AIX RISC System/6000: Version 19.0.0.0.0 - Production Start Date 17-NOV-2020 17:01:04 Uptime 0 days 0 hr. 0 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/19.3/db/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/openaix1/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=openaix1)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Services Summary... Service "hxsy_dg" has 1 instance(s). Instance "hxsy", status UNKNOWN, has 1 handler(s) for this service... The command completed successfully
為主庫和備庫建立Oracle Net服務名
主庫:
HXSY = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.24.117)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = hxsy) ) ) HXSY_DG = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.24.116)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = hxsy_dg) (UR=A) ) )
備庫:
使用備份建立備庫
openaix1:/u01/app/oracle/oradata$sqlplus / as sysdba SQL*Plus: Release 19.0.0.0.0 - Production on Tue Nov 17 17:07:09 2020 Version 19.3.0.0.0 Copyright (c) 1982, 2019, Oracle. All rights reserved. Connected to an idle instance. SQL> startup nomount ORACLE instance started. Total System Global Area 3221222936 bytes Fixed Size 9242136 bytes Variable Size 754974720 bytes Database Buffers 2449473536 bytes Redo Buffers 7532544 bytes aix1:/u01/app/oracle/product/19.3/db/dbs$rman target sys/hxsy_123456@hxsy auxiliary sys/hxsy_123456@hxsy_dg Recovery Manager: Release 19.0.0.0.0 - Production on Mon Nov 16 17:23:03 2020 Version 19.3.0.0.0 Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved. connected to target database: HXSY (DBID=1728588152) connected to auxiliary database: HXSY (not mounted) RMAN> duplicate target database for standby from active database nofilenamecheck; Starting Duplicate Db at 2020-11-16 17:23:12 using target database control file instead of recovery catalog allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=2420 device type=DISK contents of Memory Script: { backup as copy reuse passwordfile auxiliary format '/u01/app/oracle/product/19.3/db/dbs/orapwhxsy' ; } executing Memory Script Starting backup at 2020-11-16 17:23:14 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=2908 device type=DISK Finished backup at 2020-11-16 17:23:16 contents of Memory Script: { restore clone from service 'hxsy' standby controlfile; } executing Memory Script Starting restore at 2020-11-16 17:23:16 using channel ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: using network backup set from service hxsy channel ORA_AUX_DISK_1: restoring control file channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04 output file name=/u01/app/oracle/oradata/HXSY_DG/control01.ctl output file name=/u01/app/oracle/oradata/HXSY_DG/control02.ctl Finished restore at 2020-11-16 17:23:22 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/HXSY_DG/temp01.dbf"; set newname for tempfile 2 to "/u01/app/oracle/oradata/HXSY_DG/pdbseed/temp012020-11-17_00-11-36-085-AM.dbf"; set newname for tempfile 3 to "/u01/app/oracle/oradata/HXSY_DG/hxsy1/temp01.dbf"; switch clone tempfile all; set newname for datafile 1 to "/u01/app/oracle/oradata/HXSY_DG/system01.dbf"; set newname for datafile 3 to "/u01/app/oracle/oradata/HXSY_DG/sysaux01.dbf"; set newname for datafile 4 to "/u01/app/oracle/oradata/HXSY_DG/undotbs01.dbf"; set newname for datafile 5 to "/u01/app/oracle/oradata/HXSY_DG/pdbseed/system01.dbf"; set newname for datafile 6 to "/u01/app/oracle/oradata/HXSY_DG/pdbseed/sysaux01.dbf"; set newname for datafile 7 to "/u01/app/oracle/oradata/HXSY_DG/users01.dbf"; set newname for datafile 8 to "/u01/app/oracle/oradata/HXSY_DG/pdbseed/undotbs01.dbf"; set newname for datafile 9 to "/u01/app/oracle/oradata/HXSY_DG/hxsy1/system01.dbf"; set newname for datafile 10 to "/u01/app/oracle/oradata/HXSY_DG/hxsy1/sysaux01.dbf"; set newname for datafile 11 to "/u01/app/oracle/oradata/HXSY_DG/hxsy1/undotbs01.dbf"; set newname for datafile 12 to "/u01/app/oracle/oradata/HXSY_DG/hxsy1/users01.dbf"; restore from nonsparse from service 'hxsy' clone database ; sql 'alter system archive log current'; } executing Memory Script executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME renamed tempfile 1 to /u01/app/oracle/oradata/HXSY_DG/temp01.dbf in control file renamed tempfile 2 to /u01/app/oracle/oradata/HXSY_DG/pdbseed/temp012020-11-17_00-11-36-085-AM.dbf in control file renamed tempfile 3 to /u01/app/oracle/oradata/HXSY_DG/hxsy1/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 executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME Starting restore at 2020-11-16 17:23:32 using channel ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: using network backup set from service hxsy channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/HXSY_DG/system01.dbf channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:25 channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: using network backup set from service hxsy channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/HXSY_DG/sysaux01.dbf channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:16 channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: using network backup set from service hxsy channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/HXSY_DG/undotbs01.dbf channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07 channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: using network backup set from service hxsy channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/HXSY_DG/pdbseed/system01.dbf channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15 channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: using network backup set from service hxsy channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/HXSY_DG/pdbseed/sysaux01.dbf channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:16 channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: using network backup set from service hxsy channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/HXSY_DG/users01.dbf channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: using network backup set from service hxsy channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/HXSY_DG/pdbseed/undotbs01.dbf channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03 channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: using network backup set from service hxsy channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00009 to /u01/app/oracle/oradata/HXSY_DG/hxsy1/system01.dbf channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15 channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: using network backup set from service hxsy channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00010 to /u01/app/oracle/oradata/HXSY_DG/hxsy1/sysaux01.dbf channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15 channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: using network backup set from service hxsy channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00011 to /u01/app/oracle/oradata/HXSY_DG/hxsy1/undotbs01.dbf channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03 channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: using network backup set from service hxsy channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00012 to /u01/app/oracle/oradata/HXSY_DG/hxsy1/users01.dbf channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02 Finished restore at 2020-11-16 17:25:31 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=4 STAMP=1056734739 file name=/u01/app/oracle/oradata/HXSY_DG/system01.dbf datafile 3 switched to datafile copy input datafile copy RECID=5 STAMP=1056734739 file name=/u01/app/oracle/oradata/HXSY_DG/sysaux01.dbf datafile 4 switched to datafile copy input datafile copy RECID=6 STAMP=1056734740 file name=/u01/app/oracle/oradata/HXSY_DG/undotbs01.dbf datafile 5 switched to datafile copy input datafile copy RECID=7 STAMP=1056734740 file name=/u01/app/oracle/oradata/HXSY_DG/pdbseed/system01.dbf datafile 6 switched to datafile copy input datafile copy RECID=8 STAMP=1056734740 file name=/u01/app/oracle/oradata/HXSY_DG/pdbseed/sysaux01.dbf datafile 7 switched to datafile copy input datafile copy RECID=9 STAMP=1056734740 file name=/u01/app/oracle/oradata/HXSY_DG/users01.dbf datafile 8 switched to datafile copy input datafile copy RECID=10 STAMP=1056734740 file name=/u01/app/oracle/oradata/HXSY_DG/pdbseed/undotbs01.dbf datafile 9 switched to datafile copy input datafile copy RECID=11 STAMP=1056734740 file name=/u01/app/oracle/oradata/HXSY_DG/hxsy1/system01.dbf datafile 10 switched to datafile copy input datafile copy RECID=12 STAMP=1056734740 file name=/u01/app/oracle/oradata/HXSY_DG/hxsy1/sysaux01.dbf datafile 11 switched to datafile copy input datafile copy RECID=13 STAMP=1056734740 file name=/u01/app/oracle/oradata/HXSY_DG/hxsy1/undotbs01.dbf datafile 12 switched to datafile copy input datafile copy RECID=14 STAMP=1056734740 file name=/u01/app/oracle/oradata/HXSY_DG/hxsy1/users01.dbf Finished Duplicate Db at 2020-11-16 17:25:45
openaix1:/u01/app/oracle/oradata/HXSY_DG$sqlplus / as sysdba SQL*Plus: Release 19.0.0.0.0 - Production on Tue Nov 17 17:26:54 2020 Version 19.3.0.0.0 Copyright (c) 1982, 2019, Oracle. All rights reserved. Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.3.0.0.0 SQL> select instance_name,status from v$instance; INSTANCE_NAME STATUS ---------------- ------------ hxsy MOUNTED SQL> show parameter db_unique_name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_unique_name string hxsy_dg SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- /u01/app/oracle/oradata/HXSY_DG/system01.dbf /u01/app/oracle/oradata/HXSY_DG/sysaux01.dbf /u01/app/oracle/oradata/HXSY_DG/undotbs01.dbf /u01/app/oracle/oradata/HXSY_DG/pdbseed/system01.dbf /u01/app/oracle/oradata/HXSY_DG/pdbseed/sysaux01.dbf /u01/app/oracle/oradata/HXSY_DG/users01.dbf /u01/app/oracle/oradata/HXSY_DG/pdbseed/undotbs01.dbf /u01/app/oracle/oradata/HXSY_DG/hxsy1/system01.dbf /u01/app/oracle/oradata/HXSY_DG/hxsy1/sysaux01.dbf /u01/app/oracle/oradata/HXSY_DG/hxsy1/undotbs01.dbf /u01/app/oracle/oradata/HXSY_DG/hxsy1/users01.dbf 11 rows selected.
對物理備庫建立備重做日誌檔案
查詢主庫的聯機重做日誌檔案,備重做日誌檔案的大小應該與主庫聯機重做日誌檔案的大小相同,備重做日誌檔案組的數量應該比主庫聯機重做日誌檔案組多一組,計算公式為
(maximum # of logfiles +1) * maximum # of threads
aix1:/u01/app/oracle/product/19.3/db/dbs$sqlplus sys/hxsy_123456@hxsy as sysdba SQL*Plus: Release 19.0.0.0.0 - Production on Mon Nov 16 17:28:21 2020 Version 19.3.0.0.0 Copyright (c) 1982, 2019, Oracle. All rights reserved. Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.3.0.0.0 SQL> select member from v$logfile; MEMBER -------------------------------------------------------------------------------- /u01/app/oracle/oradata/HXSY/redo03.log /u01/app/oracle/oradata/HXSY/redo02.log /u01/app/oracle/oradata/HXSY/redo01.log SQL> select group#,thread#,bytes/1024/1024 from v$log; GROUP# THREAD# BYTES/1024/1024 ---------- ---------- --------------- 1 1 200 2 1 200 3 1 200 SQL> select member from v$logfile; MEMBER -------------------------------------------------------------------------------- /u01/app/oracle/oradata/HXSY_DG/redo03.log /u01/app/oracle/oradata/HXSY_DG/redo02.log /u01/app/oracle/oradata/HXSY_DG/redo01.log SQL> select group#,thread#,bytes/1024/1024 from v$log; GROUP# THREAD# BYTES/1024/1024 ---------- ---------- --------------- 1 1 200 3 1 200 2 1 200
備庫:
SQL> alter database add standby logfile thread 1 group 4('/u01/app/oracle/oradata/HXSY_DG/redo04.log') size 200M; Database altered. SQL> alter database add standby logfile thread 1 group 5('/u01/app/oracle/oradata/HXSY_DG/redo05.log') size 200M; Database altered. SQL> alter database add standby logfile thread 1 group 6('/u01/app/oracle/oradata/HXSY_DG/redo06.log') size 200M; Database altered. SQL> alter database add standby logfile thread 1 group 7('/u01/app/oracle/oradata/HXSY_DG/redo07.log') size 200M; Database altered.
主庫:
SQL> alter database add standby logfile thread 1 group 4('/u01/app/oracle/oradata/HXSY/redo04.log') size 200M; Database altered. SQL> alter database add standby logfile thread 1 group 5('/u01/app/oracle/oradata/HXSY/redo05.log') size 200M; Database altered. SQL> alter database add standby logfile thread 1 group 6('/u01/app/oracle/oradata/HXSY/redo06.log') size 200M; Database altered. SQL> alter database add standby logfile thread 1 group 7('/u01/app/oracle/oradata/HXSY/redo07.log') size 200M; Database altered.
設定主庫相關初始化引數
log_archive_config='DG_CONFIG=(hxsy,hxsy_dg)' log_archive_dest_1='LOCATION=/u01/app/oracle/arch valid_for=(ALL_LOGFILES,ALL_ROLES) db_unique_name=hxsy' log_archive_dest_2='SERVICE=hxsy_dg LGWR ASYNC valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=hxsy_dg' log_archive_dest_state_1=enable log_archive_dest_state_2=enable remote_login_passwordfile=exclusive log_archive_format= %t_%s_%r.dbf log_archive_max_processes=30
主庫以備庫角色執行時需要額外設定的引數。這些引數當主庫被轉換為備庫角色執行時生效:
fal_server='hxsy_dg' fal_client='hxsy' db_file_name_convert='/u01/app/oracle/oradata/HXSY_DG', '/u01/app/oracle/oradata/HXSY' log_file_name_convert='/u01/app/oracle/oradata/HXSY_DG', '/u01/app/oracle/oradata/HXSY' standby_file_management='auto'
SQL> alter system set log_archive_dest_1='LOCATION=/u01/app/oracle/arch valid_for=(ALL_LOGFILES,ALL_ROLES) db_unique_name=hxsy' scope=both sid='*'; System altered. SQL> alter system set log_archive_dest_2='SERVICE=hxsy_dg LGWR ASYNC valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=hxsy_dg'scope=both sid='*'; System altered. SQL> alter system set log_archive_dest_state_1=enable scope=both sid='*'; System altered. SQL> alter system set log_archive_dest_state_2=enable scope=both sid='*'; System altered. SQL> alter system set log_archive_max_processes=30 scope=both sid='*'; System altered. SQL> alter system set fal_server='hxsy_dg' scope=both sid='*'; System altered. SQL> alter system set fal_client='hxsy' scope=both sid='*'; System altered. SQL> alter system set db_file_name_convert='/u01/app/oracle/oradata/HXSY_DG', '/u01/app/oracle/oradata/HXSY' scope=spfile sid='*'; System altered. SQL> alter system set log_file_name_convert='/u01/app/oracle/oradata/HXSY_DG', '/u01/app/oracle/oradata/HXSY' scope=spfile sid='*'; System altered. SQL> alter system set standby_file_management='auto' scope=both sid='*'; System altered. SQL> alter system set log_archive_config='DG_CONFIG=(hxsy,hxsy_dg)' scope=both sid='*'; System altered. SQL> select name, database_role, open_mode from gv$database; NAME DATABASE_ROLE OPEN_MODE --------- ---------------- -------------------- HXSY PRIMARY READ WRITE SQL> select name, database_role, open_mode from gv$database; NAME DATABASE_ROLE OPEN_MODE --------- ---------------- -------------------- HXSY PHYSICAL STANDBY READ ONLY
使用alter database語句來啟用實時應用功能:
.對於物理備庫執行alter database recover managed standby database(在Oracle 12.1中需要指定current logfile子句來啟用實時應用,但在12.2中不再需要)。
在備庫節點上執行實時重做應用
SQL> alter database recover managed standby database using current logfile disconnect from session; Database altered.
alert日誌資訊如下
# tail -f /u01/app/oracle/diag/rdbms/hxsy_dg/hxsy/trace/alert_hxsy.log ORA-01157: cannot identify/lock data file 202 - see DBWR trace file ORA-01110: data file 202: '/u01/app/oracle/oradata/HXSY_DG/pdbseed/temp012020-11-17_00-11-36-085-AM.dbf' 2020-11-17T17:47:58.239174-06:00 File 202 not verified due to error ORA-01157 2020-11-17T17:47:58.390428-06:00 PDB$SEED(2):Re-creating tempfile /u01/app/oracle/oradata/HXSY_DG/pdbseed/temp012020-11-17_00-11-36-085-AM.dbf 2020-11-17T17:47:59.013123-06:00 PDB$SEED(2):Opening pdb with no Resource Manager plan active Physical standby database opened for read only access. Completed: alter database open 2020-11-17T17:50:46.966690-06:00 Warning: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE has been deprecated. Warning: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE has been deprecated. alter database recover managed standby database using current logfile disconnect from session 2020-11-17T17:50:47.069179-06:00 Attempt to start background Managed Standby Recovery process (hxsy) Starting background process MRP0 2020-11-17T17:50:47.296690-06:00 MRP0 started with pid=67, OS id=10682718 2020-11-17T17:50:47.329349-06:00 Background Managed Standby Recovery process started (hxsy) 2020-11-17T17:50:52.560871-06:00 Started logmerger process 2020-11-17T17:50:52.734970-06:00 IM on ADG: Start of Empty Journal IM on ADG: End of Empty Journal PR00 (PID:12190072): Managed Standby Recovery starting Real Time Apply max_pdb is 3 2020-11-17T17:50:54.165887-06:00 Parallel Media Recovery started with 8 slaves 2020-11-17T17:50:54.389175-06:00 stopping change tracking 2020-11-17T17:50:54.609199-06:00 PR00 (PID:12190072): Media Recovery Log /u01/app/oracle/arch/1_7_1056672314.dbf 2020-11-17T17:50:54.799176-06:00 PR00 (PID:12190072): Media Recovery Log /u01/app/oracle/arch/1_8_1056672314.dbf 2020-11-17T17:50:54.877923-06:00 TT02 (PID:12779914): Waiting for all non-current ORLs to be archived 2020-11-17T17:50:54.987923-06:00 TT02 (PID:12779914): All non-current ORLs have been archived 2020-11-17T17:50:55.311006-06:00 Completed: alter database recover managed standby database using current logfile disconnect from session 2020-11-17T17:50:55.335874-06:00 PR00 (PID:12190072): Media Recovery Waiting for T-1.S-9 (in transit) 2020-11-17T17:50:55.376975-06:00 Recovery of Online Redo Log: Thread 1 Group 4 Seq 9 Reading mem 0 2020-11-17T17:50:55.412407-06:00 Mem# 0: /u01/app/oracle/oradata/HXSY_DG/redo04.log
在主庫建立表空間test
SQL> create tablespace test datafile '/u01/app/oracle/oradata/HXSY/test01.dbf' size 50M; Tablespace created. SQL> select tablespace_name from dba_tablespaces; TABLESPACE_NAME ------------------------------ SYSTEM SYSAUX UNDOTBS1 TEMP USERS TEST 6 rows selected. SQL> select con_id,ts#,name from v$tablespace; CON_ID TS# NAME ---------- ---------- ------------------------------ 1 1 SYSAUX 1 0 SYSTEM 1 2 UNDOTBS1 1 4 USERS 1 3 TEMP 2 0 SYSTEM 2 1 SYSAUX 2 2 UNDOTBS1 2 3 TEMP 3 0 SYSTEM 3 1 SYSAUX CON_ID TS# NAME ---------- ---------- ------------------------------ 3 2 UNDOTBS1 3 3 TEMP 3 5 USERS 1 6 TEST 15 rows selected. SQL> select ts#,name from v$datafile where ts#=6 and con_id=1; TS# NAME ---------- -------------------------------------------------- 6 /u01/app/oracle/oradata/HXSY/test01.dbf
備庫alert日誌如下:
Recovery of Online Redo Log: Thread 1 Group 4 Seq 9 Reading mem 0 2020-11-17T17:50:55.412407-06:00 Mem# 0: /u01/app/oracle/oradata/HXSY_DG/redo04.log 2020-11-17T17:52:48.412685-06:00 Recovery created file /u01/app/oracle/oradata/HXSY_DG/test01.dbf 2020-11-17T17:52:48.453155-06:00 Errors in file /u01/app/oracle/diag/rdbms/hxsy_dg/hxsy/trace/hxsy_dbw0_7602670.trc: ORA-01157: cannot identify/lock data file 203 - see DBWR trace file ORA-01110: data file 203: '/u01/app/oracle/oradata/HXSY_DG/hxsy1/temp01.dbf' ORA-27037: unable to obtain file status IBM AIX RISC System/6000 Error: 2: No such file or directory Additional information: 7 Successfully added datafile 13 to media recovery Datafile #13: '/u01/app/oracle/oradata/HXSY_DG/test01.dbf' 2020-11-17T17:53:13.126690-06:00 Control autobackup written to DISK device
備庫:
SQL> select tablespace_name from dba_tablespaces; TABLESPACE_NAME ------------------------------ SYSTEM SYSAUX UNDOTBS1 TEMP USERS TEST 6 rows selected. SQL> select con_id,ts#,name from v$tablespace; CON_ID TS# NAME ---------- ---------- ------------------------------ 1 1 SYSAUX 1 0 SYSTEM 1 2 UNDOTBS1 1 4 USERS 1 3 TEMP 2 0 SYSTEM 2 1 SYSAUX 2 2 UNDOTBS1 2 3 TEMP 3 0 SYSTEM 3 1 SYSAUX CON_ID TS# NAME ---------- ---------- ------------------------------ 3 2 UNDOTBS1 3 3 TEMP 3 5 USERS 1 6 TEST 15 rows selected. SQL> select ts#,name from v$datafile where ts#=6 and con_id=1; TS# NAME ---------- -------------------------------------------------- 6 /u01/app/oracle/oradata/HXSY_DG/test01.dbf
驗證
主庫:
SQL> create table t1 as select * from dba_users; Table created. SQL> select count(*) from t1; COUNT(*) ---------- 36 SQL> create table t2(id number(20),name varchar2(20)); Table created. SQL> insert into t2 values(1,'jy'); 1 row created. SQL> commit; Commit complete. SQL> update t2 set name='hy' where id=1; 1 row updated. SQL> commit; Commit complete. SQL> delete from t2; 1 row deleted. SQL> commit; Commit complete. SQL> create table t3(id number(20),name varchar2(20)) tablespace test; Table created. SQL> insert into t3 values(1,'jy'); 1 row created. SQL> commit; Commit complete.
備庫
SQL> select count(*) from t1; COUNT(*) ---------- 36 SQL> desc t2; Name Null? Type ----------------------------------------- -------- ---------------------------- ID NUMBER(20) NAME VARCHAR2(20) SQL> select * from t2; ID NAME ---------- -------------------------------------------------- 1 jy SQL> select * from t2; ID NAME ---------- -------------------------------------------------- 1 hy SQL> select * from t2; no rows selected SQL> SQL> SQL> desc t3; Name Null? Type ----------------------------------------- -------- ---------------------------- ID NUMBER(20) NAME VARCHAR2(20) SQL> select * from t3; ID NAME ---------- -------------------------------------------------- 1 jy
驗證物理備庫是否執行正確
在建立物理備庫後並且設定重做傳輸服務,可能想要驗證主庫的資料庫修改是否會成功的傳輸到備庫。對於備庫可以查詢v$managed_standby檢視來驗證重做是否被從主庫傳輸到備庫並應用。
SQL> select client_process,process,thread#,sequence#,status from v$managed_standby where client_process='LGWR' or process='MRP0'; CLIENT_P PROCESS THREAD# SEQUENCE# STATUS -------- --------- ---------- ---------- ------------ LGWR RFS 1 9 IDLE N/A MRP0 1 9 APPLYING_LOG
上面的查詢對於使用CLIENT_PROCESS為LGWR的主庫會顯示一行記錄,它指示重做傳輸工作正常並且主重做執行緒將會被髮送到備庫。 如果主庫是RAC資料庫,那麼對於使用CLIENT_PROCESS為LGWR的當前活動的每個主庫例項都會顯示一行記錄。
上面的查詢對於MRP也行顯示一行。如果MRP的狀態顯示為APPLYING_LOG並且SEQUENCE#等於主庫當前正被髮送的日誌序列號,那麼備庫已經解決了所有的日誌差異並且當前處於實時應用日誌模式。
查詢主庫當前正被髮送日誌的序列號為9與上面的MRP程式所顯示的sequence#(9)相同
SQL> select group#,thread#,sequence#,status from v$log; GROUP# THREAD# SEQUENCE# STATUS ---------- ---------- ---------- ---------------- 1 1 7 INACTIVE 2 1 8 INACTIVE 3 1 9 CURRENT
注意MRP程式可能顯示的sequence#比主庫當前被髮送的日誌序列號小,那麼這就表示正在應用的歸檔重做日誌檔案與傳送的日誌檔案之間存在差異並且它並沒有趕上。一旦所有差異被解決,相同的查詢將顯示MRP正在應用當前sequence#。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-2750327/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- openPower伺服器安裝Oracle 19c伺服器Oracle
- Oracle 19c adg全庫遷移資料Oracle
- Oracle搭建rac到單庫的adgOracle
- Oracle 19c 新特性:ADG的自動DML重定向增強讀寫分離--ADG_REDIRECT_DMLOracle
- 19c ADG報錯Error 1094 attaching to RFS for reconnectError
- oracle ADG與DG的區別Oracle
- Oracle ADG 備庫新增備庫Oracle
- 【BUILD_ORACLE】Oracle 19c RAC搭建(六)建立RAC資料庫UIOracle資料庫
- 【BUILD_ORACLE】Oracle 19c RAC搭建(五)DB軟體安裝UIOracle
- 【BUILD_ORACLE】Oracle 19c RAC搭建(四)Grid軟體安裝UIOracle
- 【DG】Oracle 19c使用dbca來搭建物理DGOracle
- oracle 19c dg搭建duplicate過程中報錯Oracle
- 【BUILD_ORACLE】Oracle 19c RAC搭建(一)安裝資源規劃UIOracle
- 【BUILD_ORACLE】Oracle 19c RAC搭建(三)使用UDEV配置共享儲存UIOracledev
- Oracle ADG 自動切換指令碼分享Oracle指令碼
- 【BUILD_ORACLE】Oracle 19c RAC搭建(二)作業系統檢查與配置UIOracle作業系統
- Oracle 19C EMOracle
- 【TUNE_ORACLE】Oracle 19c RAC搭建番外篇之RAC引數配置參考(四)Oracle
- 【TUNE_ORACLE】Oracle 19c RAC搭建番外篇之RAC引數配置參考(五)Oracle
- 【TUNE_ORACLE】Oracle 19c RAC搭建番外篇之RAC引數配置參考(三)Oracle
- 【TUNE_ORACLE】Oracle 19c RAC搭建番外篇之RAC引數配置參考(二)Oracle
- 【TUNE_ORACLE】Oracle 19c RAC搭建番外篇之RAC引數配置參考(一)Oracle
- Oracle ADG環境下的RMAN備份策略Oracle
- oracle 19c dataguard silent install (oracle 19c dataguard 靜默安裝)Oracle
- oracle rac+adg調整redo日誌組導致adg備庫ogg抽取程式abendOracle
- Oracle 19c Concepts(01):Introduction to Oracle DatabaseOracleDatabase
- Oracle 19c Concepts(13):Oracle Database InstanceOracleDatabase
- Oracle 19c Broker配置Oracle
- oracle adg備庫歸檔滿了無法同步Oracle
- Oracle資料泵(Oracle Data Pump) 19cOracle
- Oracle:Oracle RAC 11.2.0.4 升級為 19cOracle
- Oracle 19c Concepts(10):TransactionsOracle
- Oracle 19c RPM安裝Oracle
- oracle 19c 初體驗Oracle
- Oracle 19c中的TomcatOracleTomcat
- Oracle 19c Concepts(07):SQLOracleSQL
- Oracle 19c的安裝Oracle
- oracle 19c pdb遷移Oracle