Focus On Oracle

Installing, Backup & Recovery, Performance Tuning,
Troubleshooting, Upgrading, Patching

Oracle Engineered System


当前位置: 首页 » 技术文章 » Oracle 12c+

12c RAC和RAC One Node之间相互转换

Convert RAC To RACOneNode
我们可以通过srvctl convert database命令把Oracle RAC database转化为RAC One Node database,确保满足以下条件:
A.确保RAC数据库只有一个实例,如果有多个实例,需要删除配置
B.RAC数据库使用了OMF或者至少2个Redo线程
C.如果RAC是Administrator Managed模式,必须把所有服务所指向的实例设置成你转化为RAC One Node之后的那个实例。如果有服务设置为PRECONNECT TAF policy,那么TAF policy必须设置成BASIC或者NONE
D.如果RAC是policy managed模式,必须改变所有服务的配置使其指向同一个server pool

查看当前RAC配置

[oracle@ohs1 ~]$ srvctl config database -d pgold
Database unique name: pgold
Database name:
Oracle home: /pgold/ordb/oracle/product/121
Oracle user: oracle
Spfile: +DATA_PGOLD/PGOLD/PARAMETERFILE/spfile.274.923493501
Password file: +DATA_PGOLD/PGOLD/PASSWORD/pwdpgold.256.923492907
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA_PGOLD
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: oper
Database instances: pgold1,pgold2,pgold3
Configured nodes: ohs1,ohs2,ohs3
Database is administrator managed

关闭多余的实例并移除,只保留一个
[oracle@ohs1 ~]$ srvctl stop instance -d pgold -i pgold2
[oracle@ohs1 ~]$ srvctl stop instance -d pgold -i pgold3
[oracle@ohs1 ~]$
[oracle@ohs1 ~]$ srvctl remove instance -d pgold -i pgold2
Remove instance from the database pgold? (y/[n]) y
[oracle@ohs1 ~]$ srvctl remove instance -d pgold -i pgold3
Remove instance from the database pgold? (y/[n]) y
[oracle@ohs1 ~]$
[oracle@ohs1 ~]$ srvctl config database -d pgold
Database unique name: pgold
Database name:
Oracle home: /pgold/ordb/oracle/product/121
Oracle user: oracle
Spfile: +DATA_PGOLD/PGOLD/PARAMETERFILE/spfile.274.923493501
Password file: +DATA_PGOLD/PGOLD/PASSWORD/pwdpgold.256.923492907
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA_PGOLD
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: oper
Database instances: pgold1
Configured nodes: ohs1
Database is administrator managed
[oracle@ohs1 ~]$
[oracle@ohs1 ~]$ ps -ef|grep pmon
oracle    1459 24173  0 10:03 pts/0    00:00:00 grep pmon
orgrid    4022     1  0 Sep25 ?        00:00:03 asm_pmon_+ASM1
oracle   30043     1  0 08:31 ?        00:00:00 ora_pmon_pgold1
orgrid   30047     1  0 08:31 ?        00:00:00 mdb_pmon_-MGMTDB

srvctl convert帮助信息

[oracle@ohs1 ~]$ srvctl convert database -h
Convert RAC One Node database to RAC database having one instance.
Usage: srvctl convert database -db <db_unique_name> -dbtype RAC [-node <node>]
    -db <db_unique_name>           Unique name of database to convert
    -dbtype <type>                 Type of database to which to convert: RAC
    -node <node>                   Candidate server for administrator-managed RAC database to run on
    -help                          Print usage
Convert RAC database having one instance to RAC One Node database.
Usage: srvctl convert database -db <db_unique_name> -dbtype RACONENODE [-instance <inst_name>] [-timeout <timeout>]
    -db <db_unique_name>           Unique name of database to convert
    -dbtype <type>                 Type of database to which to convert: RACONENODE
    -instance <inst_name>          Instance name prefix; required for administrator-managed RAC One Node database
    -timeout <timeout>             Online relocation timeout in minutes
    -help                          Print usage
