Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1013951
  • 博文数量: 584
  • 博客积分: 2293
  • 博客等级: 大尉
  • 技术积分: 3045
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-28 11:15
文章分类

全部博文(584)

文章存档

2012年(532)

2011年(47)

2009年(5)

我的朋友

分类: Oracle

2012-01-04 21:20:34

2月3日,我将在Oracle University主持一个关于RAC One Node新功能的简短讲座。个人认为这是单节点数据库实现Rolling Patch的最佳方案了。目前此功能仅在Linux上提供。

待结束之后再把相关内容添加于此。讲义内容


======RAC One Node初始化和Omotion迁移演示======

忙,终于有时间更新一下了。以下是RAC One Node数据库安装、初始化和通过Omotion脚本在线迁移例程的演示记录。

首先,按照常规RAC的安装方式安装11gR2的Grid和Oracle Home。在这里我准备了一套三个节点的11gR2的 RAC,并且还有一个名为orcl的数据库(有没有这个RAC数据库并不影响RAC One Node DB,因为我们要另外安装一个数据库,名为todd。)

#节点信息:
Node1: gr7251
Node2: gr7286
Node3: gr7265

#资源信息:

[grid@gr7251 ~]$ /u01/app/11.2.0/grid/bin/crsctl status resource -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS 
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ACFS.dg
ONLINE ONLINE gr7251 
ONLINE ONLINE gr7265 
ONLINE ONLINE gr7286 
ora.DATA.dg
ONLINE ONLINE gr7251 
ONLINE ONLINE gr7265 
ONLINE ONLINE gr7286 
ora.FRA.dg
ONLINE ONLINE gr7251 
ONLINE ONLINE gr7265 
ONLINE ONLINE gr7286 
ora.LISTENER.lsnr
ONLINE ONLINE gr7251 
ONLINE ONLINE gr7265 
ONLINE ONLINE gr7286 
ora.asm
ONLINE ONLINE gr7251 Started 
ONLINE ONLINE gr7265 
ONLINE ONLINE gr7286 Started 
ora.eons
ONLINE ONLINE gr7251 
ONLINE ONLINE gr7265 
ONLINE ONLINE gr7286 
ora.gsd
OFFLINE OFFLINE gr7251 
OFFLINE OFFLINE gr7265 
OFFLINE OFFLINE gr7286 
ora.net1.network
ONLINE ONLINE gr7251 
ONLINE ONLINE gr7265 
ONLINE ONLINE gr7286 
ora.ons
ONLINE ONLINE gr7251 
ONLINE ONLINE gr7265 
ONLINE ONLINE gr7286 
ora.registry.acfs
ONLINE ONLINE gr7251 
ONLINE ONLINE gr7265 
ONLINE ONLINE gr7286 
--------------------------------------------------------------------------------
Cluster Resources
-------------------------------------------------------------------------------- 
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE gr7251 
ora.LISTENER_SCAN2.lsnr
1 ONLINE ONLINE gr7286 
ora.LISTENER_SCAN3.lsnr
1 ONLINE ONLINE gr7265 
ora.gns
1 ONLINE ONLINE gr7265 
ora.gns.vip
1 ONLINE ONLINE gr7265 
ora.gr7251.vip
1 ONLINE ONLINE gr7251 
ora.gr7265.vip
1 ONLINE ONLINE gr7265 
ora.gr7286.vip
1 ONLINE ONLINE gr7286 
ora.oc4j
1 OFFLINE OFFLINE 
ora.orcl.db
1 ONLINE ONLINE gr7251 Open 
2 ONLINE ONLINE gr7286 Open 
3 ONLINE ONLINE gr7265 Open 
ora.scan1.vip
1 ONLINE ONLINE gr7251 
ora.scan2.vip
1 ONLINE ONLINE gr7286 
ora.scan3.vip
1 ONLINE ONLINE gr7265 

