--创建rac one node步骤
安装grid软件,配置grid集群;
安装oracle软件;
dbca创建rac one node。
>试验创建的rac one node数据库信息如下:
global db name: dbkdb
sid: dbkdb
service name: dbk
安装节点: node1、node2
--检查数据库信息
>环境信息检查:
[grid@node1 ~]$ crsctl status res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
.........
ora.dbkdb.db
1 ONLINE ONLINE node2 Open
ora.dbkdb.dbk.svc
1 ONLINE ONLINE node2
ora.dbking.db
1 ONLINE ONLINE node1 Open
2 ONLINE ONLINE node2 Open
.........
ora.orcl.db
1 ONLINE ONLINE node1 Open
ora.orclasm.db
1 ONLINE ONLINE node1 Open
.........
[grid@node1 ~]$
可以看到,目前这个grid集群下包含节点node1和node2,有一套rac数据库dbking,两套单实例数据库orcl(普通存储),orclasm(asm存储),一套rac one node库dbkdb。
>确认dbkdb为rac one node数据库:
[grid@node1 ~]$ srvctl config database -d dbkdb
Database unique name: dbkdb
Database name: dbkdb
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +FLASH/dbkdb/spfiledbkdb.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: dbkdb
Database instances:
Disk Groups: FLASH
Mount point paths:
Services: dbk
Type: RACOneNode --确实为rac one node类型
Online relocation timeout: 30
Instance name prefix: dbkdb
Candidate servers: node2,node1
Database is administrator managed
>rac one node库当前运行情况:
[grid@node1 ~]$ srvctl status database -d dbkdb
Instance dbkdb_1 is running on node node2
Online relocation: INACTIVE
>数据库信息检查如下:
C:UsersAdministrator>sqlplus sys/oracle@192.168.100.23/dbk as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期四 8月 4 09:38:57 2016
Copyright (c) 1982, 2010, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management,
OLAP,
Data Mining and Real Application Testing options
SQL> set line 200;
SQL> set pagesize 999;
SQL> select instance_name,status from gv$instance;
INSTANCE_NAME STATUS
------------------------------------------------ ------------------------------------
dbkdb_1 OPEN
SQL> select name from v$datafile;
NAME
----------------------------------------------------------------------------------------------
+FLASH/dbkdb/datafile/system.261.918983553
+FLASH/dbkdb/datafile/sysaux.262.918983553
+FLASH/dbkdb/datafile/undotbs1.263.918983553
+FLASH/dbkdb/datafile/users.264.918983553
+FLASH/dbkdb/datafile/undotbs2.272.918983747
SQL> select member from v$logfile;
MEMBER
----------------------------------------------------------------------------------------------
+FLASH/dbkdb/onlinelog/group_2.269.918983647
+FLASH/dbkdb/onlinelog/group_2.270.918983649
+FLASH/dbkdb/onlinelog/group_1.267.918983645
+FLASH/dbkdb/onlinelog/group_1.268.918983645
+FLASH/dbkdb/onlinelog/group_3.273.918983845
+FLASH/dbkdb/onlinelog/group_3.274.918983847
+FLASH/dbkdb/onlinelog/group_4.275.918983847
+FLASH/dbkdb/onlinelog/group_4.276.918983849
8 rows selected.
SQL>
--rac one node在线飘移
>语法:srvctl relocate database -d <db_unique_name> {[-n <target node>] [-w <timeout>] | -a [-r]} [-v]
>将dbkdb从node2漂移到node1
检查当前dbkdb运行状态:
[oracle@node1 ~]$ srvctl status database -d dbkdb
Instance dbkdb_1 is running on node node2
Online relocation: INACTIVE
发起漂移命令(oracle用户执行):
###########################如果在grid用户下执行会报“权限不足”的错误#################################################
[grid@node2 ~]$ srvctl relocate database -d dbkdb -n node1 -w 5
PRCD-1222 : Online relocation of database "dbkdb" failed but database was restored to its original state
PRCR-1037 : Failed to update cardinality of the resource ora.dbkdb.db to 2
PRCR-1071 : Failed to register or update resource ora.dbkdb.db
CRS-0245: User doesn't have enough privilege to perform the operation
####################################################################################################################
[oracle@node2 ~]$ srvctl relocate database -d dbkdb -n node1 -w 5
检查中间状态:
[oracle@node2 ~]$ srvctl status database -d dbkdb
Instance dbkdb_1 is running on node node2
Online relocation: ACTIVE
Source instance: dbkdb_1 on node2
Destination instance: dbkdb_2 on node1
漂移完成后检查实例运行状态:以经运行在node1上了
[oracle@node2 ~]$ srvctl status database -d dbkdb
Instance dbkdb_2 is running on node node1
Online relocation: INACTIVE
--rac one node数据库的伸缩能力
>伸:将dbkdb扩展成为rac数据库:转换、add实例、启动实例
当前dbkdb信息:
[oracle@node2 ~]$ srvctl config database -d dbkdb
Database unique name: dbkdb
Database name: dbkdb
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +FLASH/dbkdb/spfiledbkdb.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: dbkdb
Database instances:
Disk Groups: FLASH
Mount point paths:
Services: dbk
Type: RACOneNode
Online relocation timeout: 30
Instance name prefix: dbkdb
Candidate servers: node2,node1
Database is administrator managed
发起转换命令:srvctl convert database
[oracle@node2 ~]$ srvctl convert database -d dbkdb -c rac
再次查看dbkdb信息:
[oracle@node2 ~]$ srvctl config database -d dbkdb
Database unique name: dbkdb
Database name: dbkdb
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +FLASH/dbkdb/spfiledbkdb.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: dbkdb
Database instances: dbkdb_1
Disk Groups: FLASH
Mount point paths:
Services: dbk
Type: RAC
Database is administrator managed
已经成功从rac one node转换为rac数据库,但是目前实例只有一个。
[oracle@node2 ~]$ srvctl status database -d dbkdb
Instance dbkdb_1 is running on node node2
添加实例:
[oracle@node2 ~]$ srvctl add instance -d dbkdb -i dbkdb_2 -n node1
查看dbkdb的配置信息:
[oracle@node2 ~]$ srvctl config database -d dbkdb
Database unique name: dbkdb
Database name: dbkdb
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +FLASH/dbkdb/spfiledbkdb.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: dbkdb
Database instances: dbkdb_2,dbkdb_1
Disk Groups: FLASH
Mount point paths:
Services: dbk
Type: RAC
Database is administrator managed
[oracle@node2 ~]$ srvctl status database -d dbkdb
Instance dbkdb_2 is not running on node node1
Instance dbkdb_1 is running on node node2
实例添加成功,但是实例目前处于关闭状态:
启动新实例:
[oracle@node2 ~]$ srvctl start instance -d dbkdb -i dbkdb_2
[oracle@node2 ~]$ srvctl status database -d dbkdb
Instance dbkdb_2 is running on node node1
Instance dbkdb_1 is running on node node2
可以看到目前,rac one node数据库已经成功转换为rac数据库了。
检查dbkdb这个rac数据库信息:回滚段和日志线程组
SQL> select tablespace_name,status from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
SYSAUX ONLINE
UNDOTBS1 ONLINE
TEMP ONLINE
USERS ONLINE
UNDOTBS2 ONLINE
已选择6行。
SQL> select group#,thread#,status,members from v$log;
GROUP# THREAD# STATUS MEMBERS
---------- ---------- ---------------- ----------
1 1 CURRENT 2
2 1 INACTIVE 2
3 2 CURRENT 2
4 2 UNUSED 2
SQL>
>缩:将dbkdb转换为rac one node数据库:删除实例、转换
注意:
必须要有service;
删除rac数据库多余实例。
查看dbkdb的配置信息:
[grid@node1 ~]$ srvctl config database -d dbkdb
Database unique name: dbkdb
Database name: dbkdb
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +FLASH/dbkdb/spfiledbkdb.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: dbkdb
Database instances: dbkdb_2,dbkdb_1
Disk Groups: FLASH
Mount point paths:
Services: dbk
Type: RAC
Database is administrator managed
[grid@node1 ~]$ srvctl status database -d dbkdb
Instance dbkdb_2 is running on node node1
Instance dbkdb_1 is running on node node2
可以看到,这是一个包含2个实例的rac数据库。
dbca删除实例:图形化界面删除-略。silent模式如下:
dbca -silent -deleteinstance -gdbname dbkdb -instancename dbkdb_2 -sysdbausername sys -sysdbapassword oracle
删除实例后,检查配置信息:
[grid@node1 ~]$ srvctl config database -d dbkdb
Database unique name: dbkdb
Database name: dbkdb
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +FLASH/dbkdb/spfiledbkdb.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: dbkdb
Database instances: dbkdb_1
Disk Groups: FLASH
Mount point paths:
Services: dbk
Type: RAC
Database is administrator managed
[grid@node1 ~]$ srvctl status database -d dbkdb
Instance dbkdb_1 is running on node node2
检查数据库信息:
SQL> select group#,thread#,status,members from v$log;
GROUP# THREAD# STATUS MEMBERS
---------- ---------- ---------------- ----------
1 1 CURRENT 2
2 1 INACTIVE 2
SQL> select tablespace_name,status from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
SYSAUX ONLINE
UNDOTBS1 ONLINE
TEMP ONLINE
USERS ONLINE
UNDOTBS2 ONLINE
已选择6行。
dbkdb_2实例相应的日志线程也同时被删除了,但是其对应的undo表空间还是处于online状态的。
现在dbkdb只剩下一个isntance,可以进行rac数据库向rac one node的转换了:执行转换之前必须保证数据库有service以及仅剩下一个instance
[oracle@node2 ~]$ srvctl convert database -d dbkdb -c raconenode -i dbkdb_1 -w 5
检查dbkdb状态:
[grid@node1 ~]$ srvctl config database -d dbkdb
Database unique name: dbkdb
Database name: dbkdb
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +FLASH/dbkdb/spfiledbkdb.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: dbkdb
Database instances:
Disk Groups: FLASH
Mount point paths:
Services: dbk
Type: RACOneNode
Online relocation timeout: 2
Instance name prefix: dbkdb
Candidate servers: node2
Database is administrator managed