Step by Step 创建Oracle RAC One Node

Step by Step 创建Oracle RAC One Node

166

1        RAC ONE NODE介绍

RAC OneNode是oracle 11g RAC的一个新的选件,实现了instance在不同的node上迁移,增强了故障的保护,更好的进行联机维护,同时在需要时不用停机即可升级为多节点的RAC数据库。

 

1.1      更好的服务器整合

在该示例中,五个单实例 Oracle RAC One Node 数据库运行在一个由三台服务器组成的集群中。服务器 A 运行Oracle RAC One Node 数据库 DB1 和 DB2,服务器 B 运行数据库DB3,而服务器C运行数据库 DB4 和 DB5。每台服务器运行一个操作系统。

1.2      增强的故障保护

 

在上面的情形中,服务器 B 发生故障,之前运行在服务器 B 上的数据库实例 DB3 将在服务器 C 上启动。ORACLE RAC One Node 与cluster ware结合在一起,cluster ware确保数据库服务的可用性,当发生故障时ORACLE RAC One Node 检测故障并在另外的节点启动发生故障的数据库。

 

1.3      更大的灵活性和更强的负载管理

 

如图中所示,可以在不中断服务的情况下,把数据库instance从一台服务器迁移到另外一台服务器,特别适合服务器资源紧张或者服务器需要维护的情景。

1.4      更好的联机维护

在联机情况下把数据库服务从一台服务器迁移到另外一台备用服务器,对主服务器进行硬件维护,操作系统升级和数据库补丁等各种维护。

1.5      增强

相对于11.2.0.1,11.2.0.2有以下方面的增强

1.        OUI在安装和DBCA建库时增加了RAC One Node的选项

2.        srvctl命令更方便的对RAC One Node进行全面管理

3.         不用安装9004119补丁

 

2        环境规划

VMplayer规划两台ORACLE Enterprise Linux 5.4用于搭建11gR2 RAC One Node 环境。

  1. 网络规划

Node

OS

IP

PrivateIP

VIP

SCAN IP

11g1

Enterprise linux 5.4

10.10.10.190

192.168.0.190

10.10.10.192

10.10.10.199

11g2

Enterprise linux 5.4

10.10.10.191

192.168.0.191

10.10.10.193

10.10.10.199

  1. 软件版本

Node

Grid  Infrastructure

Oracle  Database

Share  Storage

11g1

11.2.0.2.0

11.2.0.2.0

ASM

11g2

11.2.0.2.0

11.2.0.2.0  

ASM

  1. 用户和用户组

Node

Grid Infrastructure

Oracle Database

Group

Owner

Group

Owner

11g1

asmadmin,asmdba,asmoper,oinstall

grid

dba,asmdba,oinstall

oracle

11g2

asmadmin,asmdba,asmoper,oinstall

grid

dba,asmdba,oinstall

oracle

 

3        操作系统配置

3.1      修改hosts文件

两台主机分别修改/etc/hosts文件

127.0.0.1               localhost.localdomain localhost

10.10.10.190            11g1

192.168.0.190           11g1_priv

10.10.10.192            11g1_vip

10.10.10.191            11g2

192.168.0.191           11g2_priv

10.10.10.193            11g2_vip

10.10.10.199            scan_ip

3.2      创建用户和用户组

[root@11g1~]# groupadd -g 501 oinstall

[root@11g1~]# groupadd -g 502 dba

[root@11g1~]# groupadd -g 504 asmadmin

[root@11g1~]# groupadd -g 506 asmdba

[root@11g1~]# groupadd -g 507 asmoper

 

[root@11g1~]# useradd -u 501 -g oinstall -G asmadmin,asmdba,asmoper grid

[root@11g1~]# useradd -u 502 -g oinstall -G dba,asmdba oracle

 

3.3      设置密码

[root@11g1~]# passwd oracle

Changingpassword for user oracle.

NewUNIX password:

BADPASSWORD: it is based on a dictionary word

Retypenew UNIX password:

passwd:all authentication tokens updated successfully.

 

[root@11g1~]# passwd grid

Changingpassword for user grid.

NewUNIX password:

BADPASSWORD: it is too short

Retypenew UNIX password:

