******************************************************************
以下是测试项目,来测试发现,RAC是否装好了。
******************************************************************
在运行srvctl的时候,遇到:(rac1,rac2都需要改)
/home/oracle/app/oracle/product/10.2.0/db_1/jdk/jre/bin/java: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
的错误,可以按照如下方式解决:
$ cd /home/oracle/app/oracle/product/10.2.0/db_1/bin/
$ cp srvctl srvctl.bak
$ gedit srvctl
LD_ASSUME_KERNEL=2.4.19
export LD_ASSUME_KERNEL
同样在其后新增加一行:
unset LD_ASSUME_KERNEL
测试数据库状态:(在rac1,rac2上分别测试)
$ cd /home/oracle/app/oracle/product/10.2.0/db_1/bin/
测试数据库配置
$ srvctl config database -d RAC
rac1 RAC1 /home/oracle/app/oracle/product/10.2.0/db_1
rac2 RAC2 /home/oracle/app/oracle/product/10.2.0/db_1
$
测试数据库当前状态:(在rac1,rac2上分别测试)
$ unset LANG //这个是在用telnet登录时,中文会出现乱码的情况下的设置,改成了英语(缺省设置)
$ srvctl status database -d RAC
Instance RAC1 is running on node rac1
Instance RAC2 is running on node rac2
$ srvctl status database -d rac
Instance RAC1 is running on node rac1
Instance RAC2 is running on node rac2
开来不区分大小写,rac RAC ,但在ORACLE_SID中就要写RAC1, RAC2 ,RAC,不能写rac1,rac2,rac,sqlplus里面要区别大小写。
测试集群CRS当前状态:(在rac1,rac2上分别测试)
[oracle@rac1 ~]$ crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy
[oracle@rac2 ~]$ crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy
测试集群当前状态:(在rac1,rac2上分别测试)
$ cd /home/oracle/app/crs/bin
$ ./crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....C1.inst application ONLINE ONLINE rac1
ora....C2.inst application ONLINE ONLINE rac2
ora.RAC.db application ONLINE ONLINE rac2
ora....SM1.asm application ONLINE ONLINE rac1
ora....C1.lsnr application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora....SM2.asm application ONLINE ONLINE rac2
ora....C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
$
测试集群应用程序启动状态:(在rac1,rac2上分别测试)
$ unset LANG
$ srvctl status nodeapps -n rac1
VIP is running on node: rac1
GSD is running on node: rac1
Listener is running on node: rac1
ONS daemon is running on node: rac1
$srvctl status nodeapps -n rac2
VIP is running on node: rac2
GSD is running on node: rac2
Listener is running on node: rac2
ONS daemon is running on node: rac2
测试集群ASM状态:(在rac1,rac2上分别测试)
$ srvctl status asm -n rac1
ASM instance +ASM1 is running on node rac1.
srvctl status asm -n rac2
ASM instance +ASM2 is running on node rac2.
测试命令: tnsping rac1 ,tnsping rac2 ,tnsping RAC1 ,tnsping RAC2(在rac1,rac2上分别测试)
具体结果如下:
tnsping [oracle@rac2 ~]$ tnsping rac1
TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 16-SEP-2008 23:33:42
Copyright (c) 1997, 2005, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = RAC.WORLD) (INSTANCE_NAME = RAC1)))
OK (80 msec)
[oracle@rac2 ~]$ tnsping rac2
TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 16-SEP-2008 23:33:51
Copyright (c) 1997, 2005, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = RAC.WORLD) (INSTANCE_NAME = RAC2)))
OK (20 msec)
windows客户端连接RAC的配置方法:
Tnsname.ora中的(D:\oracle\product\10.2.0\client_1\NETWORK\ADMIN)
RAC =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.100)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.101)(PORT = 1521))
(LOAD_BALANCE = yes)
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = RAC)
)
)
在C:\windows\system32\drivers\etc中的hosts中加入
192.168.1.200 rac1-vip
192.168.1.201 rac2-vip
测试检查 RAC 实例连接:(在rac1,rac2上分别测试)
验证您能够连接到每个节点上的实例和服务。(注意:这里的password,需要你输入你创建数据库的时候,赋予sys,system,那个初始密码)
sqlplus system/password@rac1
sqlplus system/password@rac2
sqlplus system/password@rac
登录上后,都执行一下: SQL>select * from gv$instance; 有结果返回就正常了。
再执行
SQL>select instance_name,host_name,archiver,thread#,status from gv$instance;
INSTANCE_NAME HOST_NAME ARCHIVER THREAD# STATUS
RAC2 rac2.localdomain STOPPED 2 OPEN
RAC1 rac1.localdomain STOPPED 1 OPEN
测试检查数据库配置:(在rac1,rac2上分别测试)
[oracle@rac1 ~]$ export ORACLE_SID=RAC1 // ORACLE_SID=RAC2 ,但不能是 ORACLE_SID=RAC,没有这个资源
[oracle@rac1 ~]$ sqlplus / as sysdba;
SQL> show sga
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 113247824 bytes
Database Buffers 167772160 bytes
Redo Buffers 2973696 bytes
SQL> select file_name,bytes/1024/1024 from dba_data_files;
FILE_NAME BYTES/1024/1024
+ORCLVOL/rac/datafile/system.262.665602059 400
+ORCLVOL/rac/datafile/undotbs1.263.665602155 200
+ORCLVOL/rac/datafile/sysaux.264.665602193 120
+ORCLVOL/rac/datafile/undotbs2.266.665602251 200
+ORCLVOL/rac/datafile/users.267.665602287 5
+ORCLVOL/rac/datafile/wisettms.273.665626799 100
//wisettms是我刚建的,是我通过http://192.168.1.100:1158/em方式进入创建的。
SQL> select group#, type, member,is_recovery_dest_file from v$logfile order by group#;
GROUP# TYPE MEMBER IS_REC
1 ONLINE +ORCLVOL/rac/onlinelog/group_1.258.665601953 NO
1 ONLINE +ORCLVOL/rac/onlinelog/group_1.259.665601963 YES
2 ONLINE +ORCLVOL/rac/onlinelog/group_2.260.665601973 NO
2 ONLINE +ORCLVOL/rac/onlinelog/group_2.261.665601981 YES
3 ONLINE +ORCLVOL/rac/onlinelog/group_3.268.665608153 NO
3 ONLINE +ORCLVOL/rac/onlinelog/group_3.269.665608175 YES
4 ONLINE +ORCLVOL/rac/onlinelog/group_4.270.665608195 NO
4 ONLINE +ORCLVOL/rac/onlinelog/group_4.271.665608215 YES
SQL> quit
[oracle@rac1 ~]$ export ORACLE_SID=+ASM1 // ORACLE_SID=+ASM2 ,但不能是 ORACLE_SID=+ASM,没有这个资源
[oracle@rac1 ~]$ sqlplus / as sysdba;
SQL> show sga
Total System Global Area 92274688 bytes
Fixed Size 1217884 bytes
Variable Size 65890980 bytes
ASM Cache 25165824 bytes
SQL> show parameter asm_disk
NAME TYPE VALUE
asm_diskgroups string ORCLVOL
SQL> select group_number, name, allocation_unit_size alloc_unit_size, state, type, total_mb,usable_file_mb,FREE_MB from v$asm_diskgroup;
GROUP_NUMBER NAME ALLOC_UNIT_SIZE STATE TYPE TOTAL_MB USABLE_FILE_MB FREE_MB
1 ORCLVOL 1048576 MOUNTED NORMAL 8188 1350 4747
SQL> select name,path,header_status,total_mb free_mb,trunc(bytes_read/1024/1024) read_mb,trunc(bytes_written/1024/1024) write_mb from v$asm_disk;
测试命令: sqlplus / as sysdba ,分别登录到rac1,rac2上执行select instance_name,host_name from v$instance;
具体结果如下:
[oracle@rac2 ~]$ sqlplus / as sysdba;
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Sep 16 23:53:32 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> conn sys/password@rac1 as sysdba
Connected.
SQL> select instance_name,host_name from v$instance;
INSTANCE_NAME HOST_NAME
-----------------------------------------------------------------------------------------------------------
RAC1 rac1.localdomain
SQL>quit
测试单个服务:(注意:这里的password,需要你输入你创建数据库的时候,赋予sys,system,那个初始密码)
[oracle@rac1 admin]$ sqlplus / as sysdba
SQL> conn sys/password@rac1 as sysdba
Connected.
SQL> SELECT instance_name, host_name FROM v$instance;
INSTANCE_NAME HOST_NAME
RAC1 rac1.localdomain
SQL> conn sys/password@rac2 as sysdba;
Connected.
SQL> select instance_name,host_name from v$instance;
INSTANCE_NAME HOST_NAME
RAC2 rac2.localdomain
SQL> quit
测试集群实例服务:(注意:这里的password,需要你输入你创建数据库的时候,赋予sys,system,那个初始密码)
[oracle@rac1 admin]$ sqlplus / as sysdba
SQL> conn sys/password@rac1 as sysdba
Connected.
SQL> SELECT * FROM v$active_instances;
INST_NUMBER-----------INST_NAME
1 rac1.localdomain:RAC1
2 rac2.localdomain:RAC2
SQL> SELECT inst_id, username, sid, serial# FROM gv$session WHERE username IS NOT NULL;
遇到:
SQL> conn sys/password@rac2 as sysdba;
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor
Warning: You are no longer connected to ORACLE.
解决方法如下: 没有找到,最好重新装rac系统。
测试命令: 察看listner 基本信息,listener.ora, tnsnames.ora
在rac1上:
[oracle@rac2 ~]$ cd app/oracle/product/10.2.0/db_1/network/admin/
[oracle@rac1 admin]$ cat listener.ora
# listener.ora.rac1 Network Configuration File: /home/oracle/app/oracle/product/10.2.0/db_1/network/admin/listener.ora.rac1
# Generated by Oracle configuration tools.
LISTENER_RAC1 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip.localdomain)(PORT = 1521)(IP = FIRST))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.100)(PORT = 1521)(IP = FIRST))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
)
)
在rac2上:
[oracle@rac2 ~]$ cd app/oracle/product/10.2.0/db_1/network/admin/
[oracle@rac2 bin]$ more /home/oracle/app/oracle/product/10.2.0/db_1/network/adm
in/listener.ora
# listener.ora.rac2 Network Configuration File: /home/oracle/app/oracle/product/
10.2.0/db_1/network/admin/listener.ora.rac2
# Generated by Oracle configuration tools.
LISTENER_RAC2 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521)(IP = FIRST))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.101)(PORT = 1521)(IP = FIRS
T))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
)
)
测试命令: 察看tnsnames.ora 基本信息, rac1 和rac2是一样的,这里只显示rac1上的内容
[oracle@rac1 ~]$ cd app/oracle/product/10.2.0/db_1/network/admin/
[oracle@rac1 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /home/oracle/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
RAC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip.localdomain)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip.localdomain)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = RAC.WORLD)
)
)
LISTENERS_RAC =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip.localdomain)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip.localdomain)(PORT = 1521))
)
RAC2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = RAC.WORLD)
(INSTANCE_NAME = RAC2)
)
)
RAC1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = RAC.WORLD)
(INSTANCE_NAME = RAC1)
)
)
测试Listener状态:(rac1,rac2都需要运行)
在rac1上:
[oracle@rac1 ~]$ lsnrctl status
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 17-SEP-2008 00:29:55
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER_RAC1
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 16-SEP-2008 17:01:55
Uptime 0 days 7 hr. 28 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /home/oracle/app/oracle/product/10.2.0/db_1/network/log/listener_rac1.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.200)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.100)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status BLOCKED, has 1 handler(s) for this service...
Service "+ASM_XPT" has 1 instance(s).
Instance "+ASM1", status BLOCKED, has 1 handler(s) for this service...
Service "RAC.WORLD" has 2 instance(s).
Instance "RAC1", status READY, has 2 handler(s) for this service...
Instance "RAC2", status READY, has 1 handler(s) for this service...
Service "RAC_XPT.WORLD" has 2 instance(s).
Instance "RAC1", status READY, has 2 handler(s) for this service...
Instance "RAC2", status READY, has 1 handler(s) for this service...
The command completed successfully
在rac2上:
[oracle@rac2 ~]$ lsnrctl status
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 17-SEP-2008 00:32:39
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER_RAC2
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 16-SEP-2008 17:02:05
Uptime 0 days 7 hr. 30 min. 34 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /home/oracle/app/oracle/product/10.2.0/db_1/network/log/listener_rac2.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.201)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.101)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM2", status BLOCKED, has 1 handler(s) for this service...
Service "+ASM_XPT" has 1 instance(s).
Instance "+ASM2", status BLOCKED, has 1 handler(s) for this service...
Service "RAC.WORLD" has 2 instance(s).
Instance "RAC1", status READY, has 1 handler(s) for this service...
Instance "RAC2", status READY, has 2 handler(s) for this service...
Service "RAC_XPT.WORLD" has 2 instance(s).
Instance "RAC1", status READY, has 1 handler(s) for this service...
Instance "RAC2", status READY, has 2 handler(s) for this service...
The command completed successfully
[oracle@rac2 ~]$
启动数据库步骤:
1、首先 能使用$crs_stat -t 命令查看系统状态,如果不能,请执行以下方法:
在两台计算机上都要运行
a、# cd /etc/init.d
# ./init.crs stop
# ./init.crs disable
b、两台计算机都需要重新启动
# reboot
c、两台计算机都需要执行
# cd /etc/init.d
# ./init.crs enable
# ./init.crs start
等待90秒钟,再用crs_stat -t 在两台计算机上测试一下:
只要不是 ,不管有多少的unknown 都行.
2、其次,使用srvctl操作数据库,不用crs_stop -f ,crs_start -f 来启动服务,因为crs_stop -f,crs_start -f启动服务,你不知道资源启动的先后顺序,牛人可以用这些命令.
a、$ ./srvctl start nodeapps -n rac1 //在rac1上执行
$ ./srvctl start nodeapps -n rac2 //在rac2上执行
$ ./srvctl start instance -d rac -i rac1 //在rac1上执行
$ ./srvctl start instance -d rac -i rac2 //在rac2上执行
$ ./crs_stat -t
如果是这样:
表示启动成功,否则,最好是哪个不能启动好,重新启动哪个的操作系统,按照1 、2 步骤来.
以下这个文档有参考价值:
CRS及相关服务的常用命令的演示
1、查看状态的命令
# su–oracle --先切换到oracle用户
$ crs_stat -t --查看crs及所有的service的状态
$ crsctl check crs --用crsctl命令,检查crs相关服务的状态
$ srvctl status nodeapps -n rac1 (rac2) --使用srvctl查看所有节点上的服务是否正常
$ srvctl status database -d rac --使用srvctl查看数据库状态
启动和关闭相关服务的命令
# su – oracle
$ crs_start–all --启动所有的crs服务
$ crs_stop–all --停止所有的crs服务
$ crsctl start crs --启动crs服务
$ crsctl stop crs --停止crs服务
$ srvctl start nodeapps -n rac1(rac2) --启动某节点上所有的应用
$ srvctl stop nodeapps -n rac1(rac2) --停止某节点上所有的应用
$ srvctl start listener -n rac1(rac2) --启动某个节点的listener
$ srvctl stop listener -n rac1(rac2) --停止某个节点的listener
$ srvctl start instance–d rac–i rac1(rac2) --启动某个instance
$ srvctl stop instance–d rac–i rac1(rac2) --停止某个instance
$ srvctl start database–d rac --启动数据库
$ srvctl stop database–d rac --停止数据库
nodeapps : 涉及 gsd , ons , lsnr 这三个服务
停止Oracle10g RAC的方法:
$ lsnrctl stop (每个节点上停止监听,也可以用srvctl来操作)
$ emctl stop dbconsole (每个节点停止dbconsole)
$ srvctl stop database -d rac (停止数据库所有实例)
$ srvctl stop nodeapps -n rac1 (停节点1服务)
$ srvctl stop nodeapps -n rac2 (停节点2服务)
# /etc/init.d/init.crs stop (root 停cluster 软件)
或者用 $ crs_stop -all
然后# init 0 关闭服务器,或者如果重新启动#init 6
启动Oracle10g RAC的方法:
(如果OS重新启动,那么下面的所有服务是自动打开的【除了dbconsole】,不用手工执行了)。
$ lsnrctl start (每个节点上启动监听,也可以用srvctl来操作)
$ emctl start dbconsole (每个节点启动dbconsole)
$ srvctl start database -d rac (启动数据库所有实例)
$ srvctl start nodeapps -n rac1 (启动节点1服务)
$ srvctl start nodeapps -n rac2 (启动节点2服务)
# /etc/init.d/init.crs start (root 启动cluster 软件)
或者用 $ crs_start -all
ora....C2.lsnr : ora.rac2.LISTENER_RAC2.lsnr
ora....C1.lsnr : ora.rac1.LISTENER_RAC1.lsnr
ora....SM2.asm : ora.rac2.ASM2.asm
ora....SM1.asm : ora.rac1.ASM1.asm
ora....C1.inst : ora.RAC.RAC1.inst
ora....C2.inst : ora.RAC.RAC2.inst
$ srvctl start nodeapps -n rac1 (启动节点1服务)
我估计等价于
$ crs_start ora.rac1.LISTENER_RAC1.lsnr
$ crs_start ora.rac1.gsd
$ crs_start ora.rac1.ons
$ crs_start ora.rac1.vip
如果执行srvctl,报告有资源错误,首先是在rac1,rac2上都执行
# cd /etc/init.d
# ./init.crs stop
都停下后,执行
# ./init.crs start
等待90秒后,
$ ./crs_stat -t
如果还有没有ONLINE的资源,就使用
$ ./crs_stop -f ...
$ ./crs_start -f ...