2026-03-12 20:51:59
This commit is contained in:
120
divers/oracle_RAT_01.md
Normal file
120
divers/oracle_RAT_01.md
Normal file
@@ -0,0 +1,120 @@
|
||||
> [Original article](https://oracle-base.com/articles/8i/resource-manager-8i)
|
||||
|
||||
Create application users:
|
||||
|
||||
create user web_user identified by "iN_j8sC#d!kX6b:_";
|
||||
create user batch_user identified by "r~65ktuFYyds+P_X";
|
||||
grant connect,resource to web_user;
|
||||
grant connect,resource to batch_user;
|
||||
|
||||
|
||||
Create a pending area:
|
||||
|
||||
BEGIN
|
||||
DBMS_RESOURCE_MANAGER.clear_pending_area;
|
||||
DBMS_RESOURCE_MANAGER.create_pending_area;
|
||||
END;
|
||||
/
|
||||
|
||||
|
||||
Create a plan:
|
||||
|
||||
BEGIN
|
||||
DBMS_RESOURCE_MANAGER.create_plan(
|
||||
plan => 'hybrid_plan',
|
||||
comment => 'Plan for a combination of high and low priority tasks.');
|
||||
END;
|
||||
/
|
||||
|
||||
|
||||
Create a web and a batch consumer group:
|
||||
|
||||
BEGIN
|
||||
DBMS_RESOURCE_MANAGER.create_consumer_group(
|
||||
consumer_group => 'WEB_CG',
|
||||
comment => 'Web based OTLP processing - high priority');
|
||||
|
||||
DBMS_RESOURCE_MANAGER.create_consumer_group(
|
||||
consumer_group => 'BATCH_CG',
|
||||
comment => 'Batch processing - low priority');
|
||||
END;
|
||||
/
|
||||
|
||||
|
||||
Assign the consumer groups to the plan and indicate their relative priority, remembering to add the OTHER_GROUPS plan directive:
|
||||
|
||||
|
||||
BEGIN
|
||||
DBMS_RESOURCE_MANAGER.create_plan_directive (
|
||||
plan => 'hybrid_plan',
|
||||
group_or_subplan => 'web_cg',
|
||||
comment => 'High Priority',
|
||||
cpu_p1 => 80,
|
||||
cpu_p2 => 0,
|
||||
parallel_degree_limit_p1 => 4);
|
||||
|
||||
DBMS_RESOURCE_MANAGER.create_plan_directive (
|
||||
plan => 'hybrid_plan',
|
||||
group_or_subplan => 'batch_cg',
|
||||
comment => 'Low Priority',
|
||||
cpu_p1 => 0,
|
||||
cpu_p2 => 80,
|
||||
parallel_degree_limit_p1 => 4);
|
||||
|
||||
DBMS_RESOURCE_MANAGER.create_plan_directive(
|
||||
plan => 'hybrid_plan',
|
||||
group_or_subplan => 'OTHER_GROUPS',
|
||||
comment => 'all other users - level 3',
|
||||
cpu_p1 => 0,
|
||||
cpu_p2 => 0,
|
||||
cpu_p3 => 100);
|
||||
END;
|
||||
/
|
||||
|
||||
|
||||
Validate and apply the resource plan:
|
||||
|
||||
BEGIN
|
||||
DBMS_RESOURCE_MANAGER.validate_pending_area;
|
||||
DBMS_RESOURCE_MANAGER.submit_pending_area;
|
||||
END;
|
||||
/
|
||||
|
||||
|
||||
Assign our users to individual consumer groups:
|
||||
|
||||
BEGIN
|
||||
-- Assign users to consumer groups
|
||||
DBMS_RESOURCE_MANAGER_PRIVS.grant_switch_consumer_group(
|
||||
grantee_name => 'web_user',
|
||||
consumer_group => 'web_cg',
|
||||
grant_option => FALSE);
|
||||
|
||||
DBMS_RESOURCE_MANAGER_PRIVS.grant_switch_consumer_group(
|
||||
grantee_name => 'batch_user',
|
||||
consumer_group => 'batch_cg',
|
||||
grant_option => FALSE);
|
||||
|
||||
DBMS_RESOURCE_MANAGER.set_initial_consumer_group('web_user', 'web_cg');
|
||||
|
||||
DBMS_RESOURCE_MANAGER.set_initial_consumer_group('batch_user', 'batch_cg');
|
||||
END;
|
||||
/
|
||||
|
||||
|
||||
Connect users:
|
||||
|
||||
connect web_user/"iN_j8sC#d!kX6b:_"
|
||||
connect batch_user/"r~65ktuFYyds+P_X"
|
||||
|
||||
Check `resource_consumer_group` column in `v$session`:
|
||||
|
||||
SELECT username, resource_consumer_group
|
||||
FROM v$session
|
||||
WHERE username IN ('WEB_USER','BATCH_USER');
|
||||
|
||||
Note that the value change for a connecte session if `RESOURCE_MANAGER_PLAN` change at instance level:
|
||||
|
||||
alter system set RESOURCE_MANAGER_PLAN = 'hybrid_plan' scope=both sid='*';
|
||||
alter system set RESOURCE_MANAGER_PLAN = '' scope=both sid='*';
|
||||
|
||||
93
divers/oracle_RAT_01.txt
Normal file
93
divers/oracle_RAT_01.txt
Normal file
@@ -0,0 +1,93 @@
|
||||
-- https://orabliss.blogspot.com/2016/02/oracle-rat-demo-part-1.html
|
||||
|
||||
CREATE PLUGGABLE DATABASE KENOBI ADMIN USER pdbdmin IDENTIFIED BY "RunDatab1218ase#1985Go!";
|
||||
alter pluggable database KENOBI open;
|
||||
alter pluggable database KENOBI save state;
|
||||
alter session set container=KENOBI;
|
||||
show con_name
|
||||
|
||||
@?/rdbms/admin/utlrp
|
||||
|
||||
|
||||
|
||||
CREATE PLUGGABLE DATABASE MAUL ADMIN USER pdbdmin IDENTIFIED BY "RunDatab1218ase#1985Go!";
|
||||
alter pluggable database MAUL open;
|
||||
alter pluggable database MAUL save state;
|
||||
alter session set container=MAUL;
|
||||
show con_name
|
||||
|
||||
@?/rdbms/admin/utlrp
|
||||
|
||||
|
||||
|
||||
|
||||
run
|
||||
{
|
||||
set nocfau;
|
||||
allocate channel ch01 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/rat1/JEDIPRD/%d_%U_%s_%t.bck';
|
||||
allocate channel ch02 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/rat1/JEDIPRD/%d_%U_%s_%t.bck';
|
||||
allocate channel ch03 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/rat1/JEDIPRD/%d_%U_%s_%t.bck';
|
||||
allocate channel ch04 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/rat1/JEDIPRD/%d_%U_%s_%t.bck';
|
||||
backup as compressed backupset incremental level 0 database section size 2G include current controlfile plus archivelog delete input;
|
||||
release channel ch01;
|
||||
release channel ch02;
|
||||
release channel ch03;
|
||||
release channel ch04;
|
||||
allocate channel ch01 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/rat1/JEDIPRD/%d_%U_%s_%t.controlfile';
|
||||
backup current controlfile;
|
||||
release channel ch01;
|
||||
}
|
||||
|
||||
run
|
||||
{
|
||||
set nocfau;
|
||||
allocate channel ch01 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/rat1/SITHPRD/%d_%U_%s_%t.bck';
|
||||
allocate channel ch02 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/rat1/SITHPRD/%d_%U_%s_%t.bck';
|
||||
allocate channel ch03 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/rat1/SITHPRD/%d_%U_%s_%t.bck';
|
||||
allocate channel ch04 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/rat1/SITHPRD/%d_%U_%s_%t.bck';
|
||||
backup as compressed backupset incremental level 0 database section size 2G include current controlfile plus archivelog delete input;
|
||||
release channel ch01;
|
||||
release channel ch02;
|
||||
release channel ch03;
|
||||
release channel ch04;
|
||||
allocate channel ch01 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/rat1/SITHPRD/%d_%U_%s_%t.controlfile';
|
||||
backup current controlfile;
|
||||
release channel ch01;
|
||||
}
|
||||
|
||||
|
||||
|
||||
create or replace directory RAT_WORKLOAD as '/home/or
|
||||
|
||||
|
||||
|
||||
|
||||
create or replace directory RAT_WORKLOAD as '/home/oracle/rat';
|
||||
execute dbms_workload_capture.start_capture('RAT_CAPTURE','RAT_WORKLOAD');
|
||||
-- execute Workload
|
||||
execute dbms_workload_capture.finish_capture();
|
||||
|
||||
SQL> col name for a12
|
||||
SQL> col status for a10
|
||||
SQL> col dir_path for a25
|
||||
SQL> set lines 300acle/rat';
|
||||
execute dbms_workload_capture.start_capture('RAT_CAPTURE','RAT_WORKLOAD');
|
||||
-- execute Workload
|
||||
execute dbms_workload_capture.finish_capture();
|
||||
|
||||
col name for a12
|
||||
col status for a10
|
||||
col dir_path for a25
|
||||
set lines 300
|
||||
|
||||
select id,name,status,start_time,end_time,connects,user_calls,dir_path from dba_workload_captures
|
||||
where id = (select max(id) from dba_workload_captures) ;
|
||||
|
||||
|
||||
|
||||
|
||||
set pagesize 0 long 30000000 longchunksize 1000
|
||||
select dbms_workload_capture.report(2,'TEXT') from dual;
|
||||
|
||||
export PATH=$ORACLE_HOME/jdk/bin:$PATH
|
||||
java -classpaexport PATH=$ORACLE_HOME/jdk/bin:$PATHth $ORACLE_HOME/jdbc/lib/ojdbc7.jar:$ORACLE_HOME/rdbms/jlib/dbrparser.jar:$ORACLE_HOME/rdbms/jlib/dbranalyzer.jar: oracle.dbreplay.workload.checker.CaptureChecker /home/oracle/rat jdbc:oracle:thin:@taris:1521/KENOBI
|
||||
139
divers/oracle_autoupgrade_01.txt
Normal file
139
divers/oracle_autoupgrade_01.txt
Normal file
@@ -0,0 +1,139 @@
|
||||
export PATH=/app/oracle/product/21/jdk/bin:$PATH
|
||||
export JAVA_HOME=/app/oracle/product/21/jdk
|
||||
|
||||
java -jar $ORACLE_HOME/rdbms/admin/autoupgrade.jar -version
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
create spfile='/app/oracle/base/admin/WEDGEPRD/spfile/spfileWEDGEPRD.ora' from pfile='/app/oracle/base/admin/WEDGEPRD/pfile/initWEDGEPRD.ora';
|
||||
|
||||
startup nomount;
|
||||
|
||||
rman auxiliary /
|
||||
|
||||
run
|
||||
{
|
||||
allocate auxiliary channel aux01 device type disk;
|
||||
allocate auxiliary channel aux02 device type disk;
|
||||
allocate auxiliary channel aux03 device type disk;
|
||||
allocate auxiliary channel aux04 device type disk;
|
||||
allocate auxiliary channel aux05 device type disk;
|
||||
allocate auxiliary channel aux06 device type disk;
|
||||
allocate auxiliary channel aux07 device type disk;
|
||||
allocate auxiliary channel aux08 device type disk;
|
||||
allocate auxiliary channel aux09 device type disk;
|
||||
allocate auxiliary channel aux10 device type disk;
|
||||
duplicate target database to WEDGE backup location '/mnt/yavin4/tmp/_oracle_/orabackup/_keep_/Standalone/11.2.0.4/WEDGE/';
|
||||
}
|
||||
|
||||
|
||||
@$ORACLE_HOME/rdbms/admin/catbundle psu apply
|
||||
@$ORACLE_HOME/rdbms/admin/utlrp
|
||||
|
||||
java -jar /mnt/yavin4/tmp/autoupgrade.jar -version
|
||||
java -jar /mnt/yavin4/tmp/autoupgrade.jar -config /home/oracle/myconfig.cfg -clear_recovery_data
|
||||
java -jar /mnt/yavin4/tmp/autoupgrade.jar -config myconfig.cfg -mode analyze
|
||||
java -jar /mnt/yavin4/tmp/autoupgrade.jar -config myconfig.cfg -mode fixups
|
||||
java -jar /mnt/yavin4/tmp/autoupgrade.jar -config myconfig.cfg -mode deploy
|
||||
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
global.autoupg_log_dir=/home/oracle
|
||||
|
||||
upg1.sid=WEDGEPRD # ORACLE_SID of the source DB/CDB
|
||||
upg1.source_home=/app/oracle/product/11.2 # Path of the source ORACLE_HOME
|
||||
upg1.target_home=/app/oracle/product/19 # Path of the target ORACLE_HOME
|
||||
upg1.start_time=NOW # Optional. [NOW | +XhYm (X hours, Y minutes after launch) | dd/mm/yyyy hh:mm:ss]
|
||||
upg1.upgrade_node=taris.swgalaxy # Optional. To find out the name of your node, run the hostname utility. Default is 'localhost'
|
||||
upg1.run_utlrp=yes # Optional. Whether or not to run utlrp after upgrade
|
||||
upg1.timezone_upg=yes # Optional. Whether or not to run the timezone upgrade
|
||||
upg1.target_version=19 # Oracle version of the target ORACLE_HOME. Only required when the target Oracle database version is 12.2
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
create spfile='/app/oracle/base/admin/ASTYPRD/spfile/spfileASTYPRD.ora' from pfile='/app/oracle/base/admin/ASTYPRD/pfile/initASTYPRD.ora';
|
||||
|
||||
startup nomount;
|
||||
|
||||
rman auxiliary /
|
||||
|
||||
run
|
||||
{
|
||||
allocate auxiliary channel aux01 device type disk;
|
||||
allocate auxiliary channel aux02 device type disk;
|
||||
allocate auxiliary channel aux03 device type disk;
|
||||
allocate auxiliary channel aux04 device type disk;
|
||||
allocate auxiliary channel aux05 device type disk;
|
||||
allocate auxiliary channel aux06 device type disk;
|
||||
allocate auxiliary channel aux07 device type disk;
|
||||
allocate auxiliary channel aux08 device type disk;
|
||||
allocate auxiliary channel aux09 device type disk;
|
||||
allocate auxiliary channel aux10 device type disk;
|
||||
duplicate target database to ASTY backup location '/mnt/yavin4/tmp/_oracle_/orabackup/_keep_/Standalone/19.11/ASTY/';
|
||||
}
|
||||
|
||||
|
||||
|
||||
cd $ORACLE_HOME/OPatch
|
||||
./datapatch
|
||||
|
||||
@$ORACLE_HOME/rdbms/admin/utlrp
|
||||
|
||||
|
||||
global.autoupg_log_dir=/home/oracle
|
||||
|
||||
#
|
||||
# Database number 3 - Noncdb to PDB upgrade
|
||||
#
|
||||
upg3.sid=WEDGEPRD
|
||||
upg3.source_home=/app/oracle/product/11.2
|
||||
upg3.target_cdb=ASTYPRD
|
||||
upg3.target_home=/app/oracle/product/19
|
||||
upg3.target_pdb_name=PDBWEDGEPRD
|
||||
upg3.start_time=NOW # Optional. 10 Minutes from now
|
||||
upg3.upgrade_node=localhost # Optional. To find out the name of your node, run the hostname utility. Default is 'localhost'
|
||||
upg3.run_utlrp=yes # Optional. Whether or not to run utlrp after upgrade
|
||||
upg3.timezone_upg=yes # Optional. Whether or not to run the timezone upgrade
|
||||
|
||||
|
||||
rman target /
|
||||
|
||||
run
|
||||
{
|
||||
set nocfau;
|
||||
allocate channel ch01 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/upgrade1/ASTYPRD/%d_%U_%s_%t.bck';
|
||||
allocate channel ch02 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/upgrade1/ASTYPRD/%d_%U_%s_%t.bck';
|
||||
allocate channel ch03 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/upgrade1/ASTYPRD/%d_%U_%s_%t.bck';
|
||||
allocate channel ch04 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/upgrade1/ASTYPRD/%d_%U_%s_%t.bck';
|
||||
backup as compressed backupset incremental level 0 database section size 2G include current controlfile plus archivelog delete input;
|
||||
release channel ch01;
|
||||
release channel ch02;
|
||||
release channel ch03;
|
||||
release channel ch04;
|
||||
allocate channel ch01 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/upgrade1/ASTYPRD/%d_%U_%s_%t.controlfile';
|
||||
backup current controlfile;
|
||||
release channel ch01;
|
||||
}
|
||||
|
||||
|
||||
run
|
||||
{
|
||||
set nocfau;
|
||||
allocate channel ch01 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/upgrade1/WEDGEPRD/%d_%U_%s_%t.bck';
|
||||
allocate channel ch02 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/upgrade1/WEDGEPRD/%d_%U_%s_%t.bck';
|
||||
allocate channel ch03 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/upgrade1/WEDGEPRD/%d_%U_%s_%t.bck';
|
||||
allocate channel ch04 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/upgrade1/WEDGEPRD/%d_%U_%s_%t.bck';
|
||||
backup as compressed backupset incremental level 0 database section size 2G include current controlfile plus archivelog delete input;
|
||||
release channel ch01;
|
||||
release channel ch02;
|
||||
release channel ch03;
|
||||
release channel ch04;
|
||||
allocate channel ch01 device type disk format '/mnt/yavin4/tmp/_oracle_/orabackup/temp/upgrade1/WEDGEPRD/%d_%U_%s_%t.controlfile';
|
||||
backup current controlfile;
|
||||
release channel ch01;
|
||||
}
|
||||
|
||||
|
||||
43
divers/oracle_clone_using_lv_snap_01.txt
Normal file
43
divers/oracle_clone_using_lv_snap_01.txt
Normal file
@@ -0,0 +1,43 @@
|
||||
On Dom0:
|
||||
|
||||
qemu-img create -f raw /vm/hdd0/kamino/data_03.img 20G
|
||||
|
||||
chown qemu:qemu /vm/hdd0/kamino/data_03.img
|
||||
chmod 600 /vm/hdd0/kamino/data_03.img
|
||||
|
||||
virsh attach-disk kamino /vm/hdd0/kamino/data_03.img vdh --driver qemu --subdriver raw --targetbus virtio --persistent
|
||||
|
||||
|
||||
qemu-img create -f raw /vm/hdd0/kamino/fra_02.img 20G
|
||||
|
||||
chown qemu:qemu /vm/hdd0/kamino/fra_02.img
|
||||
chmod 600 /vm/hdd0/kamino/fra_02.img
|
||||
|
||||
virsh attach-disk kamino /vm/hdd0/kamino/fra_02.img vdi --driver qemu --subdriver raw --targetbus virtio --persistent
|
||||
|
||||
|
||||
On VM:
|
||||
|
||||
pvcreate /dev/vdh
|
||||
pvcreate /dev/vdi
|
||||
|
||||
vgextend vg_data /dev/vdh
|
||||
vgextend vg_fra /dev/vdi
|
||||
|
||||
|
||||
|
||||
lvcreate -s -n lv_snap_data -L 19G vg_data/lv_data
|
||||
|
||||
|
||||
|
||||
|
||||
mkdir /snap_data /snap_fra
|
||||
|
||||
# On XFS add options: rw,nouuid, otherwise the mount fails
|
||||
mount -o rw,nouuid /dev/vg_data/lv_snap_data /snap_data
|
||||
|
||||
# try: xfs_admin -U generate /dev/vg_data/lv_snap_data
|
||||
|
||||
umount /snap_data
|
||||
lvremove vg_data/lv_snap_data
|
||||
|
||||
128
divers/oracle_ressource_manager_01.txt
Normal file
128
divers/oracle_ressource_manager_01.txt
Normal file
@@ -0,0 +1,128 @@
|
||||
https://oracle-base.com/articles/8i/resource-manager-8i
|
||||
|
||||
|
||||
orapwd file=orapwHUTTPRD password="Urezesf7754#hhY7711#ab?"
|
||||
|
||||
|
||||
create pluggable database DURGA admin user HUTTMASTER identified by "Ngfsf554#hhAZAR1#10!";
|
||||
alter pluggable database DURGA open;
|
||||
alter pluggable database DURGA save state;
|
||||
|
||||
alter session set container=DURGA;
|
||||
show con_name
|
||||
grant sysdba to starkiller identified by "VvvAv0332#00911HsqeZA?";
|
||||
|
||||
|
||||
|
||||
alias HUTTPRD='rlwrap sqlplus sys/"Urezesf7754#hhY7711#ab?"@taris/HUTTPRD as sysdba'
|
||||
alias DURGA='rlwrap sqlplus starkiller/"VvvAv0332#00911HsqeZA?"@taris/DURGA as sysdba'
|
||||
|
||||
|
||||
CREATE USER web_user identified by "iN_j8sC#d!kX6b:_";
|
||||
CREATE USER batch_user identified by "r~65ktuFYyds+P_X";
|
||||
|
||||
grant connect,resource to web_user;
|
||||
grant connect,resource to batch_user;
|
||||
|
||||
# create a pending area.
|
||||
|
||||
BEGIN
|
||||
DBMS_RESOURCE_MANAGER.clear_pending_area;
|
||||
DBMS_RESOURCE_MANAGER.create_pending_area;
|
||||
END;
|
||||
/
|
||||
|
||||
# create a plan
|
||||
|
||||
BEGIN
|
||||
DBMS_RESOURCE_MANAGER.create_plan(
|
||||
plan => 'hybrid_plan',
|
||||
comment => 'Plan for a combination of high and low priority tasks.');
|
||||
END;
|
||||
/
|
||||
|
||||
Create a web and a batch consumer group
|
||||
|
||||
BEGIN
|
||||
DBMS_RESOURCE_MANAGER.create_consumer_group(
|
||||
consumer_group => 'WEB_CG',
|
||||
comment => 'Web based OTLP processing - high priority');
|
||||
|
||||
DBMS_RESOURCE_MANAGER.create_consumer_group(
|
||||
consumer_group => 'BATCH_CG',
|
||||
comment => 'Batch processing - low priority');
|
||||
END;
|
||||
/
|
||||
|
||||
# assign the consumer groups to the plan and indicate their relative priority, remembering to add the OTHER_GROUPS plan directive.
|
||||
|
||||
|
||||
BEGIN
|
||||
DBMS_RESOURCE_MANAGER.create_plan_directive (
|
||||
plan => 'hybrid_plan',
|
||||
group_or_subplan => 'web_cg',
|
||||
comment => 'High Priority',
|
||||
cpu_p1 => 80,
|
||||
cpu_p2 => 0,
|
||||
parallel_degree_limit_p1 => 4);
|
||||
|
||||
DBMS_RESOURCE_MANAGER.create_plan_directive (
|
||||
plan => 'hybrid_plan',
|
||||
group_or_subplan => 'batch_cg',
|
||||
comment => 'Low Priority',
|
||||
cpu_p1 => 0,
|
||||
cpu_p2 => 80,
|
||||
parallel_degree_limit_p1 => 4);
|
||||
|
||||
DBMS_RESOURCE_MANAGER.create_plan_directive(
|
||||
plan => 'hybrid_plan',
|
||||
group_or_subplan => 'OTHER_GROUPS',
|
||||
comment => 'all other users - level 3',
|
||||
cpu_p1 => 0,
|
||||
cpu_p2 => 0,
|
||||
cpu_p3 => 100);
|
||||
END;
|
||||
/
|
||||
|
||||
# validate and apply the resource plan.
|
||||
|
||||
BEGIN
|
||||
DBMS_RESOURCE_MANAGER.validate_pending_area;
|
||||
DBMS_RESOURCE_MANAGER.submit_pending_area;
|
||||
END;
|
||||
/
|
||||
|
||||
|
||||
# assign our users to individual consumer groups.
|
||||
|
||||
BEGIN
|
||||
-- Assign users to consumer groups
|
||||
DBMS_RESOURCE_MANAGER_PRIVS.grant_switch_consumer_group(
|
||||
grantee_name => 'web_user',
|
||||
consumer_group => 'web_cg',
|
||||
grant_option => FALSE);
|
||||
|
||||
DBMS_RESOURCE_MANAGER_PRIVS.grant_switch_consumer_group(
|
||||
grantee_name => 'batch_user',
|
||||
consumer_group => 'batch_cg',
|
||||
grant_option => FALSE);
|
||||
|
||||
DBMS_RESOURCE_MANAGER.set_initial_consumer_group('web_user', 'web_cg');
|
||||
|
||||
DBMS_RESOURCE_MANAGER.set_initial_consumer_group('batch_user', 'batch_cg');
|
||||
END;
|
||||
/
|
||||
|
||||
|
||||
|
||||
|
||||
connect web_user/"iN_j8sC#d!kX6b:_"@taris/DURGA
|
||||
connect batch_user/"r~65ktuFYyds+P_X"@taris/DURGA
|
||||
|
||||
SELECT username, resource_consumer_group
|
||||
FROM v$session
|
||||
WHERE username IN ('WEB_USER','BATCH_USER');
|
||||
|
||||
|
||||
ALTER SYSTEM SET RESOURCE_MANAGER_PLAN = 'hybrid_plan';
|
||||
|
||||
62
divers/sql_quarantine_01.md
Normal file
62
divers/sql_quarantine_01.md
Normal file
@@ -0,0 +1,62 @@
|
||||
> [Original article](https://oracle-base.com/articles/19c/sql-quarantine-19c)
|
||||
|
||||
We can manually quarantine a statement based on SQL_ID or SQL_TEXT.
|
||||
Both methods accept a PLAN_HASH_VALUE parameter, which allows us to quarantine a single execution plan.
|
||||
If this is not specified, all execution plans for the statement are quarantined.
|
||||
|
||||
|
||||
-- Quarantine all execution plans for a SQL_ID.
|
||||
DECLARE
|
||||
l_sql_quarantine VARCHAR2(100);
|
||||
BEGIN
|
||||
l_sql_quarantine := sys.DBMS_SQLQ.create_quarantine_by_sql_id(
|
||||
sql_id => 'gs59hr0xtjrf8'
|
||||
);
|
||||
DBMS_OUTPUT.put_line('l_sql_quarantine=' || l_sql_quarantine);
|
||||
END;
|
||||
/
|
||||
|
||||
|
||||
SQL quarantine display:
|
||||
|
||||
set lines 256
|
||||
COLUMN sql_text FORMAT A50 TRUNC
|
||||
COLUMN plan_hash_value FORMAT 999999999999
|
||||
COLUMN name FORMAT A30
|
||||
COLUMN enabled FORMAT A3 HEAD "Ena"
|
||||
COLUMN cpu_time FORMAT A10
|
||||
COLUMN io_megabytes FORMAT A10
|
||||
COLUMN io_requests FORMAT A10
|
||||
COLUMN elapsed_time FORMAT A10
|
||||
COLUMN io_logical FORMAT A10
|
||||
|
||||
select
|
||||
name, enabled,cpu_time, io_megabytes, io_requests, elapsed_time, io_logical, plan_hash_value, sql_text
|
||||
from
|
||||
dba_sql_quarantine;
|
||||
|
||||
|
||||
The ALTER_QUARANTINE procedure allows us to alter the thresholds, to make them look more like automatically generated quarantines.
|
||||
We can use the procedure to alter the following parameters:
|
||||
|
||||
- CPU_TIME
|
||||
- ELAPSED_TIME
|
||||
- IO_MEGABYTES
|
||||
- IO_REQUESTS
|
||||
- IO_LOGICAL
|
||||
- ENABLED
|
||||
- AUTOPURGE
|
||||
|
||||
Example of setting the CPU_TIME threshold for the manually created quarantines:
|
||||
|
||||
BEGIN
|
||||
DBMS_SQLQ.alter_quarantine(
|
||||
quarantine_name => 'SQL_QUARANTINE_8zpc9pwdmb8vr',
|
||||
parameter_name => 'CPU_TIME',
|
||||
parameter_value => '1');
|
||||
END;
|
||||
/
|
||||
|
||||
|
||||
|
||||
|
||||
30
divers/tmp_script.sql
Normal file
30
divers/tmp_script.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
CREATE TABLE exemple_table (
|
||||
col1 INTEGER,
|
||||
col2 INTEGER,
|
||||
col3 INTEGER,
|
||||
col4 VARCHAR2(20)
|
||||
);
|
||||
|
||||
DECLARE
|
||||
v_col1 INTEGER;
|
||||
v_col2 INTEGER;
|
||||
v_col3 INTEGER;
|
||||
v_col4 VARCHAR2(20);
|
||||
BEGIN
|
||||
FOR i IN 1..1000000 LOOP
|
||||
v_col1 := TRUNC(DBMS_RANDOM.VALUE(1, 1000));
|
||||
v_col2 := TRUNC(DBMS_RANDOM.VALUE(1, 1000));
|
||||
v_col3 := TRUNC(DBMS_RANDOM.VALUE(1, 1000));
|
||||
v_col4 := DBMS_RANDOM.STRING('U', 10); -- 10 caractères aléatoires en majuscules
|
||||
|
||||
INSERT INTO exemple_table (col1, col2, col3, col4)
|
||||
VALUES (v_col1, v_col2, v_col3, v_col4);
|
||||
|
||||
-- Commit toutes les 10 000 lignes pour éviter les problèmes de mémoire
|
||||
IF MOD(i, 10000) = 0 THEN
|
||||
COMMIT;
|
||||
END IF;
|
||||
END LOOP;
|
||||
COMMIT;
|
||||
END;
|
||||
/
|
||||
19
divers/vminfo.txt
Normal file
19
divers/vminfo.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
bakura Oracle
|
||||
togoria Oracle
|
||||
wayland Oracle
|
||||
|
||||
exegol OEL9 - ogg21
|
||||
helska OEL9 - ogg21
|
||||
|
||||
# raxus PostgreSQL
|
||||
belasco PostgreSQL
|
||||
|
||||
jakku Windows 7 - Ciel Compta
|
||||
utapau Windows 11 (vplesnila/secret)
|
||||
|
||||
seedmachine Rocky Linux 9 generic VM
|
||||
ivera Rocky Linux 9 - docker
|
||||
|
||||
adega Windows Server 2022 SE vplesnila/Secret00!
|
||||
atrisia Windows Server 2022 SE vplesnila/Secret00!
|
||||
|
||||
Reference in New Issue
Block a user