passwd:all authentication tokens updated successfully.

3.4      配置内核参数

修改/etc/sysctl.conf文件添加以下内容

kernel.shmmni= 4096

kernel.sem= 250 32000 100 128

fs.file-max= 6553600

net.ipv4.ip_local_port_range= 9000 65500

net.core.rmem_default= 262144

net.core.rmem_max= 4194304

net.core.wmem_default= 262144

net.core.wmem_max= 1048576

3.5      set shell limits

  1. /etc/security/limits.conf添加以下内容

gridsoft nproc 2047

gridhard nproc 16384

gridsoft nofile 1024

gridhard nofile 65536

oraclesoft nproc 2047

oraclehard nproc 16384

oraclesoft nofile 1024

oraclehard nofile 65536

 

  1. /etc/pam.d/login添加以下内容

sessionrequired pam_limits.so

  1. /etc/profile添加以下内容

if [$USER = "oracle" ] || [ $USER = "grid" ]; then

if [$SHELL = "/bin/ksh" ]; then

ulimit-p 16384

ulimit-n 65536

else

ulimit-u 16384 -n 65536

fi

umask022

fi

  1. /etc/csh.login添加以下内容

if ($USER = "oracle" || $USER = "grid" ) then

limitmaxproc 16384

limitdescriptors 65536

endif

3.6       检查安装包

rpm -q --qf'%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' binutils \

compat-libstdc++-33 \

elfutils-libelf \

elfutils-libelf-devel\

gcc \

gcc-c++ \

glibc \

glibc-common \

glibc-devel \

glibc-headers \

ksh \

libaio \

libaio-devel \

libgcc \

libstdc++ \

libstdc++-devel \

make \

sysstat \

unixODBC \

unixODBC-devel

 

binutils-2.17.50.0.6-12.el5(i386)

compat-libstdc++-33-3.2.3-61(i386)

elfutils-libelf-0.137-3.el5(i386)

elfutils-libelf-devel-0.137-3.el5(i386)

gcc-4.1.2-46.el5(i386)

gcc-c++-4.1.2-46.el5(i386)

glibc-2.5-42(i686)

glibc-common-2.5-42(i386)

glibc-devel-2.5-42(i386)

glibc-headers-2.5-42(i386)

ksh-20080202-14.el5(i386)

libaio-0.3.106-3.2(i386)

libaio-devel-0.3.106-3.2(i386)

libgcc-4.1.2-46.el5(i386)

libstdc++-4.1.2-46.el5(i386)

libstdc++-devel-4.1.2-46.el5(i386)

make-3.81-3.el5(i386)

sysstat-7.0.2-3.el5(i386)

unixODBC-2.2.11-7.1(i386)

unixODBC-devel-2.2.11-7.1(i386)

 

3.7      在另一节点重复以上步骤

重复3.1,3.2,3.3,3.4,3.5,3.6步骤

4        ORACLE环境配置

4.1      创建Oracle Inventory目录

[root@11g1~]# mkdir -p u01/app/oraInventory

[root@11g1~]# chown -R grid:oinstall u01/app/oraInventory

[root@11g1~]# chmod -R 775 u01/app/oraInventory

4.2      创建Grid Home 目录

[root@11g1 ~]# mkdir -p u01/11.2.0/app

[root@11g1 ~]# chown grid:oinstall u01/11.2.0/app

[root@11g1 ~]#

[root@11g1 ~]# chmod -R 755 u01/11.2.0/app

[root@11g1 ~]# mkdir -p u01/11.2.0/grid

[root@11g1 ~]#

[root@11g1 ~]# chown -R grid:oinstall u01/11.2.0/grid

[root@11g1 ~]# chmod -R 775 u01/11.2.0/grid

4.3       创建Oracle Base目录

[root@11g1 ~]# mkdir -p u01/app/oracle

[root@11g1 ~]# mkdir u01/app/oracle/cfgtoollogs

[root@11g1 ~]# chown -R oracle:oinstall/u01/app/oracle

[root@11g1 ~]# chmod -R 775 u01/app/oracle

4.4       创建Oracle RDBMS Home目录

