單機搭建Data Guard
搭建環境:
Red Hat Linux Enterprise 5.4
Oracle 10g R2
主機作業系統主要資訊為192.168.199.128.
搭建準備:
已存在主庫(生產庫)DB_NAME=mustang SID=april
開始搭建Data Guard
首先需要準備好引數檔案,設定一些必要的引數。在主庫,先透過spfile生成pfile檔案:
SQL>create pfile=’/home/oracle/product/10.2initapril.ora’ from spfile;
然後修改主庫新生成的initapril.ora引數檔案。在原有的基礎上新增如下內容:
db_unique_name=mustang
log_archive_config='DG_CONFIG=(mustang,standby)'
log_archive_dest_2='service=standby arch async valid_for=(online_logfiles,primary_role)
db_unique_name=standby'
log_archive_dest_1='location=/home/oracle/archive valid_for=(all_logfiles,all_roles)
db_unique_name=mustang'
log_archive_dest_state_1=enable
log_archive_dest_state_2=enable
log_archive_format=%t_%s_%r.arc
log_archive_max_processes=30
fal_server=standby
fal_client=mustang
db_file_name_convert='standby','mustang'
log_file_name_convert='/home/oracle/','/home/oracle/standby/'
standby_file_management=auto
修改完引數檔案之後,要重新開啟主庫,然後透過iniapril.ora來建立spfile。如下:
SQL>create spfile=’/home/oracle/product/10.2.0/db_1/dbs/spfileapril.ora’ from pfile=’
/home/oracle/product/10.2.0/db_1/dbs/initapril.ora’;
接下來的工作就是要透過主庫的引數檔案,建立備庫需要的引數檔案,在主庫上執行:
SQL>create pfile=’ /home/oracle/product/10.2.0/db_1/dbs/initstandby.ora’ from spfile;
編輯initstandby.ora。如下所示:
standby.__db_cache_size=213909504
standby.__large_pool_size=4194304
*.control_files='/home/oracle/standby/standby.ctl'
*.db_file_multiblock_read_count=8
*.db_file_name_convert='standby','mustang'
*.db_files=80
*.db_name='mustang'
*.db_unique_name='standby'
*.fal_client='standby'
*.fal_server='mustang'
*.global_names=TRUE
*.instance_name='standby'
*.log_archive_config='DG_CONFIG=(mustang,standby)'
*.log_archive_dest_1='location=/home/oracle/standby/archive'
*.log_archive_dest_2='service=mustang arch async valid_for=(online_logfiles,primary_role)
db_unique_name=mustang'
*.log_archive_dest_state_1='enable'
*.log_archive_dest_state_2='enable'
*.log_archive_format='%t_%s_%r.arc'
*.log_archive_max_processes=30
*.log_buffer=32768
*.log_checkpoint_interval=10000
*.log_file_name_convert='/home/oracle/','/home/oracle/standby/'
*.max_dump_file_size='10240'
*.parallel_max_servers=5
*.processes=50
*.service_names='standby'
*.sga_max_size=300M
*.sga_target=300M
*.standby_file_management='auto'
*.undo_management='auto'
*.undo_tablespace='undotbs'
儲存initstandby.ora引數檔案。透過initstandby.ora生成動態檔案spfilestandby.ora:
SQL>create spfile=’/home/oracle/product/10.2.0/db_1/dbs/spfilestandby.ora’ from pfile=’
/home/oracle/product/10.2.0/db_1/dbs/initstandby.ora’;
在主庫上建立我們的密碼檔案:
[oracle@localhost dbs]$orapwd file=’ /home/oracle/product/10.2.0/db_1/dbs/orapwstandby’ password=oracle entries=10
透過主庫的控制檔案生成我們備庫的控制檔案:
SQL>alter database create standby controlfile as ‘/home/oracle/standby.ctl’;
開始建立備庫:
首先建立備庫的目錄結構,這裡我們以主庫位於同一目錄:
主庫:/home/oracle/mustang 主庫歸檔檔案:/home/oracle/archive
於是我們在/home/oracle下建立我們的備庫目錄:
mkdir standby
cd standby
mkdir archive
mkdir bdump
mkdir udump
目錄結構完成。
下一步就是要配置監聽(如果沒有監聽standby是啟動不了的)。在配置監聽之前,首先要進行一步就是要生成備庫的密碼檔案:
[oracle@localhost dbs]$orapwd file=’ /home/oracle/product/10.2.0/db_1/dbs/orapwstandby’ password=oracle entries=10
將路徑切換到/home/oracle/product/10.2.0/db_1/network/admin下。透過ls命令可以看到:
[oracle@localhost admin]$ ls
listener.ora shrept.lst sqlnet.log tnsnames.ora
再配置監聽之前,要先將我們的監聽服務停止:lsnrctl stop。
開始配置監聽
首先配置tnsnames.ora檔案。設定服務名(因為我們這裡是單機,所以配置在本機上配置就行了,如果是兩臺機的話,就要在主備庫的tnsnames.ora同時修改):
april=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521))
(CONNECT_DATA=
(SERVER=DEDICATED)
(SERVICE_NAME=mustang)
)
)
standby=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1522))
(CONNECT_DATA=
(SERVER=DEDICATED)
(SERVICE_NAME=standby)
)
)
接下來配置listener.ora檔案(建議用途netmgr配置,比較方便,因為手工配置容易出錯)。配置如下:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = mustang)
(ORACLE_HOME = /home/oracle/product/10.2.0/db_1)
(SID_NAME = april)
)
(SID_DESC =
(GLOBAL_DBNAME = standby)
(ORACLE_HOME = /home/oracle/product/10.2.0/db_1)
(SID_NAME = standby)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1522))
)
)
TRACE_LEVEL_LISTENER = USER
至此我們的監聽配置就完成,啟動監聽器:
[oracle@localhost admin]$ lsnrctl start
出現如下內容說明,已經配置成功:
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 26-JUL-2012 20:59:37
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Starting /home/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /home/oracle/product/10.2.0/db_1/network/admin/listener.ora
Log messages written to /home/oracle/product/10.2.0/db_1/network/log/listener.log
Trace information written to /home/oracle/product/10.2.0/db_1/network/trace/listener.trc
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1522)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 26-JUL-2012 20:59:37
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level user
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /home/oracle/product/10.2.0/db_1/network/log/listener.log
Listener Trace File /home/oracle/product/10.2.0/db_1/network/trace/listener.trc
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1522)))
Services Summary...
Service "mustang" has 1 instance(s).
Instance "april", status UNKNOWN, has 1 handler(s) for this service...
Service "standby" has 1 instance(s).
Instance "standby", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
我們也可以透過tnsping來檢查,是否配置成功:
[oracle@localhost admin]$ tnsping standby
TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 26-JUL-2012 21:00:45
Copyright (c) 1997, 2005, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1522)) (CONNECT_DATA= (SERVER=DEDICATED) (SERVICE_NAME=standby)))
OK (20 msec)
[oracle@localhost admin]$ tnsping april
TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 26-JUL-2012 21:00:51
Copyright (c) 1997, 2005, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)) (CONNECT_DATA= (SERVER=DEDICATED) (SERVICE_NAME=mustang)))
OK (30 msec)
看到以上提示,說明我們的監聽配置完全正確。
複製相關檔案到備庫的目錄下:
[oracle@localhost mustang]$cp /home/oracle/mustang/*.dbf /home/oracle/standby
[oracle@localhost mustang]$cp /home/oracle/standby.ctl /home/oracle/standby/
接下來,開始啟動我們的主庫和備庫,最好開啟兩個視窗進行實驗:
在主庫視窗:
1)指定以april例項開始我們的主庫:
export ORACLE_SID=april
2)
[oracle@localhost admin]$ sqlplus sys/oracle@april as sysdba
3)開啟主庫的歸檔模式和force logging:
SQL>alter database archivelog;
SQL>alter database force logging;
在備庫視窗:
1) 指定以standby例項開啟我們的備庫:
export ORACLE_SID=standby
2)
[oracle@localhost admin]$ sqlplus sys/oracle@standby as sysdba
3) 使standby資料庫處於恢復狀態,主備庫歸檔日誌同步
SQL>alter database recover managed standby database disconnect from session:
接下來就要檢視我們的Data Guard是否正常。
我們在主庫環境下,檢視當前的歸檔日誌情況:
SQL>select sequence#,first_time,next_time from v$archived_log order by sequence#;
然後切換到備庫環境下,檢視當前的歸檔日誌情況:
SQL>select sequence#,first_time,next_time from v$archived_log order by sequence#;
接著我們再次切換到主庫環境下,進行一次日誌切換:
SQL>alter system switch logfile;
再次檢視主庫的歸檔情況:
SQL>select sequence#,first_time,next_time from v$archived_log order by sequence#;
這時,你會發現多了2個歸檔檔案。
我們再切到備庫,檢視:
SQL>select sequence#,first_time,next_time from v$archived_log order by sequence#;
發現備庫的歸檔檔案也同樣多了。
至此,可以說明我們的歸檔同步了。
在主庫下:我們新建一個表,然後往表中插入資料,先不要commit。我們發現備庫中也同樣有了這個表,但是還沒有資料,如果我們commit掉主庫的事務,備庫中該表就有了資料了。
我們可以檢視主庫和備庫的switchover引數。
SQL>select switchover_status,database_role from v$database;
DG搭建工作至此完成。剛剛學習Data Guard,上文有不正確的地方,還請多多批評賜教!
©著作權歸作者所有:來自51CTO部落格作者鄭宏輝的原創作品,如需轉載,請註明出處,否則將追究法律責任
oracle單機DGOracle
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/3034/viewspace-2821231/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【DG】Data Guard搭建(physical standby)
- Oracle Data Guard Broker元件Oracle元件
- Oracle Data Guard簡介Oracle
- 1 關於 Oracle Data GuardOracle
- 2 Oracle Data Guard 安裝Oracle
- 1 Oracle Data Guard Broker 概念Oracle
- bd_ticket_guard_client_dataclient
- Oracle Data Guard和Broker概述Oracle
- 使用Data Guard Broker進行Data Guard物理備用庫配置(Oracle 19c)Oracle
- 8 Oracle Data Guard Broker 屬性Oracle
- 9 Oracle Data Guard 故障診斷Oracle
- Bd-Ticket-Guard-Client-Data逆向client
- oracle 11g data guard維護Oracle
- 4.1.6 Oracle Restart 與 Oracle Data Guard 整合OracleREST
- 【DATAGUARD】Oracle19c Data Guard BrokerOracle
- 2 開始實用 Oracle Data GuardOracle
- 19 Oracle Data Guard 相關檢視Oracle
- 主備庫記憶體不一致的Data Guard環境搭建記憶體
- 6 Oracle Data Guard Protection Modes 保護模式Oracle模式
- 【DG】Data Guard主備庫Failove切換AI
- 【DG】Data Guard主備庫Switchover切換
- 15 Oracle Data Guard Scenarios 保護場景OracleiOS
- A Oracle Data Guard Broker 升級和降級Oracle
- Oracle 12.2 How to Generate AWRs in Active Data Guard Standby DatabasesOracleDatabase
- Oracle Data Guard Feature 12cR2系列(二)Oracle
- Oracle Data Guard Feature 12cR2系列(一)Oracle
- 【ASK_ORACLE】Oracle Data Guard(一)DG架構Oracle架構
- 18 與Oracle Data Guard 相關的SQL語句OracleSQL
- [20221111]19c配置Data Guard Broker問題.txt
- 使用Broker管理Data Guard——停用、改保護模式等模式
- 需要了解的Data Guard理論知識(一)
- 需要了解的Data Guard理論知識(二)
- 需要了解的Data Guard理論知識(三)
- 【mos 1265700.1】Oracle Patch Assurance - Data Guard Standby-First Patch ApplyOracleAPP
- [20201110]How to get the Data Guard broker configuration from a SQL query.txtSQL
- 單機MGR搭建
- Oracle 19C Data Guard基礎運維-02 Switchovers(物理)Oracle運維
- Oracle 19C Data Guard基礎運維-03 Failovers(物理)Oracle運維AI