Skip to content
This repository has been archived by the owner on Jun 10, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3 from CruGlobal/rac_upgrade
Browse files Browse the repository at this point in the history
Rac Database Upgrade
  • Loading branch information
davidhollenberger authored Oct 14, 2016
2 parents 0489120 + 5b2874b commit f8e3f7e
Show file tree
Hide file tree
Showing 12 changed files with 953 additions and 34 deletions.
553 changes: 553 additions & 0 deletions files/catuposb.sql

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions tasks/get_unique_name.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---

- name: Template db_unique_name.sql
template:
src: db_unique_name.j2
dest: "{{ oracle_stage }}/db_unique_name.sh"
mode: 0744
tags: always

- name: Run db_unique_name.sql
shell: ./db_unique_name.sh
args:
chdir: "{{ oracle_stage }}"
creates: db_unique_name.log
environment: "{{ env_old }}"
tags: always

- name: Register Unique name
shell: cat db_unique_name.log
args:
chdir: "{{ oracle_stage }}"
register: db_unique_name_out
tags: always

- name: Set db_unique_name variable
set_fact:
db_unique_name: "{{ db_unique_name_out.stdout_lines[0] }}"
tags: always

- debug: var=db_unique_name
44 changes: 15 additions & 29 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,36 @@
owner: "{{ oracle_user }}"
group: "{{ oracle_group }}"
state: directory

- name: Template db_unique_name.sql
template:
src: db_unique_name.j2
dest: "{{ oracle_stage }}/db_unique_name.sh"
mode: 0744
tags: always

- name: Run db_unique_name.sql
shell: ./db_unique_name.sh
args:
chdir: "{{ oracle_stage }}"
environment: "{{ env_old }}"
register: db_unique_name_out
tags: always

- debug: var=db_unique_name_out.stdout_lines[0]

- name: Set db_unique_name variable
set_fact:
db_unique_name: "{{ db_unique_name_out.stdout_lines[0] }}"
tags: always
- name: Run pre-checks
include: pre_checks.yml
when: master_node
tags:
- always
- pre_checks

- name: get DB Unique Name
include: get_unique_name.yml
when: master_node
tags:
- always
- unique_name

#Run pre-upgrade tasks one day before upgrade
- name: run pre-upgrade tasks
include: pre_upgrade.yml
when: pre_upgrade
when: pre_upgrade and master_node
tags: pre_upgrade

#Upgrade database to 12.1.0.2
- name: upgrade database
include: upgrade.yml
include: upgrade_{{ oracle_install_type }}.yml
when: upgrade
tags: upgrade

#Upgrade Timezone
- name: upgrade timezone
include: upgrade_tzv.yml
when: upgrade_tzv
tags: upgrade_tzv

#Run final upgrade tasks 1 week after upgrading database
- name: final upgrade tasks
include: upgrade_final.yml
include: upgrade_final_{{ oracle_install_type }}.yml
when: upgrade_final
tags: upgrade_final
12 changes: 12 additions & 0 deletions tasks/pre_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---

- name: fail if required variables are not defined
fail: msg="{{ item }} is not defined for {{ ansible_hostname }}"
when: "{{ item }} is not defined"
tags: always
with_items:
- oracle_install_type
- oracle_version
- db_name
- database_parameters[db_name]
- database_parameters[db_name].log_mode
27 changes: 25 additions & 2 deletions tasks/pre_upgrade.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
---

# Fix for slow upgrades - Upgrade to 12c : CATUPOSB.SQL SLOW DURING UPGRADE (Doc ID 2147232.1)
- name: Copy updated catuposb.sql
copy:
src: catuposb.sql
dest: "{{ oracle_home }}/rdbms/admin/"
owner: "{{ oracle_user }}"
group: "{{ oracle_group }}"
mode: 0644

- debug: var=database_parameters[db_name].log_mode

- name: template enable_archivelog (noarchivelog)
Expand All @@ -9,10 +18,17 @@
when: database_parameters[db_name].log_mode == 'noarchivelog'
tags: archivelog

- name: Shutdown database immediate (noarchivelog)
- name: Shutdown database (single instance noarchivelog)
shell: echo "shutdown immediate;" | sqlplus / as sysdba
environment: "{{ env_old }}"
when: database_parameters[db_name].log_mode == 'noarchivelog'
when: database_parameters[db_name].log_mode == 'noarchivelog' and oracle_install_type == 'si'
tags:
- archivelog

- name: Shutdown database (rac, noarchivelog)
shell: srvctl stop database -d {{ db_name }}
environment: "{{ env_old }}"
when: database_parameters[db_name].log_mode == 'noarchivelog' and oracle_install_type == 'rac'
tags:
- archivelog

Expand All @@ -31,6 +47,13 @@
when: database_parameters[db_name].log_mode == 'noarchivelog'
tags: archivelog

- name: Startup database (rac, noarchivelog)
shell: srvctl start database -d {{ db_name }}
environment: "{{ env_old }}"
when: database_parameters[db_name].log_mode == 'noarchivelog' and oracle_install_type == 'rac'
tags:
- archivelog

## Backup Database
- name: template backup script (level 0)
template:
Expand Down
60 changes: 60 additions & 0 deletions tasks/upgrade_final_rac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
#Steps to run 1 Week after upgrading Database
- name: Drop restore point and set compatible parameter
shell: echo "{{ item }};" | sqlplus / as sysdba
register: sqlplus_result
failed_when: "'ERROR' in sqlplus_result.stdout or sqlplus_result.rc != 0"
environment: "{{ env }}"
when: master_node
with_items:
- DROP RESTORE POINT before_upgrade
- alter system set compatible='{{ oracle_version }}' scope=spfile

- name: Shutdown database
shell: srvctl stop database -d {{ db_name }}
environment: "{{ env }}"
when: master_node

- name: Disable Archivelog Mode
shell: echo "{{ item }};" | sqlplus / as sysdba
register: sqlplus_result
failed_when: "'ERROR' in sqlplus_result.stdout or sqlplus_result.rc != 0"
environment: "{{ env }}"
when: master_node and database_parameters[db_name].log_mode == 'noarchivelog'
with_items:
- startup mount
- alter database flashback off
- alter database noarchivelog
- shutdown immediate

- name: Start database
shell: srvctl start database -d {{ db_name }}
environment: "{{ env }}"
when: master_node

- name: Gather fixed object stats
shell: echo "exec DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;" | sqlplus / as sysdba
register: sqlplus_result
failed_when: "'ERROR' in sqlplus_result.stdout or sqlplus_result.rc != 0"
environment: "{{ env }}"
when: master_node

## Backup Database
- name: template final upgrade backup (level 0)
template:
src: final_upgrade_backup_0.j2
dest: "{{ oracle_stage }}/final_upgrade_backup_0.rman"
when: master_node and database_parameters[db_name].log_mode == 'archivelog'
tags: final_upgrade_backup

- name: final upgrade backup (level 0)
shell: rman @{{ oracle_stage }}/final_upgrade_backup_0.rman
environment: "{{ env }}"
async: 7200
poll: 10
when: master_node and database_parameters[db_name].log_mode == 'archivelog'
tags: final_upgrade_backup
register: final_upg

- debug: var=final_upg
tags: final_upgrade_backup
File renamed without changes.
Loading

0 comments on commit f8e3f7e

Please sign in to comment.