While testing a new async infrastructure, which requires more than 20 database connections, I ran out of connections and looked into upgrading PostgreSQL. The default setting for max_connections (found in /usr/local/var/postgres/postgresql.conf) is 100.
Ends up the upgrade from 9.2.4 to 9.3.1 is worthwhile for me since it greatly reduces System V shared memory requirements.
The upgrade was not time consuming, but required attention to details.
Here's what worked for me on OSX 10.9
Keep Install Notes
Initialize new 9.3 database
Migrate Data to New 9.3 Format
Create Link to Generic PostgreSQL directory
Increase System Memory for PostgreSQL
Create /etc/sysctl.conf file with following values
Reboot computer
Create postgres user
Start postgreSQL
Note: I don't use launchd
Verify PostgreSQL 9.3 Works
Vacuum db
Reinstall PG gem
Note: Uninstall the gem on the system command line and let Bundle Install reinstall your project's required version, which for me was version 0.17.
Possible Error
If you get the following...
...then run the following after uninstalling the pg gem:
A typical OSX DevTools install won't be enough, but you can run it anyway:
Install Command Line Tools (OS X Mavericks)
If you use PostgreSQL.App, you'll need to install Command Line Tools (OS X Mavericks) for Xcode - Late October 2013
Do the following:
- $ gem uninstall pg
- $ xcode
- From Xcode menu: Xcode > Open Developer Tool > More Developer Tools... > Choose "Command Line Tools (OS X Mavericks) for Xcode - Late October 2013"
- Run the installation program
- $ gem install pg
Update following in Gemfile
Bundle Install
Verify PostgreSQL 9.3 works with Rails
Change directory to your favorite Rails project open the Rails Console and do some ActiveRecord queries.
Cleanup
Notes
- Since directories have been moved and linked, do not run delete_old_cluster.sh
- When tweaking system memory setting, keep in mind that SHMMAX must be an exact multiple of 4096
- Special thanks to Matt Brictson, referenced below
- This update will likely break your PostgreSQL admin tool like pgadmin
- The pg_upgrade application only migrates the public schema.
- Upgrade to lastest (v1.18.1) pgAdmin app, but backup your data first.
- Do not remove the old version (9.2.4) until you are certain that all data has been migrated successfully.
Centos Install
This is still a work in progress...
References
http://blog.55minutes.com/2013/09/postgresql-93-brew-upgrade
http://www.postgresql.org/docs/current/static/release-9-3.html
http://www.postgresql.org/docs/8.4/static/kernel-resources.html
http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server
http://postgresapp.com
http://www.pgadmin.org/download/macosx.php