oracle+11g+ADG實(shí)施手冊(cè)(親測(cè)已成功部署多次)_第1頁(yè)
oracle+11g+ADG實(shí)施手冊(cè)(親測(cè)已成功部署多次)_第2頁(yè)
oracle+11g+ADG實(shí)施手冊(cè)(親測(cè)已成功部署多次)_第3頁(yè)
已閱讀5頁(yè),還剩29頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

oracle11gADG實(shí)施手冊(cè)(親測(cè),已成功部署多次)一:實(shí)驗(yàn)環(huán)境介紹虛擬機(jī)系統(tǒng):

RHELLinux6.4(64位)數(shù)據(jù)庫(kù)版本:

Oracle11gR2(64位)IP地址規(guī)劃:主數(shù)據(jù)庫(kù)20

SID:pridb_name:pridb_unique_name:pri備份數(shù)據(jù)庫(kù)21

SID:stddb_name:pridb_unique_name:std

安裝完成后可以通過(guò)以下命令查詢:selectdbid,name,open_mode,db_unique_namefromv$database;selectinstance_namefromv$instance;

基礎(chǔ)要求:(1)安裝兩臺(tái)虛擬機(jī)分別作為主庫(kù)和備庫(kù),硬盤(pán)大小隨意。但要保證根分區(qū)有20G,別給太小了就行。物理內(nèi)存1G,SWAP2G關(guān)于Activedatabaseduplication方式:(必看)在Oracle10g下,我們可以使用RMANduplicate命令創(chuàng)建一個(gè)具有不同DBID的復(fù)制庫(kù)。到了Oracle11gR2,RMAN的duplicate有2種方法實(shí)現(xiàn):1.Activedatabaseduplication

(本文所使用的方式,適用于11gR2之后的版本)2.Backup-basedduplication

(傳統(tǒng)方式,10g,11g通用)

Activedatabaseduplication通過(guò)網(wǎng)絡(luò),直接copytarget庫(kù)到auxiliary庫(kù),然后創(chuàng)建復(fù)制庫(kù)。這種方法就不需要先用RMAN備份數(shù)據(jù)庫(kù),然后將備份文件發(fā)送到auxiliary端。這個(gè)功能的作用是非常大的。尤其是對(duì)T級(jí)別的庫(kù)。因?yàn)閷?duì)這樣的庫(kù)進(jìn)行備份,然后將備份集發(fā)送到備庫(kù),在進(jìn)行duplicate的代價(jià)是非常大的。一備份要占用時(shí)間,二要占用備份空間,三在網(wǎng)絡(luò)傳送的時(shí)候,還需要占用帶寬和時(shí)間。所以Activedatabaseduplicate很好的解決了以上的問(wèn)題。它對(duì)大庫(kù)的遷移非常有用。如果是從RACduplicate到單實(shí)例,操作是一樣的。如果是從單實(shí)例duplicate到RAC。那么先duplicate到單實(shí)例。然后將單實(shí)例轉(zhuǎn)換成RAC。

二:安裝數(shù)據(jù)庫(kù)軟件前的系統(tǒng)配置

(主庫(kù)和備庫(kù)端都要做下列操作)1.基本配置:一定要用新裝的系統(tǒng)(這里以紅帽企業(yè)版6.4為例),系統(tǒng)要求最低配置1G內(nèi)存,2Gswap分區(qū),根分區(qū)20G以上,裝好系統(tǒng)后先配置好yum,IP地址,/etc/sysconfig/network文件中的主機(jī)名,以及/etc/hosts文件中的IP地址和主機(jī)名的對(duì)應(yīng)關(guān)系。

主庫(kù)IP:20

主庫(kù)主機(jī)名:ora11g備庫(kù)IP:21備庫(kù)主機(jī)名:ora11g-dg

2.裝包binutils-.2-5.11.el6(x86_64)compat-libcap1-1.10-1(x86_64)compat-libstdc++-33-3.2.3-69.el6(x86_64)compat-libstdc++-33-3.2.3-69.el6.i686gcc-4.4.4-13.el6(x86_64)gcc-c++-4.4.4-13.el6(x86_64)glibc-2.12-1.7.el6(i686)glibc-2.12-1.7.el6(x86_64)glibc-devel-2.12-1.7.el6(x86_64)glibc-devel-2.12-1.7.el6.i686kshpdksh-5.2.14-21.x86_64.rpmlibgcc-4.4.4-13.el6(i686)libgcc-4.4.4-13.el6(x86_64)libstdc++-4.4.4-13.el6(x86_64)libstdc++-4.4.4-13.el6.i686libstdc++-devel-4.4.4-13.el6(x86_64)libstdc++-devel-4.4.4-13.el6.i686libaio-0.3.107-10.el6(x86_64)libaio-0.3.107-10.el6.i686libaio-devel-0.3.107-10.el6(x86_64)libaio-devel-0.3.107-10.el6.i686make-3.81-19.el6sysstat-9.0.4-11.el6(x86_64)unixODBC-2.2.14-11.el6(x86_64)

