-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCREATE_CDB_PROFILE_DIRECTIVE.sql
253 lines (189 loc) · 11.6 KB
/
CREATE_CDB_PROFILE_DIRECTIVE.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
/*
PDB Performance Profiles
================================
A PDB performance profile configures resource plan directives for a set of PDBs that have the same priorities and resource controls.
Resource Plan Directives
================================
Directives control allocation of CPU and parallel execution servers.
shares
================================
The `shares` parameter within the context of Oracle Database's Resource Manager, particularly when configuring CDB profile directives for Pluggable Databases (PDBs),
is a key component in managing CPU resource distribution. This parameter determines the relative amount of CPU resources allocated to a PDB or consumer group under CPU contention.
Here’s how `shares` work:
- **Relative Importance**: The value assigned to `shares` indicates the relative importance or priority of a PDB or consumer group compared to others. A higher number
of shares grants a higher priority for receiving CPU resources when these resources are contested.
- **CPU Allocation**: When multiple PDBs or consumer groups are competing for CPU, the Database Resource Manager allocates CPU resources based on the proportion of shares
assigned to each. For instance, if you have two consumer groups, A and B, with shares set to 3 and 2 respectively, group A would receive 3/5 of the CPU resources, and group B
would receive 2/5, under conditions where CPU resources are insufficient to meet the total demand.
- **Dynamic Adjustment**: Unlike static resource allocation methods, the shares system allows for dynamic adjustment of CPU resource distribution based on the current workload
and the defined priorities. This ensures that more critical or higher-priority workloads can maintain performance under varying load conditions.
The `shares` parameter is used to establish a tiered performance model where PDBs associated with the `gold` profile are given higher priority over those with `silver` or `bronze`.
This is particularly useful in environments where multiple applications with varying performance and priority requirements are hosted within the same database infrastructure,
allowing for more flexible and efficient use of resources.
utilization_limit
================================
The CPU utilization limit for sessions connected to a PDB is set by the utilization_limit parameter in subprograms of the DBMS_RESOURCE_MANAGER package.
The utilization_limit parameter specifies the percentage of the system resources that a PDB can use. The value ranges from 0 to 100.
parallel_server_limit
================================
Limit the number of parallel execution servers (PQ) in a PDB by means of parallel statement queuing. The limit is a “queuing point” because the database queues parallel
queries when the limit is reached. This is a percentage.
PQ will be activiated automatically if this is configured within the PDB:
ALTER SESSION SET PARALLEL_DEGREE_POLICY = AUTO;
*/
exec DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();
BEGIN
DBMS_RESOURCE_MANAGER.CREATE_CDB_PLAN(
plan => 'newcdb_plan',
comment => 'CDB resource plan for soft partitioning the hardware resources across PDB tiers');
END;
/
/*
Create performance profiles called Gold, Silver, and Bronze. Each profile specifies a different set of directives depending on the importance of the type of PDB.
Gold PDBs are more mission critical than Silver PDBs, which are more mission critical than Bronze PDBs.
A PDB specifies its performance profile with the DB_PERFORMANCE_PROFILE initialization parameter.
*/
BEGIN
DBMS_RESOURCE_MANAGER.CREATE_CDB_PROFILE_DIRECTIVE(
plan => 'newcdb_plan',
profile => 'gold',
shares => 4,
utilization_limit => 60,
parallel_server_limit => 60);
END;
/
BEGIN
DBMS_RESOURCE_MANAGER.CREATE_CDB_PROFILE_DIRECTIVE(
plan => 'newcdb_plan',
profile => 'silver',
shares => 2,
utilization_limit => 30,
parallel_server_limit => 30);
END;
/
BEGIN
DBMS_RESOURCE_MANAGER.CREATE_CDB_PROFILE_DIRECTIVE(
plan => 'newcdb_plan',
profile => 'bronze',
shares => 1,
utilization_limit => 10,
parallel_server_limit => 10);
END;
/
/* Update the default plan for new PDBs */
BEGIN
DBMS_RESOURCE_MANAGER.UPDATE_CDB_DEFAULT_DIRECTIVE(
plan => 'newcdb_plan',
new_shares => 1,
new_utilization_limit => 10,
new_parallel_server_limit => 10);
END;
/
/*
Update the AutoTask directive in a CDB resource plan using the UPDATE_CDB_AUTOTASK_DIRECTIVE procedure.
The AutoTask directive applies to automatic maintenance tasks that are run in the root maintenance window.
*/
BEGIN
DBMS_RESOURCE_MANAGER.UPDATE_CDB_AUTOTASK_DIRECTIVE(
plan => 'newcdb_plan',
new_shares => 2,
new_utilization_limit => 60);
END;
/
exec DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();
exec DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();
ALTER SYSTEM SET RESOURCE_MANAGER_PLAN = 'newcdb_plan' SCOPE=BOTH;
/* review config */
COLUMN PLAN FORMAT A30
COLUMN STATUS FORMAT A10
COLUMN COMMENTS FORMAT A35
SELECT PLAN, STATUS, COMMENTS
FROM DBA_CDB_RSRC_PLANS
ORDER BY PLAN;
/*
Use PDB lockdown profiles to specify PDB initialization parameters that control resources, such as SGA_TARGET and PGA_AGGREGATE_LIMIT.
A lockdown profile prevents the PDB administrator from modifying the settings.
To prevent PDB owners from switching profiles, Oracle recommends putting the PDB performance profile in the PDB lockdown profile.
*/
-- Define GOLD Lockdown Profile with Performance Settings
BEGIN
DBMS_LOCKDOWN.create_profile(profile_name => 'GOLD');
-- Lock DB_PERFORMANCE_PROFILE parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'GOLD', rule_name => 'LOCK_DB_PERFORMANCE_PROFILE', clause => 'DB_PERFORMANCE_PROFILE', option => 'ALTER SYSTEM');
-- Lock MAX_IOPS parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'GOLD', rule_name => 'LOCK_MAX_IOPS', clause => 'MAX_IOPS', option => 'ALTER SYSTEM');
-- Lock MAX_MBPS parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'GOLD', rule_name => 'LOCK_MAX_MBPS', clause => 'MAX_MBPS', option => 'ALTER SYSTEM');
-- Lock SESSIONS parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'GOLD', rule_name => 'LOCK_SESSIONS', clause => 'SESSIONS', option => 'ALTER SYSTEM');
-- Lock PGA_AGGREGATE_TARGET parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'GOLD', rule_name => 'LOCK_PGA_AGGREGATE_TARGET', clause => 'PGA_AGGREGATE_TARGET', option => 'ALTER SYSTEM');
-- Lock PGA_AGGREGATE_LIMIT parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'GOLD', rule_name => 'LOCK_PGA_AGGREGATE_LIMIT', clause => 'PGA_AGGREGATE_LIMIT', option => 'ALTER SYSTEM');
-- Lock SGA_TARGET parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'GOLD', rule_name => 'LOCK_SGA_TARGET', clause => 'SGA_TARGET', option => 'ALTER SYSTEM');
-- Lock SGA_MIN_SIZE parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'GOLD', rule_name => 'LOCK_SGA_MIN_SIZE', clause => 'SGA_MIN_SIZE', option => 'ALTER SYSTEM');
-- Lock SHARED_POOL_SIZE parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'GOLD', rule_name => 'LOCK_SHARED_POOL_SIZE', clause => 'SHARED_POOL_SIZE', option => 'ALTER SYSTEM');
-- Lock DB_CACHE_SIZE parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'GOLD', rule_name => 'LOCK_DB_CACHE_SIZE', clause => 'DB_CACHE_SIZE', option => 'ALTER SYSTEM');
END;
/
-- Define SILVER Lockdown Profile with Performance Settings
BEGIN
DBMS_LOCKDOWN.create_profile(profile_name => 'SILVER');
-- Lock DB_PERFORMANCE_PROFILE parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'SILVER', rule_name => 'LOCK_DB_PERFORMANCE_PROFILE', clause => 'DB_PERFORMANCE_PROFILE', option => 'ALTER SYSTEM');
-- Lock MAX_IOPS parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'SILVER', rule_name => 'LOCK_MAX_IOPS', clause => 'MAX_IOPS', option => 'ALTER SYSTEM');
-- Lock MAX_MBPS parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'SILVER', rule_name => 'LOCK_MAX_MBPS', clause => 'MAX_MBPS', option => 'ALTER SYSTEM');
-- Lock SESSIONS parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'SILVER', rule_name => 'LOCK_SESSIONS', clause => 'SESSIONS', option => 'ALTER SYSTEM');
-- Lock PGA_AGGREGATE_TARGET parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'SILVER', rule_name => 'LOCK_PGA_AGGREGATE_TARGET', clause => 'PGA_AGGREGATE_TARGET', option => 'ALTER SYSTEM');
-- Lock PGA_AGGREGATE_LIMIT parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'SILVER', rule_name => 'LOCK_PGA_AGGREGATE_LIMIT', clause => 'PGA_AGGREGATE_LIMIT', option => 'ALTER SYSTEM');
-- Lock SGA_TARGET parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'SILVER', rule_name => 'LOCK_SGA_TARGET', clause => 'SGA_TARGET', option => 'ALTER SYSTEM');
-- Lock SGA_MIN_SIZE parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'SILVER', rule_name => 'LOCK_SGA_MIN_SIZE', clause => 'SGA_MIN_SIZE', option => 'ALTER SYSTEM');
-- Lock SHARED_POOL_SIZE parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'SILVER', rule_name => 'LOCK_SHARED_POOL_SIZE', clause => 'SHARED_POOL_SIZE', option => 'ALTER SYSTEM');
-- Lock DB_CACHE_SIZE parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'SILVER', rule_name => 'LOCK_DB_CACHE_SIZE', clause => 'DB_CACHE_SIZE', option => 'ALTER SYSTEM');
END;
/
-- Define BRONZE Lockdown Profile with Performance Settings
BEGIN
DBMS_LOCKDOWN.create_profile(profile_name => 'BRONZE');
-- Lock DB_PERFORMANCE_PROFILE parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'BRONZE', rule_name => 'LOCK_DB_PERFORMANCE_PROFILE', clause => 'DB_PERFORMANCE_PROFILE', option => 'ALTER SYSTEM');
-- Lock MAX_IOPS parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'BRONZE', rule_name => 'LOCK_MAX_IOPS', clause => 'MAX_IOPS', option => 'ALTER SYSTEM');
-- Lock MAX_MBPS parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'BRONZE', rule_name => 'LOCK_MAX_MBPS', clause => 'MAX_MBPS', option => 'ALTER SYSTEM');
-- Lock SESSIONS parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'BRONZE', rule_name => 'LOCK_SESSIONS', clause => 'SESSIONS', option => 'ALTER SYSTEM');
-- Lock PGA_AGGREGATE_TARGET parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'BRONZE', rule_name => 'LOCK_PGA_AGGREGATE_TARGET', clause => 'PGA_AGGREGATE_TARGET', option => 'ALTER SYSTEM');
-- Lock PGA_AGGREGATE_LIMIT parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'BRONZE', rule_name => 'LOCK_PGA_AGGREGATE_LIMIT', clause => 'PGA_AGGREGATE_LIMIT', option => 'ALTER SYSTEM');
-- Lock SGA_TARGET parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'BRONZE', rule_name => 'LOCK_SGA_TARGET', clause => 'SGA_TARGET', option => 'ALTER SYSTEM');
-- Lock SGA_MIN_SIZE parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'BRONZE', rule_name => 'LOCK_SGA_MIN_SIZE', clause => 'SGA_MIN_SIZE', option => 'ALTER SYSTEM');
-- Lock SHARED_POOL_SIZE parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'BRONZE', rule_name => 'LOCK_SHARED_POOL_SIZE', clause => 'SHARED_POOL_SIZE', option => 'ALTER SYSTEM');
-- Lock DB_CACHE_SIZE parameter
DBMS_LOCKDOWN.add_rule(profile_name => 'BRONZE', rule_name => 'LOCK_DB_CACHE_SIZE', clause => 'DB_CACHE_SIZE', option => 'ALTER SYSTEM');
END;
/
/* NB: When creating new PDBs, specify the parameters that are listed in the lockdown profiles */
/* for each PDB, assign a profile and restart it on all RAC nodes: */
--ALTER SESSION SET CONTAINER=mypdb1;
--ALTER SYSTEM SET DB_PERFORMANCE_PROFILE=gold SCOPE=spfile;
--ALTER SYSTEM SET PDB_LOCKDOWN=gold SCOPE=spfile;
--ALTER PLUGGABLE DATABASE CLOSE IMMEDIATE INSTANCES=ALL;
--ALTER PLUGGABLE DATABASE OPEN INSTANCES=ALL;