[oracle@ohs1 ~]$ 

转化为RACONENODE
[oracle@ohs1 ~]$ srvctl convert database -db pgold -dbtype RACONENODE -instance pgold -timeout 5
PRCD-1242 : Unable to convert RAC database pgold to RAC One Node database because the database had no service added
[oracle@ohs1 ~]$
[oracle@ohs1 ~]$
[oracle@ohs1 ~]$ srvctl add service -d pgold -s ohs -preferred pgold1
[oracle@ohs1 ~]$ srvctl config service -d pgold
Service name: ohs
Server pool:
Cardinality: 1
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Global: false
Commit Outcome: false
Failover type:
Failover method:
TAF failover retries:
TAF failover delay:
Connection Load Balancing Goal: LONG
Runtime Load Balancing Goal: NONE
TAF policy specification: NONE
Edition:
Pluggable database name:
Maximum lag time: ANY
SQL Translation Profile:
Retention: 86400 seconds
Replay Initiation Time: 300 seconds
Session State Consistency:
GSM Flags: 0
Service is enabled
Preferred instances: pgold1
Available instances:
[oracle@ohs1 ~]$ [oracle@ohs1 ~]$  [oracle@ohs1 ~]$ srvctl convert database -db pgold -dbtype RACONENODE -instance pgold -timeout 5 


查看并验证

[oracle@ohs1 ~]$ ps -ef|grep pmon
orgrid    4022     1  0 Sep25 ?        00:00:03 asm_pmon_+ASM1
oracle    4122 24173  0 10:08 pts/0    00:00:00 grep pmon
oracle   30043     1  0 08:31 ?        00:00:00 ora_pmon_pgold1
orgrid   30047     1  0 08:31 ?        00:00:00 mdb_pmon_-MGMTDB
[oracle@ohs1 ~]$ srvctl config database -d pgold
Database unique name: pgold
Database name:
Oracle home: /pgold/ordb/oracle/product/121
Oracle user: oracle
Spfile: +DATA_PGOLD/PGOLD/PARAMETERFILE/spfile.274.923493501
Password file: +DATA_PGOLD/PGOLD/PASSWORD/pwdpgold.256.923492907
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA_PGOLD
Mount point paths:
Services: ohs
Type: RACOneNode
Online relocation timeout: 5
Instance name prefix: pgold
Candidate servers: ohs1
OSDBA group: dba
OSOPER group: oper
Database instances:
Database is administrator managed


转化后实例名发生了变化

[oracle@ohs1 ~]$
[oracle@ohs1 ~]$ srvctl stop database -d pgold
[oracle@ohs1 ~]$ srvctl start database -d pgold
[oracle@ohs1 ~]$
[oracle@ohs1 ~]$
[oracle@ohs1 ~]$ ps -ef|grep pmon
orgrid    4022     1  0 Sep25 ?        00:00:03 asm_pmon_+ASM1
oracle    5670     1  0 10:12 ?        00:00:00 ora_pmon_pgold_1
oracle    6125 24173  0 10:13 pts/0    00:00:00 grep pmon
orgrid   30047     1  0 08:31 ?        00:00:00 mdb_pmon_-MGMTDB
[oracle@ohs1 ~]$ srvctl config database -d pgold
Database unique name: pgold
Database name:
Oracle home: /pgold/ordb/oracle/product/121
Oracle user: oracle
Spfile: +DATA_PGOLD/PGOLD/PARAMETERFILE/spfile.274.923493501
Password file: +DATA_PGOLD/PGOLD/PASSWORD/pwdpgold.256.923492907
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA_PGOLD
Mount point paths:
Services: ohs
Type: RACOneNode
Online relocation timeout: 5
Instance name prefix: pgold
Candidate servers: ohs1
OSDBA group: dba
OSOPER group: oper
Database instances:
Database is administrator managed
[oracle@ohs1 ~]$

