当前位置:首页 > 行业动态 > 正文

建立Oracle数据库的主备关系

建立Oracle数据库的主备关系,主要是为了实现数据的实时同步和高可用性,在主备关系中,一个数据库作为主库(Primary),负责处理所有的数据更新操作;另一个数据库作为备库(Standby),用于接收主库的数据更新,并保持与主库的数据同步,当主库出现故障时,备库可以快速接管主库的工作,保证业务的连续性。

建立Oracle数据库的主备关系  第1张

以下是建立Oracle数据库主备关系的详细步骤:

1、配置主库参数文件

需要在主库的参数文件中设置以下参数:

log_archive_dest_state_1=enable

log_archive_dest_1=’location=/u01/app/oracle/oradata/primary/standby’

fal_client=primary

standby_file_management=auto

db_unique_name=’primary’

db_file_name_convert=’/u01/app/oracle/oradata/primary/system.dbf’

db_block_size=8192

db_create_file_dest=’/u01/app/oracle/oradata/primary’

db_recovery_file_dest=’/u01/app/oracle/fast_recovery_area’

db_flashback_online_logs_target=’fal’

db_flashback_recovery_area=’AUTO’

db_flashback_enabled=’TRUE’

db_flashback_on=true

db_flashback_retention_target=0

db_flashback_retention_policy=LOGS

db_flashback_archive_dest=’LOCATION=/u01/app/oracle/fast_recovery_area’

db_create_online_log_dest=’disk’

db_log_archive_config=’DEST_STATE=ENABLE VALID_FOR=(ALL_LOGFILES, ALL_ROLES) DB_UNIQUE_NAME=primary LOG_ARCHIVE_DEST=location="/u01/app/oracle/oradata/primary/standby" ASYNC=false COMPRESSION=none RMAN=ON CONFIGURED_CAPTURE=false’

2、创建归档日志目录

在主库上创建一个目录,用于存储归档日志文件。

mkdir p /u01/app/oracle/oradata/primary/standby
chown R oracle:dba /u01/app/oracle/oradata/primary/standby

3、创建备用服务器实例

在备库上创建一个与主库相同的实例,并使用主库的参数文件。

dbca silent responseFile /u01/app/oracle/product/12.1.0/dbhome_1/assistants/dbca/templates/dbca.rsp gdbname primary syspassword Oradoc_db1 systempassword Oradoc_db1 characterset AL32UTF8 sampleschema false createpwd primary storagetype FILE_SYSTEM memory 4G processors 2 instance number 2 nodenumber 1 automatedBackup false destination /u01/app/oracle/oradata/secondary characterset AL32UTF8 globalDBName primary service name primary initPassword Oradoc_db1 force nonContainerized true orclSnapshotDir /u01/app/oracle/fast_recovery_area copyData false crosscheck true spfile /u01/app/oracle/product/12.1.0/dbhome_1/database/spfileprimary.ora controlFile /u01.app.oracle.product.12.1.0.dbhome.1.database.ctlprimary.ora passwordFile /u01.app.oracle.product.12.1.0.dbhome.1.database.pwdprimary.ora startMode auto compatible <version> diagnosticDestination /u01.app.oracle.product.12.1.0.dbhome.1.rdbms<br>diag___________________________________________&nbsp;<```
4、配置备用服务器实例
在备库实例上执行以下命令,将主库设置为备用服务器的源:

设置备用服务器实例的参数文件路径

ALTER SYSTEM SET db_unique_name=’secondary’ SCOPE=SPFILE;

ALTER SYSTEM SET db_file_name={‘system’,’users’,’example’} SCOPE=SPFILE;

ALTER SYSTEM SET log_archive_dest={‘location=//u01.app.oracle.local/u01.app.oracle.oradata/u01.app.oracle.local/secondary} SCOPE=SPFILE;

ALTER SYSTEM SET fal_client={‘secondary’} SCOPE=SPFILE;

ALTER SYSTEM SET db_block_size=8192 SCOPE=SPFILE;

ALTER SYSTEM SET db_create_file={‘primary’,’secondary’} SCOPE=SPFILE;

ALTER SYSTEM SET db_recovery_file={‘primary’,’secondary’} SCOPE=SPFILE;

ALTER SYSTEM SET db_flashback={‘on’,’off’} SCOPE=SPFILE;

ALTER SYSTEM SET db_flashback={‘logs’,’transactions’,’both’} SCOPE=SPFILE;

ALTER SYSTEM SET db_flashback={‘enable’,’disable’} SCOPE=SPFILE;

ALTER SYSTEM SET db_flashback={‘threshold’,’target’,’policy’,’retention target’,’retention policy’,’archive destination’,’compressed backups’,’valid for all logfiles and roles’,’asynch commit’,’configured capture’,’auto switchover on failover’,’auto switchover on new primary failover’,’auto switchover on local node failure’,’auto switchover on remote node failure’,’auto switchover on connection loss’,’auto switchover on client disconnect’,’auto switchover on session reset’,’auto switchover on transaction rollback’,’auto switchover on transaction commit error’,’auto switchover on transaction prepare error’,’auto switchover on transaction deadlock error’,’auto switchover on transaction serialization error’,’auto switchover on transaction lock time out error’,’auto switchover on transaction system error’,’auto switchover on transaction too long error’,’auto switchover on transaction cancel error’,’auto switchover on transaction update conflict error’,’auto switchover on transaction invalid lock id error’,’auto switchover on transaction deadlock detected error’,’auto switchover on transaction indoubt error’,’auto switchover on transaction distributed deadlock error’,’auto switchover on transaction state change error’,’auto switchover on transaction object lock error’,’auto switchover on transaction object busy error’,’auto switchover on transaction object not found error’,’auto switchover on transaction object no longer valid error’,’auto switchover on transaction object pinned error’,’auto switchover on transaction object purged error’,’auto switchover on transaction object expired error’,’auto switchover on transaction object closed error’,’auto switchover on transaction object locked by another session error’} SCOPE=SPFILE;

ALTER SYSTEM SET db_flashback={‘fast start failover enable’} SCOPE=SPFILE;

ALTER SYSTEM SET db_flashback={‘fast start failover disable’} SCOPE=SPFILE;

ALTER SYSTEM SET db_flashback={‘fast start failover wait for complete recovery before switching over to the new primary’} SCOPE=SPFILE;

ALTER SYSTEM SET db_flashback={‘fast start failover wait for apply redo to complete before switching over to the new primary’} SCOPE=SPFILE;

ALTER SYSTEM SET db_flashback={‘fast start failover wait for archived redo logs to be applied before switching over to the new primary’} SCOPE=SPFILE;

ALTER SYSTEM SET db_flashback={‘fast start failover wait for log apply to complete before switching over to the new primary’} SCOPE=SPFILE;

ALTER SYSTEM SET db

0

随机文章