orlaterunixODBC-2.2.14-11.el6.i686

orlaterunixODBC-devel-2.2.14-11.el6(x86_64)

orlaterunixODBC-devel-2.2.14-11.el6.i686

orlater

3.創(chuàng)建相關(guān)的組與用戶:/usr/sbin/groupaddoinstall/usr/sbin/groupadd-g502dba/usr/sbin/groupadd-g503oper/usr/sbin/useradd-u502-goinstall-Gdba,operoracle

#passwdoracle

4.創(chuàng)建所需的目錄并賦予特定的屬主和屬組mkdir-p/u01/app/oraclechown-Roracle:oinstall/u01/appchmod-R775/u01/app

5.編輯limits.conf文件vim/etc/security/limits.conf添加下面5行內(nèi)容:vim/etc/security/limits.conforacle

soft

nproc

2047oracle

hard

nproc

16384oracle

soft

nofile

1024oracle

hard

nofile

65536oracle

soft

stack

10240

6.編輯sysctl.conf文件,設(shè)置相關(guān)參數(shù)vim/etc/sysctl.conf添加/修改下列內(nèi)容:(注意!下面的參數(shù),若是已經(jīng)存在,則直接修改數(shù)值,不要再添加同樣的參數(shù),相同的參數(shù)只能有一個(gè)!如果需要修改的參數(shù)已經(jīng)大于下面的數(shù)字,則不用修改,請(qǐng)仔細(xì)核對(duì)?。﹙im/etc/sysctl.conf

fs.aio-max-nr=1048576fs.file-max=6815744kernel.shmall=2097152kernel.shmmax=4294967295kernel.shmmni=4096kernel.sem=25032000100128net.ipv4.ip_local_port_range=900065500net.core.rmem_default=262144net.core.rmem_max=4194304net.core.wmem_default=262144net.core.wmem_max=1048576#sysctl–p使其生效#/sbin/sysctl-p保存退出后,別忘了用sysctl-p命令使參數(shù)生效!

7.編輯vim/home/oracle/.bash_profile文件,配置相關(guān)環(huán)境變量添加下列幾行:exportORACLE_BASE=/u01/app/oracleexportORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1exportORACLE_SID=pri(備庫(kù)端設(shè)置為std)exportLD_LIBRARY_PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/local/bin:exportCLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlibexportPATH=$ORACLE_HOME/bin:$PATH

注意:服務(wù)器需要關(guān)閉iptables和selinuxlinux6.4系統(tǒng):iptables–FServiceiptablessaveSetenforce0Vi/etc/selinux/config[oracle@ora11gadmin]$more/etc/selinux/config

#ThisfilecontrolsthestateofSELinuxonthesystem.#SELINUX=cantakeoneofthesethreevalues:#enforcing-SELinuxsecuritypolicyisenforced.#permissive-SELinuxprintswarningsinsteadofenforcing.#disabled-NoSELinuxpolicyisloaded.SELINUX=disabled#SELINUXTYPE=cantakeoneofthesetwovalues:#targeted-Targetedprocessesareprotected,#mls-MultiLevelSecurityprotection.SELINUXTYPE=targeted

三:開(kāi)始安裝oracle11g數(shù)據(jù)庫(kù)軟件

(主庫(kù)和備庫(kù)端都要做下列操作)1.掛載oracle11g的鏡像到/mnt/cdrom目錄下,并把3個(gè)包解壓到/usr/local/src目錄下cd/mnt/cdrom/unzipp13390677_112040_Linux-x86-64_1of7.zip-d/usr/local/srcunzipp13390677_112040_Linux-x86-64_2of7.zip-d/usr/local/srcunzipp13390677_112040_Linux-x86-64_3of7.zip-d/usr/local/src(只裝數(shù)據(jù)庫(kù)的話,解壓前兩個(gè)包即可,第三個(gè)包是grid)2.root身份執(zhí)行xhost+,然后切換到oracle用戶進(jìn)入/usr/local/src/database目錄中,執(zhí)行runInstaller開(kāi)始安裝(database是默認(rèn)解壓完的目錄名)#xhost+#su-oracle$./runInstaller注意:安裝oracle11g要求分辨率最低為1024x768,不然無(wú)法完整顯示安裝過(guò)程

安裝過(guò)程:略注意:主庫(kù)在安裝完軟件后需要進(jìn)行DBCA建庫(kù)操作,推薦不要啟用歸檔模式,會(huì)節(jié)省時(shí)間,備庫(kù)端不要建庫(kù)!可以開(kāi)啟監(jiān)聽(tīng)程序

四:開(kāi)始搭建Dataguard

1:將數(shù)據(jù)庫(kù)改為強(qiáng)制日志模式

(此步驟只在主庫(kù)上做)[oracle@pri~]$sqlplus/assysdba

查看當(dāng)前是否強(qiáng)制日志模式:SYS@pri>selectname,log_mode,force_loggingfromv$database;

NAMELOG_MODEFOR

PRI

NOARCHIVELOGNO

SYS@pri>alterdatabaseforcelogging;

Databasealtered.

SYS@pri>selectname,log_mode,force_loggingfromv$database;

NAMELOG_MODEFOR

PRI

NOARCHIVELOGYES

2:創(chuàng)建密碼文件

(此步驟只在主庫(kù)上做)注意:兩端分別創(chuàng)建自己的密碼文件好像有問(wèn)題,備庫(kù)的密碼文件需要跟主庫(kù)一致,否則導(dǎo)致日志傳輸不到備庫(kù),有待驗(yàn)證。我最后是將主庫(kù)的密碼文件直接copy到備庫(kù),重命名后使用。[oracle@pri~]$cd$ORACLE_HOME/dbs[oracle@ora11gdbs]$lshc_pri.dat

init.ora

initpri.ora

lkPRI

orapwpri

snapcf_pri.f

spfilepri.ora

已經(jīng)有一個(gè)密碼文件了[oracle@pridbs]$orapwdfile=orapwpripassword=oracleforce=y這條命令可以手動(dòng)生成密碼文件,force=y的意思是強(qiáng)制覆蓋當(dāng)前已有的密碼文件(如果有可以不建立)

將主庫(kù)的密碼文件copy給備庫(kù),并重命名[oracle@pridbs]$scporapwpri21:$ORACLE_HOME/dbs/orapwstd

3:創(chuàng)建standbyredolog日志組

(此步驟只在主庫(kù)上做)原則:1:standbyredolog的文件大小與primary數(shù)據(jù)庫(kù)onlineredolog文件大小相同2:standbyredolog日志文件組的個(gè)數(shù)依照下面的原則進(jìn)行計(jì)算:Standbyredolog組數(shù)公式>=(每個(gè)instance日志組個(gè)數(shù)+1)*instance個(gè)數(shù)假如只有一個(gè)節(jié)點(diǎn),這個(gè)節(jié)點(diǎn)有三組redolog,所以Standbyredolog組數(shù)>=(3+1)*1==4所以至少需要?jiǎng)?chuàng)建4組Standbyredolog

