Saturday, August 30, 2014

ORA-28031 error

Note Id "What to Check When Dealing With Ora-28031: Maximum Of 148 Enabled Roles Exceeded? (Doc ID 778785.1)" explains this well

#1. One must check first the number of roles granted to a user or role. It is useful to know that, with the sole exception of IDENTIFIED GLOBALLY roles, as documented, the roles created by a user are automatically granted to that user.
Check the number of roles that have been granted to all users and roles, using the following query:

This query should indicate the number of roles that have been granted to all users, including roles that have been granted via roles.
select "Grantee", count(*) "Role Number" from
(
select distinct connect_by_root grantee "Grantee", granted_role
from dba_role_privs
connect by prior granted_role=grantee
)
group by "Grantee"
order by "Grantee","Role Number"
/ 
Equally helpful could be the following query, returning the roles that have been granted to a specific user:


select distinct connect_by_root grantee,granted_role
from dba_role_privs
connect by prior granted_role=grantee
start with grantee='';

Keeping in mind, as seen at:
MAX_ENABLED_ROLES
documentation page, that the number of enabled roles for a user cannot be larger than 148, if any of the above users has more than 148 roles enabled, some policy should be envisaged so that the roles are not be enabled all at once.

Of course, the easiest thing that can be done is to reset the number of default roles for the user, as indicated at the ALTER USER documentation page:
alter user default roles ;

The list of roles can be: an explicit list of roles, all roles or all roles except .

Sometimes, it happens that sessions running as SYS (this is mostly common in job sessions) fail with the ORA-28031 and the user SYS has indeed more than 148 roles. However, normal sessions don't have any problems connecting and running commands in the database.
The SYS user does not require all the roles that have been defined in the database. Simply set DBA as the only default role for sys:

alter user SYS default roles DBA;

and this should eliminate the error when running statistics taking jobs or advisories.

The most difficult scenario to address situation is when the application enables or disables roles and, for some reasons, the number of jobs defined for a user surpasses 148. In this situation, the application must be checked and commands like:
set roles all;
or
execute dbms_session.set_role('ALL');

should be replaced with commands enabling only specific roles, which are, of course, less than 148.

Wednesday, August 6, 2014

TO FIND ORACLE HOME WITH FROM SQL PROMPT

1ST WAY

SQL> select file_spec from dba_libraries where library_name='ORDIMLIBS';

FILE_SPEC
------------------------------------------------------------
/u01/app/oracle/product/1110/dbhome/lib/libordim11.so



2ND WAY

SQL> host echo $ORACLE_HOME
/opt/oracle/product/10.2.0/db_1

Tuesday, June 24, 2014

how to tail alert log in adrci

==> adrci

ADRCI: Release 11.2.0.3.0 - Production on Tue Jun 24 20:28:32 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

ADR base = "/opt/app/oracle"
adrci>  show homes
ADR Homes:
diag/asm/+asm/+ASM
diag/asmtool/user_oracle/host_2740023319_80
diag/diagtool/user_oracle/host_2740023319_11
diag/tnslsnr/server/listener
diag/rdbms/dbname/DBNAME
diag/clients/user_oracle/host_2740023319_11
adrci> set homes diag/rdbms/dbname/DBNAME
adrci> show alert -tail -f
2014-06-24 12:08:41.139000 +00:00

Thursday, June 5, 2014

sql for sizes

1. Top 10 segments


SELECT * FROM
(
select 
    SEGMENT_NAME, 
    SEGMENT_TYPE, 
    BYTES/1024/1024/1024 GB, 
    TABLESPACE_NAME 
from 
    dba_segments
order by 3 desc  
) WHERE
ROWNUM >= 10;

Thursday, May 22, 2014

How to install and execute latest Exacheck


Step1 : Download the latest exacheck from this node "Oracle Exadata Database Machine exachk or HealthCheck (Doc ID 1070954.1)"


Step 2: Create the directory on the server which you want to use as Exacheck directory and copy the downloaded file there. 
 i use naming convention like exachk_224, exchk_225_beta


Step 3: Unzip the bundle
==> unzip exachk_225_BETA_bundle.zip
Archive:  exachk_225_BETA_bundle.zip
  inflating: exachk.zip
  inflating: ExachkBestPracticeChecks_v225_BETA.pdf
  inflating: ExachkFeatureFixHistory_v225_BETA.pdf
  inflating: ExachkUserGuide_v225_BETA.pdf
  inflating: exachk_dbm_maa_public.html
  inflating: exachk_dbm_post-upgrade_public.html
  inflating: exachk_dbm_pre-upgrade_public.html
  inflating: exachk_diff_sample_report_public.html
  inflating: exachk_profile_sysadmin_sample_public.html

  inflating: md5sums.txt

