Data Guard不只是一个备份恢复的工具,某些情况下它甚至可以与primary数据库完全一模一样。
但是,它存在的目的并不仅仅是为了恢复数据,应该说它的存在是为了确保企业数据的高可用性,数据保护以及灾难恢复。
一个处于Open 状态对外提供服务,这个数据库叫作Primary Database;
第二个处于恢复状态,叫作Standby Database。
select protection_mode,protection_level from v$database;
操作系统:Centos7.9
数据库版本11.2.0.4
主库IP:192.168.13.30 pri SID=pri
备库IP:192.168.13.40 std SID=std
select name,log_mode,force_logging from v$database;
alter database force logging;
[oracle@pri dbs]$ scp orapwpri 192.168.13.40:$ORACLE_HOME/dbs/orapwstd
[oracle@pri dbs]$ cd /home/oracle/u01/app/oracle/oradata/
[oracle@pri oradata]$ mkdir standbylog
[oracle@pri oradata]$ sqlplus / as sysdba
SQL> set pagesize 100
SQL> col member for a60
SQL> select group#,member from v$logfile order by group#;
SQL> show parameter spfile;
SQL> create pfile from spfile;
[oracle@pri dbs]$ vi initpri.ora
pri.__db_cache_size=2919235584
pri.__java_pool_size=33554432
pri.__large_pool_size=50331648
pri.__oracle_base=/home/oracle/u01/app/oracle#ORACLE_BASE set from environment
pri.__pga_aggregate_target=1241513984
pri.__sga_target=3724541952
pri.__shared_io_pool_size=0
pri.__shared_pool_size=687865856
pri.__streams_pool_size=0
*.audit_file_dest=/home/oracle/u01/app/oracle/admin/pri/adump
*.audit_trail=db
*.compatible=11.2.0.4.0
*.control_files=/home/oracle/u01/app/oracle/oradata/pri/control01.ctl,/home/oracle/u01/app/oracle/fast_recovery_area/pri/control02.ctl
*.db_block_size=8192
*.db_domain=
*.db_name=pri
*.db_recovery_file_dest=/home/oracle/u01/app/oracle/fast_recovery_area
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest=/home/oracle/u01/app/oracle
*.dispatchers=(PROTOCOL=TCP) (SERVICE=priXDB)
*.open_cursors=300
*.pga_aggregate_target=1240465408
*.processes=150
*.remote_login_passwordfile=EXCLUSIVE
*.sga_target=3721396224
*.undo_tablespace=UNDOTBS1
*.db_unique_name=pri
*.log_archive_config=dg_config=(pri,std)
*.log_archive_dest_1=location=/home/oracle/u01/app/oracle/arch valid_for=(all_logfiles,all_roles) db_unique_name=pri
*.log_archive_dest_2=service=std valid_for=(online_logfiles,primary_role) db_unique_name=std
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.log_archive_max_processes=4
*.fal_server=std
*.fal_client=pri
*.db_file_name_convert=/home/oracle/u01/app/oracle/oradata/std,/home/oracle/u01/app/oracle/oradata/pri
*.log_file_name_convert=/home/oracle/u01/app/oracle/oradata/std,/home/oracle/u01/app/oracle/oradata/pri
*.standby_file_management=auto
[oracle@pri dbs]$ mkdir -p /home/oracle/u01/app/oracle/arch
SQL> shu immediate
SQL> startup mount;
SQL> alter database archivelog;
SQL> alter database open;
SQL> archive log list
SQL> show parameter spfile;
[oracle@pri dbs]$ vi /home/oracle/u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.13.30)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = pri)
(ORACLE_HOME = /home/oracle/u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = pri)
)
)
ADR_BASE_LISTENER = /home/oracle/u01/app/oracle
~
[oracle@pri dbs]$ vi /home/oracle/u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
pri =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.13.30)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pri)
)
)
std =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.13.40)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = std)
)
)
[oracle@std dbs]$ vi /home/oracle/u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.13.40)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = std)
(ORACLE_HOME = /home/oracle/u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = std)
)
)
ADR_BASE_LISTENER = /home/oracle/u01/app/oracle
[oracle@pri dbs]$ lsnrctl start
[oracle@pri dbs]$ tnsping pri
[oracle@pri dbs]$ tnsping std
[oracle@pri dbs]$ scp initpri.ora 192.168.13.40:$ORACLE_HOME/dbs/initstd.ora
[oracle@std dbs]$ vi initstd.ora
pri.__db_cache_size=2919235584
pri.__java_pool_size=33554432
pri.__large_pool_size=50331648
pri.__oracle_base=/home/oracle/u01/app/oracle#ORACLE_BASE set from environment
pri.__pga_aggregate_target=1241513984
pri.__sga_target=3724541952
pri.__shared_io_pool_size=0
pri.__shared_pool_size=687865856
pri.__streams_pool_size=0
*.audit_file_dest=/home/oracle/u01/app/oracle/admin/pri/adump
*.audit_trail=db
*.compatible=11.2.0.4.0
*.control_files=/home/oracle/u01/app/oracle/oradata/pri/control01.ctl,/home/oracle/u01/app/oracle/fast_recovery_area/pri/control02.ctl
*.db_block_size=8192
*.db_domain=
*.db_name=pri
*.db_recovery_file_dest=/home/oracle/u01/app/oracle/fast_recovery_area
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest=/home/oracle/u01/app/oracle
*.dispatchers=(PROTOCOL=TCP) (SERVICE=priXDB)
*.open_cursors=300
*.pga_aggregate_target=1240465408
*.processes=150
*.remote_login_passwordfile=EXCLUSIVE
*.sga_target=3721396224
*.undo_tablespace=UNDOTBS1
*.db_unique_name=pri
*.log_archive_config=dg_config=(pri,std)
*.log_archive_dest_1=location=/home/oracle/u01/app/oracle/arch valid_for=(all_logfiles,all_roles) db_unique_name=pri
*.log_archive_dest_2=service=std valid_for=(online_logfiles,primary_role) db_unique_name=std
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
pri.__db_cache_size=1392508928
pri.__java_pool_size=16777216
pri.__large_pool_size=33554432
pri.__oracle_base=/home/oracle/u01/app/oracle#ORACLE_BASE set from environment
pri.__pga_aggregate_target=620756992
pri.__sga_target=1862270976
pri.__shared_io_pool_size=0
pri.__shared_pool_size=402653184
pri.__streams_pool_size=0
*.audit_file_dest=/home/oracle/u01/app/oracle/admin/std/adump
*.audit_trail=db
*.compatible=11.2.0.4.0
*.control_files=/home/oracle/u01/app/oracle/oradata/std/control01.ctl,/home/oracle/u01/app/oracle/oradata/std/control02.ctl
*.db_block_size=8192
*.db_domain=
*.db_name=pri
*.db_recovery_file_dest=/home/oracle/u01/app/oracle/fast_recovery_area
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest=/home/oracle/u01/app/oracle
*.dispatchers=(PROTOCOL=TCP) (SERVICE=stdXDB)
*.open_cursors=300
*.pga_aggregate_target=2423259136
*.processes=150
*.remote_login_passwordfile=EXCLUSIVE
*.sga_target=4294967296
*.undo_tablespace=UNDOTBS1
*.db_unique_name=std
*.log_archive_config=dg_config=(pri,std)
*.log_archive_dest_1=location=/home/oracle/u01/app/oracle/arch valid_for=(all_logfiles,all_roles) db_unique_name=std
*.log_archive_dest_2=service=pri valid_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=/home/oracle/u01/app/oracle/oradata/pri,/home/oracle/u01/app/oracle/oradata/std
*.log_file_name_convert=/home/oracle/u01/app/oracle/oradata/pri,/home/oracle/u01/app/oracle/oradata/std
*.standby_file_management=auto
[oracle@std dbs]$ mkdir -pv /home/oracle/u01/app/oracle/admin/std/adump
[oracle@std dbs]$ mkdir -pv /home/oracle/u01/app/oracle/oradata/std/
[oracle@std dbs]$ mkdir -pv /home/oracle/u01/app/oracle/fast_recovery_area
[oracle@std dbs]$ mkdir -pv /home/oracle/u01/app/oracle/arch
[oracle@std dbs]$ mkdir -pv /home/oracle/u01/app/oracle/diag/rdbms/std/std/trace
[oracle@std dbs]$ mkdir -pv /home/oracle/u01/app/oracle/oradata/standbylog
SQL> create spfile from pfile;
SQL> startup nomount;
[oracle@std dbs]$ rman target sys/123456@pri auxiliary sys/123456@std
RMAN> duplicate target database for standby from active database nofilenamecheck;
SQL> select status from v$instance;
SQL> alter database recover managed standby database disconnect from session;
SQL> archive log list
SQL> alter database recover managed standby database cancel;
SQL> shu immediate
SQL> alter database mount standby database;
SQL> alter database open read only;
SQL> alter database recover managed standby database using current logfile disconnect from session;
SQL> archive log list
SQL> select switchover_status,database_role,open_mode from v$database;
SQL> alter database commit to switchover to physical standby;
alter database commit to switchover to primary;
end
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/129649.html
19C DG Broker配置和测试 img{ display:block; margin:0 auto !important; width:100%; } body{ width:75%; ...
DG备库读写测试方案 img{ display:block; margin:0 auto !important; width:100%; } body{ width:75%; margin:0...
摘要:因为是在虚拟机上面模拟搭建,所以我们可以设置六个不同的端口来模拟六台虚拟机。官网然后将压缩包上传的虚拟机的服务器上,这里我用的是版本。把这了的改为接下来执行执行这条命令就可以后台启动了查看进程是否启动成功好了,单机版的版的已经搭建成功了。 首先放一张Redis的架构图: showImg(https://segmentfault.com/img/remote/14600000174635...
阅读 1249·2023-01-11 13:20
阅读 1557·2023-01-11 13:20
阅读 1011·2023-01-11 13:20
阅读 1680·2023-01-11 13:20
阅读 3971·2023-01-11 13:20
阅读 2518·2023-01-11 13:20
阅读 1310·2023-01-11 13:20
阅读 3485·2023-01-11 13:20