[root@11g1 ~]# mkdir -p/u01/app/oracle/product/11.2.0/db_1

[root@11g1 ~]# chown -R oracle:oinstall/u01/app/oracle/product/11.2.0/db_1

[root@11g1 ~]# chmod -R 775/u01/app/oracle/product/11.2.0/db_1

4.5       配置环境变量

  1. 节点1 grid

ORACLE_SID=+ASM1; export ORACLE_SID

ORACLE_BASE=/u01/11.2.0/app; export ORACLE_BASE

ORACLE_HOME=/u01/11.2.0/grid; export ORACLE_HOME

NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS";export NLS_DATE_FORMAT

ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11

 

PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin

PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin

PATH=${PATH}:/u01/app/common/oracle/bin

export PATH

 

LD_LIBRARY_PATH=$ORACLE_HOME/lib

LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib

LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib

export LD_LIBRARY_PATH

 

 

CLASSPATH=$ORACLE_HOME/JRE

CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib

CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib

CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib

export CLASSPATH

 

THREADS_FLAG=native; export THREADS_FLAG

umask 022

  1. 节点1 oracle

ORACLE_SID=test1; export ORACLE_SID

ORACLE_UNQNAME=test; export ORACLE_UNQNAME

ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE

ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1;export ORACLE_HOME

ORACLE_TERM=xterm; export ORACLE_TERM

NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS";export NLS_DATE_FORMAT

ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11

 

PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin

PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin

PATH=${PATH}:/u01/app/common/oracle/bin

export PATH

 

LD_LIBRARY_PATH=$ORACLE_HOME/lib

LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib

LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib

export LD_LIBRARY_PATH

 

CLASSPATH=$ORACLE_HOME/JRE

CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib

CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib

CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib

export CLASSPATH

 

THREADS_FLAG=native; export THREADS_FLAG

umask 022

 

  1. 节点2 grid

ORACLE_SID=+ASM2; export ORACLE_SID

ORACLE_BASE=/u01/11.2.0/app; export ORACLE_BASE

ORACLE_HOME=/u01/11.2.0/grid; export ORACLE_HOME

NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS";export NLS_DATE_FORMAT

ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11

 

PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin

PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin

PATH=${PATH}:/u01/app/common/oracle/bin

export PATH

 

LD_LIBRARY_PATH=$ORACLE_HOME/lib

LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib

LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib

export LD_LIBRARY_PATH

 

 

CLASSPATH=$ORACLE_HOME/JRE

CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib

CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib

CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib

export CLASSPATH

 

THREADS_FLAG=native; export THREADS_FLAG

umask 022

 

  1. 节点2  oracle

ORACLE_SID=test2; export ORACLE_SID

ORACLE_UNQNAME=test; export ORACLE_UNQNAME

ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE

ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1;export ORACLE_HOME

ORACLE_TERM=xterm; export ORACLE_TERM

NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS";export NLS_DATE_FORMAT

ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11

 

PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin

PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin

PATH=${PATH}:/u01/app/common/oracle/bin

export PATH

 

LD_LIBRARY_PATH=$ORACLE_HOME/lib

LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib

LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib

export LD_LIBRARY_PATH

 

CLASSPATH=$ORACLE_HOME/JRE

CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib

CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib

CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib

export CLASSPATH

 

THREADS_FLAG=native; export THREADS_FLAG

umask 022

 

4.6       在另一节点重复以上步骤

重复4.1,4.2,4.3,4.4,4.5步骤

5        准备共享存储

5.1      共享存储

Block  Device

Diskgroup  Name

Size

Comments

/dev/sdb1

ocr

2GB

for OCR and vote disk

/dev/sdc1

data

10GB

for oracle data disk

5.2      分区

[root@11g1Server]# fdisk dev/sdb

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-261, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-261,default 261):

Using default value 261

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

 

[root@11g1Server]# fdisk dev/sdc

 

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-1305, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-1305,default 1305):

Using default value 1305

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

 

在另外一节点load分区

[root@11g2 ]# partprobe

5.3       raw

[root@11g1~]# raw dev/raw/raw1 dev/sdb1

/dev/raw/raw1: bound to major 8, minor 17

