Sunday, April 14, 2013

DBMS_REPAIR SCRIPT - ORA-26040: Data block was loaded using the NOLOGGING option

Applies to:
Oracle Server - Enterprise Edition - Version 8.1.5.0 to 11.2.0.3 [Release 8.1.5 to 11.2]
Purpose
This script is intended to provide a simple and quick way to run DBMS_REPAIR to identify and skip corrupted blocks
Script
REM Create the repair table in a given tablespace:

BEGIN
  DBMS_REPAIR.ADMIN_TABLES (
  TABLE_NAME => 'REPAIR_TABLE',
  TABLE_TYPE => dbms_repair.repair_table,
  ACTION => dbms_repair.create_action,
  TABLESPACE => '&tablespace_name');
END;
/ 

REM Identify corrupted blocks for schema.object:

set serveroutput on
DECLARE num_corrupt INT;
BEGIN
  num_corrupt := 0;
  DBMS_REPAIR.CHECK_OBJECT (
  SCHEMA_NAME => '&schema_name',
  OBJECT_NAME => '&object_name',
  REPAIR_TABLE_NAME => 'REPAIR_TABLE',
  corrupt_count => num_corrupt);
  DBMS_OUTPUT.PUT_LINE('number corrupt: ' || TO_CHAR (num_corrupt));
END;
/

REM Optionally display any corrupted block identified by check_object:

select BLOCK_ID, CORRUPT_TYPE, CORRUPT_DESCRIPTION 
from REPAIR_TABLE;

REM Mark the identified blocks as corrupted

DECLARE num_fix INT;
BEGIN
  num_fix := 0;
  DBMS_REPAIR.FIX_CORRUPT_BLOCKS (
  SCHEMA_NAME => '&schema_name',
  OBJECT_NAME=> '&object_name',
  OBJECT_TYPE => dbms_repair.table_object,
  REPAIR_TABLE_NAME => 'REPAIR_TABLE',
  FIX_COUNT=> num_fix);
  DBMS_OUTPUT.PUT_LINE('num fix: ' || to_char(num_fix));
END;
/

REM Allow future DML statements to skip the corrupted blocks:

BEGIN
  DBMS_REPAIR.SKIP_CORRUPT_BLOCKS (
  SCHEMA_NAME => '&schema_name',
  OBJECT_NAME => '&object_name',
  OBJECT_TYPE => dbms_repair.table_object,
  FLAGS => dbms_repair.SKIP_FLAG);
END;
/

Notes:

  • Recreate indexes after using DBMS_REPAIR as INDEX scan may produce errors if accessing the corrupt block. If there is an unique index, then reinserting the same data may also produce error ORA-1.
  • Use the dbms_repair.NOSKIP_FLAG in the FLAGS value in procedure SKIP_CORRUPT_BLOCKS if it is needed to stop skipping corrupt blocks in the object after the dbms_repair.SKIP_FLAG was used. 
  • If the goal is to skip the corrupt blocks for a specific object, it is just needed to run procedure SKIP_CORRUPT_BLOCKS. Only blocks producing ORA-1578 will be skipped in that case. If different errors are produced then it is required to run these additional procedures: ADMIN_TABLES, CHECK_OBJECT and FIX_CORRUPT_BLOCKS 
  • If it is needed to clear a table from corruptions and after using procedure SKIP_CORRUPT_BLOCKS, the table can be moved with: "alter table MOVE" instead of recreating or truncating it. Then use the dbms_repair.NOSKIP_FLAG described above. Note that the data inside the corrupt blocks is lost.
Reference: 
DBMS_REPAIR SCRIPT [ID 556733.1]

Monday, April 1, 2013

How to edit template's blogger



...insert code here...
...insert code here...
Reference: http://alexgorbatchev.com/SyntaxHighlighter/manual/configuration

How to use encrypted password in JBoss EAP 6 datasource


In order to use encrypted password in EAP 6 datasource follow the bellow mentioned steps:
Step-1). Encrypt the database password by running the following script:
JBOSS_HOME=/apps/jboss-jpp-6.0
echo "Please enter the password to be encrypted"
read password
java -cp $JBOSS_HOME/modules/org/picketbox/main/picketbox-4.0.14.Final-redhat-3.jar:$JBOSS_HOME/modules/org/picketbox/main/picketbox-commons-1.0.0.final-redhat-2.jar:$JBOSS_HOME/modules/org/picketbox/main/picketbox-infinispan-4.0.14.Final-redhat-2.jar:$JBOSS_HOME/modules/org/jboss/logging/main/jboss-logging-3.1.2.GA-redhat-1.jar org.picketbox.datasource.security.SecureIdentityLoginModule $password
Step-2). In your JBoss configuration file like "standalone.xml", "standalone-full.xml", "domain.xml"...etc in the [subsystem xmlns="urn:jboss:domain:security:1.2"] subsystem create a by specifying the encrypted database password as following:

 
  
    
    
    
  
 

