当前位置:Gxlcms > mysql > OCM考试中Dataguar的配置

OCM考试中Dataguar的配置

时间:2021-07-01 10:21:17 帮助过:43人阅读

OCM中Dataguar的配置,在同一主机上实现 1、打开主数据库的logging功能ALTER DATABASE FORCE LOGGING;2、打开主数据库的归档功能

OCM中Dataguar的配置,在同一主机上实现

1、打开主数据库的logging功能
ALTER DATABASE FORCE LOGGING;
2、打开主数据库的归档功能
alter database archivelog;
3、关闭主数据库,启动到mount模式
alter database add standby logfile group 4 '/Oracle/oradata/test/sredo4.dbf' size 20m;
alter database add standby logfile group 5 '/oracle/oradata/test/sredo5.dbf' size 20m;
alter database add standby logfile group 6 '/oracle/oradata/test/sredo6.dbf' size 20m;

alter database create standby controlfile as '/oracle/oradata/std/control01.dbf';

备份主数据库的数据文件、控制文件到/oracle/oradata/std/

4、配置网络参数

监听器和TNSNAMES

主库与从库的LISTENER.ORA

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = db)(PORT = 1521))
)
)
)

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = test)
(ORACLE_HOME = /oracle/db10g)
(SID_NAME = test)
)
(SID_DESC =
(GLOBAL_DBNAME = standby)
(ORACLE_HOME = /oracle/db10g)
(SID_NAME = stb)
)
)

主库与从库的TNSNAMES.ORA:

test =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = db)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test)
)
)


stb =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = db)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = stb)
)
)

5、创建备用数据库的参数文件
create pfile from spfile;
cp inittest.ora initstb.ora

主TEST数据库创建pfile文件,添加以下参数:
注:删除一切关于MTS的参数(shared server)

DB_UNIQUE_NAME=test
LOG_ARCHIVE_CONFIG='DG_CONFIG=(test,stb)'
LOG_ARCHIVE_DEST_1='LOCATION=/oracle/arch/test VALID_FOR=(ALL_LOGFILES,ALL_ROLES) '
LOG_ARCHIVE_DEST_2='SERVICE=stb LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby'
FAL_SERVER=stb
FAL_CLIENT=test
DB_FILE_NAME_CONVERT='/oracle/oradata/stb','/oracle/oradata/test'
LOG_FILE_NAME_CONVERT='/oracle/oradata/stb','/oracle/oradata/test'
STANDBY_FILE_MANAGEMENT=AUTO


从库STANDBY数据库修改以下Pfile内容
control_files='/oracle/oradata/stb/control01.ctl'
core_dump_dest='/oracle/admin/stb/cdump'
user_dump_dest='/oracle/admin/stb/udump'
background_dump_dest='/oracle/admin/stb/bdump'

以下为添加的参数
DB_UNIQUE_NAME=stb
LOG_ARCHIVE_CONFIG='DG_CONFIG=(stb,test)'
LOG_ARCHIVE_DEST_1='LOCATION=/oracle/arch/stb VALID_FOR=(ALL_LOGFILES,ALL_ROLES) '
LOG_ARCHIVE_DEST_2='SERVICE=test LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=test'
FAL_SERVER=test
FAL_CLIENT=stb
DB_FILE_NAME_CONVERT='/oracle/oradata/test','/oracle/oradata/stb'
LOG_FILE_NAME_CONVERT='/oracle/oradata/test','/oracle/oradata/stb'
STANDBY_FILE_MANAGEMENT=AUTO


6、启动从库到mount,,并把数据库变成recover managed状态,注意过程从库的警告日志文件:
SQL>startup mount;

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

7、启动主库数据库,切换日志,并观察主从库的警告日志文件,如果归档成功,说明配置成功:
SQL>alter system switch logfile;


8、主从角色的切换,主库查看状态:
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
-----------------
TO STANDBY

SQL>alter database commit to switchover to standby;

9、从库操作:
SQL>alter database commit to switchover to primary;

10、在主库上(注意此时的角色转换)切换日志,如果主从库归档成功,说明Standby配置成功。

更多Oracle相关信息见Oracle 专题页面 ?tid=12

linux

人气教程排行