这篇文章主要讲解了“怎么搭建Data Guard”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么搭建Data Guard”吧!一、规划说明:在Data Guard中,- db_name:主备库必须保持一致;- db_unique_name:主备库必须不一致;- service_names和instance_name可以保持一致或不一致。Data Guard允许主备库有不同的CPU型号,不同的操作系统(例如windows & linux),不同的操作系统位数(32-bit/64-bit)或者不同的数据库位数(32-bit/64-bit)。Data Guard只支持Oracle database企业版,不支持标准版本。在物理备库中,Oracle主备库的compatiable参数必须保持一致(通常情况下,我们说的Data Guard都是指物理备库)。在逻辑备库中,备库的compatiable必须大于或等于主库参数。主库可以是单实例库或者RAC,备库也可以是单实例或是RAC。如果主备库的操作系统一致,那么主备库的存储路径必须保持不同,否则,备库可能会覆盖主库文件。如果主备库都是RAC,主库使用了ASM和OMF(Oracle managed files)命名管理,那么备库也应该使用ASM和OMF管理。step1:
主库开启force loggingstep2:
备库配置listener.ora文件step3:
主备库配置tnsnames.ora文件step4:
主库添加standby logfilestep5:
主备库修改参数文件step6: RMAN复制数据库step7: DG检查,应用日志step8:
开启备库,实时应用日志# systemctl stop firewalld# systemctl disable firewalld# vi /etc/selinux/configselinux=disabledSQL> archive log list;Database log mode Archive ModeAutomatic archival EnabledArchive destination /archivelog/ORCLOldest online log sequence 26Next log sequence to archive 28Current log sequence 28# vi /etc/hosts#Primary IP1免费主机域名72.16.70.178primary#Standby IP172.16.70.179standbySQL> alter database force logging;(Oracle用户)备库添加静态监听$ vi $ORACLE_HOME/network/admin/listener.ora(添加以下内容)SID_LIST_LISTENER =(SID_LIST =(SID_DESC =(GLOBAL_DBNAME = SBDB)(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)(SID_NAME = SBDB)))开启监听$ lsnrctl start(主备库一致)$ vi $ORACLE_HOME/network/admin/tnsnames.oraORCL=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = primary)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = ORCL) ))SBDB=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = standby)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = SBDB)))tns连通性检测$ tnsping ORCL$ tnsping SBDBSQL> select group#,thread#,bytes/1024/1024 M,status from v$log;SQL> select member from v$logfile;SQL> alter database add standby logfile ‘/u01/app/oracle/oradata/ORCL/redo04.log’ size 50m;SQL> alter database add standby logfile ‘/u01/app/oracle/oradata/ORCL/redo05.log’ size 50m;SQL> alter database add standby logfile ‘/u01/app/oracle/oradata/ORCL/redo06.log’ size 50m;SQL> alter database add standby logfile ‘/u01/app/oracle/oradata/ORCL/redo07.log’ size 50m;查看日志组状态SQL> select group#,status,type,member from v$logfile;(主库修改参数)1)生成参数文件SQL> create pfile from spfile;2)修改参数文件$ cd /u01/app/oracle/product/11.2.0/db_1/dbs$ vi initORCL.ora添加以下内容:db_unique_name=ORCLlog_archive_config=’dg_config=(ORCL,SBDB)’log_archive_dest_1=’location=/archivelog/ORCLvalid_for=(all_logfiles,all_roles) db_unique_name=ORCL’log_archive_dest_2=’service=SBDBlgwr async valid_for=(online_logfiles,primary_roles) db_unique_name=SBDB’log_archive_dest_state_1=enablelog_archive_dest_state_2=enabledb_file_name_convert=’/u01/app/oracle/oradata/SBDB’,’/u01/app/oracle/oradata/ORCL’log_file_name_convert=’/u01/app/oracle/oradata/SBDB’,’/u01/app/oracle/oradata/ORCL’fal_server=SBDBfal_client=ORCLstandby_file_management=auto 3)生成spfile,重启库使参数生效SQL> shutdown immediate;SQL> create spfile from pfile;SQL> startup;(备库修改)1)将主库pfile传到备库$ scp initORCL.ora standby:$ORACLE_HOME/dbs/initSBDB.ora2)修改参数文件$ cd /u01/app/oracle/product/11.2.0/db_1/dbs$ vi initSBDB.ora执行以下命令:%s/ORCL/AAAA/g:%s/SBDB/ORCL/g:%s/AAAA/SBDB/g最后将db_name修改回ORCL最后结果如下:*.audit_file_dest=’/u01/app/oracle/admin/SBDB/adump’*.audit_trail=’db’*.compatible=’11.2.0.4.0’*.control_files=’/u01/app/oracle/oradata/SBDB/control01.ctl’,’/u01/app/oracle/oradata/SBDB/control02.ctl’*.db_block_size=8192*.db_domain=”*.db_name=’ORCL’*.diagnostic_dest=’/u01/app/oracle’*.dispatchers='(PROTOCOL=TCP) (SERVICE=SBDBXDB)’*.log_archive_dest_1=’LOCATION=/archivelog/SBDB’*.log_archive_format=’%t_%s_%r.dbf’*.memory_target=769654784*.open_cursors=300*.processes=150*.remote_login_passwordfile=’EXCLUSIVE’*.undo_tablespace=’UNDOTBS1’db_unique_name=SBDBlog_archive_免费主机域名config=’dg_config=(SBDB,ORCL)’log_archive_dest_1=’location=/archivelog/SBDB valid_for=(all_logfiles,all_roles) db_unique_name=SBDB’log_archive_dest_2=’service=ORCLlgwr async valid_for=(online_logfiles,primary_roles) db_unique_name=ORCL’log_archive_dest_state_1=enablelog_archive_dest_state_2=enabledb_file_name_convert=’/u01/app/oracle/oradata/ORCL’,’/u01/app/oracle/oradata/SBDB’log_file_name_convert=’/u01/app/oracle/oradata/ORCL’,’/u01/app/oracle/oradata/SBDB’fal_server=ORCLfal_client=SBDBstandby_file_management=auto3)备库创建上述目录$ mkdir -p /u01/app/oracle/admin/SBDB/adump$ mkdir -p /u01/app/oracle/oradata/SBDB$ mkdir -p /archivelog/SBDB4)备库创建密码文件$ cd $ORACLE_HOME/dbs/$ orapwd file=orapwSBDB password=oracle1) 备库开启到nomount状态SQL> create spfile from pfile;SQL> startup nomount;2)RMAN复制数据库(主库执行)$rman target / auxiliary sys/oracle@SBDBRMAN>duplicate target database for standby from active database;此时,已经完成了DataGuard搭建部分!1) 查询主备库状态(主库)SQL> col db_unique_name for a15SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS————— —————— —————- ——————–ORCL READ WRITE PRIMARYFAILED DESTINATION(备库)DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS————– —————— —————- ——————–SBDB MOUNTED PHYSICAL STANDBYSESSIONS ACTIVE2)备库应用日志SQL> alter database recover managed standby database using current logfile disconnect from session;此时注意检查备库SWITCHOVER_STATUS状态,直到SWITCHOVER_STATUS为NOT ALLOWED为正常。3)备库取消应用日志SQL> alter database recover managed standby database cancel;4)开启备库SQL> alter database open;5)备库开启实时应用SQL> alter database recover managed standby database using current logfile disconnect from session;6)再次检查备库状态SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS————— ——————– —————- ——————–SBDB READ ONLY WITH APPLY PHYSICAL STANDBY NOT ALLOWED7)查看备库进程状态SQL> select process, pid, status, client_process from v$managed_standby;PROCESS PID STATUS CLIENT_P——— ———- ———— ——–ARCH 24183 CONNECTED ARCHARCH 24186 CONNECTED ARCHARCH 24188 CLOSING ARCHARCH 24190 CONNECTED ARCHRFS 24533 IDLE LGWRRFS 24527 IDLE UNKNOWNRFS 24529 IDLE ARCHRFS 24707 IDLE UNKNOWNMRP0 24918 APPLYING_LOG N/A此时,备库已经是实时应用状态(Active Data Guard)感谢各位的阅读,以上就是“怎么搭建Data Guard”的内容了,经过本文的学习后,相信大家对怎么搭建Data Guard这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是云技术,小编将为大家推送更多相关知识点的文章,欢迎关注!
本篇内容介绍了“SQL函数有哪些”的免费主机域名有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!round() 遵循四舍五入把原值转化为指定小数位数,如:round(…