Step-3). Create a DataSource like following by specifying the rather than passing the cleartext username & password:

  jdbc:mysql://localhost:3306/testDB
  com.mysql.jdbc.Driver
  mysql-connector-java-5.1.13-bin.jar
  
   encryptedSecurityDomain
  

Step-4). Restart your JBoss EAP6 and then with the help of CLI utility you can test your DataSource as following:
In Standalone mode:
[standalone@localhost:9999 /] /subsystem=datasources/data-source=MySqlDS_Pool:test-connection-in-pool { "outcome" => "success", "result" => [true] } Reference : https://access.redhat.com/knowledge/solutions/184963


Wednesday, March 27, 2013

How to Change DBSNMP Password in Database 10g and 11g Monitored by DB Control

To change the password of the user DBSNMP you must strictly follow the steps below, otherwise the 10g or 11g DB Control used to manage your database will not function properly.

1. Stop the standalone dbconsole
On Unix - DB Control Release up to 11.1.x
$ export ORACLE_SID=
$ emctl stop dbconsole

On Unix - DB Control Release 11.2.x and higher
$ export ORACLE_SID=
$ export ORACLE_UNQNAME=

$ emctl stop dbconsole
On Windows - DB Control Release up to 11.1.x
Stop the Windows Service OracleDBConsole orOpen a DOS Command Window and type
C:> set ORACLE_SID=
C:> set ORACLE_HOME=

C:> cd %ORACLE_HOME%/bin
C:> emctl stop dbconsole
On Windows - DB Control Release 11.2.x and higher
Stop the Windows Service OracleDBConsole or Open a DOS Command Window and type
C:> set ORACLE_SID=
C:> set ORACLE_UNQNAME=

C:> set ORACLE_HOME=

C:> cd %ORACLE_HOME%/bin
C:> emctl stop dbconsole

Check that the DB Control is stopped
On Unix
$ emctl status dbconsole
On Windows
Check the status of the Windows Service OracleDBConsole or Open a DOS Command Window, cd to the database $ORACLE_HOME\bin and type
emctl status dbconsole 

Connect to the database as a user with DBA privilege with SQL*Plus and execute
alter user dbsnmp identified by ;
Check the new password
SQL> connect dbsnmp/[@database_alias]
Go to $ORACLE_HOME/host_sid/sysman/emd, Save the file targets.xml to targets.xml.orig, Edit the file targets.xml with your favorite text editor
Search for the line: encrypted_string
>" encrypted="TRUE">
       Replace the encrypted value by the new password value
       Replace TRUE by FALSE

Restart the standalone dbconsole
On Unix - DB Control Release up to 11.1.x
$ export ORACLE_SID=
$ emctl start dbconsole
On Unix - DB Control Release 11.2.x and higher
$ export ORACLE_SID=
$ export ORACLE_UNQNAME=
$ emctl start dbconsole

On Windows - DB Control Release up to 11.1.x
Start the Windows Service OracleDBConsole
Or
Open a DOS Command Window and type
set ORACLE_SID=
set ORACLE_HOME=
cd %ORACLE_HOME%/bin
emctl start dbconsole 

On Windows - DB Control Release 11.2.x and higher
Start the Windows Service OracleDBConsole
Or
Open a DOS Command Window and type
set ORACLE_SID=
set ORACLE_UNQNAME=
set ORACLE_HOME=
cd %ORACLE_HOME%/bin
emctl start dbconsole 

Check that the password has been encrypted
Edit the file targets.xml
Search for the line: 
Check that the password VALUE is encrypted
Check that the value of ENCRYPTED is TRUE

Note: In case of RAC DB, the dbsnmp password should be changed in targets.xml not only for instances(oracle_database), but also for rac_database target. The file targets.xml needs to be updated on all the RAC Cluster nodes.
References

How to query multiple LDAP authentication sources in JBoss EPP 5.2?



Issue

· Is it possible to query multiple LDAP authentication sources in EPP 5.2?

· Are there any known limitations to this feature?

Environment

· JBoss Enterprise Portal Platform (EPP) 5.2

Resolution

Yes it is possible to query multiple LDAP servers in JBoss EPP 5.2. Follow the steps below to configure multiple LDAP resources for users:

