OS X Server.app 4 Completely Breaks PostgreSQL

There a new flavor of brokenness with Server.app 4's PostgreSQL -- it doesn't even exist as a serveradmin service!


Does anyone know how to tell serveradmin to start/stop PostgreSQL?


I've been able to migrate my old data and get a running PostgreSQL server with these commands:


su -

mv /Library/Server/PostgreSQL/Data /Library/Server/PostgreSQL/DataOld

rm -fr /Library/Server/PostgreSQL/Data

mkdir -p /Library/Server/PostgreSQL/Data

chown -R _postgres:_postgres /Library/Server/PostgreSQL/Data

chmod 700 /Library/Server/PostgreSQL/Data

sudo -u _postgres /Applications/Server.app/Contents/ServerRoot/usr/bin/initdb /Library/Server/PostgreSQL/Data -E utf8 --lc-ctype=C

# assume migration put old pg data in /Library/Server/PostgreSQL/Data-9.2

sudo -u _postgres /Applications/Server.app/Contents/ServerRoot/usr/bin/pg_upgrade -b /Applications/Server.app/Contents/ServerRoot/usr/libexec/postgresql9.2 -B /Applications/Server.app/Contents/ServerRoot/usr/bin -d /Library/Server/PostgreSQL/Data-9.2 -D /Library/Server/PostgreSQL/Data


# Server.app 4 doesn't include the postgres launch plist!

# assume your previous <= Mavericks backup is in /Volumes/Backup

cp /Volumes/Backup/Applications/Server.app/Contents/ServerRoot/System/Library/Laun chDaemons/org.postgresql.postgres.plist /Applications/Server.app/Contents/ServerRoot/System/Library/LaunchDaemons/

launchctl load -w /Applications/Server.app/Contents/ServerRoot/System/Library/LaunchDaemons/org.p ostgresql.postgres.plist

lsof -i ':5432'

nmap -p 5432 localhost

See here and here for background on how to fix postgres in Server.app 3.1.2.


Now the problem is that postgres launches don't persist over reboots, and that serveradmin doesn't control postgres. The commands


sudo serveradmin start postgres

sudo serveradmin start expialidocious


both return the same error because neither are serveradmin-managed services.


How does one get serveradmin start postgres to work?

Mac mini, OS X Mavericks (10.9), Server, 16 GB, EyeTV+Turbo.264 HD

Posted on Jan 17, 2015 8:04 PM

Reply
3 replies

Jan 18, 2015 12:17 PM in response to essandess

There is no longer any provision for starting a PostgreSQL process other than the ones reserved for built-in services. Create a launch daemon with content such as the following:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<dict>
<key>Label</key>
<string>org.postgresql.postgres</string>
<key>UserName</key>
<string>_postgres</string>
<key>GroupName</key>
<string>_postgres</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Server.app/Contents/ServerRoot/usr/bin/postgres</string>
<string>--apple-configuration</string>
<string>/Library/Server/PostgreSQL/Config/org.postgresql.postgres.plist</string>
</array>
<key>KeepAlive</key>
<dict>
<key>PathState</key>
<dict>
<key>/Library/Server/PostgreSQL/Data</key>
<true/>
</dict>
</dict>
<key>StandardErrorPath</key>
<string>/Library/Logs/PostgreSQL/PostgreSQL.log</string>
<key>StandardOutPath</key>
<string>/Library/Logs/PostgreSQL/PostgreSQL.log</string>
</dict>
</plist>
<plist version="1.0">

Also create these directories and files, owned by _postgres:_postgres:

/Library/Logs/PostgreSQL
/Library/Server/PostgreSQL
/Library/Server/PostgreSQL/Backup
/Library/Server/PostgreSQL/Config
/Library/Server/PostgreSQL/Config/org.postgresql.postgres.plist
/Library/Server/PostgreSQL/Data

Finally, initialize the database with a suitable invocation of initdb(1).

For more details, see the PostgreSQL documentation. You may find it easier to use a packaged third-party distribution independent of the built-in one.

Jan 18, 2015 6:49 PM in response to Linc Davis

Thanks again Linc. I was hoping against hope that for a product named Server, professional dignity would preserve a native database capability.


Because Server.app relies so heavily on PostgreSQL, I'm guessing that using it as you describe will be easier and at least as stable as running "sudo port install postgresql94-server" and then reconfiguring all postgres-based applications to use the Macports version.

I take it from your response that there will not be a way to control postgres from serveradmin, i.e." sudo serveradmin start postgres", and that all control comes from loading/unloading the plist.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

OS X Server.app 4 Completely Breaks PostgreSQL

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.