#SCAN信息:
三个节点使用统一的DNS名,11gR2简称为SCAN。和DHCP结合使用可以使客户端的TNS配置简化到极点。比VIP更方便。

[grid@gr7251 ~]$ srvctl config scan
SCAN name: cl7251-scan.cl7251.example.com, Network: 1/10.196.180.0/255.255.252.0/eth3
SCAN VIP name: scan1, IP: /10.196.181.243/10.196.181.243
SCAN VIP name: scan2, IP: /10.196.181.253/10.196.181.253
SCAN VIP name: scan3, IP: /10.196.180.254/10.196.180.254
[grid@gr7251 ~]$ srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
SCAN Listener LISTENER_SCAN2 exists. Port: TCP:1521
SCAN Listener LISTENER_SCAN3 exists. Port: TCP:1521

# GNS信息:
[root@gr7251 ~]# /u01/app/11.2.0/grid/bin/srvctl config gns -a
GNS is enabled.
GNS is listening for DNS server requests on port 53
GNS is using port 5353 to connect to mDNS
GNS status: OK
Domain served by GNS: cl7251.example.com
GNS version: 11.2.0.1.0
GNS VIP network: ora.net1.network

[grid@gr7251 ~]$ srvctl status gns
GNS is running on node gr7265.
GNS is enabled on node gr7265.

# 观察一下RAC One Node的必要补丁9004119

注意这个补丁是Rolling Patch

[oracle@gr7251 ~]$ cd toddstage/9004119/
[oracle@gr7251 9004119]$ /u01/app/oracle/product/11.2.0/dbhome_1/OPatch/opatch query
Invoking OPatch 11.1.0.6.6

Oracle Interim Patch Installer version 11.1.0.6.6
Copyright (c) 2009, Oracle Corporation. All rights reserved.


Oracle Home : /u01/app/oracle/product/11.2.0/dbhome_1
Central Inventory : /u01/app/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.1.0.6.6
OUI version : 11.2.0.1.0
OUI location : /u01/app/oracle/product/11.2.0/dbhome_1/oui
Log file location : /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2010-02-04_10-20-18AM.log

Patch history file: /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch_history.txt

--------------------------------------------------------------------------------
Patch created on 22 Oct 2009, 12:29:39 hrs US/Pacific
Need to shutdown Oracle instances: true
Patch is roll-backable: true
Patch is a rolling patch: true
Patch has sql related actions: false
Patch is an online patch: false
Patch is a portal patch: false

List of platforms supported:
46: Linux Intel

List of bugs to be fixed:
9004119: PATCH FOR RAC ONE NODE SCRIPTS

This patch does not have a patch type.

List of optional components:
oracle.rdbms: 11.2.0.1.0

List of optional actions:
Copy racone2rac to /u01/app/oracle/product/11.2.0/dbhome_1/bin/racone2rac
Copy Omotion to /u01/app/oracle/product/11.2.0/dbhome_1/bin/Omotion
Copy raconefix to /u01/app/oracle/product/11.2.0/dbhome_1/bin/raconefix
Copy raconeinit to /u01/app/oracle/product/11.2.0/dbhome_1/bin/raconeinit
Copy raconestatus to /u01/app/oracle/product/11.2.0/dbhome_1/bin/raconestatus

Possible XML representation of the patch:






9004119




--------------------------------------------------------------------------------

OPatch succeeded.


# 打补丁-90044119

因为有个名为orcl的数据库的三个例程orcl1,orcl2,orcl3分别运行在三个节点上,我用滚动方式打这个补丁。期间根据提示滚动关 闭/启动各个例程,命令是:

[oracle@gr7251 ~]$ srvctl stop instance -d orcl -i orcl1
[oracle@gr7251 ~]$ srvctl start instance -d orcl -i orcl1
[oracle@gr7251 ~]$ srvctl stop instance -d orcl -i orcl3
[oracle@gr7251 ~]$ srvctl start instance -d orcl -i orcl3
[oracle@gr7251 ~]$ srvctl stop instance -d orcl -i orcl2
[oracle@gr7251 ~]$ srvctl start instance -d orcl -i orcl2