通过relocate可以把实例信息飘到指定节点
[oracle@ohs1 ~]$ srvctl relocate database -d pgold -n ohs2
[oracle@ohs1 ~]$ ps -ef|grep pmon
orgrid    4022     1  0 Sep25 ?        00:00:03 asm_pmon_+ASM1
oracle   10433  3561  0 10:23 pts/2    00:00:00 grep pmon
orgrid   30047     1  0 08:31 ?        00:00:00 mdb_pmon_-MGMTDB
[oracle@ohs1 ~]$ ssh ohs2 ps -ef|grep pmon
orgrid   20463     1  0 08:34 ?        00:00:00 asm_pmon_+ASM2
oracle   28119     1  0 10:21 ?        00:00:00 ora_pmon_pgold_2
[oracle@ohs1 ~]$ 


Convert RACOneNode To RAC
同样我们可以通过srvctl convert database命令把Oracle RAC One Node转化为RAC database

查看RAC数据库类型

[oracle@ohs1 ~]$ srvctl config database -d pgold

Database unique name: pgold
Database name:
Oracle home: /pgold/ordb/oracle/product/121
Oracle user: oracle
Spfile: +DATA_PGOLD/PGOLD/PARAMETERFILE/spfile.274.923493501
Password file: +DATA_PGOLD/PGOLD/PASSWORD/pwdpgold.256.923492907
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA_PGOLD
Mount point paths:
Services: ohs
Type: RACOneNode
Online relocation timeout: 5
Instance name prefix: pgold
Candidate servers: ohs1,ohs2
OSDBA group: dba
OSOPER group: oper
Database instances:
Database is administrator managed
[oracle@ohs1 ~]$ 


转化为RAC数据库

[oracle@ohs1 ~]$ srvctl convert database -d pgold -dbtype RAC -node ohs1
[oracle@ohs1 ~]$ ps -ef|grep pmon
orgrid    4022     1  0 Sep25 ?        00:00:03 asm_pmon_+ASM1
oracle   12690     1  0 10:29 ?        00:00:00 ora_pmon_pgold_2
oracle   19052 24173  0 10:46 pts/0    00:00:00 grep pmon
orgrid   30047     1  0 08:31 ?        00:00:00 mdb_pmon_-MGMTDB

[oracle@ohs1 ~]$


查看并验证信息

[oracle@ohs1 ~]$ srvctl config database -d pgold
Database unique name: pgold
Database name:
Oracle home: /pgold/ordb/oracle/product/121
Oracle user: oracle
Spfile: +DATA_PGOLD/PGOLD/PARAMETERFILE/spfile.274.923493501
Password file: +DATA_PGOLD/PGOLD/PASSWORD/pwdpgold.256.923492907
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA_PGOLD
Mount point paths:
Services: ohs
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: oper
Database instances: pgold_2
Configured nodes: ohs1
Database is administrator managed
[oracle@ohs1 ~]$ 


增加其他节点信息

[oracle@ohs1 ~]$ srvctl add instance -d pgold -i pgold2 -n ohs2
[oracle@ohs1 ~]$ srvctl add instance -d pgold -i pgold3 -n ohs3
[oracle@ohs1 ~]$
[oracle@ohs1 ~]$ ps -ef|grep pmon
orgrid    4022     1  0 Sep25 ?        00:00:03 asm_pmon_+ASM1
oracle    9871 24173  0 11:45 pts/0    00:00:00 grep pmon
oracle   19976     1  0 10:47 ?        00:00:00 ora_pmon_pgold_2
orgrid   30047     1  0 08:31 ?        00:00:00 mdb_pmon_-MGMTDB


删除之前节点,并重新添加(这样做,只是为了换个实例名字.从pgold_2到pgold1,是可选步骤)