查看當(dāng)前線程與日志組的對(duì)應(yīng)關(guān)系及日志組的大小:SYS@pri>selectthread#,group#,bytes/1024/1024fromv$log;

THREAD#GROUP#BYTES/1024/1024

115012501350如上,我現(xiàn)在的環(huán)境有三組redolog,每個(gè)日志組的大小都是50M,所以Standbyredolog組數(shù)>=(3+1)*1==4所以至少需要?jiǎng)?chuàng)建4組Standbyredolog,大小均為50M(thread:線程,只有在多實(shí)例數(shù)據(jù)庫(kù)才有用的參數(shù),例如RAC環(huán)境,單實(shí)例不考慮)

查看當(dāng)前有哪些日志組及其成員:SYS@pri>colmemberfora50SYS@pri>selectgroup#,memberfromv$logfile;

GROUP#MEMBER3/u01/app/oracle/oradata/pri/redo03.log2/u01/app/oracle/oradata/pri/redo02.log1/u01/app/oracle/oradata/pri/redo01.log

先手動(dòng)創(chuàng)建standbylog日志組所需的目錄:(創(chuàng)建新目錄只是為了便于區(qū)分,并非必須)[oracle@ora11goradata]$cd/u01/app/oracle/oradata/[oracle@ora11goradata]$lsstandbylogpri

新建4個(gè)日志組作為standbyredolog日志組,大小與原來(lái)的日志組一致:由于已經(jīng)存在group1-3,,所以group號(hào)只能從4開(kāi)始SYS@pri>alterdatabaseaddstandbylogfilegroup4'/u01/app/oracle/oradata/standbylog/std_redo04.log'size50m;alterdatabaseaddstandbylogfilegroup5'/u01/app/oracle/oradata/standbylog/std_redo05.log'size50m;alterdatabaseaddstandbylogfilegroup6'/u01/app/oracle/oradata/standbylog/std_redo06.log'size50m;alterdatabaseaddstandbylogfilegroup7'/u01/app/oracle/oradata/standbylog/std_redo07.log'size50m;

查看standby日志組的信息:SYS@pri>selectgroup#,sequence#,status,bytes/1024/1024fromv$standby_log;

GROUP#SEQUENCE#STATUSBYTES/1024/102440UNASSIGNED5050UNASSIGNED5060UNASSIGNED5070UNASSIGNED50

查看當(dāng)前有哪些日志組及其成員:SYS@pri>setpagesize100SYS@pri>colmemberfora60SYS@pri>selectgroup#,memberfromv$logfileorderbygroup#;

