Opened 9 years ago

Closed 6 years ago

#49095 closed defect (fixed)

postgresql94 El Capitan initdb using default instructions fails without any failure message.

Reported by: neilt (Neil Tiffin) Owned by: jyrkiwahlstedt
Priority: Normal Milestone:
Component: ports Version: 2.3.4
Keywords: elcapitan Cc:
Port: postgresql94

Description

Removed MacPorts and Xcode, upgraded to El Capitan, install Xcode 7.0.1, install new MacPorts 2.3.4. Then start installing ports manually. Installed postgresql94 then postgresql94-server. Created the default dir using the commands from the install script.

Then I went to look at the init'd database and it was not present.

MBP:postgresql94 nt$ sudo mkdir -p /opt/local/var/db/postgresql94/defaultdb
MBP:postgresql94 nt$ sudo chown postgres:postgres /opt/local/var/db/postgresql94/defaultdb
MBP:postgresql94 nt$ sudo su postgres -c '/opt/local/lib/postgresql94/bin/initdb -D /opt/local/var/db/postgresql94/defaultdb'
MBP:postgresql94 nt$ cd /opt/local/var/db/postgresql94/defaultdb
MBP:defaultdb nt$ pwd
/opt/local/var/db/postgresql94/defaultdb
MBP:defaultdb nt$ ls -lah
total 0
drwxr-xr-x  2 postgres  postgres    68B Oct  4 12:47 .
drwxr-xr-x  3 root      admin      102B Oct  4 12:47 ..
MBP:defaultdb nt$ cd ..
MBP:postgresql94 nt$ pwd
/opt/local/var/db/postgresql94
MBP:postgresql94 nt$ ls -lah
total 0
drwxr-xr-x  3 root      admin      102B Oct  4 12:47 .
drwxr-xr-x  3 root      admin      102B Oct  4 12:47 ..
drwxr-xr-x  2 postgres  postgres    68B Oct  4 12:47 defaultdb

The above is the exact output from the commands. The port install did not show any abnormal results at all. I did the 'csrutil disable' thinking that might be part of the problem with the new security, but it did not make a difference. I have removed postgresql and installed it multiple times. The binaries are present '/opt/local/lib/postgresql94/bin'

If I try to initdb a database in my user account it works fine.

MBP:~ nt$ mkdir postgresql_test
MBP:~ nt$ cd postgresql_test
MBP:postgresql_test nt$ /opt/local/lib/postgresql94/bin/initdb -D .                                       
The files belonging to this database system will be owned by user "nt".
This user must also own the server process.

The database cluster will be initialized with locale "C".
The default database encoding has accordingly been set to "SQL_ASCII".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory . ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
creating template1 database in ./base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /opt/local/lib/postgresql94/bin/postgres -D .
or
    /opt/local/lib/postgresql94/bin/pg_ctl -D . -l logfile start

MBP:postgresql_test nt$ 

I don't have any idea how to troubleshoot this when no error messages are printed.

Change History (8)

comment:1 Changed 9 years ago by neilt (Neil Tiffin)

Cc: neilt@… added

Cc Me!

comment:2 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: mww@… neilt@… removed
Keywords: elcapitan added
Owner: changed from macports-tickets@… to mww@…
Priority: HighNormal

comment:3 Changed 9 years ago by jyrkiwahlstedt

Does /opt/local/var/log/postgresql94/postgres.log show anything?

comment:4 Changed 9 years ago by jyrkiwahlstedt

Also, what does the database directory contain: "sudo -u postgres ls -l /opt/local/var/db/postgresql94/defaultdb/"? Did you start the database server?

comment:5 in reply to:  3 Changed 9 years ago by neilt (Neil Tiffin)

Replying to jwa@…:

Does /opt/local/var/log/postgresql94/postgres.log show anything?

Nope, although the timestamp is about right.

MBP:myPoliticsDatabase nt$ sudo ls -lah /opt/local/var/log/postgresql94/postgres.log
-rw-r--r--  1 postgres  postgres     0B Oct  4 13:32 /opt/local/var/log/postgresql94/postgres.log

comment:6 in reply to:  4 Changed 9 years ago by neilt (Neil Tiffin)

Replying to jwa@…:

Also, what does the database directory contain: "sudo -u postgres ls -l /opt/local/var/db/postgresql94/defaultdb/"? Did you start the database server?

It is my understanding that I have to init the database before starting the server.

But in answer to your question, I get no results when I do ’sudo su postgres’ anything. Which is what the install script recommends.

For example this works:

   MBP:myPoliticsDatabase nt$ initdb --version
   initdb (PostgreSQL) 9.4.4

This, based on the install instructions does not:

   MBP:myPoliticsDatabase nt$ sudo su postgres -c 'initdb --version'
   MBP:myPoliticsDatabase nt$ 

But I did notice the following does work:

   MBP:myPoliticsDatabase nt$ sudo -u postgres initdb --version
   Password:
   initdb (PostgreSQL) 9.4.4

So I tried the following using your suggestion below:

  MBP:myPoliticsDatabase nt$ sudo -u postgres /opt/local/lib/postgresql94/bin/initdb -D /opt/local/var/db/postgresql94/defaultdb 

And that worked fine.

So the issue is that ’sudo su postgres’ as recommended in the install text does not work and ‘sudo -u postgres’ does work. See the last line of the install instructions below.

For reference this is what the install script outputs to the terminal:

Configure PostgreSQL
###########################################################
# A startup item has been generated that will aid in
# starting postgresql94-server with launchd. It is disabled
# by default. Execute the following command to start it,
# and to cause it to launch at startup:
#
# sudo port load postgresql94-server
# sudo port unload postgresql94-server
###########################################################
--->  Installing postgresql94-server @9.4.4_0
--->  Activating postgresql94-server @9.4.4_0

To create a database instance, after install do
sudo mkdir -p /opt/local/var/db/postgresql94/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql94/defaultdb
sudo su postgres -c '/opt/local/lib/postgresql94/bin/initdb -D /opt/local/var/db/postgresql94/defaultdb'

comment:7 Changed 8 years ago by mf2k (Frank Schima)

Cc: jyrkiwahlstedt removed
Owner: changed from mww@… to jyrkiwahlstedt
Status: newassigned

comment:8 Changed 6 years ago by jmroot (Joshua Root)

Resolution: fixed
Status: assignedclosed

In a2ce1b3d3f2dbd9b776c7c72fd8c14c709252c77/macports-ports (master):

postgresql9{1,2,3,4}-server: fix db creation notes

Running the previously suggested command from a directory not readable
by the postgres user would fail.

Maintainer timeout.
Fixes: #32817
Fixes: #39341
Fixes: #49095

Note: See TracTickets for help on using tickets.