ORA-00845: MEMORY_TARGET not supported on this system

While creating a startup database using dbca the database creation GUI gives error message in a pop up window,
ORA-00845: MEMORY_TARGET not supported on this system
from where you can ignore the error message.
The similar scenario also occur whenever you try to start your database then startup shows error message like below. 

SQL> STARTUP
ORA-00845: MEMORY_TARGET not supported on this system

Cause of the Problem
•Starting from Oracle 11g the automatic memory management feature is now defined with parameter MEMORY_TARGET and MEMMORY_MAX_TARGET.

•On linux file system the shared memory need to be mounted on /dev/shm directory on the operating system.

•And the size of /dev/shm needs to be greater than MEMORY_TARGET or MEMMORY_MAX_TARGET.

•The AMM (Automatic Memory Management) now in 11g manages both SGA and PGA together by MMAN process.

•The MEMORY_TARGET parameter in 11g comes for (SGA_TARGET+PGA_AGGREGATE_TARGET) which was in 10g.

•And MEMORY_MAX_TARGET parameter in 11g comes instead of SGA_MAX_TARGET parameter which was in 10g.

•The ORA-00845:can arises for the following two reasons on linux system.

  1. If the shared memory which is mapped to /dev/shm directory is less than the size of MEMORY_TARGET or MEMORY_MAX_TARGET.
    or,
  2. If the shared memory is not mapped to /dev/shm directory.

Solution
Make sure /dev/shm is properly mounted. You can see it by,
#df -h or #df -k command.
The output should be similar like
$ df -k
Filesystem            Size  Used Avail Use% Mounted on

shmfs                 1G    512M 512M  50% /dev/shm

We see here for /dev/shm we have assigned 1G memory. Now if you set MEMORY_TARGET more than 1G then above ORA-845 will arise. For example if you have MEMORY_TARGET or MEMORY_MAX_TARGET set to 12G then you can mount shared memory to 13g like below.
As a root user,
# mount -t tmpfs shmfs -o size=13g /dev/shm
In order to make the settings persistence so that it will affect after restarting machine add an entry in /etc/fstab similar to the following:

shmfs /dev/shm tmpfs size=13g 0

Remote Root Access to MySql

Set a root password.

mysql -u root
mysql> SET PASSWORD FOR ‘ROOT’@’LOCALHOST”
> = PASSWORD(‘new_password’);

Create a new HOST for root and allow root to login from anywhere.

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’
> IDENTIFIED BY ‘password’ WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> exit

Allow remote logins.

sudo vi /etc/mysql/my.cnf

Out-of-the-box, MySQL only allows connections from the localhost identified by the IP Address of 127.0.0.1.  We need to remove that restriction, so find the line that says

bind-address = 127.0.0.1

and comment it out.

Oracle em not working due to expired passwords

Ensure that ORACLE_HOME is set to the correct home

1. Stop the standalone dbconsole
on Unix
$ emctl stop dbconsole
on Windows
Stop the Windows Service Oracle<oracle_home_name>DBConsole
Or
Open a DOS Command Window and type
C> emctl stop dbconsole

2. Check that the standalone dbconsole is stopped
on Unix
$ emctl status dbconsole
on Windows
Check the status of the Windows Service Oracle<oracle_home_name>DBConsole
Or
Open a DOS Command Window and type
C> emctl status dbconsole

3. Connect to the database as a user with DBA privilege with SQL*Plus
and execute
SQL> alter user sysman identified by <new_password> ;

4. Check the new password
SQL> connect sysman/<new_password>[@database_alias]

5. Go to $ORACLE_HOME/host_sid/sysman/config
5.1 Save the file emoms.properties to emoms.properties.orig
5.2 Edit the file emoms.properties
a. Search for the line beginning with:
oracle.sysman.eml.mntr.emdRepPwd=
Replace the encrypted value by the new password value
b. Search for the line:
oracle.sysman.eml.mntr.emdRepPwdEncrypted=TRUE
Replace TRUE by FALSE

6. Restart the standalone dbconsole
on Unix
$ emctl start dbconsole
on Windows
Start the Windows Service Oracle<oracle_home_name>DBConsole
Or
Open a DOS Command Window and type
C> emctl start dbconsole

7. Check that the password has been encrypted
Edit the file emoms.properties
7.1 Search for the line beginning with:
oracle.sysman.eml.mntr.emdRepPwd=
Check that the password is encrypted
7.2 Search for the line beginning with:
oracle.sysman.eml.mntr.emdRepPwdEncrypted=
Check that the value is TRUE

Reinstall Grub

Boot your Helena live CD
* Open a terminal – Applications, Accessories, Terminal.
* Determine your normal system partition – `sudo fdisk -l` (That is a lowercase L)
* If you aren’t sure, run `df -Th`. Look for the correct disk size and ext3 or ext4 format.
* Mount your normal system partition:

sudo mount /dev/sdXY /mnt

- Example: sudo mount /dev/sda1 /mnt
- Note: substitue the correct partition: sda1, sdb5, etc.
- Note: GRUB 2 counts the first drive (X) as “0″, but the first partition (Y) as “1″

* Only if you have a separate boot partition:

sudo mount /dev/sdXY /mnt/boot

- with sdXY being your /boot partition designation.

* Reinstall GRUB 2:

sudo grub-install –root-directory=/mnt /dev/sdX

- Example: sudo grub-install –root-directory=/mnt /dev/sda
- Note: Substitute the correct device – sda, sdb, etc. Do ”not” specify a partition number.

* Unmount the partition:

sudo umount /mnt

* Reboot.

Reorder partition drive numbers in linux

Open a terminal and type

sudo fdisk -l

That’s a lowercase “L”. This will list storage devices in alphanumeric order. Look through the data reported and note the name of any devices that are listed out of numerical order.

To reorder the Linux drive partition numbers for device sdc, all we need to do is open a terminal…

  • type
    sudo fdisk /dev/sdc
  • then
    • press “x” to enter Expert Mode
    • press “f” to fix the drive order
    • press “i” to ignore the warning (if it shows)
    • press “w” to write changes to the disk
    • press “q” to  quit fdisk

 

Apache log rotation on Linux

A tool called logrotate can be used for rotating log files. It is a generic tool can can be configured to handle any log generated by any service.

The main configuration file of logrotate is /etc/logrotate.conf from where it picks up default setup.

It then reads service specific instructions from /etc/logrotate.d directory

The apache logrotate configuration is /etc/logrotate.d/httpd

/var/log/httpd/*log {
daily
rotate 7
compress
missingok
notifempty
sharedscripts
create 644 root root
postrotate
/sbin/service httpd reload > /dev/null 2>/dev/null || true
endscript
}