GROUP#

MEMBER

1

/u01/app/oracle/oradata/pri/redo01.log2

/u01/app/oracle/oradata/pri/redo02.log3

/u01/app/oracle/oradata/pri/redo03.log4

/u01/app/oracle/oradata/standbylog/std_redo04.log5

/u01/app/oracle/oradata/standbylog/std_redo05.log6

/u01/app/oracle/oradata/standbylog/std_redo06.log7

/u01/app/oracle/oradata/standbylog/std_redo07.log

4:修改主庫(kù)的pfile參數(shù)文件

(此步驟只在主庫(kù)上做)

查看spfile的路徑:SYS@pri>showparameterspfile;

NAMETYPEVALUEspfilestring/u01/app/oracle/product/11.2.0/db_1/dbs/spfilepri.ora

用spfile創(chuàng)建一個(gè)pfile,用于修改:

SYS@pri>createpfilefromspfile;

修改主庫(kù)的pfile:/u01/app/oracle/product/11.2.0/db_1/dbs/initpri.ora[oracle@pri~]$cd$ORACLE_HOME/dbspri.__db_cache_size=318767104pri.__java_pool_size=4194304pri.__large_pool_size=4194304pri.__oracle_base='/u01/app/oracle'#ORACLE_BASEsetfromenvironmentpri.__pga_aggregate_target=335544320pri.__sga_target=503316480pri.__shared_io_pool_size=0pri.__shared_pool_size=163577856pri.__streams_pool_size=0*.audit_file_dest='/u01/app/oracle/admin/pri/adump'*.audit_trail='db'*.compatible='.0'*.control_files='/u01/app/oracle/oradata/pri/control01.ctl','/u01/app/oracle/flash_recovery_area/pri/control02.ctl'*.db_block_size=8192*.db_domain=''*.db_name='pri'*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'*.db_recovery_file_dest_size=4070572032*.diagnostic_dest='/u01/app/oracle'*.dispatchers='(PROTOCOL=TCP)(SERVICE=priXDB)'*.log_archive_format='%t_%s_%r.dbf'*.memory_target=836763648*.open_cursors=300*.processes=150*.remote_login_passwordfile='EXCLUSIVE'*.undo_tablespace='UNDOTBS1'以下內(nèi)容是需要新增加的:*.db_unique_name='pri'DG主庫(kù)和備庫(kù)的db_name必須一致,db_unique_name不一致*.log_archive_config='dg_config=(pri,std)'pri主數(shù)據(jù)庫(kù)SID,std備份數(shù)據(jù)庫(kù)SID*.log_archive_dest_1='location=/u01/app/oracle/archvalid_for=(all_logfiles,all_roles)db_unique_name=pri'主數(shù)據(jù)庫(kù)的歸檔日志路徑和SID*.log_archive_dest_2='service=stdvalid_for=(online_logfiles,primary_role)db_unique_name=std'備份數(shù)據(jù)庫(kù)的SID*.log_archive_dest_state_1=enable*.log_archive_dest_state_2=enable*.log_archive_max_processes=4*.fal_server='std'備份數(shù)據(jù)庫(kù)的SID*.fal_client='pri'主數(shù)據(jù)庫(kù)的SID*.db_file_name_convert='/u01/app/oracle/oradata/std','/u01/app/oracle/oradata/pri'第一個(gè)目錄是備份數(shù)據(jù)庫(kù)數(shù)據(jù)文件路徑(備份服務(wù)器上有此目錄),第二個(gè)是主數(shù)據(jù)庫(kù)數(shù)據(jù)文件路徑*.log_file_name_convert='/u01/app/oracle/oradata/std','/u01/app/oracle/oradata/pri'第一個(gè)目錄是備份數(shù)據(jù)庫(kù)數(shù)據(jù)文件路徑(備份服務(wù)器上有此目錄),第二個(gè)是主數(shù)據(jù)庫(kù)數(shù)據(jù)文件路徑*.standby_file_management='auto'修改完畢,保存退出

手工創(chuàng)建/u01/app/oracle/arch:

[oracle@pridbs]$mkdir–p/u01/app/oracle/arch

5:用修改過(guò)的pfile重新創(chuàng)建一個(gè)spfile,用于重啟數(shù)據(jù)庫(kù)

(此步驟只在主庫(kù)上做)關(guān)閉數(shù)據(jù)庫(kù):SYS@pri>shutdownimmediate;Databaseclosed.Databasedismounted.ORACLEinstanceshutdown.

用修改過(guò)的pfile重新創(chuàng)建一個(gè)spfile:SYS@pri>createspfilefrompfile;

此時(shí)把數(shù)據(jù)庫(kù)改為歸檔模式:

(如果當(dāng)初建庫(kù)時(shí)選擇了啟用歸檔,則此步驟忽略)由于當(dāng)前數(shù)據(jù)庫(kù)已關(guān)閉,首先需要把數(shù)據(jù)庫(kù)啟動(dòng)到mount狀態(tài)SYS@pri>startupmount;