[oracle@ohs1 ~]$ srvctl stop database -d pgold
[oracle@ohs1 ~]$
[oracle@ohs1 ~]$ srvctl remove instance -d pgold -instance pgold_2
Remove instance from the database pgold? (y/[n]) y
PRKO-3147 : Instance pgold_2 cannot be removed because it is the only preferred instance for service(s) ohs for database pgold
[oracle@ohs1 ~]$
[oracle@ohs1 ~]$ srvctl modify service -d pgold -service ohs -preferred pgold2,pgold3 -modifyconfig
[oracle@ohs1 ~]$ srvctl config service -d pgold
Service name: ohs
Server pool:
Cardinality: 2
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Global: false
Commit Outcome: false
Failover type:
Failover method:
TAF failover retries:
TAF failover delay:
Connection Load Balancing Goal: LONG
Runtime Load Balancing Goal: NONE
TAF policy specification: NONE
Edition:
Pluggable database name:
Maximum lag time: ANY
SQL Translation Profile:
Retention: 86400 seconds
Replay Initiation Time: 300 seconds
Session State Consistency:
GSM Flags: 0
Service is enabled
Preferred instances: pgold2,pgold3
Available instances:
[oracle@ohs1 ~]$
[oracle@ohs1 ~]$ srvctl remove instance -d pgold -instance pgold_2
Remove instance from the database pgold? (y/[n]) y
[oracle@ohs1 ~]$ srvctl add instance -d pgold -instance pgold1 -node ohs1
[oracle@ohs1 ~]$ 


查看变更后的RAC配置信息

[oracle@ohs1 ~]$ srvctl config database -d pgold
Database unique name: pgold
Database name:
Oracle home: /pgold/ordb/oracle/product/121
Oracle user: oracle
Spfile: +DATA_PGOLD/PGOLD/PARAMETERFILE/spfile.274.923493501
Password file: +DATA_PGOLD/PGOLD/PASSWORD/pwdpgold.256.923492907
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA_PGOLD
Mount point paths:
Services: ohs
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: oper
Database instances: pgold1,pgold2,pgold3
Configured nodes: ohs1,ohs2,ohs3
Database is administrator managed


启动数据库并验证

[oracle@ohs1 ~]$ srvctl start database -d pgold
[oracle@ohs1 ~]$
[oracle@ohs1 ~]$ ps -ef|grep pmon
orgrid    4022     1  0 Sep25 ?        00:00:03 asm_pmon_+ASM1
oracle   17789     1  0 12:03 ?        00:00:00 ora_pmon_pgold1
oracle   18583 24173  0 12:05 pts/0    00:00:00 grep pmon
orgrid   30047     1  0 08:31 ?        00:00:00 mdb_pmon_-MGMTDB
[oracle@ohs1 ~]$ ssh ohs2 ps -ef|grep pmon
oracle     539     1  0 12:03 ?        00:00:00 ora_pmon_pgold2
orgrid   20463     1  0 08:34 ?        00:00:00 asm_pmon_+ASM2
[oracle@ohs1 ~]$ ssh ohs3 ps -ef|grep pmon
orgrid    2597     1  0 Sep25 ?        00:00:02 asm_pmon_+ASM3
oracle   25239     1  0 12:03 ?        00:00:00 ora_pmon_pgold3
[oracle@ohs1 ~]$ 



Reference

http://docs.oracle.com/cd/E11882_01/rac.112/e41960/onenode.htm#RACAD7897



关键词:12c rac 

相关文章

Install Oracle Domain Service Cluster Step by Step
Oracle RAC and Third Party Cloud
How to generate AWR on PDB and ADG(12.2 afterwards)
ORA-12514 During DataPump Export/Import In RAC
在12c上使用wm_concat
How to config IB network listener
Oracle MAA汇总
Exadata with database 12.2
如何在oracle 12c中正确的应用补丁?
在OEL6.8上安装12.2 RAC
Oracle Database 12.2 Hands-On Lab
How to Convert Physical Standby to Snapshot Standby
Top