Chinaunix首页 | 论坛 | 博客
  • 博客访问: 103677851
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: Oracle

2008-04-30 13:41:02

第八章. 启动第二个节点实例
8.1 准备第二个节点的日志与重做
在第一个节点上

SQL>shutdown immediate

SQL>startup mount pfile=file name

SQL> alter database add logfile thread 2

2 group 4 ( /u01/oracle/oradata/rac/redo04.log ) size 10240K,

3 group 5 ( /u01/oracle/oradata/rac/redo05.log ) size 10240K,

4 group 6 ( /u01/oracle/oradata/rac/redo06.log ) size 10240k;

SQL>alter database open;

SQL> alter database enable public thread 2;

SQL> create undo tablespace undotbs2 datafile

2 /u01/oracle/oradata/rac/undotbs2_01.dbf size 200m;

Tablespace created.

8.2 启动第二个实例
如果是单节点,再开启一个连接终端

su - oracle

$export ORACLE_SID=rac2

$ sqlplus "/ as sysdba"

SQL>startup pfile=file name

这里的pfile就是共享的那个pfile

如果是多节点,到另外一个节点,执行以上同样的操作

8.3 验证RAC
SQL> select THREAD#,STATUS,ENABLED from gv$thread;

THREAD# STATUS ENABLED

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

1       OPEN PUBLIC

2       OPEN PUBLIC

1         OPEN     PUBLIC

2         OPEN     PUBLIC

SQL> select INSTANCE_NUMBER,INSTANCE_NUMBER,STATUS,HOST_NAME from gv$instance;

INSTANCE_NUMBER INSTANCE_NUMBER STATUS   HOST_NAME

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

1                   1                 OPEN         dbrac1

2                   2                 OPEN         dbrac2

第九章. 测试、使用RAC
9.1监听的配置
LISTENER1 =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS_LIST =

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

)

)

)

LISTENER2 =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = dbrac)(PORT = 1522))

)

)

)

以上是单节点模拟RAC的配置,两个实例采用不同的端口来模拟,如果是多节点的RAC,每个节点只要配置自己相应的监听即可。

启动监听,当看到状态类似如下时,表示正确,否则,需要检查每个实例的local_listener与remote_listener参数。

$ lsnrctl status

LSNRCTL for Linux: Version 9.2.0.4.0 - Production on 29-MAY-2004 10:38:08

Copyright (c) 1991, 2002, Oracle Corporation. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.168.205)(PORT=1521)))

STATUS of the LISTENER

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

Alias LISTENER

Version TNSLSNR for Linux: Version 9.2.0.4.0 - Production

Start Date 25-MAY-2004 01:27:14

Uptime 4 days 9 hr. 10 min. 54 sec

Trace Level off

Security OFF

SNMP OFF

Listener Parameter File /u01/oracle//ora920/network/admin/listener.ora

Listener Log File /u01/oracle//ora920/network/log/listener.log

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.168.205)(PORT=1521)))

Services Summary...

Service "rac" has 2 instance(s).

Instance "rac1", status READY, has 1 handler(s) for this service...

Instance "rac2", status READY, has 1 handler(s) for this service...

The command completed successfully

9.2本地名称的配置
rac=

(description=

(load_balance=on)

(failover=on)

(address_list=

(address=(protocol=tcp)(host=dbrac)(port=1521))

(address=(protocol=tcp)(host=dbrac)(port=1522)))

(connect_data=

(service_name=rac)))

rac1=

(description=

(address=(protocol=tcp)(host=dbrac)(port=1521))

(connect_data=

(service_name=rac)

(instance_name=rac1)))

rac2=

(description=

(address=(protocol=tcp)(host=dbrac)(port=1522))

(connect_data=

(service_name=rac)

(instance_name=rac2)))

以上是对一个节点的RAC的配置,如果是多个节点,只需要修改主机名与端口即可

9.3 负载均衡测试
[oracle@dbtest admin]$ more test.sh

#!/bin/sh

sqlplus "test/test@rac" <
select instance_name from v\$instance;

exit

EOF

[oracle@dbtest admin]$ ./test.sh

SQL*Plus: Release 9.2.0.4.0 - Production on Sat May 29 10:50:08 2004

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to:

Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production

With the Partitioning, Real Application Clusters, OLAP and Oracle Data Mining options

JServer Release 9.2.0.4.0 - Production

SQL>

INSTANCE_NAME

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

rac2

[oracle@dbtest admin]$ ./test.sh

SQL*Plus: Release 9.2.0.4.0 - Production on Sat May 29 10:50:08 2004

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to:

Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production

With the Partitioning, Real Application Clusters, OLAP and Oracle Data Mining options

JServer Release 9.2.0.4.0 - Production

SQL>

INSTANCE_NAME

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

rac1

9.4失败切换(failover)测试
需要修改tnsnames.ora为如下形式

rac=

(description=

# (enable=broken)

(load_balance=on)

(failover=on)

(address_list=

(address=(protocol=tcp)(host=dbtest)(port=1521))

(address=(protocol=tcp)(host=dbtest)(port=1522)))

(connect_data=

(service_name=rac)

(failover_mode=(type=select)(method=basic)

)

)

)

注意其中的failover_mode

SQL> connect test/test@rac

SQL> select INSTANCE_NUMBER,INSTANCE_NAME from v$instance;

INSTANCE_NUMBER INSTANCE_NAME

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

2 rac2

如果现在关闭实例rac2,再执行如上语句,可以发现

SQL> select INSTANCE_NUMBER,INSTANCE_NAME from v$instance;

INSTANCE_NUMBER INSTANCE_NAME

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

1 rac1

已经变为rac1

9.5 rac环境下修改为归档模式
1.停止所有node

2.修改init文件*.cluster_database=false

3.在一个node做修改

startup mount;

alter database archivelog ;

SQL> archive log list;

SQL>alter database open;

4.还原 *.cluster_database=true

5.启动所有node





第十章.从单节点数据库变为RAC
首先假定数据库软件的Cluster已经安装,OCM已经安装配置。

10.1修改参数文件
增加如类似如下的内容

*.cluster_database = TRUE

*.cluster_database_instances = 2

*.undo_management=AUTO

.undo_tablespace=undotbs

.instance_name=RAC1

.instance_number=1

.thread=1

.local_listener=LISTENER_RAC1

.remote_listener=LISTENER_RAC2

10.2创建cluster视图
利用$ORACLE_HOME/rdbms/admin/catclust.sql

10.3重新创建控制文件
把maxinstances 从1变为定义的节点数目

$ sqlplus /nolog

SQL> connect / as sysdba

SQL> startup mount

SQL> alter database backup controlfile to trace;

10.4创建第二个实例的redo与undo
启动第一个实例

SQL>alter database

add logfile thread 2

group 3 ( /dev/RAC/redo2_01_100.dbf ) size 100M,

group 4 ( /dev/RAC/redo2_02_100.dbf ) size 100M;

alter database enable public thread 2;

SQL>CREATE UNDO TABLESPACE UNDOTBS2 DATAFILE

/dev/RAC/undotbs_02_210.dbf SIZE 200M ;

最后,在第二个节点上安装软件、设置环境变量、启动实例

小结
1、 描述了RAC的运行原理与运行机制

2、 描述了RAC for Linux的必要条件,如内核要求如软件要求

3、 描述各种存储设备的与多种文件系统,如Raw,ocfs等

4、 描述了Cluster管理软件在不同平台上的安装方法

5、 描述了数据库软件在不同平台上的安装方法

6、 描述了手工创建RAC数据库并启动多个数据库的方法

7、 介绍了RAC的一些特征与管理方法


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