[root@11g1~]# raw dev/raw/raw2 dev/sdc1

/dev/raw/raw2: bound to major 8, minor 18

 

[root@11g1~]# chown grid:asmadmin dev/raw/raw*

 

/etc/sysconfig/rawdevices添加以下内容

/dev/raw/raw1  /dev/sdb1

/dev/raw/raw2   /dev/sdc1

同时在另一节的rawdevices添加以上内容

 

1        安装Grid Infrastructure

[grid@11g1grid]$ ./runInstaller

 

 

 

 

 

 

 

 

设置SSH等效性

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

两个节点分布执行orainstRoot.sh和root.sh

2        安装ORACLE数据库软件

[oracle@11g1database]$ ./runInstaller

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3        创建RAC ONE NODE库

 

 

 

 

service name 不能与db默认的服务名一样。

4        RAC One Node管理

4.1       验证RAC OneNode

[grid@11g2 ~]$ srvctl config database -d test

Databaseunique name: test

Databasename: test

Oraclehome: /u01/app/oracle/product/11.2.0/db_1

Oracleuser: oracle

Spfile:+DATA/test/spfiletest.ora

Domain:

Startoptions: open

Stopoptions: immediate

Databaserole: PRIMARY

Managementpolicy: AUTOMATIC

Serverpools: test

Databaseinstances:

DiskGroups: DATA

Mountpoint paths:

Services:onenode

Type:RACOneNode                                                     <<类型为RACOneNode

Onlinerelocation timeout: 30

Instancename prefix: test

Candidateservers: 11g1

Databaseis administrator managed

 

[grid@11g2 ~]$ srvctl status database -d test

Instance test_1 is running on node 11g1

Online relocation: INACTIVE

4.2       Online migration

 

[grid@11g1 grid]$ srvctl relocate database -d test -n11g2 -v

Added target node 11g2

Configuration updated to two instances                      <<node2 启动instance

Instance test_2 started

Services relocated

Waiting for 30 minutes for instance test_1 tostop.....  <<在原来的节点停止instance30分钟为默认的timeout time,用于给活动session完成活动的事务并迁移到新的节点,如果在指定的timeout 内不能完成事务,则事务将被cancelsession将被remove,可以-w选项来指定这个timeout

Instance test_1 stopped

Configuration updated to one instance

[grid@11g1 grid]$ srvctl status database -d test

Instance test_2 is running on node 11g2

Online relocation: INACTIVE

4.3       Convertto RAC

[grid@11g1 ~]$ srvctl config database -d test

Database unique name: test

Database name: test

Oracle home: /u01/app/oracle/product/11.2.0/db_1

Oracle user: oracle

Spfile: +DATA/test/spfiletest.ora

Domain:

Start options: open

Stop options: immediate

Database role: PRIMARY

Management policy: AUTOMATIC

Server pools: test

Database instances:

Disk Groups: DATA

Mount point paths:

Services: onenode

Type: RACOneNode

Online relocation timeout: 30

Instance name prefix: test

Candidate servers: 11g1

Database is administrator managed

 

[grid@11g1 ~]$ srvctl convert database -d test -c rac-n 11g1

[grid@11g1 ~]$ srvctl config database -d test

Database unique name: test

Database name: test

Oracle home: /u01/app/oracle/product/11.2.0/db_1

Oracle user: oracle

Spfile: +DATA/test/spfiletest.ora

Domain:

Start options: open

Stop options: immediate

Database role: PRIMARY

Management policy: AUTOMATIC

Server pools: test

Database instances: test_1

Disk Groups: DATA

Mount point paths:

Services: onenode

Type: RAC                                                                   <<类型转换为RAC

Database is administrator managed

 

[grid@11g1 ~]$ srvctl add instance -d test -i test_2-n 11g2

[grid@11g1 ~]$ srvctl start instance -d test -i test_2

[grid@11g1 ~]$ srvctl status database -d test

Instance test_1 is running on node 11g1

Instance test_2 is running on node 11g2

5        参考文档

《Oracle 白皮书—Oracle Real Application Clusters One Node》

posted @ 2021-11-23 22:50  耀阳居士  阅读(249)  评论(0编辑  收藏  举报