再做 Oracle 11gR2 RAC+DG2

这一部分开始创建dg备库的asm磁盘组,然后执行RAC主库准备工作。

dg备库切换到grid用户,执行asmca开始配置

dg23

dg24

创建DATA磁盘组,这是将来存放数据的.

dg25

稍等片刻创建成功

dg26

用同样的方法创建FLASH磁盘组,完成如下:

dg27

 

dg切换到oracle用户,查看一下刚才创建的磁盘组

su -grid

sqlplus / as sysdba

select name from v$asm_diskgroup;

NAME

————————————————————————————

DATA

GRIDDG

FLASH

可见ASM磁盘组创建成功

挂载刚才创建的磁盘/dev/sde

由于格式化成了ext3分区,因此可以直接挂载到/rman_backup目录下

mount /dev/sde /rman_backup

df -h

dg28

执行chown -R oracle:oinstall /rman_backup 配置一下rman_backup的属主

dg29

至此dg备库asm磁盘组RMAN备份磁盘创建完成。

 

RAC主库准备

node1节点添加磁盘10GB,用来存放数据库全备,控制文件,初始化文件,日志文件等。

关闭node1,为node1添加磁盘,和dg备库添加磁盘过程相同。

然后格式化成ext3文件系统,挂载到/rman_backup下,如下图所示

dg30

 

RAC主库具体准备工作如下:

1. RAC主库必须置为Force Logging模式

2. RAC主库必须置为归档模式

3. RAC 主库执行RMAN全备

4. RAC主库执行创建物理备库控制文件

5. RAC主库创建物理备库初始化参数文件

6. RAC主库修改口令文件,使双节点SYS用户口令一致

 

切换主库为Force Logging模式

执行如下操作:

node1 -> su – oracle

Password:

node1 -> sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Wed Jun 15 21:22:12 2016

Copyright (c) 1982, 2009, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options

SQL> select name, log_mode , force_logging from gv$database;

NAME LOG_MODE FOR

——— ———— —

DEVDB NOARCHIVELOG NO

DEVDB NOARCHIVELOG NO

SQL> alter database force logging;

Database altered.

SQL> select name, log_mode , force_logging from gv$database;

NAME LOG_MODE FOR

——— ———— —

DEVDB NOARCHIVELOG YES

DEVDB NOARCHIVELOG YES

现在发现Force Logging生效了。

 

RAC主库修改为归档模式

这里我们需要通过grid来打开和关闭数据库

su – grid

crs_stat -t 查看数据库状态

dg32

 

srvctl stop database -d devdb 关闭实例

dg31

查看实例状态

srvctl status database -d devdb

dg33

 

node1切换日志模式为arvhivelog

su – oracle

sqlplus

starup mount;

select open_mode , log_mode from v$database;

alter database archivelog;

select open_mode , log_mode from v$database;

shutdown immidiate;

再次切换到grid用户,然后打开数据库

su – grid

srvctl start database -d devdb

crs_stat -t

dg34

 

su – oracle

sqlplus

select name , log_mode , force_loggging from gv$database;

可以看出LOG_MODE已经变成了archivelog了。

 

RAC主库RMAN全备

su – oracle

rman target /

然后写一个RMAN全备脚本执行即可完成数据库全备

RMAN> run {

allocate channel c1 type disk;

allocate channel c2 type disk;

allocate channel c3 type disk;

backup database format ‘/rman_backup/Full_%U.bak’;

release channel c1;

release channel c2;

release channel c3;

}

backup archivelog all format ‘/rman_backup/ARC_%U.bak’;

执行成功,数据库备份到了/rman_backup/目录,如下:

dg35

 

主库创建备库的控制文件

RMAN> backup device type disk format ‘/rman_backup/standby_%U.ctl’ current controlfile for standby;

Starting backup at 2016/06/17 00:01:09

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including standby control file in backup set

channel ORA_DISK_1: starting piece 1 at 2016/06/17 00:01:12

channel ORA_DISK_1: finished piece 1 at 2016/06/17 00:01:14

piece handle=/rman_backup/standby_0fr8au65_1_1.ctl tag=TAG20160617T000109 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

Finished backup at 2016/06/17 00:01:15

执行成功

/rman_backup目录已经存在了控制文件standby_0fr8au65_1_1.ctl

dg36

 

RAC主库创建备库的初始化文件

node1切换到oracle用户,并用sqlplus登录

su – oracle

sqlplus

create pfile=’/rman_backup/initphydb.ora’ from spfile; 将初始化文件放到/rman_backup目录下,以后还需要修改

rman_backup目录中已经出现initphydb.ora初始化文件了

dg37

 

RAC主库修改SYS口令,和dg备库的SYS口令一致.

node1和node2切换到oracle用户sqlplus后,执行

alter user sys identified by Oracle168;

即可修改口令文件

验证口令文件是否有效,这里必须编辑node1和node2的tnsnames.ora文件

node1的tnsnames.ora中添加

devdb2 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.137.152)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = devdb)

(INSTANCE_NAME = devdb2)

)

)

node1的tnsnames.ora中添加

devdb1 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.137.151)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = devdb)

(INSTANCE_NAME = devdb1)

)

)

保存退出

node1和node2上分别测试登陆对方

node1上

conn sys/Oracle168@devdb2 as sysdba

dg38

node2上

conn sys/Oracle168@devdb1 as sysdba

dg39

至此RAC主库准备完成.

Leave a Reply