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