Bo's Oracle Station

查看: 2085|回复: 0

Oracle RAC数据库Admin-managed和Policy-Managed之间双向转化

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2022-4-14 16:51:10 | 显示全部楼层 |阅读模式
1. 从Admin-Managed Oracle RAC数据库转化成Policy-Managed:
把Admin-managed的Oracle数据库转化成Policy-Managed的本质上就是添加Serverpool。而Serverpool可以直接添加进入当前的策略,也可以由创建策略集时通过相应的指令创建。如果是Flex集群,那么这些Serverpool就会通过策略归属于某些Category,由这些Category来决定哪些Serverpool是HUB,哪些Serverpool是LEAF。
下面通过实验来演示如何把一个Admin-Managed Oracle RAC数据库转化成Policy-Managed,首先安装好一套Admin-Managed Oracle RAC数据库:
  1. [grid@racdb01 ~]$ srvctl config database -d racdb
  2. Database unique name: racdb
  3. Database name: racdb
  4. Oracle home: /u01/app/oracle/product/12.2.0/dbhome_1
  5. Oracle user: oracle
  6. Spfile: +DATA/racdb/spfileracdb.ora
  7. Domain:
  8. Start options: open
  9. Stop options: immediate
  10. Database role: PRIMARY
  11. Management policy: AUTOMATIC
  12. Server pools:
  13. Database instances: racdb1,racdb2
  14. Disk Groups: DATA,FRA
  15. Mount point paths:
  16. Services:
  17. Type: RAC
  18. Database is administrator managed
复制代码
添加服务器池 mypool(最小数目 0 ,最大数目 2)
  1. [oracle@racdb01 ~]$ srvctl add serverpool -g mypool -l 0 -u 2
复制代码
将Server Pool加入数据库的定义:
  1. [oracle@racdb01 ~]$ srvctl modify database -d racdb -g mypool
复制代码
检查RAC数据库racdb新的配置:
  1. [grid@racdb01 ~]$ srvctl config database -d racdb
  2. Database unique name: racdb
  3. Database name: racdb
  4. Oracle home: /u01/app/oracle/product/12.2.0/dbhome_1
  5. Oracle user: oracle
  6. Spfile: +DATA/racdb/spfileracdb.ora
  7. Domain:
  8. Start options: open
  9. Stop options: immediate
  10. Database role: PRIMARY
  11. Management policy: AUTOMATIC
  12. Server pools:
  13. Database instances: racdb1,racdb2
  14. Disk Groups: DATA,FRA
  15. Mount point paths:
  16. Services: mypool
  17. Type: RAC
复制代码
发现数据库已经使用Policy Managed选项了。
在数据库层面查看Free Serverpool的配置:
  1. [grid@racdb01 ~]$ srvctl config serverpool -g Free
  2. Server pool name: Free
  3. Importance: 0, Min: 0, Max: -1
  4. Candidate server names:
复制代码
在数据库层面查看Generic Serverpool的配置,(Generic Serverpool不让直接管理):
  1. [grid@racdb01 ~]$ srvctl config serverpool -g Generic
  2. PRKO-3160 : Server pool Generic is internally managed as part of administratormanaged database configuration and therefore cannot be queried directly via
  3. srvpool object.
复制代码
在数据库层面查看mypool Serverpool的配置:
  1. [grid@racdb01 ~]$ srvctl config serverpool -g mypool
  2. Server pool name: mypool
  3. Importance: 0, Min: 0, Max: 2
  4. Candidate server names:
复制代码
注意:min_size属性指定节点的基数。假设min_size为2,数据库实例可以运行在服务器池的两台服务器上。
Serverpool不仅可以在数据库层面上查看,也可以在集群件层面查看(也可以使用crsctl添加服务器池到集群):
  1. [grid@racdb02 ~]$ crsctl add serverpool sp1 -attr "MIN_SIZE=1, MAX_SIZE=1,IMPORTANCE=1" -f
  2. CRS-2673: Attempting to stop 'ora.racdb.db' on 'racdb01'
  3. CRS-2677: Stop of 'ora.racdb.db' on 'racdb01' succeeded