ORACLEinstancestarted.Databasemounted.SYS@pri>alterdatabasearchivelog;

啟用歸檔模式Databasealtered.

SYS@pri>alterdatabaseopen;

OPEN數(shù)據(jù)庫(kù)Databasealtered.

SYS@pri>archiveloglist;

查看是否啟用歸檔模式SQL>archiveloglist;DatabaselogmodeArchiveModeAutomaticarchivalEnabledArchivedestination/u01/app/oracle/archOldestonlinelogsequence22Nextlogsequencetoarchive24Currentlogsequence24如上,歸檔路徑已經(jīng)改為/u01/app/oracle/arch,證明對(duì)pfile的修改已生效

查看當(dāng)前數(shù)據(jù)庫(kù)是否使用spfile啟動(dòng):

SYS@pri>showparameterspfile;

NAMETYPEVALUEspfilestring/u01/app/oracle/product/11.2.0/db_1/dbs/spfilepri.ora

如上,若能看到spfile的路徑,則證明數(shù)據(jù)庫(kù)是使用spfile啟動(dòng)的,若沒(méi)有值,則說(shuō)明是用pfile啟動(dòng)的。

確認(rèn)數(shù)據(jù)庫(kù)已經(jīng)啟用歸檔模式和強(qiáng)制日志模式:SYS@pri>selectname,log_mode,force_loggingfromv$database;

NAMELOG_MODEFOR

PRIARCHIVELOGYES

6:修改監(jiān)聽(tīng)文件,添加靜態(tài)監(jiān)聽(tīng)

(主庫(kù)、備庫(kù)都要做)主庫(kù):[oracle@pri~]$cd$ORACLE_HOME/network/admin[oracle@priadmin]$vimlistener.ora

添加的內(nèi)容如下紅色字體部分:#listener.oraNetworkConfigurationFile:/u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora#GeneratedbyOracleconfigurationtools.

LISTENER=

(DESCRIPTION_LIST=

(DESCRIPTION=

(ADDRESS=(PROTOCOL=TCP)(HOST=20)(PORT=1521))

(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))

)

)

SID_LIST_LISTENER=

(SID_LIST=

(SID_DESC=

(GLOBAL_DBNAME=pri)

(ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)

(SID_NAME=pri)

)

)

ADR_BASE_LISTENER=/u01/app/oracle主庫(kù)修改后最終效果如下圖:

備庫(kù):[oracle@pri~]$cd$ORACLE_HOME/network/admin[oracle@priadmin]$vimlistener.ora

添加的內(nèi)容如下紅色字體部分:#listener.oraNetworkConfigurationFile:/u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora#GeneratedbyOracleconfigurationtools.

LISTENER=

(DESCRIPTION_LIST=

(DESCRIPTION=

(ADDRESS=(PROTOCOL=TCP)(HOST=21)(PORT=1521))

(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))

)

)

SID_LIST_LISTENER=

(SID_LIST=

(SID_DESC=

(GLOBAL_DBNAME=std)

(ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)

(SID_NAME=std)

)

)

ADR_BASE_LISTENER=/u01/app/oracle備庫(kù)修改后最終效果如下圖:

使新增加的監(jiān)聽(tīng)生效:

(主庫(kù)和備庫(kù)端都要做)[oracle@priadmin]$lsnrctlstop[oracle@priadmin]$lsnrctlstart

確認(rèn)新增加的靜態(tài)監(jiān)聽(tīng)有效:主庫(kù):[oracle@pri~]$lsnrctlstatus(N行省略)ServicesSummary...Service"pri"has2instance(s).Instance"pri",statusUNKNOWN,has1handler(s)forthisservice...Instance"pri",statusREADY,has1handler(s)forthisservice...Service"priXDB"has1instance(s).Instance"pri",statusREADY,has1handler(s)forthisservice...Thecommandcompletedsuccessfully

備庫(kù):[oracle@std~]$lsnrctlstatus(N行省略)ServicesSummary...Service"std"has2instance(s).Instance"std",statusUNKNOWN,has1handler(s)forthisservice...Thecommandcompletedsuccessfully如上,靜態(tài)監(jiān)聽(tīng)添加成功

7:編輯網(wǎng)絡(luò)服務(wù)名配置文件tnsnames.ora

(主庫(kù)和備庫(kù)端都要做)[oracle@ora11gadmin]$pwd/u01/app/oracle/product/11.2.0/db_1/network/admin[oracle@ora11gadmin]$lslistener.orasamplestnsnames.oralistener.ora_bakshrept.lsttnsnames.ora_bak[oracle@ora11gadmin]$moretnsnames.ora#tnsnames.oraNetworkConfigurationFile:/u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora#GeneratedbyOracleconfigurationtools.pri=