Step 4:Unzip the exachk.zip
==> unzip exachk.zip
Archive:  exachk.zip
   creating: .cgrep/
  inflating: .cgrep/auto_upgrade_check.pl
  inflating: .cgrep/ggdiscovery.sh
  inflating: .cgrep/create_version.pl
  inflating: .cgrep/scgrepx86
  inflating: .cgrep/scgrep
  inflating: .cgrep/checkDiskFGMapping.sh
  inflating: .cgrep/exalogic_zfs_checks.aksh
  inflating: .cgrep/auto_upgrade.pl
  inflating: .cgrep/asrexacheck
  inflating: .cgrep/utlusts.sql
  inflating: .cgrep/utlu112i.sql
  inflating: .cgrep/oracle-upstarttmpl.conf
  inflating: .cgrep/lcgrep3
  inflating: .cgrep/init.tmpl
   creating: .cgrep/profiles/
  inflating: .cgrep/profiles/F6AFECA37F177C3FE04313C0E50A56BF.prf
  inflating: .cgrep/profiles/D49B218473787400E0431EC0E50A0BB9.prf
  inflating: .cgrep/profiles/DF65D0F7FB6F1014E04312C0E50A7808.prf
  inflating: .cgrep/profiles/D49C0AB26A6D45A8E0431EC0E50ADE06.prf
  inflating: .cgrep/profiles/D49C4F9F48735396E0431EC0E50A9A0B.prf
  inflating: .cgrep/profiles/DFE9C207A8F2428CE04313C0E50A6B0A.prf
  inflating: .cgrep/profiles/D49BDC2EC9E624AEE0431EC0E50A3E12.prf
  inflating: .cgrep/profiles/DF65D6117CB41054E04312C0E50A69D1.prf
  inflating: .cgrep/profiles/D8367AD6754763FEE04312C0E50A6FCB.prf
  inflating: .cgrep/profiles/DA94919CD0DE0913E04312C0E50A7996.prf
  inflating: .cgrep/profiles/D49C0FBF8FBF4B1AE0431EC0E50A0F24.prf
 extracting: .cgrep/profiles/F13E11974A282AB3E04312C0E50ABCBF.prf
  inflating: .cgrep/profiles/EF6C016813C51366E04313C0E50AE11F.prf
  inflating: .cgrep/profiles/F32F44CE0BCD662FE04312C0E50AB058.prf
  inflating: .cgrep/profiles/E2E972DDE1E14493E04312C0E50A1AB1.prf
  inflating: .cgrep/profiles/D49AD88F8EE75CD8E0431EC0E50A0BC3.prf
  inflating: .cgrep/profiles/E8DF76E07DD82E0DE04313C0E50AA55D.prf
  inflating: .cgrep/profiles/EA5EE324E7E05128E04313C0E50A4B2A.prf
  inflating: .cgrep/profiles/E1BF012E8F210839E04313C0E50A7B68.prf
  inflating: .cgrep/profiles/D462A6F7E9C340FDE0431EC0E50ABE12.prf
  inflating: .cgrep/pxhcdr.sql
  inflating: .cgrep/diff_collections.pl
  inflating: .cgrep/utluppkg.sql
  inflating: .cgrep/versions.dat
  inflating: .cgrep/profiles.dat
  inflating: .cgrep/rack_comparison.py
  inflating: .cgrep/raw_data_browser.pl
  inflating: .cgrep/lcgrep6
  inflating: .cgrep/check_reblance_free_space.sql
  inflating: .cgrep/psqlplus
  inflating: .cgrep/show_file_in_html.pl
  inflating: .cgrep/reset_crshome.pl
  inflating: .cgrep/CollectionManager_App.sql
  inflating: .cgrep/preupgrd.sql
  inflating: .cgrep/ogghc_11203.sql
  inflating: .cgrep/merge_collections.pl
  inflating: .cgrep/scnhealthcheck.sql
  inflating: .cgrep/ogghc_11204.sql
  inflating: .cgrep/lcgrep5
  inflating: .cgrep/ogghc_12101.sql
  inflating: exachk
  inflating: UserGuide.txt
  inflating: readme.txt
  inflating: CollectionManager_App.sql
  inflating: rules.dat

  inflating: collections.dat


Step 5: Execute the script ./exachk


==> ./exachk

CRS stack is running and CRS_HOME is not set. Do you want to set CRS_HOME to /u01/app/11.2.0/grid?[y/n][y]y


Checking ssh user equivalency settings on all nodes in cluster


It will check all the database running and and then ask for ROOT  password for compute node and cell node
once it finishes execution


It comes back with detailed HTML report and zipped files. 











how to install oracle apex




























SQL> @apxldimg.sql /opt/app/apex

PL/SQL procedure successfully completed.


PL/SQL procedure successfully completed.

. Loading images directory: /opt/app/apex/apex/images

Directory created.


PL/SQL procedure successfully completed.


PL/SQL procedure successfully completed.


PL/SQL procedure successfully completed.


Commit complete.


Directory dropped.

timing for: Load Images
Elapsed: 00:00:31.67

Thursday, May 15, 2014

VI , sed and Awk command for DBA

1.Remove lines with SQL> from a file

sed --in-place '/SQL> select/d' test.sql

for f in *.sql;
do
sed --in-place '/SQL>/d' "$f";
done




2.remove empty lines from a files

sed -i '/^\s*$/d' file