[oracle@gr7251 9004119]$ /u01/app/oracle/product/11.2.0/dbhome_1/OPatch/opatch apply
Invoking OPatch 11.1.0.6.6

Oracle Interim Patch Installer version 11.1.0.6.6
Copyright (c) 2009, Oracle Corporation. All rights reserved.

Oracle Home : /u01/app/oracle/product/11.2.0/dbhome_1
Central Inventory : /u01/app/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.1.0.6.6
OUI version : 11.2.0.1.0
OUI location : /u01/app/oracle/product/11.2.0/dbhome_1/oui
Log file location : /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2010-02-04_10-22-44AM.log

Patch history file: /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch_history.txt

ApplySession applying interim patch '9004119' to OH '/u01/app/oracle/product/11.2.0/dbhome_1'

Running prerequisite checks...

OPatch detected the node list and the local node from the inventory. OPatch will patch the local system then propagate the patch to the remote nodes.


This node is part of an Oracle Real Application Cluster.
Remote nodes: 'gr7265' 'gr7286'
Local node: 'gr7251'
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/u01/app/oracle/product/11.2.0/dbhome_1')

Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files and inventory (not for auto-rollback) for the Oracle Home
Backing up files affected by the patch '9004119' for restore. This might take a while...
Backing up files affected by the patch '9004119' for rollback. This might take a while...

Patching component oracle.rdbms, 11.2.0.1.0...
Copying file to "/u01/app/oracle/product/11.2.0/dbhome_1/bin/racone2rac"
Copying file to "/u01/app/oracle/product/11.2.0/dbhome_1/bin/Omotion"
Copying file to "/u01/app/oracle/product/11.2.0/dbhome_1/bin/raconefix"
Copying file to "/u01/app/oracle/product/11.2.0/dbhome_1/bin/raconeinit"
Copying file to "/u01/app/oracle/product/11.2.0/dbhome_1/bin/raconestatus"
ApplySession adding interim patch '9004119' to inventory

Verifying the update...
Inventory check OK: Patch ID 9004119 is registered in Oracle Home inventory with proper meta-data.
Files check OK: Files from Patch ID 9004119 are present in Oracle Home.

The local system has been patched. You can restart Oracle instances on it.


Patching in rolling mode.

Remaining nodes to be patched:
'gr7265' 'gr7286'
What is the next node to be patched?
gr7265
You have selected 'gr7265' from 'gr7265' 'gr7286'

The node 'gr7265' will be patched next.

Please shutdown Oracle instances running out of this ORACLE_HOME on 'gr7265'.
(Oracle Home = '/u01/app/oracle/product/11.2.0/dbhome_1')

Is the node ready for patching? [y|n]
y
User Responded with: Y
Updating nodes 'gr7265'
Apply-related files are:
FP = "/u01/app/oracle/product/11.2.0/dbhome_1/.patch_storage/9004119_Oct_22_2009_12_29_39/rac/copy_files.txt"
DP = "/u01/app/oracle/product/11.2.0/dbhome_1/.patch_storage/9004119_Oct_22_2009_12_29_39/rac/copy_dirs.txt"
MP = "/u01/app/oracle/product/11.2.0/dbhome_1/.patch_storage/9004119_Oct_22_2009_12_29_39/rac/make_cmds.txt"
RC = "/u01/app/oracle/product/11.2.0/dbhome_1/.patch_storage/9004119_Oct_22_2009_12_29_39/rac/remote_cmds.txt"

