12
SERVER POOLS AND POLICY MANAGED DATABASES Author: RAC Attack Community Creation Date: March 23, 2014 Last Updated: March 23, 2014 Version: 1.0

RACAttack 12c Advanced Lab: Server Pools and Policy-managed databases

Embed Size (px)

DESCRIPTION

RACAttack 12c pre-conference workshop at IOUG Collaborate 14 will have a few advanced labs for people already confident with a simple RAC installation. This advanced lab handbook introduces server pools and policy managed databases to your Oracle RAC 12c implementation!

Citation preview

Page 1: RACAttack 12c Advanced Lab: Server Pools and Policy-managed databases

SERVER POOLS AND POLICY MANAGED DATABASES

Author: RAC Attack Community

Creation Date: March 23, 2014

Last Updated: March 23, 2014

Version: 1.0

Page 2: RACAttack 12c Advanced Lab: Server Pools and Policy-managed databases

Server Pools and Policy Managed Databases

Author: RAC Attack Community

Last Updated: March 21, 2014

Page#: 2

1 PREFACE

RAC Attack is an Oracle RAC SIG community effort to invite all Oracle Users to install and configure a 2-

Node RAC environment on their own hardware (laptops) with experienced RAC Attack Ninja’s support.

The effort has gained much support within the last year of its inception and is held at most major

conferences. For more information, visit http://racattack.org/12c.

2 PURPOSE

The purpose of this particular is to illustrate a conversion from Admin-Managed RAC Databases to Policy

Managed databases, a feature introduced with Oracle 11gR2 but still quite uncommon.

Policy Managed Databases require less configuration effort and achieve superior High Availability for the

most critical databases. The database instances are no more directly assigned to cluster nodes. The

database are assigned instead to server pools and there is no more a one-to-one relation between

instances and servers.

2.1 SERVER POOLS

Server pools are the foundation of policy managed databases. They are used to partition a cluster into

smaller groups of servers. Because databases are assigned to server pools, their size directly affects the

resources available to the databases.

The size of server pools is driven by three main attributes:

• MIN_SIZE: The minimum number of servers that compose the server pool

• MAX_SIZE: The maximum number of servers

• IMPORTANCE: The priority level (from 0 to 1000, higher numbers means higher priority)

These factors are used by the cluster to assign server pools when the cluster starts.

Page 3: RACAttack 12c Advanced Lab: Server Pools and Policy-managed databases

Server Pools and Policy Managed Databases

Author: RAC Attack Community

Last Updated: March 21, 2014

Page#: 3

2.2 POLICY MANAGED DATABASES

With admin-managed databases, you must set manually which instances run on which servers. This is

somehow an additional effort on one side, but on the other it allows DBAs to choose how many instances

can run for each database:

Policy-managed databases however span the entire server pool, so the number of instances is always

equal to the number of servers composing the server pool, and it is the same for each database in the

server pool.

Page 4: RACAttack 12c Advanced Lab: Server Pools and Policy-managed databases

Server Pools and Policy Managed Databases

Author: RAC Attack Community

Last Updated: March 21, 2014

Page#: 4

3 ASSUMPTIONS

This lab assumes that the user has an existing 2-node RAC environment configured as per the base RAC

Attack 12c manual instructions listed here.

4 CONVERT TO POLICY MANAGED DATABASES

4.1 GET CURRENT SERVER POOLS

[oracle@collabn1 bin]$ . oraenv

ORACLE_SID = [oracle] ? RAC

[oracle@collabn1 ~]$ srvctl status srvpool -detail

Server pool name: Free Active servers count: 0

Active server names:

Server pool name: Generic

Active servers count: 2

Active server names: collabn1,collabn2 NAME=collabn1 STATE=ONLINE

NAME=collabn2 STATE=ONLINE

Page 5: RACAttack 12c Advanced Lab: Server Pools and Policy-managed databases

Server Pools and Policy Managed Databases

Author: RAC Attack Community

Last Updated: March 21, 2014

Page#: 5

When a cluster is configured with admin managed databases, only two server pools exist: Generic and

Free. The first contains the database instances, the second contain servers that don’t have database

configured.

4.2 GET DATABASE MANAGEMENT MODE

[oracle@collabn1 ~]$ srvctl config database -db RAC

Database unique name: RAC Database name: RAC

Oracle home: /u01/app/oracle/product/12.1.0/dbhome_1

Oracle user: oracle

Spfile: +DATA/RAC/spfileRAC.ora

Password file: +DATA/RAC/orapwrac Domain: racattack

Start options: open

Stop options: immediate

Database role: PRIMARY

Management policy: AUTOMATIC Server pools: RAC

Database instances: RAC1,RAC2

Disk Groups: FRA,DATA

Mount point paths:

Services: svctest

Type: RAC

Start concurrency:

