最近在学习Oracle dataguard相关知识。本系列就Oracle Enterprise Linux 5.5 X86_64位环境下Oracle 10g 10.2.0.5.0双节点RAC数据库配置一套物理dataguard做一记录,一来给自己的学习做一简单记录,二来,同样希望可以给广大网友及Oracle数据库技术爱好者提供思路。
在实施之前,简单介绍下背景、最终目标及配置步骤:
- 背景介绍:主库是一套运行在Oracle Enterprise Linux 5.5 X86_64位环境下Oracle 10g 10.2.0.5.0双节点RAC数据库,主库用的是ASM存储,ASM磁盘利用raw来实现;
- 最终目标:需要给该主库搭建一套同样是运行在Oracle Enterprise Linux 5.5 X86_64位环境下的物理备库,并且能够switchover,确保高可用
- 配置步骤: 1 了解现有主库的配置信息;
2 搭建一台干净的新机器,用于创建物理备库使用;
3 在物理备机上安装oracle数据库软件,并且升级到同主库软件版本一致,即10.2.0.5.0;
4 在物理备机上创建ASM实例,ASM磁盘同样选择裸设备来实现;
5 配置物理备库;
6 确认switchover成功,双节点RAC+physical standby既可提供实例级别容灾(RAC功能)又可以提供存储级别容灾(Dataguard功能),做到真正的高可用!
本篇是整个实施过程的系列1:本篇的内容主要是查看主库基本配置信息,及创建一台干净的Linux服务器,用作备库。
一 首先了解下现有双节点RAC数据库配置信息:
1 节点1系统基本信息:
[root@oracle-rac1 ~]# hostname oracle-rac1.gillion.com.cn [root@oracle-rac1 ~]# uname -rm 2.6.18-194.0.0.0.3.el5 x86_64 [root@oracle-rac1 ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 ext3 20G 12G 6.8G 64% / /dev/sda1 ext3 99M 19M 75M 21% /boot tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm [root@oracle-rac1 ~]# ifconfig eth0 Link encap:Ethernet HWaddr 00:0C:29:3A:B8:31 inet addr:172.16.0.33 Bcast:172.16.15.255 Mask:255.255.240.0 inet6 addr: fe80::20c:29ff:fe3a:b831/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:836563 errors:0 dropped:0 overruns:0 frame:0 TX packets:10459 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:73068451 (69.6 MiB) TX bytes:2856621 (2.7 MiB) eth0:1 Link encap:Ethernet HWaddr 00:0C:29:3A:B8:31 inet addr:172.16.0.35 Bcast:172.16.15.255 Mask:255.255.240.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 eth1 Link encap:Ethernet HWaddr 00:0C:29:3A:B8:3B inet addr:192.168.139.13 Bcast:192.168.139.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe3a:b83b/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1484344 errors:0 dropped:0 overruns:0 frame:0 TX packets:707841 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:327352385 (312.1 MiB) TX bytes:353601291 (337.2 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:265726 errors:0 dropped:0 overruns:0 frame:0 TX packets:265726 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:61035429 (58.2 MiB) TX bytes:61035429 (58.2 MiB) [root@oracle-rac1 ~]# cat /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost 172.16.0.33 oracle-rac1.gillion.com.cn oracle-rac1 172.16.0.35 oracle-rac1-vip oracle-rac1-vip.gillion.com.cn 192.168.139.13 oracle-rac1-priv 172.16.0.34 oracle-rac2.gillion.com.cn oracle-rac2 172.16.0.36 oracle-rac2-vip oracle-rac2-vip.gillion.com.cn 192.168.139.14 oracle-rac2-priv [root@oracle-rac1 ~]# su - oracle [oracle@oracle-rac1 ~]$ . oraenv ORACLE_SID = [oracle] ? glndb [oracle@oracle-rac1 ~]$ export ORACLE_SID=glndb1 [oracle@oracle-rac1 ~]$ env | grep ORA ORACLE_SID=glndb1 ORACLE_BASE=/u01/app/oracle ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1 [oracle@oracle-rac1 ~]$
2 节点1数据库基本信息:
[oracle@oracle-rac1 ~]$ sqlplus SQL*Plus: Release 10.2.0.5.0 - Production on Tue Feb 14 09:11:00 2012 Copyright (c) 1982, 2010, Oracle. All Rights Reserved. SQL> conn / as sysdba; Connected. SQL> select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi PL/SQL Release 10.2.0.5.0 - Production CORE 10.2.0.5.0 Production TNS for Linux: Version 10.2.0.5.0 - Production NLSRTL Version 10.2.0.5.0 - Production SQL> alter session set nls_date_format='yyyy/mm/dd hh24:mi:ss'; Session altered. SQL> select dbid,name,created,log_mode,db_unique_name from gv$database; DBID NAME CREATED LOG_MODE DB_UNIQUE_NAME ---------- --------- ------------------- ------------ --------- 3995745524 GLNDB 2010/08/03 10:44:04 ARCHIVELOG glndb 3995745524 GLNDB 2010/08/03 10:44:04 ARCHIVELOG glndb SQL> show parameter db_name; NAME TYPE VALUE ------------------------------------ ----------- --------- db_name string glndb SQL> show parameter db_unique; NAME TYPE VALUE ------------------------------------ ----------- --------- db_unique_name string glndb SQL> archive log list; Database log mode Archive Mode Automatic archival Enabled Archive destination /home/oracle/arch1 Oldest online log sequence 7699 Next log sequence to archive 7700 Current log sequence 7700 SQL> show parameter spfile NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ spfile string +ORADATA/glndb/spfileglndb.ora SQL>
3 节点2基本信息:
[root@oracle-rac2 ~]# hostname oracle-rac2.gillion.com.cn [root@oracle-rac2 ~]# uname -rm 2.6.18-194.0.0.0.3.el5 x86_64 [root@oracle-rac2 ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 ext3 20G 12G 6.9G 63% / /dev/sda1 ext3 99M 19M 75M 21% /boot tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm [root@oracle-rac2 ~]# ifconfig eth0 Link encap:Ethernet HWaddr 00:0C:29:D1:B5:4C inet addr:172.16.0.34 Bcast:172.16.15.255 Mask:255.255.240.0 inet6 addr: fe80::20c:29ff:fed1:b54c/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:833250 errors:0 dropped:0 overruns:0 frame:0 TX packets:8442 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:72725394 (69.3 MiB) TX bytes:2440410 (2.3 MiB) eth0:1 Link encap:Ethernet HWaddr 00:0C:29:D1:B5:4C inet addr:172.16.0.36 Bcast:172.16.15.255 Mask:255.255.240.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 eth1 Link encap:Ethernet HWaddr 00:0C:29:D1:B5:56 inet addr:192.168.139.14 Bcast:192.168.139.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fed1:b556/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1534148 errors:0 dropped:0 overruns:0 frame:0 TX packets:655976 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:424024468 (404.3 MiB) TX bytes:256611983 (244.7 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:274642 errors:0 dropped:0 overruns:0 frame:0 TX packets:274642 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:61783289 (58.9 MiB) TX bytes:61783289 (58.9 MiB) [root@oracle-rac2 ~]# cat /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost 172.16.0.33 oracle-rac1.gillion.com.cn oracle-rac1 172.16.0.35 oracle-rac1-vip oracle-rac1-vip.gillion.com.cn 192.168.139.13 oracle-rac1-priv 172.16.0.34 oracle-rac2.gillion.com.cn oracle-rac2 172.16.0.36 oracle-rac2-vip oracle-rac2-vip.gillion.com.cn 192.168.139.14 oracle-rac2-priv [root@oracle-rac2 ~]# su - oracle [oracle@oracle-rac2 ~]$ . oraenv ORACLE_SID = [oracle] ? glndb [oracle@oracle-rac2 ~]$ export ORACLE_SID=glndb2 [oracle@oracle-rac2 ~]$ env |grep ORA ORACLE_SID=glndb2 ORACLE_BASE=/u01/app/oracle ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1 [oracle@oracle-rac2 ~]$
4 点2数据库基本信息:
[oracle@oracle-rac2 ~]$ sqlplus SQL*Plus: Release 10.2.0.5.0 - Production on Tue Feb 14 09:25:47 2012 Copyright (c) 1982, 2010, Oracle. All Rights Reserved. SQL> conn / as sysdba; Connected. SQL> select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi PL/SQL Release 10.2.0.5.0 - Production CORE 10.2.0.5.0 Production TNS for Linux: Version 10.2.0.5.0 - Production NLSRTL Version 10.2.0.5.0 - Production SQL> alter session set nls_date_format='yyyy/mm/dd hh24:mi:ss'; Session altered. SQL> set line 160 SQL> select dbid,name,created,log_mode,db_unique_name from gv$database; DBID NAME CREATED LOG_MODE DB_UNIQUE_NAME ---------- --------- ------------------- ------------ --------- 3995745524 GLNDB 2010/08/03 10:44:04 ARCHIVELOG glndb 3995745524 GLNDB 2010/08/03 10:44:04 ARCHIVELOG glndb SQL> show parameter db_name NAME TYPE VALUE ------------------------------------ ----------- -------------- db_name string glndb SQL> show parameter db_unique NAME TYPE VALUE ------------------------------------ ----------- -------------- db_unique_name string glndb SQL> archive log list; Database log mode Archive Mode Automatic archival Enabled Archive destination /home/oracle/arch2 Oldest online log sequence 3270 Next log sequence to archive 3271 Current log sequence 3271 SQL> show parameter spfile NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ spfile string +ORADATA/glndb/spfileglndb.ora SQL>
5 数据文件、 控制文件基本信息:
SQL> select name,bytes/1024/1024 M from v$datafile 2 union 3 select name,0 from v$controlfile 4 order by 2 5 ; NAME M -------------------------------------------------- ---------- +ORADATA/glndb/controlfile/current.256.726057849 0 +ORADATA/glndb/datafile/example.435.756233417 2 +ORADATA/glndb/datafile/users.265.726057871 2 +ORADATA/glndb/datafile/undotbs3.268.774870843 200 +ORADATA/glndb/datafile/undotbs2.264.726057869 261 +ORADATA/glndb/datafile/sysaux.262.726057863 1290 +ORADATA/glndb/datafile/system.260.726057851 6039 7 rows selected. SQL>
6 联机日志文件信息:
SQL> select * from v$log; GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------------- 1 1 7700 52428800 1 NO CURRENT 445626703 2012/02/13 23:06:00 2 1 7699 52428800 1 YES INACTIVE 445622543 2012/02/13 23:05:29 4 2 3271 52428800 1 NO CURRENT 445627780 2012/02/13 23:05:58 5 2 3270 52428800 1 YES INACTIVE 445332258 2012/02/13 09:05:39 SQL>
7 资源状态信息:
[oracle@oracle-rac2 ~]$ /u01/app/oracle/product/10.2.0/crs/bin/crs_stat -t Name Type Target State Host ------------------------------------------------------------ ora.glndb.db application ONLINE ONLINE oracle-rac2 ora...._svc.cs application ONLINE ONLINE oracle-rac1 ora....db1.srv application ONLINE ONLINE oracle-rac1 ora....b1.inst application ONLINE ONLINE oracle-rac1 ora....b2.inst application ONLINE ONLINE oracle-rac2 ora....svc2.cs application ONLINE ONLINE oracle-rac2 ora....db2.srv application ONLINE ONLINE oracle-rac2 ora....SM1.asm application ONLINE ONLINE oracle-rac1 ora....C1.lsnr application ONLINE ONLINE oracle-rac1 ora....ac1.gsd application ONLINE ONLINE oracle-rac1 ora....ac1.ons application ONLINE ONLINE oracle-rac1 ora....ac1.vip application ONLINE ONLINE oracle-rac1 ora....SM2.asm application ONLINE ONLINE oracle-rac2 ora....C2.lsnr application ONLINE ONLINE oracle-rac2 ora....ac2.gsd application ONLINE ONLINE oracle-rac2 ora....ac2.ons application ONLINE ONLINE oracle-rac2 ora....ac2.vip application ONLINE ONLINE oracle-rac2 [oracle@oracle-rac2 ~]$
二 在获取了RAC主库的基本信息之后,接下来搭建一套新的机器做物理dataguard用
本文采用的是在一套虚拟机上搭建另外的备库机器,该虚拟机软件是VMware ESX 4.0,该软件其实可以认为是一个操作系统,是直接装在物理机器上的,有别于Vmware公司的VMware Server、VMware Workstation软件,后两者是先需要有操作系统,然后在操作系统上安装该虚拟机软件。而且,VMware ESX 4.0虚拟机软件相对来说也要比后两者稳定。
- 用Vmware vSphere Client工具登录虚拟机控制台:
登录控制台后,虚拟机信息概览:
2 选择File–New–Virtual Machine,新建虚拟机命名为10gRAC-Dataguard:
3 接下来一步一步走,同在VMware Server、VMware Workstation里创建新虚拟机一样,在此不再赘述。配置后的虚拟机概览如下:
4 给10gRAC-Dataguard加电,开始安装操作系统,虚拟机磁盘分区如下:
5 虚拟机网络配置信息如下:
IPv4:172.16.0.202
Netmask:255.255.240.0
Gateway:172.16.15.254
DNS:Null
Hostname:ora10grac-dg
6 软件包安装时,选择客户化,其中,下述是选择要安装的软件包:
Desktop Environments:GNOME Desktop Environment
Applications:
Editors
Graphics
Development:
Development Libraries
Development Tools
GNOME Software Development
Legacy Software Development
X software Development
Base System:
Administration Tools
Base
Legacy Software Support
System Tools (其中,选择oracleasm软件包。注:默认情况下并没有oracleasmlib-2.0.4-1.el5软件包,如果采用asmlib来管理和创建asm磁盘的话,仍需要后续手工安装该RPM包,否则将来配置ASM存储时会找不到ASM磁盘!!!)
暂时,先安装这些软件包,稍后在安装oracle软件时,如有缺失软件包的话,再续安装,至于其它的Server,虚拟化,集群软件包一概不装!
7 接下来,进行格式化文件系统,进入系统安装。稍后,还有一些后续的配置工作,记得不要开启SELinux并且关闭防火墙!最后,一台新的虚拟机配置成功,登录界面如下:
8 新虚拟机基本信息如下:
[root@ora10grac-dg ~]# hostname ora10grac-dg [root@ora10grac-dg ~]# uptime 11:17:18 up 2 min, 2 users, load average: 1.98, 1.23, 0.47 [root@ora10grac-dg ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/sda1 ext3 7.8G 2.8G 4.7G 37% / tmpfs tmpfs 1.1G 0 1.1G 0% /dev/shm [root@ora10grac-dg ~]# ifconfig eth0 Link encap:Ethernet HWaddr 00:0C:29:2E:60:24 inet addr:172.16.0.202 Bcast:172.16.15.255 Mask:255.255.240.0 inet6 addr: fe80::20c:29ff:fe2e:6024/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3356 errors:0 dropped:0 overruns:0 frame:0 TX packets:196 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:333071 (325.2 KiB) TX bytes:21084 (20.5 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:1056 errors:0 dropped:0 overruns:0 frame:0 TX packets:1056 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1753796 (1.6 MiB) TX bytes:1753796 (1.6 MiB) [root@ora10grac-dg ~]# uname -rm 2.6.18-194.el5 x86_64 [root@ora10grac-dg ~]#
这样,一台新的物理备库机器配置成功!接下来需要在该机器上安装oracle软件,配置ASM,升级oracle软件到10.2.0.5.0版本,下篇继续!