The root of the problem
The
ORA-00845 error in Oracle Database occurs when the Linux operating system cannot allocate enough shared memory (
/dev/shm) to satisfy the
MEMORY_TARGET or
MEMORY_MAX_TARGET parameters defined in the database's initialization file (
pfile or
spfile). The
/dev/shm directory is a temporary filesystem that uses RAM, and its default size is usually half of the available physical memory.When Oracle attempts to start the instance, it checks that the size of
/dev/shm is at least equal to the value specified in
MEMORY_TARGET. If this is not the case, the engine refuses to start and generates the aforementioned error.
Step by Step: Solving the ORA-00845 Error
1. Check the Current Size of /dev/shm
Run the following command to check the size mounted at
/dev/shm:
df -h /dev/shm
You can also check the kernel's shared memory parameters with:
sysctl -a | grep shm
2. Resize /dev/shm Dynamically
To temporarily adjust the size of
/dev/shm, run:
sudo mount -o remount,size=<nuevo_tamaño> /dev/shm
Replace
<nuevo_tamaño> with a value greater than or equal to your
MEMORY_TARGET (for example,
8G for 8 gigabytes).
3. Permanent Configuration in /etc/fstab
To make the change permanent, edit the
/etc/fstab file:
sudo vi /etc/fstab
Add or modify the line corresponding to
/dev/shm to specify the new size:
tmpfs /dev/shm tmpfs defaults,size=<nuevo_tamaño> 0 0
4. Restart the Temporary Storage Services
To apply the changes, restart the
tmp.mount service:
sudo systemctl restart tmp.mount
5. Verify the Changes
Confirm that the new size has been applied correctly:
df -h /dev/shm
6. Restart the Oracle Instance
With the size of
/dev/shm adjusted, try restarting the Oracle instance:
sqlplus / as sysdba
STARTUP
Frequently Asked Questions (FAQs)
What happens if /dev/shm already has a sufficient size but the error persists?
Check the kernel parameters related to shared memory (
SEMMNI,
SEMMSL,
SEMMNS, and
SEMOPM). You can adjust them in
/etc/sysctl.conf and apply the changes with
sysctl -p.
What is the recommended size for MEMORY_TARGET?
The ideal value depends on the workload and the memory available on the server. Oracle recommends allocating between 50% and 80% of the physical memory for
MEMORY_TARGET in dedicated environments.
How can I see the current value of MEMORY_TARGET in my database?
Run the following query in SQL*Plus:
SHOW PARAMETER MEMORY_TARGET;