Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #2

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions roles/oradb-manage-statspack/README.md
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 <thorsten.bruhns@googlemail.com>
26 changes: 26 additions & 0 deletions roles/oradb-manage-statspack/defaults/main.yml
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 %}"
43 changes: 43 additions & 0 deletions roles/oradb-manage-statspack/files/spcreate.sh
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
23 changes: 23 additions & 0 deletions roles/oradb-manage-statspack/files/spdrop.sh
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
3 changes: 3 additions & 0 deletions roles/oradb-manage-statspack/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- role: orasw-meta
Loading