PostgreSQL Not Starting: FATAL: could not write lock file “postmaster.pid”: No space left on device
I have a couple development servers I have been using for testing PostgreSQL configured with walmgr for log shipping. The secondary server stopped working the other day and I finally got a chance to look into it this morning and attempted to restart Postgres via a terminal but it failed. Below I describe how the error was noticed, what was done to troubleshoot PSQL not starting, and what was done to resolve the problem so PostgreSQL would start without issue.
Attempt To Start PostgreSQL From CentOS Linux CLI:
[root@cent2 ~]# /etc/init.d/postgresql start Starting postgresql service: [FAILED]
As you can see attempting to start postgresql from the command line fails. The first place you should look at is the pgstartup.log file located in the main Postgres directory which by default on CentOS Linux is /var/lib/pgsql. Below is what was discovered in the pgstartup.log file on the CentOS server where postgresql would not start.
Contents Of pgstartup.log File On CentOS Linux:
[root@cent2 pgsql]# less pgstartup.log FATAL: could not write lock file "postmaster.pid": No space left on device FATAL: could not write lock file "postmaster.pid": No space left on device [root@cent2 pgsql]#
As seen above when attempting to start postgresql via the CLI the application is unable to write the postmaster.pid file because there is not any space left on the device which means that the specific partition where postmaster.pid is written is out of space. You can verify the partition that needs to be expanded or have data removed by using the df command as shown below.
Use df To Determine Disk Space Available On A CentOS Linux Server:
[root@cent2 pgsql]# df -kh Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 66G 63G 628K 100% / /dev/sdc1 33G 177M 31G 1% /data /dev/sda1 99M 25M 70M 27% /boot tmpfs 125M 0 125M 0% /dev/shm [root@cent2 pgsql]#
Notice above that 100% of VolGroup00-LogVol00 or “/” is being used. After removing unecessary data from the root partition PostgreSQL started without issue as shown in the below output from a terminal window.
Start PostgreSQL From CentOS Linux Command Line:
[root@cent2 pgsql]# /etc/init.d/postgresql start Starting postgresql service: [ OK ]
Remember when there are issues starting PostgreSQL you can typically locate the issue with ease by viewing the pgstartup.log file located in the PostgreSQL root directory which on CentOS Linux is /var/lib/pgsql.