Instantiating the file "/u01/app/oracle/product/11.2.0/dbhome_1/.patch_storage/9004119_Oct_22_2009_12_29_39/rac/copy_files.txt.instantiated" by replacing $ORACLE_HOME in "/u01/app/oracle/product/11.2.0/dbhome_1/.patch_storage/9004119_Oct_22_2009_12_29_39/rac/copy_files.txt" with actual path.
Propagating files to remote nodes...
Instantiating the file "/u01/app/oracle/product/11.2.0/dbhome_1/.patch_storage/9004119_Oct_22_2009_12_29_39/rac/copy_dirs.txt.instantiated" by replacing $ORACLE_HOME in "/u01/app/oracle/product/11.2.0/dbhome_1/.patch_storage/9004119_Oct_22_2009_12_29_39/rac/copy_dirs.txt" with actual path.
Propagating directories to remote nodes...

The node 'gr7265' has been patched. You can restart Oracle instances on it.


The node 'gr7286' will be patched next.


Please shutdown Oracle instances running out of this ORACLE_HOME on 'gr7286'.
(Oracle Home = '/u01/app/oracle/product/11.2.0/dbhome_1')

Is the node ready for patching? [y|n]
y
User Responded with: Y
Updating nodes 'gr7286'
Apply-related files are:
FP = "/u01/app/oracle/product/11.2.0/dbhome_1/.patch_storage/9004119_Oct_22_2009_12_29_39/rac/copy_files.txt"
DP = "/u01/app/oracle/product/11.2.0/dbhome_1/.patch_storage/9004119_Oct_22_2009_12_29_39/rac/copy_dirs.txt"
MP = "/u01/app/oracle/product/11.2.0/dbhome_1/.patch_storage/9004119_Oct_22_2009_12_29_39/rac/make_cmds.txt"
RC = "/u01/app/oracle/product/11.2.0/dbhome_1/.patch_storage/9004119_Oct_22_2009_12_29_39/rac/remote_cmds.txt"

Propagating files to remote nodes...
Propagating directories to remote nodes...

The node 'gr7286' has been patched. You can restart Oracle instances on it.


OPatch succeeded.

# 用DBCA创建一个新的数据库,名为todd,创建Summary如下:

Create Database - Summary
Database Configuration Summary
Global Database Name: todd
Database Configuration: Admin-Managed Cluster Database
Node List: gr7251
SID List: todd1
Management Option Type: None
Storage Type: Automatic Storage Management (ASM)
Memory Configuration Type: Automatic Shared Memory Management 
注意要选择Admin-Managed Cluster Database。并且运行节点只能选择一个节点,我选择了gr7251,这才是RAC One Node的数据库,否则就是RAC了。

# 创建一个支持TAF的服务,名为SERV,方便Omotion做在线迁移。

SQL> begin dbms_service.create_service('SERV','SERV',FAILOVER_METHOD=>dbms_service.FAILOVER_METHOD_BASIC,FAILOVER_TYPE=>dbms_service.FAILOVER_TYPE_SELECT,FAILOVER_RETRIES=>300); end;
2 /
PL/SQL procedure successfully completed.
[oracle@gr7251 ~]$ srvctl add service -d todd -s SERV -r "todd1" -P BASIC -e SELECT -z 300 -y AUTOMATIC
[oracle@gr7251 ~]$ srvctl start service -d todd -s SERV
[grid@gr7251 ~]$ /u01/app/11.2.0/grid/bin/crs_stat -t | grep svc
ora....erv.svc ora....ce.type ONLINE ONLINE gr7251

# 在测试客户端添加一个针对SERV的TNSNAME,因为使用了SCAN,所以VIP们就没地方露脸了。 =)

SERV =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = cl7251-scan.cl7251.example.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = SERV)
)
)

# 在todd数据库上执行raconeinit脚本初始化RAC One Node功能。如果你没有这个脚本,那么是因为上面那个没打。

我指定todd数据库的例程只运行在节点gr7251上,节点gr7265和gr7286作为备用节点。

[oracle@gr7251 ~]$ $ORACLE_HOME/bin/raconeinit
Candidate Databases on this cluster:

# Database RAC One Node Fix Required
=== ======== ============ ============
[1] todd NO N/A

