Oracle 19c adg全庫遷移資料
Oracle 19c adg全庫遷移資料
導讀:使用adg將生產資料複製至預生產環境,使用failover將主備庫完成分開成2個互不相關的資料庫。adg複製資料這個過程類似於使用mysql ab複製功能,將a庫資料複製給b庫即可。
# 環境背景 primary環境:3節點rac standby環境:單例項本地儲存
使用adg遷移資料的基本思路與步驟:
##################################################################################### # adg搭建過程: 1.primary開啟force logging模式 2.primary配置tnsnames.ora 3.primary與standby庫建立Standby Redo Log 4.primary配置adg引數 5.standby建立密碼檔案 6.standby建立所需目錄與許可權 7.standby建立臨時例項與配置靜態監聽 8.standby庫rman的auxiliary技術恢復primary庫的資料檔案,引數檔案,standby controlfile等 9.standby啟動日誌應用 10.standby檢查adg狀態 # failover拆分adg,使原primary和standby成為2個互不相關的資料庫 11.使用failover拆分adg 12.清除primary和standby的adg引數 13.standby重啟open成為獨立的primary庫 14.oracle 19c dataguard 管理命令彙總 #####################################################################################
1.primary開啟force logging模式
##################################################################################### # Enable Archiving and Enable force logging in rac --rac srvctl stop databaas -d <db_unique_name> srvctl start database -d <db_unique_name> -o mount SQL> alter system set log_archive_dest_1='LOCATION=+ARCH'; SQL> alter database archivelog; # enable database force_logging mode SQL> alter database force logging; srvctl stop database -d <db_unique_name> srvctl start database -d <db_unique_name> SQL> archive log list; SQL> select DBID, INST_ID, NAME, OPEN_MODE,force_logging from gv$database; --Single instance SQL> shutdown immediate; SQL> startup mount; SQL> alter system set log_archive_dest_1='LOCATION=/ARCH'; SQL> alter database archivelog; SQL> alter database force logging; SQL> alter database open; SQL> archive log list; SQL> select force_logging from v$database; ##################################################################################### # enable database force_logging mode as follows: SQL> select DBID, INST_ID, NAME, OPEN_MODE,force_logging from gv$database; DBID INST_ID NAME OPEN_MODE FORCE_LOGGING ---------- ---------- ------------------ ---------------------------------------- ----------------------------------- 1090140655 3 RACDB READ WRITE YES 1090140655 1 RACDB READ WRITE YES 1090140655 2 RACDB READ WRITE YES #####################################################################################
2.primary配置tnsnames.ora
2.1 所有節點的tnsnames.ora均新增以下配置,並使用tnsping racdbadg驗證聯通性 RACDB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.0.107)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = racdb) ) ) racdbdg = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.204)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = racdbdg) ) ) 2.2 tnsping檢查聯通性,所有節點均驗證 tnsping racdb tnsping racdbdg
3.primary與standby庫建立Standby Redo Log
##################################################################################### # primary庫建立srl檔案,standby庫恢復時會自動建立 # 參考:Usage, Benefits and Limitations of Standby Redo Logs (SRL) (Doc ID 219344.1) --oracle 10g Real-Time Apply we directly apply Redo Data from Standby RedoLogs --Note that starting with Oracle 11g ARCH Log Transport Method is deprecated. # SRL要求: SRL檔案大小:保持與primary庫redo logfile大小一致. SRL檔案數目:(maximum number of logfiles for each thread + 1) *maximum number of threads --檢查叢集例項數 show parameter cluster_database_instances # SRL建立: --thread1 alter database add standby logfile thread 1 group 20 ('+DATA') size 200M; ...... --thread2 alter database add standby logfile thread 2 group 23 ('+DATA') size 200M; ...... --thread3 alter database add standby logfile thread 3 group 26 ('+DATA') size 200M; ...... # SRL檢查: select t.group#,t.status,t.type,t.member,d.thread#,d.sequence#,d.bytes/1024/1024 m from v$logfile t,v$standby_log d where t.group#=d.group# order by 1,5; ###################################################################################### # 操作記錄: # 建立srl: col member for a50 set line 200 --檢查叢集例項數 SQL> show parameter cluster_database_instances NAME TYPE VALUE ------------------------------------ ---------------------- ------------------------------ cluster_database_instances integer 3 SQL> select t.group#,t.status,t.type,t.member,d.thread#,d.bytes/1024/1024 m from v$logfile t,v$log d where t.group#=d.group# order by 1,5; GROUP# STATUS TYPE MEMBER THREAD# M ---------- -------------- -------------- -------------------------------------------------- ---------- ---------- 1 ONLINE +DATA/RACDB/ONLINELOG/group_1.263.1092523891 1 200 2 ONLINE +DATA/RACDB/ONLINELOG/group_2.264.1092523891 1 200 3 ONLINE +DATA/RACDB/ONLINELOG/group_3.268.1092525365 2 200 4 ONLINE +DATA/RACDB/ONLINELOG/group_4.269.1092525365 2 200 5 ONLINE +DATA/RACDB/ONLINELOG/group_5.270.1092525367 3 200 6 ONLINE +DATA/RACDB/ONLINELOG/group_6.271.1092525367 3 200 # SRL建立: --thread1 alter database add standby logfile thread 1 group 20 ('+DATA') size 200M; alter database add standby logfile thread 1 group 21 ('+DATA') size 200M; alter database add standby logfile thread 1 group 22 ('+DATA') size 200M; --thread2 alter database add standby logfile thread 2 group 23 ('+DATA') size 200M; alter database add standby logfile thread 2 group 24 ('+DATA') size 200M; alter database add standby logfile thread 2 group 25 ('+DATA') size 200M; --thread3 alter database add standby logfile thread 3 group 26 ('+DATA') size 200M; alter database add standby logfile thread 3 group 27 ('+DATA') size 200M; alter database add standby logfile thread 3 group 28 ('+DATA') size 200M; # SRL檢查: SQL> select t.group#,t.status,t.type,t.member,d.thread#,d.sequence#,d.bytes/1024/1024 m from v$logfile t,v$standby_log d where t.group#=d.group# order by 1,5; GROUP# STATUS TYPE MEMBER THREAD# M ---------- -------------- -------------- -------------------------------------------------- ---------- ---------- 20 STANDBY +DATA/RACDB/ONLINELOG/group_20.275.1118890319 1 200 21 STANDBY +DATA/RACDB/ONLINELOG/group_21.276.1118890335 1 200 22 STANDBY +DATA/RACDB/ONLINELOG/group_22.283.1118894803 1 200 23 STANDBY +DATA/RACDB/ONLINELOG/group_23.282.1118894859 2 200 24 STANDBY +DATA/RACDB/ONLINELOG/group_24.281.1118894859 2 200 25 STANDBY +DATA/RACDB/ONLINELOG/group_25.280.1118894859 2 200 26 STANDBY +DATA/RACDB/ONLINELOG/group_26.279.1118894873 3 200 27 STANDBY +DATA/RACDB/ONLINELOG/group_27.278.1118894875 3 200 28 STANDBY +DATA/RACDB/ONLINELOG/group_28.277.1118894875 3 200
4.primary配置adg引數
##################################################################################### ##與角色無關的引數(primary庫均需配置的引數) --db_name和db_unique_name無需更改 db_name=racdb db_unique_name=racdb --tunning arch processes,19c default is 4 log_archive_max_processes=4 --log_archive_config is list of db_unique_name parameter log_archive_config='adg_CONFIG=(racdb,racdbadg)'; ##primary角色引數(若不考慮切換,僅primary庫配置即可) --LOCATION=local archivelog directory;ALL_LOGFILES=redo log files or archivelog files is valid;ALL_ROLES=primary or the standby role is valid log_archive_dest_1='LOCATION=+ARCH VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=racdb' --service=net_service_name;LGWR=redo archival process ;ASYNC=network transtmisson mode; NOAFFIRM=disk write option ; online redo log files is valid;PRIMARY_ROLE=primary role is valid log_archive_dest_2='SERVICE=racdbadg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=racdbadg' --log archive destination is valid,default is enable;歸檔路徑是否開啟自動傳輸,enable引數時歸檔路徑可用於後續歸檔自動傳輸;defer引數修改enable之前歸檔路徑為不可用 LOG_ARCHIVE_DEST_STATE_1=ENABLE LOG_ARCHIVE_DEST_STATE_2=ENABLE ##################################################################################### # primary庫線上執行命令如下: --關閉日誌傳輸,待standby庫資料恢復完成後開啟日誌傳輸 alter system set log_archive_dest_state_2=defer; alter system set log_archive_config='dg_CONFIG=(racdb,racdbdg)' ; alter system set log_archive_dest_1='LOCATION=+ARCH VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=racdb' ; alter system set log_archive_dest_2='SERVICE=racdbdg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=racdbdg' ; alter system set standby_file_management='AUTO';
5.standby建立密碼檔案
# 將primary庫的密碼檔案copy至standby庫,並修改相應的oracle_sid即可.密碼檔案,預設使用sys為資料同步使用者。也可建立新使用者 ##################################################################################### --primary srvctl config database -d racdb su - grid asmcmd cp +DATA/RACDB/PASSWORD/pwdracdb.274.1113430875 /tmp/ scp /tmp/pwdracdb.274.1113430875 oracle@192.168.56.204:/u01/app/oracle/product/19.0.0/db_1/dbs/orapwracdbdg --standby chmod u+x orapwracdbdg ls -l orapwracdbdg ##################################################################################### # 操作記錄: --rac環境檢視密碼檔案位置 [oracle@rac2:/home/oracle]$srvctl config database -d racdb # 3個節點的密碼檔案以共享的方式儲存在asm磁碟組中,所以copy一個即可 ...... Password file: +DATA/RACDB/PASSWORD/pwdracdb.274.1113430875 ...... --從asm磁碟組中複製密碼至本地,並copy至standby su - grid [grid@rac1:/home/grid]$asmcmd cp +DATA/RACDB/PASSWORD/pwdracdb.274.1113430875 /tmp/ copying +DATA/RACDB/PASSWORD/pwdracdb.274.1113430875 -> /tmp//pwdracdb.274.1113430875 [grid@rac1:/home/grid]$scp /tmp/pwdracdb.274.1113430875 oracle@192.168.56.204:/u01/app/oracle/product/19.0.0/db_1/dbs/orapwracdbdg oracle@192.168.56.204's password: pwdracdb.274.1113430875 100% 2048 847.8KB/s 00:00 chmod u+x orapwracdbdg [root@rac_dg dbs]# ls -l orapwracdbdg -rwxr----- 1 oracle oinstall 2048 11月 6 21:33 orapwracdbdg
6.standby建立所需目錄與許可權
##################################################################################### su - root mkdir -p /home/oracle/data/racdb/datafile mkdir -p /home/oracle/data/adump mkdir -p /home/oracle/data/arch mkdir -p /home/oracle/data/racdb/onlinelog chown -R oracle:oinstall /home/oracle/data chmod -R 775 /home/oracle/data #####################################################################################
7.standby建立臨時例項與配置靜態監聽
7.1 開啟臨時例項racdb su - oracle echo db_name=racdb > /u01/app/oracle/product/19.0.0/db_1/dbs/initracdbdg.ora ORACLE_SID=racdbdg sqlplus / as sysdba startup nomount pfile='/u01/app/oracle/product/19.0.0/db_1/dbs/initracdbdg.ora'; 7.2 standby庫配置靜態監聽;使nomount狀態可使用rman進行連結 cat /u01/app/oracle/product/19.0.0/db_1/network/admin/listener.ora LISTENER = (ADDRESS_LIST= (ADDRESS=(PROTOCOL=tcp)(HOST=rac_dg)(PORT=1521)) (ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) # SID_LIST_<lsnr> # List of services the listener knows about and can connect # clients to. There is no default. See the Net8 Administrator's # Guide for more information. # SID_LIST_LISTENER= (SID_LIST= (SID_DESC= (GLOBAL_DBNAME=racdbdg) (SID_NAME=racdbdg) (ORACLE_HOME=/u01/app/oracle/product/19.0.0/db_1) ) ) 7.3 lsnrctl配置重新載入,靜態監聽狀態檢視 lsnrctl stop lsnrctl start lsnrctl status sqlplus / as sysdba alter system register; lsnrctl status # 配置靜態監聽成功日誌輸出如下: ...... Listener Parameter File /u01/app/oracle/product/19.0.0/db_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/rac_dg/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac_dg)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Services Summary... Service "racdb" has 1 instance(s). Instance "racdbdg", status BLOCKED, has 1 handler(s) for this service... Service "racdbdg" has 1 instance(s). Instance "racdbdg", status UNKNOWN, has 1 handler(s) for this service... The command completed successfully 7.4 靜態監聽的登入驗證(nomount狀態) [oracle@rac_dg:/u01/app/oracle/product/19.0.0/db_1/dbs]$sqlplus sys/oracle@192.168.56.204:/racdbdg as sysdba SQL*Plus: Release 19.0.0.0.0 - Production on Sun Nov 6 21:56:52 2022 Version 19.9.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.9.0.0.0 SQL> 7.5 standby配置tnsnames.ora,以備fal使用 cat /u01/app/oracle/product/19.0.0/db_1/network/admin/tnsnames.ora RACDB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.0.107)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = racdb) ) ) racdbdg = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.204)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = racdbdg) ) )
8.standby庫rman的auxiliary技術恢復primary庫的資料檔案,引數檔案,standby controlfile等
# standby庫配置adg引數 ##################################################################################### ##與角色無關的引數 db_name=racdb --(不變) db_unique_name=racdbdg log_archive_max_processes=4 log_archive_config='adg_CONFIG=(racdb,racdbdg) ##standby角色引數(若不考慮切換,僅standby庫配置即可) --The fal_server is init.ora parameters are used for the gap resolution fal_server='racdb' --failover log log_archive_dest_1='LOCATION=/home/oracle/data/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=racdbdg' log_archive_dest_2='SERVICE=racdb LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=racdb' --all the modification of datafiles on the primary database will be reflected on the standby site DB_FILE_NAME_CONVERT='+DATA','+DATA_dg' LOG_FILE_NAME_CONVERT='+DATA','+DATA_dg' standby_file_management='AUTO' ##################################################################################### # 線上命令如下: rman target sys/oracle@racdb auxiliary sys/oracle@racdbdg run { allocate channel c1 type disk; allocate channel c2 type disk; allocate AUXILIARY channel c3 type disk; allocate AUXILIARY channel c4 type disk; duplicate target database for standby from active database spfile parameter_value_convert'racdb','racdbdg' set db_name='racdb' set db_unique_name='racdbdg' set db_file_name_convert='+data/','/home/oracle/data/' set log_file_name_convert='+data/','/home/oracle/data/' set control_files='home/oracle/data/stadnby.ctl' set fal_server='racdb' set standby_file_management='AUTO' set log_archive_config='dg_config=(racdb,racdbdg)' set memory_target='500m' set cluster_database='false' set diagnostic_dest='/home/oracle/data/adump/' set log_archive_dest_1='LOCATION=/home/oracle/data/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=racdbdg' set log_archive_dest_2='SERVICE=racdb LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=racdb' nofilenamecheck; release channel c1; release channel c2; release channel c3; release channel c4; } --rman的auxiliary恢復完成,並且standby已開啟至mount狀態 SQL> select instance_name,status from v$instance; INSTANCE_NAME STATUS -------------------------------- ------------------------ racdbdg MOUNTED
9.standby啟動adg
##################################################################################### --primary庫未傳輸日誌,primary庫開啟傳輸日誌 alter system set log_archive_dest_state_2=enable; --standby庫執行 select database_role,protection_mode,open_mode from v$database; alter database recover managed standby database cancel; alter database open; --start active redo apply alter database recover managed standby database using current logfile disconnect; select database_role,protection_mode,open_mode from v$database; --close redo apply alter database recover managed standby database cancel; ##################################################################################### # 操作記錄: --oracle 19c enable adg SQL> set line 200 SQL> select database_role,protection_mode,open_mode from v$database; DATABASE_ROLE PROTECTION_MODE OPEN_MODE -------------------------------- ---------------------------------------- ---------------------------------------- PHYSICAL STANDBY MAXIMUM PERFORMANCE MOUNTED SQL> alter database recover managed standby database cancel; alter database recover managed standby database cancel * ERROR at line 1: ORA-16136: Managed Standby Recovery not active SQL> alter database open; Database altered. SQL> alter database recover managed standby database using current logfile disconnect; Database altered. SQL> select database_role,protection_mode,open_mode from v$database; DATABASE_ROLE PROTECTION_MODE OPEN_MODE -------------------------------- ---------------------------------------- ---------------------------------------- PHYSICAL STANDBY MAXIMUM PERFORMANCE READ ONLY WITH APPLY
10.standby檢查adg狀態
##################################################################################### --檢查adg庫狀態 select database_role,protection_mode,open_mode,switchover_status from v$database; --接收歸檔日誌傳輸序列與應用情況 select sequence#,first_time,next_time,applied from v$archived_log order by sequence#; --檢查日誌傳輸與日誌應用程式狀態,若是沒有mgr進行,則優先檢查是否有gap select role,thread#,sequence#,action from v$dataguard_process; --檢查是否有gap select thread#,low_sequence#,high_sequence# from v$archive_gap; --檢查lag情況;可判斷adg是否有延遲 col name for a23 col value for a13 col time_computed for a20 col datum_time for a20 select name,value,time_computed,datum_time from v$dataguard_stats; ##################################################################################### # 操作記錄: --檢查日誌傳輸與日誌應用程式狀態 select role,thread#,sequence#,action from v$dataguard_process; ROLE THREAD# SEQUENCE# ACTION ------------------------------------------------ ---------- ---------- ------------------------ log writer 0 0 IDLE redo transport monitor 0 0 IDLE gap manager 0 0 IDLE redo transport timer 0 0 IDLE archive local 0 0 IDLE archive redo 0 0 IDLE archive redo 0 0 IDLE archive redo 0 0 IDLE RFS ping 1 151 IDLE RFS async 1 151 IDLE RFS archive 0 0 IDLE managed recovery 1 151 APPLYING_LOG 12 rows selected. # managed recovery 'applying_log' shows redo is applied --檢查接收歸檔日誌傳輸與應用狀態 SQL> select sequence#,first_time,next_time,applied from v$archived_log order by sequence#; SEQUENCE# FIRST_TIME NEXT_TIME APPLIED ---------- ----------------------- ----------------------- ------------------ 150 07-NOV-2022 00:58:48 07-NOV-2022 02:39:56 YES --檢查lag情況;可判斷adg是否有延遲 col name for a23 col value for a13 col time_computed for a20 col datum_time for a20 select name,value,time_computed,datum_time from v$dataguard_stats; NAME VALUE TIME_COMPUTED DATUM_TIME ----------------------- ------------- -------------------- -------------------- transport lag +00 00:00:00 11/07/2022 02:53:50 11/07/2022 02:53:48 apply lag +00 00:00:00 11/07/2022 02:53:50 11/07/2022 02:53:48 apply finish time 11/07/2022 02:53:50 estimated startup time 53 11/07/2022 02:53:50 # DATUM_TIME估算standby庫接收的時間 # TIME_COMPUTED估算standby庫完成的時間 # transport lagstandby庫transport of redo傳輸滯後的指標 # apply lagstandby庫applying redo滯後的指標
11.使用failover拆分adg
##################################################################################### --未執行failover前檢視adg狀態 col database_role for a30 col PROTECTION_MODE for a30 col open_mode for a30 col switchover_status for a30 set line 200 select database_role,protection_mode,open_mode,switchover_status from v$database; --確保adg沒有gap,若有gap解決後在failover select thread#,low_sequence#,high_sequence# from v$archive_gap; --執行failover select database_role from v$database; recover managed standby database cancel; alter database recover managed standby database finish; select name,open_mode,database_role from v$database; alter database activate standby database; select database_role from v$database; alter database open; ##################################################################################### # 操作記錄: --未執行failover前檢視adg狀態 col database_role for a30 col PROTECTION_MODE for a30 col open_mode for a30 col switchover_status for a30 set line 200 select database_role,protection_mode,open_mode,switchover_status from v$database; DATABASE_ROLE PROTECTION_MODE OPEN_MODE SWITCHOVER_STATUS ------------------------------ ------------------------------ ------------------------------ ------------------------------ PHYSICAL STANDBY MAXIMUM PERFORMANCE READ ONLY WITH APPLY NOT ALLOWED --確保adg沒有gap,若有gap解決後在failover SQL> select thread#,low_sequence#,high_sequence# from v$archive_gap; no rows selected SQL> select database_role from v$database; DATABASE_ROLE ------------------------------ PHYSICAL STANDBY SQL> recover managed standby database cancel; Media recovery complete. SQL> alter database recover managed standby database finish; # alert 報錯 hang:NET (PID:80835): Begin: SRL archival # 解決辦法:備庫配置log_archive_dest_1和log_archive_dest_2所需引數均可 SQL> alter database recover managed standby database finish; Database altered. select name,open_mode,database_role from v$database; NAME OPEN_MODE ------------------ ---------------------------------------- DATABASE_ROLE -------------------------------- RACDB READ ONLY PHYSICAL STANDBY SQL> alter database activate standby database; Database altered. SQL> select database_role from v$database; DATABASE_ROLE -------------------------------- PRIMARY SQL> alter database open; Database altered
12.清除primary和standby的adg引數
##################################################################################### primary: alter system set log_archive_config='' ; alter system set log_archive_dest_1='LOCATION=+ARCH' ; alter system set log_archive_dest_2='' ; alter system set standby_file_management='MANUAL'; standby: alter system set log_archive_config='' ; alter system set log_archive_dest_1='LOCATION=/home/oracle/data/racdb/arch' ; alter system set log_archive_dest_2='' ; alter system set standby_file_management='MANUAL'; alter system set fal_server=''; alter system reset DB_FILE_NAME_CONVERT scope=spfile; alter system reset LOG_FILE_NAME_CONVERT scope=spfile; #####################################################################################
13.standby重啟open成為獨立的primary庫
shutdown immediate startup 13.1 解決臨時檔案 # 新增臨時檔案,因rman恢復時不會恢復臨時檔案,故需新建立 ##################################################################################### select TABLESPACE_NAME,FILE_NAME from dba_temp_files; alter database tempfile '/home/oracle/data/racdb/tempfile/temp.265.1092523901' drop; create tablespace temp datafile '/home/oracle/data/racdb/datafile/temp01.dbf' size 100m autoextend on; alter tablespace temp add tempfile '/home/oracle/data/racdb/datafile/temp01.dbf' size 100m autoextend on; select TABLESPACE_NAME,FILE_NAME from dba_temp_files; ##################################################################################### # 操作記錄: SQL> select TABLESPACE_NAME,FILE_NAME from dba_temp_files; select TABLESPACE_NAME,FILE_NAME from dba_temp_files * ERROR at line 1: ORA-01157: cannot identify/lock data file 201 - see DBWR trace file ORA-01110: data file 201: '/home/oracle/data/racdb/tempfile/temp.265.1092523901' SQL> alter database tempfile '/home/oracle/data/racdb/tempfile/temp.265.1092523901' drop; Database altered. SQL> create tablespace temp datafile '/home/oracle/data/racdb/datafile/temp01.dbf' size 100m autoextend on; create tablespace temp datafile '/home/oracle/data/racdb/datafile/temp01.dbf' size 100m autoextend on * ERROR at line 1: ORA-01543: tablespace 'TEMP' already exists SQL> alter tablespace temp add tempfile '/home/oracle/data/racdb/datafile/temp01.dbf' size 100m autoextend on; Tablespace altered. SQL> select TABLESPACE_NAME,FILE_NAME from dba_temp_files; TABLESPACE_NAME ------------------------------------------------------------ FILE_NAME -------------------------------------------------------------------------------- TEMP /home/oracle/data/racdb/datafile/temp01.dbf 13.2 增加service_names # 若預生產環境預設連線的service_names是racdb,這裡我們增加一個叫racdb的service_names SQL> show parameter name NAME TYPE VALUE ------------------------------------ ---------------------- ------------------------------ cdb_cluster_name string cell_offloadgroup_name string db_file_name_convert string db_name string racdb db_unique_name string racdbdg global_names boolean FALSE instance_name string racdbdg lock_name_space string log_file_name_convert string pdb_file_name_convert string processor_group_name string NAME TYPE VALUE ------------------------------------ ---------------------- ------------------------------ service_names string racdbdg SQL> alter system set service_names=racdbdg,racdb; System altered. SQL> show parameter name NAME TYPE VALUE ------------------------------------ ---------------------- ------------------------------ cdb_cluster_name string cell_offloadgroup_name string db_file_name_convert string db_name string racdb db_unique_name string racdbdg global_names boolean FALSE instance_name string racdbdg lock_name_space string log_file_name_convert string pdb_file_name_convert string processor_group_name string NAME TYPE VALUE ------------------------------------ ---------------------- ------------------------------ service_names string RACDBDG, RACDB
14.oracle 19c dataguard 管理命令彙總
14.1 檢視adg型別與保護模式 SQL> select database_role,protection_mode,open_mode from v$database; DATABASE_ROLE PROTECTION_MODE OPEN_MODE -------------------------------- ---------------------------------------- ---------------------------------------- PHYSICAL STANDBY MAXIMUM PERFORMANCE READ ONLY WITH APPLY 14.2 檢查standby庫日誌傳輸與日誌應用的延遲 set line 200 col name for a23 col value for a13 col time_computed for a20 col datum_time for a20 select name,value,time_computed,datum_time from v$dataguard_stats; NAME VALUE TIME_COMPUTED DATUM_TIME ----------------------- ------------- -------------------- -------------------- transport lag +00 00:00:00 10/27/2022 05:47:57 10/27/2022 05:47:55 apply lag +00 00:00:00 10/27/2022 05:47:57 10/27/2022 05:47:55 apply finish time 10/27/2022 05:47:57 estimated startup time 51 10/27/2022 05:47:57 # DATUM_TIME估算standby庫接收的時間;包含standby庫上次接收此資料的時間戳 # TIME_COMPUTED估算standby庫完成的時間;包含應用滯後度量時獲取的時間戳 # transport lagstandby庫transport of redo傳輸滯後的指標 # apply lagstandby庫applying redo滯後的指標 14.3 檢查日誌傳輸與日誌應用程式狀態 select role,thread#,sequence#,action from v$dataguard_process; ROLE THREAD# SEQUENCE# ACTION ------------------------------------------------ ---------- ---------- ------------------------ log writer 0 0 IDLE redo transport monitor 0 0 IDLE gap manager 0 0 IDLE redo transport timer 0 0 IDLE archive local 0 0 IDLE archive redo 0 0 IDLE archive redo 0 0 IDLE archive redo 0 0 IDLE RFS ping 1 119 IDLE RFS async 1 119 IDLE managed recovery 1 119 APPLYING_LOG # managed recovery 'applying_log' shows redo is applied 14.4 檢查接收歸檔日誌傳輸與應用狀態 select sequence#,first_time,next_time,applied from v$archived_log order by sequence#; 14.5 oracle 19c adg備庫配置歸檔日誌自動刪除策略 rman target / configure archivelog deletion policy to applied on all standby;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26442936/viewspace-2924258/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ORACLE資料庫遷移Oracle資料庫
- 資料庫-oracle-資料庫遷移資料庫Oracle
- Oracle資料庫資料遷移流程Oracle資料庫
- oracle 19c pdb遷移Oracle
- oracle 遷移資料庫到asmOracle資料庫ASM
- 透過rman全庫備份遷移資料庫資料庫
- Oracle資料庫(資料泵)遷移方案(上)Oracle資料庫
- Oracle資料庫(資料泵)遷移方案(下)Oracle資料庫
- 無外網Oracle資料庫遷移Oracle資料庫
- Oracle資料庫(DataGuard)遷移方案(上)Oracle資料庫
- Oracle資料庫(DataGuard)遷移方案(中)Oracle資料庫
- Oracle資料庫(DataGuard)遷移方案(下)Oracle資料庫
- 【DATAPUMP】使用DataPump遷移Oracle資料庫Oracle資料庫
- Oracle資料庫遷移之一:RMANOracle資料庫
- Oracle資料庫遷移方案比較Oracle資料庫
- 【遷移】使用rman遷移資料庫資料庫
- 資料庫遷移資料庫
- ORACLE 資料遷移Oracle
- 使用RMAN進行Oracle資料庫遷移Oracle資料庫
- ORACLE資料庫切換和遷移方案Oracle資料庫
- Oracle遷移資料庫過程記錄Oracle資料庫
- 跨平臺遷移oracle資料庫指南Oracle資料庫
- Win環境至Linux環境Oracle資料庫遷移全過程LinuxOracle資料庫
- Oracle 9i 11g歷史庫升級遷移資料至19c CDBOracle
- 資料庫遷移 :理解資料庫
- laravel資料庫遷移Laravel資料庫
- Odoo遷移資料庫Odoo資料庫
- redis資料庫遷移Redis資料庫
- Cacti 遷移資料庫資料庫
- 資料庫遷移方案資料庫
- 遷移資料庫成功!資料庫
- 建立資料庫遷移資料庫
- oracle資料庫遷移-文件 -LINUX_TO_WINDOWSOracle資料庫LinuxWindows
- SQL 遷移資料庫至ORACLE簡易方法SQL資料庫Oracle
- 建立Oracle ADG standby資料庫若干方法Oracle資料庫
- Oracle資料庫中資料行遷移與行連結Oracle資料庫
- 資料庫遷移神器——Flyway資料庫
- 遷移MySQL 5.7資料庫MySql資料庫