Step 1: Configure multiple identityStore with different providerURL pointing to different LDAP servers. An example configuration given below:


        PortalLDAPStore1
        org.picketlink.idm.impl.store.ldap.LDAPIdentityStoreImpl
        
        
          JBOSS_IDENTITY_MEMBERSHIP
        
        
          
            USER
            ...
          
          
            otherobject
            ...
          
        
        
          
          ...
         
      
      
        PortalLDAPStore2
        ...
         
          
          ...
         
      


Step 2: Map the identity store in repository configuration. An example provided below:


    PortalRepository
    org.picketlink.idm.impl.repository.FallbackIdentityStoreRepository
    
    
    HibernateStore
    HibernateStore
    
        
            PortalLDAPStore1
            
                USER
                otherobject
            
            
        
        
            PortalLDAPStore2
            
                USER
                ...
            
            
        
    
    
        
    


Please note there is one limitation with this feature. The same user cannot be in multiple LDAP servers. In other words, if there is a UID uniqueness among the LDAP servers, then it should be fine to query users from multiple LDAP resources.

How To Change the Password of the Database User Sysman

Database Release prior 10.2.0.4

The Oracle user SYSMAN is the schema of the standalone repository of the Enterprise Manager DB Control.

To ensure that you change the SYSMAN password in the right database, you must check that the environment variable ORACLE_SID is set.
You must also check that the environment variable ORACLE_HOME is set and that the path includes the correct $ORACLE_HOME/bin.

To change the password of the user sysman you must strictly follow the steps below, otherwise your DB Control used to manage your database will not function properly.
Stop the DB Control
On Unix
$ emctl stop dbconsole
On Windows
Stop the Windows Service OracleDBConsole or Open a Command Window and type
C:> emctl stop dbconsole

Check that the DB Control is stopped
On Unix
$ emctl status dbconsole
On Windows
Check the status of the Windows Service OracleDBConsole or Open a DOS Command Window and type
C:> emctl status dbconsole
Connect to the database as a user with DBA privilege with SQL*Plus and execute:
SQL> alter user sysman identified by ;
Example:
SQL> alter user sysman identified by rainbow ;
Check the new password
SQL> connect sysman/[@database_alias]
Example:
SQL> connect sysman/rainbow@DBRH
Go to $ORACLE_HOME/host_sid/sysman/config, Save the file emoms.properties to emoms.properties.orig Edit the file emoms.properties, Search for the line beginning with:
oracle.sysman.eml.mntr.emdRepPwd=Replace the encrypted value by the new password value
Example:
oracle.sysman.eml.mntr.emdRepPwd=rainbow
Search for the line:
oracle.sysman.eml.mntr.emdRepPwdEncrypted=TRUE
Replace TRUE by FALSE
Restart the DB Control
On Unix
$ emctl start dbconsole
On Windows
Start the Windows Service OracleDBConsole or Open a DOS Command Window and type
C:> emctl start dbconsole
Check that the password has been encrypted, Edit the file $ORACLE_HOME/host_sid/sysman/config/emoms.properties, Search for the line beginning with:
oracle.sysman.eml.mntr.emdRepPwd=Check that the password is encrypted
Search for the line beginning with:
oracle.sysman.eml.mntr.emdRepPwdEncrypted=Check that the value is TRUE
Database Release beginning 10.2.0.4
The Oracle user SYSMAN is the schema of the standalone repository of the Enterprise Manager DB Control.
To ensure that you change the SYSMAN password in the right database, you must check that the environment variable ORACLE_SID is set.

For the DB Control Release 11.2 and higher
you need to set the environment variable ORACLE_UNQNAME to the value of the DB_UNIQUE_NAME database parameter.

You must also check that the environment variable ORACLE_HOME is set and that the path includes the correct $ORACLE_HOME/bin.

To change the password of the user sysman you must strictly follow the steps below, otherwise your DB Control used to manage your database will not function properly.
1. Stop the DB Control
On Unix
$ emctl stop dbconsole
On Windows
Stop the Windows Service OracleDBConsole or Open a Command Window and type
C:> emctl stop dbconsole
2. Check that the DB Control is stopped
On Unix
$ emctl status dbconsole
On Windows
Check the status of the Windows Service OracleDBConsole or Open a DOS Command Window and type
C:> emctl status dbconsole
Connect to the database as a user with DBA privilege with SQL*Plus and execute:

SQL> alter user sysman identified by ;
Check the new password

SQL> connect sysman/[@database_alias]
From the database directory $ORACLE_HOME/bin, execute:
On Unix
$ emctl setpasswd dbconsole
Provide the new SYSMAN password
On Windows
C:> emctl setpasswd dbconsole
Provide the new SYSMAN password
3.Restart the DB Control
On Unix
$ emctl start dbconsole
On Windows
Start the Windows Service OracleDBConsole or Open a DOS Command Window and type
C:> emctl start dbconsole