Enter the database to initialize [1]: 1


Database todd is now running on server gr7251

Candidate servers that may be used for this DB: gr7265 gr7286

Enter the names of additional candidate servers where this DB may run (space delimited): gr7265 gr7286

Please wait, this may take a few minutes to finish.........
Database configuration modified.

# 现在可以在客户端上发起工作负载了,这个负载在之后的时间里从来没有停止过,包括在Omotion脚本在节点间迁移例程的时候。这需要服务SERV支持 TAF或FAN,我之前已经启用了TAF。

[oracle@gr7251 ~]$ sqlplus system/oracle_4U@SERV
SQL*Plus: Release 11.2.0.1.0 Production on Thu Feb 4 12:04:08 2010
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> select * from dba_objects order by 1,2,3,4,5,6;
//命令的返回略去,注意在线迁移时它不会报错,不会停止。感谢TAF。

# 终于可以执行Omotion脚本在线迁移了,我的目的是把todd数据库的例程从gr7251在线迁移到gr7265。(因为我基本没有截断任何输出,所 以你能坚持看到这里也挺不容易的。)

[oracle@gr7251 ~]$ $ORACLE_HOME/bin/Omotion
RAC One Node databases on this cluster:

# Database Server Fix Required
=== ======== ============================== ============
[1] todd gr7251 N

Enter number of the database to migrate [1]: 1

Specify maximum time in minutes for migration to complete (max 30) [30]: 1

Available Target Server(s) :
# Server Available
=== ================== =========
[1] gr7265 Y
[2] gr7286 Y

Enter number of the target node [1]: 1

Omotion Started...
Starting target instance on gr7265...
Migrating sessions...
Stopping source instance on gr7251...
Timeout exceeded, aborting instance...
Omotion Completed...

=== Current Status ===
Database todd is running on node gr7265

[oracle@gr7251 ~]$ $ORACLE_HOME/bin/raconestatus
RAC One Node databases on this cluster:


Database UP Fix Required Current Server Candidate Server Names
======== == ============ ============================== ========================================

todd Y N gr7265 gr7265 gr7251 gr7286


Available Free Servers:

[oracle@gr7251 ~]$ srvctl status database -d todd
Instance todd_2 is running on node gr7265

现在你想在gr7251上做什么可以开始了,比如打滚动补丁。客户的会话全在gr7265上了。

# 我还有时间,再迁移回去。

[oracle@gr7251 ~]$ $ORACLE_HOME/bin/Omotion
RAC One Node databases on this cluster:

# Database Server Fix Required
=== ======== ============================== ============
[1] todd gr7265 N

Enter number of the database to migrate [1]: 1

Specify maximum time in minutes for migration to complete (max 30) [30]: 1

Available Target Server(s) :
# Server Available
=== ================== =========
[1] gr7251 Y
[2] gr7286 Y

Enter number of the target node [1]: 1

Omotion Started...
Starting target instance on gr7251...
Migrating sessions...
Stopping source instance on gr7265...
Timeout exceeded, aborting instance...
Omotion Completed...

=== Current Status ===
Database todd is running on node gr7251

[oracle@gr7251 ~]$ $ORACLE_HOME/bin/raconestatus
RAC One Node databases on this cluster:


Database UP Fix Required Current Server Candidate Server Names
======== == ============ ============================== ========================================
todd Y N gr7251 gr7251 gr7265 gr7286


Available Free Servers:

[oracle@gr7251 ~]$ srvctl status database -d todd
Instance todd_1 is running on node gr7251

# 总结

RAC One Node是一个介于RAC数据库和单例程数据库的一个解决方案,搭建在标准Cluster框架之上,数据库的例程却只有一个,运行在一个节点上。与FAN 和TAF功能配合使用,在Omotion脚本的帮助下可以方便地实现在线例程迁移。能使非RAC数据库也能享受滚动补丁等最小化宕机服务。

阅读(1907) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~