Stop concurrency:

Database is administrator managed

The last line states that the database is admin-managed.

4.3 CREATE A NEW SERVER POOL

[oracle@collabn1 ~]$ srvctl status serverpool

Server pool name: Free Active servers count: 0

Server pool name: Generic

Active servers count: 2

[oracle@collabn1 ~]$ srvctl add srvpool -serverpool RACATTACK -min 1 -max 2 -importance 10

[oracle@collabn1 ~]$ srvctl status serverpool

Server pool name: Free

Active servers count: 0

Server pool name: Generic

Active servers count: 2

Server pool name: RACATTACK

Active servers count: 0

[oracle@collabn1 ~]$

The RACATTACK server pool is created, however it is empty because there are no servers available in the

“Free” server pool or other server pools with lower priority.

Page 6: RACAttack 12c Advanced Lab: Server Pools and Policy-managed databases

Server Pools and Policy Managed Databases

Author: RAC Attack Community

Last Updated: March 21, 2014

Page#: 6

4.4 FREE-UP A NODE FOR THE NEW SERVER POOL

In order to get a server for the new created server pool, we should either add a node to the cluster or

remove a server from the generic server pool. We’ll choose the second one as it is the easiest example for

the lab.

To get a server from the Generic server pool we need to remove all the instances assigned to a chosen

node (we’ll free up the collabn1 node first).

Stop the instance, remove any exclusive service assigned to it, if existing, and remove the instance from

the clusterware configuration:

[oracle@collabn1 ~]$ srvctl stop instance -db RAC -instance RAC1

[oracle@collabn1 ~]$ srvctl remove service -service svctest -db RAC

[oracle@collabn1 ~]$ srvctl remove instance -db RAC -instance RAC1

Remove instance from the database RAC? (y/[n]) y

[oracle@collabn1 ~]$ srvctl status serverpool

Server pool name: Free

Active servers count: 0

Server pool name: Generic

Active servers count: 1 Server pool name: RACATTACK

Active servers count: 1

[oracle@collabn1 ~]$

As you can see, the freed node is immediately assigned to RACATTACK server pool because it is already

configured.

4.5 CONVERTING THE DATABASE TO POLICY-MANAGED

Converting a DB to policy managed is as simple as modifying it by specifying the new server pool through

srvctl, however this will shut down completely the database the time necessary for the reconfiguration

(seconds to minutes). The “-force” switch is necessary to confirm the shutdown of the database.

[oracle@collabn1 ~]$ srvctl status database -db RAC Instance RAC2 is running on node collabn2

[oracle@collabn1 ~]$ srvctl modify database -db RAC -serverpool RACATTACK -force

[oracle@collabn1 ~]$

The database now is running on two instances, two nodes.

[oracle@collabn1 ~]$ srvctl status database -db RAC

Instance RAC_1 is running on node collabn2

Instance RAC_2 is running on node collabn1

Why?

Page 7: RACAttack 12c Advanced Lab: Server Pools and Policy-managed databases

Server Pools and Policy Managed Databases

Author: RAC Attack Community

Last Updated: March 21, 2014

Page#: 7

Once the admin-managed database instances have been removed from the cluster, the Generic server

pool is automatically emptied because RAC is the only database in the cluster. The servers are then

assigned both to the RACATTACK server pool.

[oracle@collabn1 ~]$ srvctl status serverpool Server pool name: Free

Active servers count: 0

Server pool name: Generic

Active servers count: 0

Server pool name: RACATTACK

Active servers count: 2

Notice that the instance names contain an underscore (RAC_1 and RAC_2), this is the naming convention

used by the clusterware for policy managed databases. The cluster automatically adds UNDO tablespaces

and REDO threads to new the database in order to satisfy new instances in the server pool. This is has not

been done in our example however, because the database was already composed by two instances.

The instances, RAC_1 and RAC_2, may not be assigned respectively to collabn1 and collabn2. The server

assignment is dynamic and the first instance is usually configured on the first available node so don’t rely

on this.

Verify that the instance is now policy managed:

[oracle@collabn1 ~]$ srvctl config database -d RAC Database unique name: RAC

Database name: RAC

Oracle home: /u01/app/oracle/product/12.1.0/dbhome_1

Oracle user: oracle

Spfile: +DATA/RAC/spfileRAC.ora

Password file: +DATA/RAC/orapwrac

Domain: racattack

Start options: open

Stop options: immediate

Database role: PRIMARY

Management policy: AUTOMATIC Server pools: RACATTACK

Database instances:

Disk Groups: FRA,DATA

Mount point paths:

Services: Type: RAC

Start concurrency: Stop concurrency:

Database is policy managed

5 PLAYING WITH THE SERVER POOLS

The server pool now has min pool size 1, max pool size 2.

Page 8: RACAttack 12c Advanced Lab: Server Pools and Policy-managed databases