Reference to Oracle support: [ID 259379.1]

Tuesday, January 29, 2013

Script to housekeeping log files


Script to housekeeping log files

#!/bin/sh
DIR_LIST="/opt/app/oracle/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace /opt/app/oracle/admin/$ORACLE_SID/adump /opt/app/grid/product/11.2/grid/rdbms/audit /opt/app/grid/diag/asm/+asm/+ASM/trace"
PATTERN="*\.aud || *\.trc"
for DIR in $DIR_LIST
do
  filename=$DIR/`date +%Y%m%d`.tar.gz
  echo echo $filename
  `/usr/bin/find $DIR -iname "*\.aud" -o -iname "*\.trc" -o -iname "*\.trm" -daystart -mtime -31 | xargs tar czPf $filename --remove-files`
done

Monday, January 28, 2013

Setup Postfix & Sendmail


1. setup mailx

Create file .mailrc in the user home directory as below

vi ~/.mailrc as below
#set smtp-use-starttls
#set nss-config-dir=~/.mozilla/firefox/xxxxxxxx.default/
#set ssl-verify=ignore
set smtp=smtp://smtp.gmail.com:465
#set smtp-auth=login
#set smtp-auth-user=$FROM_EMAIL_ADDRESS
#set smtp-auth-password=$EMAIL_ACCOUNT_PASSWORD
set from="gmailaccount@gmail.com"

2. Test send email
echo "Test Mail - `date`" | mailx -s "Database Alerts" gmailacc@gmail.com

3. Create SMTP Server Relay using postfix
Edit file /etc/postfix/main.cf as below


# readme_directory: The location of the Postfix README files.
#
readme_directory = /usr/share/doc/packages/postfix/README_FILES
inet_protocols = all
biff = no
mail_spool_directory = /var/mail
canonical_maps = hash:/etc/postfix/canonical
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_alias_domains = hash:/etc/postfix/virtual
relocated_maps = hash:/etc/postfix/relocated
transport_maps = hash:/etc/postfix/transport
sender_canonical_maps = hash:/etc/postfix/sender_canonical
masquerade_exceptions = root
masquerade_classes = envelope_sender, header_sender, header_recipient
myhostname = localhost
program_directory = /usr/lib/postfix
inet_interfaces = all
masquerade_domains =
mydestination = $myhostname, localhost.$mydomain
defer_transports =
mynetworks_style = subnet
mynetworks = 192.168.0
disable_dns_lookups = no
relayhost = smtp.gmail.com
mailbox_command =
mailbox_transport =
strict_8bitmime = no
disable_mime_output_conversion = no
smtpd_sender_restrictions = hash:/etc/postfix/access
smtpd_client_restrictions =
smtpd_helo_required = no
smtpd_helo_restrictions =
strict_rfc821_envelopes = no
smtpd_recipient_restrictions = permit_mynetworks,reject_unauth_destination
smtp_sasl_auth_enable = no
smtpd_sasl_auth_enable = no
smtpd_use_tls = no
smtp_use_tls = no
alias_maps = hash:/etc/aliases
mailbox_size_limit = 0
message_size_limit = 10240000
myorigin = gmail.com

Monday, January 14, 2013

ORA-00845: MEMORY_TARGET not supported on this system

Symptoms

During the startup of database instance the following error is raised:

SQL> connect sys as sysdba
Enter password:
Connected to an idle instance.
SQL> STARTUP NOMOUNT
ORA-00845: MEMORY_TARGET not supported on this system

Cause
The new AMM functionality uses /dev/shm on Linux for SGA and PGA management. The error occur if either MEMORY_TARGET or MEMORY_TARGET is configured larger than the configured /dev/shm size, or if /dev/shm is mounted incorrectly.
Solution
Please confirm that ORACLE_HOME is set correctly. This error sometimes happens when it is not set correctly.
Make sure that the /dev/shm size configured large enough, like in:
# mount -t tmpfs shmfs -o size=12g /dev/shm
In this case the size of the shared memory device is configured to be 12GB.
In order to make the same change persistent across system reboots, add an entry for this to the /etc/fstab mount table, as in:
shmfs /dev/shm tmpfs size=12g 0
Make sure that the df output shows the correct /dev/shm configuration when using Oracle on the system:
$ df -k
Filesystem 1K-blocks Used Available Use% Mounted on
...
shmfs 6291456 832356 5459100 14% /dev/shm

How do restrict or modify size of /dev/shm permanently?
You need to add or modify entry in /etc/fstab file so that system can read it after the reboot.
To changes to take effect immediately remount /dev/shm.
# mount -o remount /dev/shm