环境准备
两台vmware虚拟机,os版本7.6,数据库版本19.3.0
192.168.112.50 dg1
192.168.112.51 dg2
[oracle@dg1 ~]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.6 (Maipo)
[oracle@dg1 ~]$ sqlplus -v
SQL*Plus: Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[root@dg2 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.6 (Maipo)
主库配置
1.确认归档开启
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/arch
Oldest online log sequence 3
Next log sequence to archive 5
Current log sequence 5
2.开启force logging
SQL> select force_logging from v$database;
FORCE_LOGGING
------------------------------------------------------------------------------
NO
SQL> alter database force logging;
Database altered.
SQL> select force_logging from v$database;
FORCE_LOGGING
------------------------------------------------------------------------------
YES
3.主库添加standby logfile
建议standby logfile比本地的多1组,且大小最好保持一致
SQL> select thread#,bytes/1024/1024,count(*) from v$log group by thread#,bytes/1024/1024;
THREAD# BYTES/1024/1024 COUNT(*)
---------- --------------- ----------
1 200 3
SQL> select group#,bytes/1024/1024 from v$standby_log;
no rows selected
本地log有三组,每组300M,所以standby端需要建4组,每组300M
SQL> alter database add standby logfile thread 1 size 200M;
Database altered.
SQL> alter database add standby logfile thread 1 size 200M;
Database altered.
SQL> alter database add standby logfile thread 1 size 200M;
Database altered.
SQL> alter database add standby logfile thread 1 size 200M;
Database altered.
SQL> select group#,bytes/1024/1024 from v$standby_log;
GROUP# BYTES/1024/1024
---------- ---------------
4 200
5 200
6 200
7 200
4.配置tnsnames.ora
sty =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.112.51)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = dg2)))
主库需要加上备库的tns连接串,备库加上主库的
5.拷贝主库的密码文件到备库
[oracle@dg1 dbs]$ scp orapwdg1 oracle@dg2:$ORACLE_HOME/dbs/
[oracle@dg2 dbs]$ ll
total 8
-rw-r--r-- 1 oracle oinstall 3079 May 14 2015 init.ora
-rw-r----- 1 oracle oinstall 2048 May 25 22:59 orapwdg1
[oracle@dg2 dbs]$ pwd
/u01/app/oracle/product/19.3.0/db_1/dbs