forked from oravirt/ansible-oracle
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
oradb-manage-statspack: New role for Statspack (#41)
* oradb-manage-statspack: new role for Statspack The new role could be used to install and configure Statspack jobs in nonCDB, CDB and PDBs.
- Loading branch information
Showing
7 changed files
with
421 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
Role Name | ||
========= | ||
|
||
A brief description of the role goes here. | ||
|
||
Requirements | ||
------------ | ||
|
||
Do not create the perfstat user before creating the statspack | ||
inside the database. The detection of existing statspack installation | ||
is based on the perfstat user. The installation will be skkipped when | ||
user is existing. | ||
|
||
Role Variables | ||
-------------- | ||
|
||
The following example only shows mandatory variables from oracle_databases: | ||
|
||
```yaml | ||
oracle_databases: | ||
- oracle_db_name: DB1 | ||
oracle_db_type: SI | ||
statspack: | ||
state: present | ||
tablespace: sysaux | ||
tablespace_temp: temp | ||
purgedays: 14 | ||
snaplevel: 7 | ||
snapinterval: "FREQ=hourly;byminute=0;bysecond=0" | ||
``` | ||
Dependencies | ||
------------ | ||
Author Information | ||
------------------ | ||
Thorsten Bruhns <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
# Global Defaults for Purge and Snapshot-Jobs. | ||
# could be overwritten per dtabase with: | ||
# oracle_databases: | ||
# - oracle_db_name: test | ||
# statspack: | ||
# purgedays: 60 | ||
purgedays: 35 | ||
purgeinterval: "FREQ=daily;byhour=3;byminute=15;bysecond=0" | ||
snapinterval: "FREQ=hourly;byminute=0;bysecond=0" | ||
snaplevel: 7 | ||
|
||
db_user: system | ||
db_password_cdb: "{% if dbpasswords is defined and dbpasswords[dbh.oracle_db_name] is defined and dbpasswords[dbh.oracle_db_name][db_user] is defined%}{{dbpasswords[dbh.oracle_db_name][db_user]}}{% else %}{{ default_dbpass}}{% endif%}" # noqa yaml | ||
db_password_pdb: "{%- if dbpasswords is defined and dbpasswords[pdb.0.cdb] is defined and dbpasswords[pdb.0.cdb][db_user] is defined -%} | ||
{{dbpasswords[pdb.0.cdb][db_user]}} | ||
{%- else -%} | ||
{{ default_dbpass}} | ||
{%- endif -%}" | ||
|
||
db_service_name: "{% if dbh is defined %} | ||
{%- if dbh.oracle_db_unique_name is defined %}{{ dbh.oracle_db_unique_name }} | ||
{%- elif dbh.oracle_db_instance_name is defined %}{{ dbh.oracle_db_instance_name }} | ||
{%- else %}{{ dbh.oracle_db_name }} | ||
{%- endif %} | ||
{%- endif %}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/bash | ||
set -euo pipefail | ||
|
||
cd $HOME | ||
|
||
env | grep ^ORACLE | sort | ||
|
||
PDB=${pdb_name:-"_"} | ||
|
||
${ORACLE_HOME}/bin/sqlplus -S -L /nolog <<EOF | ||
conn / as sysdba | ||
define perfstat_password=${perfstat_password} | ||
define temporary_tablespace=${temporary_tablespace} | ||
define default_tablespace=${default_tablespace} | ||
define purgedates=${purgedates} | ||
define snaplevel=${snaplevel} | ||
whenever sqlerror exit 1 rollback | ||
begin | ||
if '${PDB}' <> '_' then | ||
execute immediate 'alter session set container = ${PDB}'; | ||
end if; | ||
end; | ||
/ | ||
@?/rdbms/admin/spcreate | ||
set echo on | ||
alter session set current_schema=perfstat; | ||
PROMPT Fixup for idle Events (old stupid bug from Oracle...) | ||
-- Re-fill STATS\$IDLE_EVENT with latest idle events that Oracle regularly forgets to update. | ||
delete from perfstat.STATS\$IDLE_EVENT; | ||
insert into perfstat.STATS\$IDLE_EVENT select name from V\$EVENT_NAME where wait_class='Idle'; | ||
commit; | ||
PROMPT Create custom index for selecting sql_id from STATS\$SQLTEXT | ||
create index perfstat.STATS\$SQLTEXT_UK1 on STATS\$SQLTEXT(sql_id, piece); | ||
exit | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/bash | ||
set -euo pipefail | ||
|
||
cd $HOME | ||
|
||
env | grep ^ORACLE | sort | ||
|
||
PDB=${pdb_name:-"_"} | ||
|
||
${ORACLE_HOME}/bin/sqlplus -S -L /nolog <<EOF | ||
conn / as sysdba | ||
whenever oserror exit 1 rollback | ||
begin | ||
if '${PDB}' <> '_' then | ||
execute immediate 'alter session set container = ${PDB}'; | ||
end if; | ||
end; | ||
/ | ||
@?/rdbms/admin/spdrop | ||
exit | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
dependencies: | ||
- role: orasw-meta |
Oops, something went wrong.