Skip to content

Unable to set-up postgre (using vagrant install)

Hi,

I'm trying to run the "gitlab developement kit" under vagrant environment but without success. I tried on my mac (I have two mac, and same issue for both). So I erased everything before posting this issue :

I'm cloning the master of this project

cd gitlab-development-kit && vagrant up

[...] waiting, and I have the first issue with the installation

==> default: Can't check signature: public key not found
==> default: Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found.
==> default: Assuming you trust Michal Papis import the mpapis public key (downloading the signatures).
==> default: GPG signature verification failed for '/home/vagrant/.rvm/archives/rvm-1.26.0.tgz' - 'https://github.com/wayneeseguin/rvm/releases/download/1.26.0/1.26.0.tar.gz.asc'!

Ok, I vagrant ssh, and run

gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
exit

And I force the installation once again

vagrant provision

Installation is done and I can ssh

vagrant ssh
source /home/vagrant/.rvm/scripts/rvm # ask by the installation after the vagrant provision command

Perfect, now I'm following the README which tells me to go under '/vagrant/' and 'make'

cd /vagrant/
make

"Make" is in progress and works fine until the rule about postgresql.

creating directory postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
creating template1 database in postgresql/data/base/1 ... LOG:  could not link file "pg_xlog/xlogtemp.10067" to "pg_xlog/000000010000000000000001" (initialization of log file): Operation not permitted
FATAL:  could not open file "pg_xlog/000000010000000000000001": No such file or directory
child process exited with exit code 1
initdb: removing data directory "postgresql/data"

I have the same issue on my other computer.

So I'm trying to isolate the problem.

make --debug
[...]
 File `postgresql/data/PG_VERSION' does not exist.
      Must remake target `postgresql/data/PG_VERSION'.
/usr/lib/postgresql/9.3/bin/initdb -E utf-8 postgresql/data
The files belonging to this database system will be owned by user "vagrant".
This user must also own the server process.

initdb: invalid locale name ""
The database cluster will be initialized with locales
  COLLATE:  en_US.UTF-8
  CTYPE:    C
  MESSAGES: en_US.UTF-8
  MONETARY: en_US.UTF-8
  NUMERIC:  en_US.UTF-8
  TIME:     en_US.UTF-8
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
creating template1 database in postgresql/data/base/1 ... LOG:  could not link file "pg_xlog/xlogtemp.10234" to "pg_xlog/000000010000000000000001" (initialization of log file): Operation not permitted
FATAL:  could not open file "pg_xlog/000000010000000000000001": No such file or directory
child process exited with exit code 1
initdb: removing data directory "postgresql/data"
make: *** [postgresql/data/PG_VERSION] Error 1

Ok now I have the command line to reproduce the error :

/usr/lib/postgresql/9.3/bin/initdb -E utf-8 postgresql/data

First I'm trying to see where is this famous file.

vagrant@vagrant-ubuntu-trusty-64:/vagrant$ sudo find / -name '000000010000000000000001' 
/var/lib/postgresql/9.3/main/pg_xlog/000000010000000000000001

vagrant@vagrant-ubuntu-trusty-64:/vagrant$ sudo ls -la /var/lib/postgresql/9.3/main/pg_xlog/000000010000000000000001
-rw------- 1 postgres postgres 16777216 Nov  9 18:45 /var/lib/postgresql/9.3/main/pg_xlog/000000010000000000000001

I'm a little bit concerned about this permission, but apparently it's good. (I tried to chmod -R 777 /var/lib to see if it will change something. It didn't) So let's check the 'postgresql/data' directory. I decided to keep it to be able to have more information.

/usr/lib/postgresql/9.3/bin/initdb -E utf-8 postgresql/data --noclean
[...]
child process exited with exit code 1
initdb: data directory "postgresql/data" not removed at user's request

vagrant@vagrant-ubuntu-trusty-64:/vagrant$ ls -la postgresql/data/
total 40
drwxr-xr-x 1 vagrant vagrant   646 Nov  9 18:37 .
drwxr-xr-x 1 vagrant vagrant   102 Nov  9 18:37 ..
-rw------- 1 vagrant vagrant     4 Nov  9 18:37 PG_VERSION
drwxr-xr-x 1 vagrant vagrant   102 Nov  9 18:37 base
drwxr-xr-x 1 vagrant vagrant    68 Nov  9 18:37 global
drwxr-xr-x 1 vagrant vagrant    68 Nov  9 18:37 pg_clog
-rw------- 1 vagrant vagrant  4473 Nov  9 18:37 pg_hba.conf
-rw------- 1 vagrant vagrant  1636 Nov  9 18:37 pg_ident.conf
drwxr-xr-x 1 vagrant vagrant   136 Nov  9 18:37 pg_multixact
drwxr-xr-x 1 vagrant vagrant   102 Nov  9 18:37 pg_notify
drwxr-xr-x 1 vagrant vagrant    68 Nov  9 18:37 pg_serial
drwxr-xr-x 1 vagrant vagrant    68 Nov  9 18:37 pg_snapshots
drwxr-xr-x 1 vagrant vagrant    68 Nov  9 18:37 pg_stat
drwxr-xr-x 1 vagrant vagrant    68 Nov  9 18:37 pg_stat_tmp
drwxr-xr-x 1 vagrant vagrant    68 Nov  9 18:37 pg_subtrans
drwxr-xr-x 1 vagrant vagrant    68 Nov  9 18:37 pg_tblspc
drwxr-xr-x 1 vagrant vagrant    68 Nov  9 18:37 pg_twophase
drwxr-xr-x 1 vagrant vagrant   102 Nov  9 18:37 pg_xlog
-rw------- 1 vagrant vagrant 20558 Nov  9 18:37 postgresql.conf

and for pg_xlog (the culprit)

vagrant@vagrant-ubuntu-trusty-64:/vagrant$ ls -la postgresql/data/pg_xlog/
total 0
drwxr-xr-x 1 vagrant vagrant 102 Nov  9 18:37 .
drwxr-xr-x 1 vagrant vagrant 646 Nov  9 18:37 ..
drwxr-xr-x 1 vagrant vagrant  68 Nov  9 18:37 archive_status

I don't see anything bad about the permissions.

Let's see what 'strace' can tell me. Maybe the path are wrong (env variable, ...)

vagrant@vagrant-ubuntu-trusty-64:/vagrant$ strace /usr/lib/postgresql/9.3/bin/initdb -E utf-8 postgresql/data 2> /tmp/output
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ grep 000000010000000000000001 /tmp/output 
write(4, "insert OID = 760 ( smgrin 11 10 "..., 130LOG:  could not link file "pg_xlog/xlogtemp.2191" to "pg_xlog/000000010000000000000001" (initialization of log file): Operation not permitted
FATAL:  could not open file "pg_xlog/000000010000000000000001": No such file or directory

Nothing very interesting, and I don't see any references about this file anywhere (expect inside binaries files) on the installation ('/').

I'm lost, and I didn't find anything on google about it neither. (this one http://lists.freebsd.org/pipermail/freebsd-hackers/2012-December/041475.html is not exactly the same issue)

Any suggestions ? (sorry for the verbose mode :p) If you need more information, tell me.