Why getting error mongod dead but subsys locked and Insufficient free space for journal files on Linux?
You can add following to the config file provided when running mongod --config mongod.conf
For MongoDB 3.x (latest version)
storage:
mmapv1:
smallFiles: true
For version 2.6+
storage:
smallFiles: true
For version 2.4 and less
smallfiles = true
Then just execute mongod to accept your config file (here it assumes that location of the config is /etc/mongodb.conf):
mongod -f /etc/mongodb.conf
Documentation for smallfiles parameter:
Set to true to modify MongoDB to use a smaller default data file size.
Specifically, smallfiles reduces the initial size for data files and
limits them to 512 megabytes. The smallfiles setting also reduces the
size of each journal files from 1 gigabyte to 128 megabytes.
Mongod - Insufficient free space for journal files after being hacked
Increasing disk space on my EC2 instance solved the problem.
MongoDB Insufficient free space for journal files
ec2 has upgraded their storage limit volume , so does how I managed to workaround this problem.
aws ec2 - Mongodb EROR: Insufficient free space for journal files
t2 or m4 instances are working with EBS drive (you get more CPU/RAM but not more disk space as you attach disk from EBS)
You can expand your EBS volume to get more disk space
The high-level step-by-step procedure will be:
Run the command
df –h
on your EBS Volume. It will display the drive’s details before resizing and the available space on the drivestop your instance and detach the existing volume from this instance
create a snapshot from the volume (the one you just detached)
Go to the snapshot area of the console and select your snapshot then Create Volume. In the pop up window you can adjust the size (make sure to give it enough space)
when volume will be ready, attach this new volume to your instance (attach as root device) and start your instance
ssh to your instance and rerun
df -h
to check the new available space on the drive.
In case the info given by df -h
does not show the expected space, you would need to claim the free space, run sudo resize2fs /dev/xvda???
(make sure to replace ??? by the number of your partition given by df -h
)
Why is my disk size reduced and not using the free space of storageSize? ongodb
dataSize
is the size of your raw data. For example document {a: false}
has a size of 9 Bytes
storageSize
is the size of the physical used disk space of your data (without indexes). As you see, your data is compressed by around 50%
indexSize
is the size of the physical used disk space of your indexes.
So, all your collectionXXX.wt + indexXXX.wt files should have a size of around 434.8 GiByte
Solution: put in a bigger disk or remove unused data.
How to solve lack of space issue in mongodb
You don't need to recover your DB. Here are your options:
- If you don't have more space to add and don't care about durability of writes you can disable journalling by setting configuration option
journal = false
. - You can set
smallfiles = true
to make journal files smaller. - Allocate more disk space or move data directory to a larger disk.
In either case you don't have to really restart the server. Just shutdown mongod, fix the problem and start it up.
Example 1:
I'm running Linux VM on AWS and I have only 8GB in my root '/' where mongo places it data files by default. I create a new EBS partition or attach some other partition, format it and mount it. Next I edit mongod config to place my data directory on this new drive/partition. I also move all the files from the old directory to that new place. I startup mongo and it should work fine. Don't forget to set correct directory permissions, etc.
Example 2:
I shutdown my VM or Server and resize disk. If you use LVM, etc you might not need to shutdown - depends. Start mongod - all works.
Mongod Process starts but Systemctl status shows failed
"when I run cluster1.conf
as user, the process starts." does not make much sense. cluster1.conf
is a configuration file, it does not start anything.
When you run systemctl status mongod
, then it typically shows
● mongod.service - MongoDB Database Server
Loaded: loaded (/etc/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2021-08-27 09:44:26 CEST; 2 weeks 3 days ago
Docs: https://docs.mongodb.org/manual
Main PID: 38710 (mongod)
Tasks: 28
Memory: 270.8M
CGroup: /system.slice/mongod.service
└─38710 /usr/bin/mongod -f /etc/mongod.conf
Check the service file /etc/systemd/system/mongod.service
there you see entry like
Environment="OPTIONS=-f /etc/mongod.conf"
EnvironmentFile=-/etc/sysconfig/mongod
ExecStart=/usr/bin/mongod $OPTIONS
Which means, config file /etc/mongod.conf
is used (rather than /home/cluster1.conf
)
Related Topics
Add User to Group But Not Reflected When Run "Id"
When to Use Kernel Threads VS Workqueues in the Linux Kernel
What Occurs When a File Is 'Source'-D in Unix/Linux Context
How to Delete Files Older Than Specific Date in Linux
Differencebetween Clock_Monotonic & Clock_Monotonic_Raw
How to Write Integer to Binary File Using Bash
Insmod Error: Inserting './Hello.Ko': -1 Invalid Module Format"
Linking Symbols to Fixed Addresses on Linux
Bypass Rsync Prompt "Are You Sure You Want to Continue Connecting"
How to List the Contents of a Package Using Yum
Ubuntu - Run Command on Start-Up with "Sudo"
How to Check the Version of Openmp on Linux
Get MAC Address Using Shell Script