Server Pools and Policy Managed Databases

Author: RAC Attack Community

Last Updated: March 21, 2014

Page#: 8

[oracle@collabn1 ~]$ srvctl config srvpool -serverpool RACATTACK Server pool name: RACATTACK

Importance: 10, Min: 1, Max: 2

Category: hub

Candidate server names:

Because it’s the only server pool, it can get its maximum number of servers.

Check the status of the database using crsctl:

[oracle@collabn1 ~]$ /u01/app/12.1.0/grid/bin/crsctl stat res -t -w "TYPE = ora.database.type"

--------------------------------------------------------------------------------

Name Target State Server State details

--------------------------------------------------------------------------------

Cluster Resources --------------------------------------------------------------------------------

ora.rac.db

1 ONLINE ONLINE collabn2 Open,STABLE

2 ONLINE ONLINE collabn1 Open,STABLE

--------------------------------------------------------------------------------

Now try to shrink the server pool:

[oracle@collabn1 ~]$ srvctl modify srvpool -serverpool RACATTACK -min 1 -max 1 -force

[oracle@collabn1 ~]$ /u01/app/12.1.0/grid/bin/crsctl stat res -t -w "TYPE = ora.database.type" --------------------------------------------------------------------------------

Name Target State Server State details

-------------------------------------------------------------------------------- Cluster Resources

-------------------------------------------------------------------------------- ora.rac.db

1 ONLINE ONLINE collabn2 Open,STABLE

2 ONLINE OFFLINE Instance Shutdown,ST

ABLE

--------------------------------------------------------------------------------

Have you notice the behavior? Even if we have shrunk the server pool, the second instance is already

configured and showing up as an offline instance.

This is a misleading behavior for the users, but according to Oracle, it is the expected behavior.

Now try to add another server pool.

[oracle@collabn1 ~]$ srvctl add srvpool -serverpool ANOTHERPOOL -min 1 -max 1 -importance 1

[oracle@collabn1 ~]$ srvctl status serverpool Server pool name: Free

Active servers count: 0

Server pool name: Generic

Active servers count: 0

Server pool name: ANOTHERPOOL

Active servers count: 1

Server pool name: RACATTACK

Page 9: RACAttack 12c Advanced Lab: Server Pools and Policy-managed databases

Server Pools and Policy Managed Databases

Author: RAC Attack Community

Last Updated: March 21, 2014

Page#: 9

Active servers count: 1

The server pool is added and one server is assigned to ANOTHERPOOL.

Now try to specify a minimum size of 2:

[oracle@collabn1 ~]$ srvctl modify srvpool -serverpool ANOTHERPOOL -min 2 -max 2 -importance 2 [oracle@collabn1 ~]$ srvctl status serverpool

Server pool name: Free

Active servers count: 0

Server pool name: Generic

Active servers count: 0

Server pool name: ANOTHERPOOL

Active servers count: 1

Server pool name: RACATTACK

Active servers count: 1

The new server pool has lower importance than RACATTACK, so the RAC database survives and both

server pools have 1 server assigned.

Expand RACATTACK again: [oracle@collabn1 ~]$ srvctl modify srvpool -serverpool RACATTACK -min 2 -max 2

[oracle@collabn1 ~]$ /u01/app/12.1.0/grid/bin/crsctl stat res -t -w "TYPE = ora.database.type" --------------------------------------------------------------------------------

Name Target State Server State details --------------------------------------------------------------------------------

Cluster Resources

-------------------------------------------------------------------------------- ora.rac.db

1 ONLINE ONLINE collabn2 Open,STABLE 2 ONLINE ONLINE collabn1 Open,STABLE

--------------------------------------------------------------------------------

Review the current configuration and status of server pools:

[oracle@collabn1 ~]$ srvctl config srvpool Server pool name: Free

Importance: 0, Min: 0, Max: -1

Category:

Candidate server names:

Server pool name: Generic

Importance: 0, Min: 0, Max: -1

Category:

Candidate server names: Server pool name: ANOTHERPOOL

Importance: 2, Min: 2, Max: 2

Category: hub

Candidate server names:

Server pool name: RACATTACK Importance: 10, Min: 2, Max: 2

Category: hub Candidate server names:

[oracle@collabn1 ~]$ srvctl status serverpool

Server pool name: Free

Page 10: RACAttack 12c Advanced Lab: Server Pools and Policy-managed databases

Server Pools and Policy Managed Databases

Author: RAC Attack Community

Last Updated: March 21, 2014

Page#: 10

Active servers count: 0 Server pool name: Generic

Active servers count: 0

Server pool name: ANOTHERPOOL

Active servers count: 0

Server pool name: RACATTACK

Active servers count: 2

Now try to give more importance to ANOTHERPOOL. Because it requires shutting down the database