(DESCRIPTION=

(ADDRESS=(PROTOCOL=TCP)(HOST=20)(PORT=1521))

(CONNECT_DATA=

(SERVER=DEDICATED)

(SERVICE_NAME=pri)

)

)

std=

(DESCRIPTION=

(ADDRESS=(PROTOCOL=TCP)(HOST=21)(PORT=1521))

(CONNECT_DATA=

(SERVER=DEDICATED)

(SERVICE_NAME=std)

)

)

編輯結(jié)果如下圖:

保證主庫(kù)和備庫(kù)的tnsnames.ora文件中的內(nèi)容完全相同,可以把修改后的文件直接傳給備庫(kù)。[oracle@ora11gadmin]$scptnsnames.ora21:$ORACLE_HOME/network/admintnsnames.ora100%9250.9KB/s00:00

配置完后,確保在任意一端上都能tnsping通對(duì)方:[oracle@priadmin]$tnspingstd[oracle@stdadmin]$tnspingpri

8:在備庫(kù)端,修改pfile參數(shù)文件

(只在備庫(kù)端做)首先,在主庫(kù)端把pfile拷貝給備庫(kù)端的$ORACLE_HOME/dbs目錄下,并重命名:[oracle@ora11g-dg~]$cd$ORACLE_HOME/dbs[oracle@ora11g-dgdbs]$lshc_std.datinit.orainitstd.oralkSTDorapwstdspfilestd.ora[oracle@ora11gdbs]$scpinitpri.ora53:$ORACLE_HOME/dbs/initstd.orainitpri.ora100%14971.5KB/s00:00然后在備庫(kù)端進(jìn)行修改:[oracle@ora11g-db~]$cd$ORACLE_HOME/dbs

[oracle@ora11g-dgdbs]$moreinitstd.orapri.__db_cache_size=318767104pri.__java_pool_size=4194304pri.__large_pool_size=4194304pri.__oracle_base='/u01/app/oracle'#ORACLE_BASEsetfromenvironmentpri.__pga_aggregate_target=335544320pri.__sga_target=503316480pri.__shared_io_pool_size=0pri.__shared_pool_size=163577856pri.__streams_pool_size=0*.audit_file_dest='/u01/app/oracle/admin/std/adump'*.audit_trail='db'*.compatible='.0'*.control_files='/u01/app/oracle/oradata/std/control01.ctl','/u01/app/oracle/oradata/std/control02.ctl'*.db_block_size=8192*.db_domain=''*.db_name='pri'DG主庫(kù)和備庫(kù)的db_name必須一致,db_unique_name不一致*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'*.db_recovery_file_dest_size=4070572032*.diagnostic_dest='/u01/app/oracle'*.dispatchers='(PROTOCOL=TCP)(SERVICE=stdXDB)'*.log_archive_format='%t_%s_%r.dbf'*.memory_target=836763648*.open_cursors=300*.processes=150*.remote_login_passwordfile='EXCLUSIVE'*.undo_tablespace='UNDOTBS1'以下需要手工添加:*.db_unique_name='std'*.log_archive_config='dg_config=(pri,std)'*.log_archive_dest_1='location=/u01/app/oracle/archvalid_for=(all_logfiles,all_roles)db_unique_name=std'*.log_archive_dest_2='service=privalid_for=(online_logfiles,primary_role)db_unique_name=pri'*.log_archive_dest_state_1=enable*.log_archive_dest_state_2=enable*.log_archive_max_processes=4*.fal_server='pri'*.fal_client='std'*.db_file_name_convert='/u01/app/oracle/oradata/pri','/u01/app/oracle/oradata/std'*.log_file_name_convert='/u01/app/oracle/oradata/pri','/u01/app/oracle/oradata/std'*.standby_file_management='auto'

修改完畢,保存退出

注意:整個(gè)搭建過(guò)程最需要留意的就是主庫(kù)和備庫(kù)的PFILE配置,建議修改完后仔細(xì)對(duì)照主備庫(kù)PFILE的區(qū)別

9:在備庫(kù)端手工創(chuàng)建所需的目錄

