环境:主备库都为单实例并且数据库SID相同
OS:red hat 6.5
Oracle:11.2.0.4.3
主库操作
1. 开启归档模式
创建归档目录
[root@enn ~]# mkdir -p /u01/archivelog
[root@enn ~]# chown -R oracle:oinstall /u01/archivelog
[root@enn ~]# chmod 777 /u01/archivelog
数据库到mount状态开启归档模式
[root@enn ~]# su - oracle
[oracle@enn ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sun Jul 20 23:46:46 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup mount
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 541068368 bytes
Database Buffers 289406976 bytes
Redo Buffers 2371584 bytes
Database mounted.
设置主库归档目录
SQL> alter system set log_archive_dest='/u01/archivelog';
alter system set log_archive_dest_1='location=/data/oracle/log1/archive_log'; 最后的目录名称需要为archive_log
开启归档模式
SQL> alter database archivelog;
Database altered.
查看归档设置
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/archivelog
Oldest online log sequence 2
Next log sequence to archive 4
Current log sequence 4
2. 启动force_logging模式
查看是否force_logging模式
SQL> select log_mode,force_logging from v$database;
LOG_MODE FOR
------------ ---
ARCHIVELOG NO
开启force_logging模式
SQL> alter database force logging;
Database altered.
3.创建备库日志文件路径
查看数据库的日志组个数与大小,因为我们创建 standby 日志组的个数是原日志
组个数+1 再与 thread 的积((2+1)*3),size 不能小于原日志文件的大小。
SQL> select group#,thread#,bytes/1024/1024 M ,STATUS from v$log;
GROUP# THREAD# M STATUS
linux系统安装oracle11g---------- ---------- ---------- ----------------
1 1 50 CURRENT
3 1 50 INACTIVE
2 1 50 INACTIVE
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ENN/redo03.log
/u01/app/oracle/oradata/ENN/redo02.log
/u01/app/oracle/oradata/ENN/redo01.log
创建备库日志组路径
SQL> alter database add standby logfile thread 1 group 4 ('/u01/app/oracle/oradata/ENN/redo04.log') size 50M;
Database altered.
SQL> alter database add standby logfile thread 1 group 5 ('/u01/app/oracle/oradata/ENN/redo05.log') size 50M;
Database altered.
SQL> alter database add standby logfile thread 1 group 6 ('/u01/app/oracle/oradata/ENN/redo06.log') size 50M;
Database altered.
SQL> alter database add standby logfile thread 1 group 7 ('/u01/app/oracle/oradata/ENN/redo07.log') size 50M;
Database altered.
查看状态
SQL> select group#,status,type,member from v$logfile;
GROUP# STATUS TYPE MEMBER
---------- ------- ------- ----------------------------------------
3 ONLINE /u01/app/oracle/oradata/ENN/redo03.log
2 ONLINE /u01/app/oracle/oradata/ENN/redo02.log
1 ONLINE /u01/app/oracle/oradata/ENN/redo01.log
4 STANDBY /u01/app/oracle/oradata/ENN/redo04.log
5 STANDBY /u01/app/oracle/oradata/ENN/redo05.log
6 STANDBY /u01/app/oracle/oradata/ENN/redo06.log
7 STANDBY /u01/app/oracle/oradata/ENN/redo07.log
4.创建监听
执行netca创建
[oracle@enn oracle]$ netca
修改tnsname文件
[oracle@enn oracle]$ cd $ORACLE_HOME/network/admin
[oracle@enn admin]$ a
ENN =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.80.15 )(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = enn)
)
)
ENN_DG =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.80.16)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = enn_dg)
)
)
a复制到备库中
[oracle@enn admin]$ a oracle@192.168.80.16:$ORACLE_HOME/network/a
oracle@192.168.80.16's password:
a 100% 361 0.4KB/s 00:00
注:可以使用图形配置tnsname
[oracle@enn admin]$ netmgr
附:如果备库tnsping不通, 关闭防火墙
[oracle@enn_dg ~]$ tnsping enn
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 21-JUL-2014 09:26:09
Copyright (c) 1997, 2013, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.80.15)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = ENN)))
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论