Wednesday, March 07, 2018

Datapatch CDB / PDB hits prereq checks failed

Symptom:

     When we patch PSU on CDB / PDB , we need to ./datapatch -verbose under Opatch

     It reports
      Error: prereq checks failed!
  patch 21555660: The database must be in upgrade mode

Reason:

     Patch 21555660 (Database PSU 12.1.0.2.5, Oracle JavaVM Component ) is not in place of CDB/PDBs. It needs outages to upgrade this OJVM to pass thorough.

     Check both CDB and PDBs for that as the component applies to each PDBs

    sql: select comp_name, version from  dba_registry where comp_name like   '%JAVA Virtual Machin%' and status = 'VALID';

Solution:

If it is CDB$ROOT
  alter system set cluster_database=false scope=spfile;
  startup upgrade
  rerun datapatch
  alter system set cluster_database=true scope=spfile;
  startup

If it is PDB$SEED or other PDB
    alter pluggable database <PDB>  open upgrade;
    rerun datapatch
    alter pluggable database <PDB>  close immediate;
    alter pluggable database <PDB> open;

Tuesday, March 06, 2018

Datapatch CDB / PDB hits ORA-01652 Error

Symptom:

     When we patch PSU on CDB , we need to ./datapatch -verbose under Opatch

     It reports
      DBD::Oracle::st bind_param failed: ORA-01652: unable to extend temp segment by 128 in tablespace TEMP

Reason:

     Datapatch is expected to patch all open PDBs in the CDB which includes PDB$SEED. Our application based PDBs are with enough TEMP . Unfortunately  PDB$SEED does not have much by default

Solution:

     Login PDB$SEED ,add 500m tempfile manually.

Monday, March 05, 2018

Note on Ansible Shell

Symptom :
   Always get below when we use variable in ansible playbook. It turns out we use |  to work around it.

Error Code:
tasks:
   - name: display databases in the GI via srvctl
     shell:   "{{ srvctl_locl }}" config database
     register: dblist
   - debug: msg="{{ dblist.stdout_lines }}"


Error Stack:
The offending line appears to be:

   - name: display databases in the GI via srvctl
     shell: '{{srvctl_locl }}' config database
                               ^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes.  Always quote template expression brackets when they
start a value. For instance:

    with_items:
      - {{ foo }}

Should be written as:

    with_items:
      - "{{ foo }}"

exception type: <class 'yaml.parser.ParserError'>
exception: while parsing a block mapping
  in "<unicode string>", line 16, column 6
did not find expected key
  in "<unicode string>", line 17, column 32

 
Solution:

tasks:
   - name: display databases in the GI via srvctl
     shell: |
         "{{ srvctl_locl }}" config database
     register: dblist
   - debug: msg="{{ dblist.stdout_lines }}"



Other ansible Tip:

- name: use loop control to display a specific attribute  of item ie stdout_lines ,std_err, start etc
     command: sleep 1
     with_items: "{{dbstatus.results }}"
     loop_control:
          label: "{{ item.stdout_lines }}" 

Sunday, March 04, 2018

Ansible Nested With_Items in Debug module

Use srvctl to list and display all Oracle DB instance status on the host

tasks:
   - name: display databases in the GI via srvctl
     shell: /u01/app/11.2.0.4/grid/bin/srvctl config database
     register: dblist
   - debug: msg="{{ dblist.stdout_lines }}"

   - name: display status of databases in the GI via srvctl
     shell:  /u01/app/11.2.0.4/grid/bin/srvctl status database -d  "{{ item }}"
     register: dbstatus
     with_items:
        - "{{ dblist.stdout_lines }}"
   - debug: msg="{{ item.stdout_lines }}"
     with_items:
        - "{{ dbstatus.results }}"

Wget With Proxy and Egrep

use -e for wget to use proxy

wget "https://rpmfind.net/linux/centos/7.4.1708/extras/x86_64/Packages/python2-jmespath-0.9.0-3.el7.noarch.rpm" -e  use_proxy=yes -e https_proxy=testproxy.test.com:80

egrep -v 'str one|str two' test.log

ps -few|grep pmon|egrep -v 'grep|MGM'|awk -F" " '{print $8}'|cut -d_ -f3