Thread: Permission denied error for initdb

Permission denied error for initdb

From
Tom Dron
Date:
Hi all,

I'm trying to use PostgreSQL on a sever running Debian without root access. I've installed it locally to ~/.local, however when I run initdb I get the following:

fbbgsa@web1:~/.local$ initdb -D ~/.local/data
The files belonging to this database system will be owned by user "fbbgsa".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /home/.local/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 10
selecting default shared_buffers ... 400kB
creating configuration files ... ok
creating template1 database in /home/.local/data/base/1 ... FATAL:  shmat(id=18808835) failed: Permission denied
child process exited with exit code 1
initdb: removing contents of data directory "/home/.local/data"

--

dt tells me that shared memory is mounted in /dev/shm, which is entirely empty, and ipcs also displays nothing. I'm also unable to run strace to see what initdb is doing. Is there perhaps a setting related to shared memory that I can change, or another way to see more information about what's going on with shmat?

Re: Permission denied error for initdb

From
Tom Lane
Date:
Tom Dron <thomas.e.dron@gmail.com> writes:
> fbbgsa@web1:~/.local$ initdb -D ~/.local/data
> ...
> creating template1 database in /home/.local/data/base/1 ... FATAL:
>  shmat(id=18808835) failed: Permission denied

That's really weird.  Usually problems appear at the preceding shmget
call, not shmat.  I'd guess that somehow the System V shared memory
facility is turned off on that machine, but surely it'd fail at shmget
if so.  Still, it might be informative to do "sysctl -a | grep shm"
and see what the shmmax/shmall/shmmni parameters are set to.

Also, I gather from the printout that this isn't a terribly late-model
Postgres.  If you could try 9.4 or later, that might conceivably have
better luck because it requires only a very small SysV segment.
(This error doesn't sound like it's dependent on segment size, but
I'm grasping at straws...)

            regards, tom lane


Re: Permission denied error for initdb

From
Tom Dron
Date:
Yeah, it's 9.3.15, its the required version for the main software I want to use, but I can try a later version if this doesn't end up working.

For some reason I can't find sysctl ANYWHERE on this system, but just looking at the values in /proc/sys/kernel I get:

shmmni: 4096
shmmax: 18446744073692774399
shmall: 18446744073692774399

I'm guessing it might be odd that shmmax and shmall are the same size?

On Thu, Nov 24, 2016 at 12:58 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Tom Dron <thomas.e.dron@gmail.com> writes:
> fbbgsa@web1:~/.local$ initdb -D ~/.local/data
> ...
> creating template1 database in /home/.local/data/base/1 ... FATAL:
>  shmat(id=18808835) failed: Permission denied

That's really weird.  Usually problems appear at the preceding shmget
call, not shmat.  I'd guess that somehow the System V shared memory
facility is turned off on that machine, but surely it'd fail at shmget
if so.  Still, it might be informative to do "sysctl -a | grep shm"
and see what the shmmax/shmall/shmmni parameters are set to.

Also, I gather from the printout that this isn't a terribly late-model
Postgres.  If you could try 9.4 or later, that might conceivably have
better luck because it requires only a very small SysV segment.
(This error doesn't sound like it's dependent on segment size, but
I'm grasping at straws...)

                        regards, tom lane