(備庫(kù)端做,不提前創(chuàng)建的話恢復(fù)時(shí)會(huì)報(bào)錯(cuò)?。﹎kdir-pv/u01/app/oracle/admin/std/adumpmkdir-pv/u01/app/oracle/diag/rdbms/std/std/tracemkdir-pv/u01/app/oracle/archmkdir-pv/u01/app/oracle/oradata/stdmkdir-pv/u01/app/oracle/oradata/standbylogmkdir-pv/u01/app/oracle/flash_recovery_area

10:用修改后的pfile創(chuàng)建一個(gè)spfile,用于啟動(dòng)數(shù)據(jù)庫(kù)

(備庫(kù)端做)[oracle@std~]$sqlplus/assysdbaConnectedtoanidleinstance.

SYS@std>createspfilefrompfile;Filecreated.

將數(shù)據(jù)庫(kù)啟動(dòng)到nomount狀態(tài):SYS@std>startupnomount;ORACLEinstancestarted.

TotalSystemGlobalArea839282688bytesFixedSize2233000bytesVariableSize482348376bytesDatabaseBuffers352321536bytesRedoBuffers2379776bytesSYS@std>

11:利用RMAN在備庫(kù)上恢復(fù)主庫(kù)

(備庫(kù)端做)[oracle@std~]$rmantargetsys/oracle@priauxiliarysys/oracle@std

RecoveryManager:Release.0-ProductiononTueApr1516:39:282014

Copyright(c)1982,2011,Oracleand/oritsaffiliates.Allrightsreserved.

connectedtotargetdatabase:PRI(DBID=775616459)connectedtoauxiliarydatabase:PRI(notmounted)

RMAN>duplicatetargetdatabaseforstandbyfromactivedatabasenofilenamecheck;這條命令可以直接恢復(fù)數(shù)據(jù)文件,standby控制文件,standby日志組,非常霸道StartingDuplicateDbat16-MAR-16usingtargetdatabasecontrolfileinsteadofrecoverycatalogallocatedchannel:ORA_AUX_DISK_1channelORA_AUX_DISK_1:SID=134devicetype=DISK

contentsofMemoryScript:{backupascopyreusetargetfile'/u01/app/oracle/product/11.2.0/db_1/dbs/orapwpri'auxiliaryformat'/u01/app/oracle/product/11.2.0/db_1/dbs/orapwstd';}executingMemoryScript

Startingbackupat16-MAR-16allocatedchannel:ORA_DISK_1channelORA_DISK_1:SID=140devicetype=DISKFinishedbackupat16-MAR-16

contentsofMemoryScript:{backupascopycurrentcontrolfileforstandbyauxiliaryformat'/u01/app/oracle/oradata/std/control01.ctl';}executingMemoryScript

Startingbackupat16-MAR-16usingchannelORA_DISK_1channelORA_DISK_1:startingdatafilecopycopyingstandbycontrolfileoutputfilename=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_pri.ftag=TAG20160316T110737RECID=2STAMP=906635257channelORA_DISK_1:datafilecopycomplete,elapsedtime:00:00:01Finishedbackupat16-MAR-16

contentsofMemoryScript:{sqlclone'alterdatabasemountstandbydatabase';}executingMemoryScript

sqlstatement:alterdatabasemountstandbydatabase

contentsofMemoryScript:{setnewnamefortempfile1to"/u01/app/oracle/oradata/std/temp01.dbf";switchclonetempfileall;setnewnamefordatafile1to"/u01/app/oracle/oradata/std/system01.dbf";setnewnamefordatafile2to"/u01/app/oracle/oradata/std/sysaux01.dbf";setnewnamefordatafile3to"/u01/app/oracle/oradata/std/undotbs01.dbf";setnewnamefordatafile4to"/u01/app/oracle/oradata/std/users01.dbf";backupascopyreusedatafile1auxiliaryformat"/u01/app/oracle/oradata/std/system01.dbf"datafile2auxiliaryformat"/u01/app/oracle/oradata/std/sysaux01.dbf"datafile3auxiliaryformat"/u01/app/oracle/oradata/std/undotbs01.dbf"datafile4auxiliaryformat"/u01/app/oracle/oradata/std/users01.dbf";sql'altersystemarchivelogcurrent';}executingMemoryScript

executingcommand:SETNEWNAME

renamedtempfile1to/u01/app/oracle/oradata/std/temp01.dbfincontrolfile

executingcommand:SETNEWNAME

executingcommand:SETNEWNAME

executingcommand:SETNEWNAME

executingcommand:SETNEWNAME

Startingbackupat16-MAR-16usingchannelORA_DISK_1channelORA_DISK_1:startingdatafilecopyinputdatafilefilenumber=00001name=/u01/app/oracle/oradata/pri/system01.dbfoutputfilename=/u01/app/oracle/oradata/std/system01.dbftag=TAG20160316T110744channelORA_DISK_1:datafilecopycomplete,elapsedtime:00:01:38channelORA_DISK_1:startingdatafilecopyinputdatafilefilenumber=00002name=/u01/app/oracle/oradata/pri/sysaux01.dbfoutputfilename=/u01/app/oracle/oradata/std/sysaux01.dbftag=TAG20160316T110744channelORA_DISK_1:datafilecopycomplete,elapsedtime:00:01:09channelORA_DISK_1:startingdatafilecopyinputdatafilefilenumber=00003name=/u01/app/oracle/oradata/pri/undotbs01.dbfoutputfilename=/u01/app/oracle/oradata/std/undotbs01.dbftag=TAG20160316T110744channelORA_DISK_1:datafilecopycomplete,elapsedtime:00:00:15channelORA_DISK_1:startingdatafilecopyinputdatafilefilenumber=00004name=/u01/app/oracle/oradata/pri/users01.dbfoutputfilename=/u01/app/oracle/oradata/std/users01.dbftag=TAG20160316T110744channelORA_DISK_1:datafilecopycomplete,elapsedtime:00:00:01Finishedbackupat16-MAR-16

sqlstatement:altersystemarchivelogcurrent

contentsofMemoryScript:{switchclonedatafileall;}executingMemoryScript

datafile1switchedtodatafilecopyinputdatafilecopyRECID=2STAMP=906635463filename=/u01/app/oracle/oradata/std/system01.dbfdatafile2switchedtodatafilecopyinputdatafilecopyRECID=3STAMP=906635463filename=/u01/app/oracle/oradata/std/sysaux01.dbfdatafile3switchedtodatafilecopyinputdatafilecopyRECID=4STAMP=906635463filename=/u01/app/oracle/oradata/std/undotbs01.dbfdatafile4switchedtodatafilecopyinputdatafilecopyRECID=5STAMP=906635463filename=/u01/app/oracle/oradata/std/users01.dbfFinishedDuplicateDbat16-MAR-16

RMAN>恢復(fù)數(shù)據(jù)庫(kù)結(jié)束

12:嘗試開(kāi)啟備庫(kù)

登陸并查看數(shù)據(jù)庫(kù)當(dāng)前狀態(tài):

[oracle@std~]$sqlplus/assysdba

SQL*Plus:Release.0ProductiononTueJan1416:41:502014Copyright(c)1982,2010,Oracle.Allrightsreserved.

Connectedto:OracleDatabase11gEnterpriseEditionRelease.0-64bitProductionWiththePartitioning,OLAP,DataMiningandRealApplicationTestingoptions

SYS@std>startupSYS@std>selectstatusfromv$instance;

STATUSMOUNTED

(RMAN恢復(fù)完直接就是mount狀態(tài))

13:備庫(kù)啟動(dòng)日志應(yīng)用(啟用備庫(kù)前確認(rèn)歸檔日志是否都已拷貝)SYS@std>alterdatabaserecovermanagedstandbydatabasedisconnectfromsession;Databasealtered.(停止日志應(yīng)用的命令是:alterdatabaserecovermanagedstandbydatabasecancel;)

查看日志應(yīng)用情況:SYS@std>setpagesize100SYS@std>selectsequence#,appliedfromv$archived_logorderby1;

SEQUENCE#APPLIED8YES9YES10YES

如上,如果發(fā)現(xiàn)有個(gè)NO的,也是正常的,說(shuō)明該日志在主庫(kù)上還沒(méi)有歸檔,可以在主庫(kù)上運(yùn)行altersystemswitchlogfile;命令來(lái)進(jìn)行日志切換,再到備庫(kù)查看日志應(yīng)用情況

14:分別查看主庫(kù)和備庫(kù)的歸檔序列號(hào)是否一致:先在主庫(kù)手動(dòng)切換一下日志:SYS@pri>altersystemswitchlogfile;

Systemaltered.然后查看主庫(kù):SYS@pri>archiveloglist;SQL>archiveloglist;DatabaselogmodeArchiveModeAutomaticarchivalEnabledArchivedestination/u01/app/oracle/archOldestonlinelogsequence22Nextlogsequencetoarchive24Currentlogsequence24備庫(kù):SQL>archiveloglist;DatabaselogmodeArchiveModeAutomaticarchivalEnabledArchivedestination/u01/app/oracle/archOldestonlinelogsequence22Nextlogsequencetoarchive0Currentlogsequence24

結(jié)果完全一致,至此,DataGuard的搭建成功!

15:檢查命令查看standby啟動(dòng)的DG進(jìn)程SQL>selectprocess,client_process,sequence#,statusfromv$managed_standby;

PROCESS

CLIENT_P

SEQUENCE#STATUS

ARCH

ARCH

23CLOSING

ARCH

ARCH

0CONNECTED

//歸檔進(jìn)程

ARCH

ARCH

21CLOSING

ARCH

ARCH

0CONNECTED

RFS

ARCH

0IDLE

RFS

UNKNOWN

0IDLE

RFS

LGWR

24IDLE

//歸檔傳輸進(jìn)程

RFS

UNKNOWN

0IDLE

MRP0

N/A

24APPLYING_LOG

//日志應(yīng)用進(jìn)程

9rowsselected.

查看數(shù)據(jù)庫(kù)的保護(hù)模式:SQL>selectdatabase_role,protection_mode,protection_level,open_modefromv$database;

DATABASE_ROLE

PROTECTION_MODE

PROTECTION_LEVEL

OPEN_MODE

PRIMARY

MAXIMUMPERFORMANCE

MAXIMUMPERFORMANCE

READWRITE

#standby端查看,也是一樣的。

SQL>selectdatabase_role,protection_mode,protection_level,open_modefromv$database;

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論