概述
1、环境信息:
系统:
oracle-linux 5.7
数据库版本:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
主库:192.168.12.31
备库:192.168.12.231 SID:yoon
2、查看DG是否已经安装:
SQL> select * from v$option where parameter = 'Oracle Data Guard';
PARAMETER
-------------------- --------------------
Oracle Data Guard
TRUE表示已经安装可以配置,否则需要安装相应软件
3、查看主库是否开启归档:
SQL> archive log list;
Database log mode
Automatic archival
Archive destination
Oldest online log sequence
Current log sequence
4、设置主库为归档模式:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 2505338880 bytes
Fixed Size
Variable Size
Database Buffers
Redo Buffers
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
SQL> archive log list;
Database log mode
Automatic archival
Archive destination
Oldest online log sequence
Next log sequence to archive
Current log sequence
5、设置主库为强制记录日志:
SQL> alter database force logging;
Database altered.
6、创建standy log files:
SQL> select group#,member from v$logfile;
------- -----------------------------------
添加:
SQL> alter database add standby logfile group 7 '/opt/oracle/oradata/yoon/standby07.log' size 50m;
Database altered.
SQL> alter database add standby logfile group 8 '/opt/oracle/oradata/yoon/standby08.log' size 50m;
Database altered.
SQL> alter database add standby logfile group 9 '/opt/oracle/oradata/yoon/standby09.log' size 50m;
Database altered.
SQL> alter database add standby logfile group 10 '/opt/oracle/oradata/yoon/standby10.log' size 50m;
Database altered.
7、创建standby控制文件:
SQL> shutdown immediate
SQL> startup mount
SQL> alter database create standby controlfile as '/opt/oracle/oradata/yoon/standby_control01.ctl';
Database altered.
SQL>alter database open;
8、设置db_unique_name:
默认db_name和db_unique_name是一样的,主库是yoon
在配置DG中主库和备库的SID可以一样,But,db_unique_name不能相同,备库设置为:yoondg
SQL> show parameter db_unique_name;
NAME
------------------------------------ ---------- ------------------------------
db_unique_name
--注意虽然默认db_unique_name和db_name是一致的,但是需要显式设置,否则在spfile中没有此参数
SQL> alter system set db_unique_name=yoon scope=spfile;
System altered.
9、配置主库listener.ora:
# listener.ora Network Configuration File: /opt/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER=
LISTENER =
ADR_BASE_LISTENER = /opt/oracle
# listener.ora Network Configuration File: /opt/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
YOON =
YOONDG =
10、将主库listener.ora和tnsnames.ora拷贝到备库修改
[root@1231 admin]# scp listener.ora tnsnames.ora oracle@192.168.12.231:/opt/oracle/product/11.2.0/db_1/network/admin/
# listener.ora Network Configuration File: /opt/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER=
LISTENER =
ADR_BASE_LISTENER = /opt/oracle
# listener.ora Network Configuration File: /opt/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
YOONDG =
YOON =
11、配置完以后在主和备的oralce用户下测试下是否能ping通
主:
[oracle@1231 ~]$ tnsping yoon
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.31)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = yoon)))
OK (0 msec)
[oracle@1231 ~]$ tnsping yoondg
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.231)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = yoondg)))
OK (10 msec)
备:
[oracle@12231 ~]$ tnsping yoon
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.31)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = yoon)))
OK (0 msec)
[oracle@12231 ~]$ tnsping yoondg
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.231)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = yoondg)))
OK (0 msec)
12、重做日志传输配置
a.配置归档日志位置:
SQL> alter system set log_archive_dest_1='location=/opt/oracle/archive_bak valid_for=(all_logfiles,primary_roles) db_unique_name=yoon'
System altered.
b.配置重做日志到备份库:
SQL> alter system set log_archive_dest_2='service=yoondg lgwr sync valid_for=(online_logfiles,primary_role) db_unique_name=yoondg' scope=spfile;
System altered.
13、配置FAL_SERVER
主:
SQL> alter system set fal_server='yoondg';
System altered.
14、Data Guard 配置里的另外一个库的名字
SQL> alter system set log_archive_config='dg_config=(yoon,yoondg)';
System altered.
SQL> alter system set log_archive_dest_state_1=enable scope=spfile;
System altered.
SQL> alter system set log_archive_dest_state_2=enable scope=spfile;
System altered.
SQL> create pfile from spfile;
File created.
SQL> create spfile from pfile;
File created.
15、查看主库inityoon.ora信息
yoon.__db_cache_size=1946157056
yoon.__java_pool_size=16777216
yoon.__large_pool_size=16777216
yoon.__oracle_base='/opt/oracle'#ORACLE_BASE set from environment
yoon.__pga_aggregate_target=838860800
yoon.__sga_target=2516582400
yoon.__shared_io_pool_size=0
yoon.__shared_pool_size=520093696
yoon.__streams_pool_size=0
*.audit_file_dest='/opt/oracle/admin/yoon/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/opt/oracle/oradata/yoon/control01.ctl','/opt/oracle/fast_recovery_area/yoon/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='yoon'
*.db_recovery_file_dest='/opt/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4322230272
*.db_unique_name='YOON'
*.diagnostic_dest='/opt/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=yoonXDB)'
*.fal_server='yoondg'
*.log_archive_config='dg_config=(yoon,yoondg)'
*.log_archive_dest_1='location=/opt/oracle/archive_bak valid_for=(all_logfiles,primary_roles) db_unique_name=yoon'
*.log_archive_dest_2='service=yoondg lgwr sync valid_for=(online_logfiles,primary_role) db_unique_name=yoondg'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.open_cursors=300
*.pga_aggregate_target=837812224
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
*.sga_target=2514485248
*.undo_tablespace='UNDOTBS1'
16、将主库的数据文件、控制文件、参数文件、密码文件拷贝到备库对应的目录
[root@1231 oracle]# scp -r admin/ fast_recovery_area/ oradata/ oracle@192.168.12.231:/opt/oracle/
17、修改备库参数文件
yoon.__db_cache_size=1946157056
yoon.__java_pool_size=16777216
yoon.__large_pool_size=16777216
yoon.__oracle_base='/opt/oracle'#ORACLE_BASE set from environment
yoon.__pga_aggregate_target=838860800
yoon.__sga_target=2516582400
yoon.__shared_io_pool_size=0
yoon.__shared_pool_size=520093696
yoon.__streams_pool_size=0
*.audit_file_dest='/opt/oracle/admin/yoon/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/opt/oracle/oradata/yoon/control01.ctl','/opt/oracle/fast_recovery_area/yoon/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='yoon'
*.db_recovery_file_dest='/opt/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4322230272
*.db_unique_name='YOONDG'
*.diagnostic_dest='/opt/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=yoonXDB)'
*.fal_server='yoon'
*.log_archive_config='dg_config=(yoondg,yoon)'
*.log_archive_dest_1='location=/opt/oracle/archive_bak valid_for=(all_logfiles,primary_roles) db_unique_name=yoondg'
*.log_archive_dest_2='service=yoon lgwr sync valid_for=(online_logfiles,primary_role) db_unique_name=yoon'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.open_cursors=300
*.pga_aggregate_target=837812224
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
*.sga_target=2514485248
*.undo_tablespace='UNDOTBS1'
18、在备库通过pfile创建spfile
19、删除备库的控制文件control01.ctl和control02.ctl
20、启动备库
SQL> startup nomount
ORACLE instance started.
Total System Global Area 2505338880 bytes
Fixed Size
Variable Size
Database Buffers
Redo Buffers
SQL>
SQL> alter database mount standby database;
Database altered.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SQL>shutdown immediate;
21、备用服务器的管理模式与只读模式
a.启动到管理模式
SQL>shutdown immediate;
SQL>startup nomount;
SQL>alter database mount standby database;
SQL>alter database recover managed standby database disconnect from session;
b.启动到只读模式
SQL>shutdown immediate;
SQL>startup nomount;
SQL>alter database mount standby database;
SQL> alter database open read only;
c.在管理恢复模式下到只读模式
SQL> recover managed standby database cancel;
SQL> alter database open read only;
d.从只读方式到管理恢复方式
SQL> recover managed standby database disconnect from session;
22、DG启动:
监听:先起备库再起主库
数据库:先起备库再起主库
关闭:与启动相反.
最后
以上就是孤独冰棍为你收集整理的oracle-11g-配置dataguard的全部内容,希望文章能够帮你解决oracle-11g-配置dataguard所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复