RAC, it asks to use the –force switch:

[oracle@collabn1 ~]$ srvctl modify srvpool -serverpool ANOTHERPOOL -min 2 -max 2 -importance 20

PRCS-1011 : Failed to modify server pool ANOTHERPOOL

CRS-2736: The operation requires stopping resource 'ora.rac.db' on server 'collabn2'

CRS-2736: The operation requires stopping resource 'ora.rac.db' on server 'collabn1'

CRS-2738: Unable to modify server pool 'ora.ANOTHERPOOL' as this will affect running resources,

but the force option was not specified

You can verify the actions that the clusterware would do by using the new 12c –eval switch:

[oracle@collabn1 ~]$ srvctl modify srvpool -serverpool ANOTHERPOOL -min 2 -max 2 -importance 20 -

eval Database rac will be stopped on nodes collabn2,collabn1

Server collabn1 will be moved from pool RACATTACK to pool ANOTHERPOOL

Server collabn2 will be moved from pool RACATTACK to pool ANOTHERPOOL

Finally, use the -force switch and verify that the RAC database is shut down by the cluster.

[oracle@collabn1 ~]$ srvctl modify srvpool -serverpool ANOTHERPOOL -min 2 -max 2 -importance 20 -

force

[oracle@collabn1 ~]$ /u01/app/12.1.0/grid/bin/crsctl stat res -t -w "TYPE = ora.database.type"

--------------------------------------------------------------------------------

Name Target State Server State details

--------------------------------------------------------------------------------

Cluster Resources

--------------------------------------------------------------------------------

ora.rac.db

1 ONLINE OFFLINE Instance Shutdown,ST ABLE

2 ONLINE OFFLINE Instance Shutdown,ST

ABLE

--------------------------------------------------------------------------------

6 RAC ONE NODE

Oracle RAC One Node may be convenient and cheaper than Oracle RAC for many customers.

As final step in this lab we’ll convert our database to RAC One Node.

Page 11: RACAttack 12c Advanced Lab: Server Pools and Policy-managed databases

Server Pools and Policy Managed Databases

Author: RAC Attack Community

Last Updated: March 21, 2014

Page#: 11

Because our RAC database is already shut down (no servers assigned to RACATTACK server pool), we can

remove it from the configuration:

[oracle@collabn1 ~]$ srvctl remove database -db RAC

Remove the database RAC? (y/[n) y

Then we can add back the database as RAC One Node:

[oracle@collabn1 ~]$ srvctl add database -db RAC -oraclehome /u01/app/oracle/product/12.1.0/dbhome_1 -dbtype RACONENODE -serverpool ANOTHERPOOL -spfile

+DATA/RAC/spfileRAC.ora -pwfile +DATA/RAC/orapwrac -domain racattack -diskgroup "FRA,DATA" [oracle@collabn1 ~]$ srvctl start database -db RAC

[oracle@collabn1 ~]$ /u01/app/12.1.0/grid/bin/crsctl stat res -t -w "TYPE = ora.database.type"

--------------------------------------------------------------------------------

Name Target State Server State details

-------------------------------------------------------------------------------- Cluster Resources

--------------------------------------------------------------------------------

ora.rac.db

1 ONLINE ONLINE collabn2 Open,STABLE

--------------------------------------------------------------------------------

The database has only one instance as expected.

Review its configuration:

[oracle@collabn1 ~]$ srvctl config database -d RAC Database unique name: RAC

Database name:

Oracle home: /u01/app/oracle/product/12.1.0/dbhome_1

Oracle user: oracle

Spfile: +DATA/RAC/spfileRAC.ora

Password file: +DATA/RAC/orapwrac Domain: racattack

Start options: open

Stop options: immediate

Database role: PRIMARY

Management policy: AUTOMATIC Server pools: ANOTHERPOOL

Database instances: Disk Groups: FRA,DATA

Mount point paths:

Services: Type: RACOneNode

Online relocation timeout: 30 Instance name prefix: RAC

Candidate servers:

Database is policy managed

Now the instance to the other node of the cluster:

Page 12: RACAttack 12c Advanced Lab: Server Pools and Policy-managed databases

Server Pools and Policy Managed Databases

Author: RAC Attack Community

Last Updated: March 21, 2014

Page#: 12

[oracle@collabn1 ~]$ srvctl relocate database -db RAC

[oracle@collabn1 ~]$

[oracle@collabn1 ~]$ /u01/app/12.1.0/grid/bin/crsctl stat res -t -w "TYPE = ora.database.type" --------------------------------------------------------------------------------

Name Target State Server State details

--------------------------------------------------------------------------------

Cluster Resources

-------------------------------------------------------------------------------- ora.rac.db

2 ONLINE ONLINE collabn1 Open,STABLE

--------------------------------------------------------------------------------