點擊上方“IT那活兒”公眾號,關注后了解更多內容,不管IT什么活兒,干就完了!!!
作為oracle數據庫提供的一種容災方式,ADG在我們日常生產中還是比較常見的,如何更快更好的搭建一套ADG,也是一個DBA需要掌握的基本技能。
IP: 172.25.18.251
DATABASE VERSION: 11.2.0.4.0
DB_NAME:ptgbss
DB_UNIQUE_NAME:ptgbss
Standby Database
先搭建好備庫的數據庫軟件,無需建庫。保持主庫和備庫的DB_NAME參數一致,DB_UNIQUE_NAME參數不能一致。
主庫配置
[oracle@localhost ~]$ telnet 172.25.18.252 1521
Trying 172.25.18.252...
Connected to 172.25.18.252.
Escape character is ^].
^C
^CConnection closed by foreign host.
[oracle@localhost ~]$
vi /u01/product/11.2.0/db_1/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
PTGBSS =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.18.251)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ptgbss)
)
)
PTGBSSDG =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.18.252)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ptgbssdg)
(UR=A)
)
)
tnsping 測試一下是否通:
[oracle@localhost admin]$ tnsping ptgbssdg
2.3 主庫開啟force_logging
查看是否已經開始強制日志:
select force_logging from v$database;
開啟強制日志:
ALTER DATABASE FORCE LOGGING;
2.4 主庫配置DG相關參數
主庫添加standby 日志,日志大小與online日志保持一致,數量比online日志數量多一組:
set line 200
col member for a50
SELECT * FROM V$LOGFILE;
alter database add standby logfile thread 1 group 10 /u01/oradata/ptgbss/redo10.log size 1024M;
alter database add standby logfile thread 1 group 11 /u01/oradata/ptgbss/redo11.log size 1024M;
alter database add standby logfile thread 1 group 12 /u01/oradata/ptgbss/redo12.log size 1024M;
alter database add standby logfile thread 1 group 13 /u01/oradata/ptgbss/redo13.log size 1024M;
alter database add standby logfile thread 1 group 14 /u01/oradata/ptgbss/redo14.log size 1024M;
alter database add standby logfile thread 1 group 15 /u01/oradata/ptgbss/redo15.log size 1024M;
alter database add standby logfile thread 1 group 16 /u01/oradata/ptgbss/redo16.log size 1024M;
alter database add standby logfile thread 1 group 17 /u01/oradata/ptgbss/redo17.log size 1024M;
alter database add standby logfile thread 1 group 18 /u01/oradata/ptgbss/redo18.log size 1024M;
alter database add standby logfile thread 1 group 19 /u01/oradata/ptgbss/redo19.log size 1024M;
修改DG相關參數:
alter system set LOG_ARCHIVE_CONFIG=DG_CONFIG=(ptgbss,ptgbssdg) scope=both ;
alter system set LOG_ARCHIVE_DEST_1=LOCATION=/data/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ptgbss scope=both;
alter system set LOG_ARCHIVE_DEST_2=SERVICE=ptgbssdg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ptgbssdg scope=both;
alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE scope=both;
alter system set LOG_ARCHIVE_DEST_STATE_2=ENABLE scope=both;
alter system set FAL_SERVER=ptgbssdg scope=both;
alter system set FAL_CLIENT=ptgbss scope=both;
alter system set standby_file_management=auto;
alter system set db_file_name_convert=/data/ptgbssdg,/data/ptgbss scope=spfile;
alter system set log_file_name_convert=/u01/oradata/ptgbssdg,/u01/oradata/ptgbss scope=spfile;
2.5 生成PFILE參數文件
create pfile from spfile;
2.6 傳輸參數文件和密碼文件到備庫
[oracle@localhost dbs]$ scp /u01/product/11.2.0/db_1/dbs/initptgbss.ora 172.25.18.252:/u01/product/11.2.0/db_1/dbs
[oracle@localhost dbs]$ scp /u01/product/11.2.0/db_1/dbs/orapwptgbss 172.25.18.252:/u01/product/11.2.0/db_1/dbs
備庫相關參數配置
1)數據文件目錄
2)日志文件目錄
3)歸檔目錄
3.2 備庫配置listener.ora
[oracle@ptgbssdg ~]$ vi /u01/product/11.2.0/db_1/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = ptgbssdg)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /u01
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ptgbss)
(ORACLE_HOME = /u01/product/11.2.0/db_1)
(SID_NAME = ptgbssdg)
)
)
3.3 備庫配置tnsname
# tnsnames.ora Network Configuration File: /u01/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
PTGBSS =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.18.251)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ptgbss)
)
)
PTGBSSDG =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.18.252)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ptgbssdg)
)
)
3.4 備庫修改參數文件
ptgbss.__db_cache_size=17448304640
ptgbssdg.__db_cache_size=16642998272
ptgbss.__java_pool_size=134217728
ptgbssdg.__java_pool_size=134217728
ptgbss.__large_pool_size=134217728
ptgbssdg.__large_pool_size=134217728
ptgbss.__oracle_base=/u01#ORACLE_BASE set from environment
ptgbssdg.__oracle_base=/u01#ORACLE_BASE set from environment
ptgbss.__pga_aggregate_target=3422552064
ptgbssdg.__pga_aggregate_target=3422552064
ptgbss.__sga_target=19327352832
ptgbssdg.__sga_target=19327352832
ptgbss.__shared_io_pool_size=0
ptgbssdg.__shared_io_pool_size=0
ptgbss.__shared_pool_size=1476395008
ptgbssdg.__shared_pool_size=2281701376
ptgbss.__streams_pool_size=0
ptgbssdg.__streams_pool_size=0
*.audit_file_dest=/u01/admin/ptgbss/adump --此處修改
*.audit_trail=db
*.compatible=11.2.0.4.0
*.control_files=/u01/oradata/ptgbssdg/control01.ctl,/u01/fast_recovery_area/ptgbssdg/control02.ctl --此處修改存放控制文件路徑
*.db_block_size=8192
*.db_domain=
*.db_file_name_convert=/data/ptgbss,/data/ptgbssdg --此處修改
*.db_name=ptgbss --此處修改
*.db_recovery_file_dest=/u01/fast_recovery_area --此處修改對應的路徑
*.db_recovery_file_dest_size=4385144832
*.db_unique_name=ptgbssdg --此處修改
*.diagnostic_dest=/u01
*.dispatchers=(PROTOCOL=TCP) (SERVICE=ptgbssXDB)
*.fal_client=PTGBSSDG --此處修改
*.fal_server=PTGBSS --此處修改
*.log_archive_config=DG_CONFIG=(ptgbssdg,ptgbss) --此處修改
*.log_archive_dest_1=location=/data/arch --此處修改
*.log_archive_dest_2=SERVICE=ptgbssdg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ptgbssdg --此處修改
*.log_archive_dest_state_1=ENABLE --修改此處參數
*.log_archive_dest_state_2=ENABLE --修改此處參數
*.log_file_name_convert=/u01/oradata/ptgbss,/u01/oradata/ptgbssdg --此處修改對應路徑
*.open_cursors=300
*.pga_aggregate_target=3365928960
*.processes=150
*.remote_login_passwordfile=EXCLUSIVE
*.sga_max_size=19327352832
*.sga_target=19327352832
*.standby_file_management=AUTO
*.undo_tablespace=UNDOTBS1
3.5 啟動備庫到nomount狀態,啟動監聽
啟動監聽lsnrctl start:
---主庫和備庫都需要驗證連通性:
sqlplus sys/oracle@ptgbss AS SYSDBA
sqlplus sys/oracle@ptgbssdg AS SYSDBA
3.6 使用RMAN DUPLICATE 主庫到備庫
rman target sys/oracle@ptgbss auxiliary sys/oracle@ptgbssdg
run
{
allocate channel cl1 type disk;
allocate channel cl2 type disk;
allocate channel cl3 type disk;
allocate auxiliary channel c1 type disk;
allocate auxiliary channel c2 type disk;
allocate auxiliary channel c3 type disk;
duplicate target database for standby from active database nofilenamecheck;
release channel c1;
release channel c2;
release channel c3;
}
備庫開啟日志應用并查看
4.1 duplicate成功后在備庫開啟日志應用
alter database open;
alter database recover managed standby database using current logfile disconnect from session;
select sequence#,thread#,applied from v$archived_log;
4.2 查看日志應用情況
col name for a50
select name,SEQUENCE#,APPLIED from v$archived_log order by sequence#;
select max(sequence#) from v$archived_log where applied=YES;
select thread#,max(sequence#) from v$archived_log where applied=YES group by threa
查看錯誤:
select dest_id,error from v$archive_dest;
查看gap:
select * from v$archive_gap;
查看standby日志狀態:
查看備庫狀態:
select MESSAGE from v$dataguard_status;
總 結:
文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。
轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/129274.html
RAC補丁日常更新成功反遇異常處理 img{ display:block; margin:0 auto !important; width:100%; } body{ width:75%; m...
摘要:搭建項目前準備工作首先你需要一臺電腦,建議做開發的電腦最好是內存以上最佳,土豪隨意。技術棧本次搭建主要采用開始搭建創建項目文件夾個人比價喜歡使用創建文件夾,畢竟接下來下載官方腳手架還是的用。 網上搜索了很久Vue項目搭建指南,并沒有找到寫的比較符合心意的,所以打算自己擼一個指南,集合眾家之所長(不善于排版,有點逼死強迫癥,如果覺得寫的有問題,可以留言斧正,覺得寫的太差的,可以留言哪里差...
摘要:項目地址前言大數據技術棧思維導圖大數據常用軟件安裝指南一分布式文件存儲系統分布式計算框架集群資源管理器單機偽集群環境搭建集群環境搭建常用命令的使用基于搭建高可用集群二簡介及核心概念環境下的安裝部署和命令行的基本使用常用操作分區表和分桶表視圖 項目GitHub地址:https://github.com/heibaiying... 前 言 大數據技術棧思維導圖 大數據常用軟件安裝指...
摘要:原文地址實戰指南二在中搭建服務器學習最快的方法就是直接使用,在實戰指南一介紹中,我們已經介紹了如何快速搭建,以及如何在中運行我們的第一個程序。 原文地址:Docker實戰指南(二):在Docker中搭建Nginx服務器 Introduction 學習Docker最快的方法就是直接使用,在Docker實戰指南(一):Docker介紹中,我們已經介紹了如何快速搭建Docker,以及如何在D...
閱讀 1347·2023-01-11 13:20
閱讀 1685·2023-01-11 13:20
閱讀 1133·2023-01-11 13:20
閱讀 1860·2023-01-11 13:20
閱讀 4101·2023-01-11 13:20
閱讀 2705·2023-01-11 13:20
閱讀 1386·2023-01-11 13:20
閱讀 3598·2023-01-11 13:20