复制代码
  1. [grid@racdb02 ~]$ crsctl status serverpool -p
  2. NAME=Free
  3. IMPORTANCE=0
  4. MIN_SIZE=0
  5. MAX_SIZE=-1
  6. SERVER_NAMES=
  7. PARENT_POOLS= EXCLUSIVE_POOLS=
  8. ACL=owner:grid:rwx,pgrp:oinstall:rwx,other::r-x
  9. NAME=Generic
  10. IMPORTANCE=0
  11. MIN_SIZE=0
  12. MAX_SIZE=-1
  13. SERVER_NAMES=
  14. PARENT_POOLS= EXCLUSIVE_POOLS=
  15. ACL=owner:grid:r-x,pgrp:oinstall:r-x,other::r-x
  16. NAME=ora.mypool
  17. IMPORTANCE=0
  18. MIN_SIZE=0
  19. MAX_SIZE=2
  20. SERVER_NAMES=
  21. PARENT_POOLS= EXCLUSIVE_POOLS=
  22. ACL=owner:oracle:rwx,pgrp:oinstall:rwx,other::r--
  23. NAME=sp1
  24. IMPORTANCE=1
  25. MIN_SIZE=1
  26. MAX_SIZE=1
  27. SERVER_NAMES=
  28. PARENT_POOLS= EXCLUSIVE_POOLS=
  29. ACL=owner:grid:rwx,pgrp:oinstall:rwx,other::r—
复制代码
  1. [grid@racdb02 ~]$ crsctl add serverpool sp2 -attr "MIN_SIZE=1, MAX_SIZE=1, IMPORTANCE=2"
复制代码

2. 从Policy-Managed Oracle RAC数据库转化成Admin-Managed:
你不能直接转换Policy-Managed的RAC数据库为Administrator-Managed的RAC数据库。而是可以使用srvctl remove servicesrvctl remove database命令删除Policy-Managed配置,然后再使用srvctl add database和srvctl add instance命令注册该数据库为一个Admin-Managed的RAC数据库。一旦注册了数据库和实例,最后必需使用srvctl add service命令添加回服务。
1)使用SRVCTL工具删除数据库 :
  1. [oracle@racdb01 ~]$ srvctl remove database -d racdb
  2. PRKO-3141 : Database racdb could not be removed because it was running
复制代码
如果数据库正在运行可以使用-f(force)删除正在运行的数据库,但是不推荐使用该方式。我们采用正常停止数据库并删除的方式(数据库的数据不会被删除,删除的只是集群件中数据库的注册信息):
  1. [oracle@racdb01 ~]$ srvctl remove database -d racdb
  2. PRKO-3141 : Database racdb could not be removed because it was running
复制代码
  1. [oracle@racdb01 ~]$ srvctl stop database -d racdb
  2. [oracle@racdb01 ~]$ srvctl status database -d racdb
  3. Instance racdb_1 is not running on node racdb01
  4. Instance racdb2 is not running on node racdb02
  5. [oracle@racdb01 ~]$ srvctl remove database -d racdb
  6. Remove the database racdb? (y/[n]) y
  7. [oracle@racdb01 ~]$ srvctl status database -d racdb
  8. PRCD-1120 : The resource for database racdb could not be found.
  9. PRCR-1001 : Resource ora.racdb.db does not exist
复制代码
2)添加Admin-Managed数据库:
  1. [oracle@racdb01 ~]$ srvctl add database -d racdb -o /u01/app/oracle/product/12.2.0/dbhome_1 -y automatic
复制代码
  1. [grid@racdb01 ~]$ srvctl config database -d racdb
  2. Database unique name: racdb
  3. Database name: racdb
  4. Oracle home: /u01/app/oracle/product/12.2.0/dbhome_1
  5. Oracle user: oracle
  6. Spfile: +DATA/racdb/spfileracdb.ora
  7. Domain:
  8. Start options: open
  9. Stop options: immediate
  10. Database role: PRIMARY
  11. Management policy: AUTOMATIC
  12. Server pools:
  13. Database instances: racdb1,racdb2
  14. Disk Groups: DATA,FRA
  15. Mount point paths:
  16. Services:
  17. Type: RAC
  18. Database is administrator managed
复制代码
3)添加数据库实例:
  1. [oracle@racdb01 ~]$ srvctl add instance -d racdb -i racdb1 -n racdb01
  2. [oracle@racdb01 ~]$ srvctl add instance -d racdb -i racdb2 -n racdb02
  3. [oracle@racdb01 ~]$ srvctl start database -d racdb
  4. [oracle@racdb01 ~]$ srvctl status database -d racdb
  5. Instance racdb1 is running on node racdb01
  6. Instance racdb2 is running on node racdb02
复制代码
如果有非默认service需使用srvctl add service命令添加回改服务,并且注意Admin-Managed的服务的语法和Policy-Managed的服务的语法是不一样的。

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-11-21 20:04 , Processed in 0.039124 second(s), 25 queries .

快速回复 返回顶部 返回列表