0

So I'm still having issue's attempting to get my postgresql db running on my rails apps since the Yosemite upgrade. I wish I never upgraded now. I've searched the net and there is a related question here on stackoverflow about this same issue.

`pg_tblspc` missing after installation of latest version of OS X (Yosemite or El Capitan)

I am getting the same error on my command line.

No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

and in my web browser it gives me the PG::ConnectionBad error. I did the solution that @Donovan stated for solving the issue by adding the three missing directories pg_tblspc,pg_twophase,pg_stat_tmp that for some reason Yosemite got rid of. I ran all the correct command line operations but still receive the same error and no luck. This is what my database.yml file looks like as well.

# PostgreSQL. Versions 8.2 and up are supported.
#
# Install the pg driver:
#   gem install pg
# On Mac OS X with macports:
#   gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
#   gem install pg
#       Choose the win32 build.
#       Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile
# gem 'pg'
#
development:
  adapter: postgresql
  encoding: unicode
  database: task_manager_development
  pool: 5


# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.
# host: localhost
# port: 5432

# Schema search path. The server defaults to $user,public
#schema_search_path: myapp,sharedapp,public

# Minimum log levels, in increasing order:
#   debug5, debug4, debug3, debug2, debug1,
#   log, notice, warning, error, fatal, and panic
# The server defaults to notice.
#min_messages: warning

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
 adapter: postgresql
 encoding: unicode
 database: task_manager_test
 pool: 5


production:
 adapter: postgresql
 encoding: unicode
 database: task_manager_production
 pool: 5

I've also tried un-commenting out the localhost and port 5432 and still have no luck. I really need help here. Basically everything else I've read online too says that adding those multiple directories and restarting your postgresql should solve the problem but it hasn't worked for me. I must not be doing something correctly or am missing something. I'm considering re-installing homebrew and ROR but i'm afraid I may lose all my data from my ROR apps. Any help would be great!!

Community
  • 1
  • 1
bigREDcode
  • 139
  • 2
  • 11
  • Have you considered installing from source? (If you install under your home directory, that makes it simpler, too: `./configure --prefix=/Users/your_user/opt;make;make install`.) I've been holding off on the upgrade... – TK-421 Dec 08 '14 at 23:52
  • You mean restarting postgresql from the source or directory of my rails app? – bigREDcode Dec 09 '14 at 00:32
  • You may also want to check permissions/ownership on the various files and directories mentioned. – Dmitri Goldring Dec 09 '14 at 00:36
  • How do I do that? @DmitriGoldring? – bigREDcode Dec 09 '14 at 00:48
  • Use 'ls -l' to list the files in your db directory (where you created those directories), you should see a user name and a group (the group will likely be staff). Make sure the user name matches the other files in the directory. If not, you can use the chown command to fix the ownership. The permissions are at the beginning of the 'ls' output and should also match the rest of the directories. – Dmitri Goldring Dec 09 '14 at 01:04
  • so cd into my database.yml file and then run the "ls -l" command and then I should see the user name and group? I configured my postgresql so I don't need to have a user name and password btw. – bigREDcode Dec 09 '14 at 01:49

1 Answers1

0

Edit your postgresql.conf file and add the following like:

unix_socket_directory = '/tmp/'

then restart postgres

Joe Love
  • 4,498
  • 1
  • 17
  • 29
  • How do I do that from the command line? Do I literally try and open the file in my text editor? Or are you talking about in my database.yml file? – bigREDcode Dec 09 '14 at 20:06
  • 1
    Ok I believe I found it in the connections and authentication area. This is commented out currently, `#unix_socket_directories = '/tmp' # comma-separated list of directories` Should I uncomment that out, save, and then restart and see if it works? Sorry, I'm a novice to this postgresql debugging. – bigREDcode Dec 09 '14 at 20:26
  • Yes. It's likely saving the file to another directory, and your client is looking in that directory. – Joe Love Dec 10 '14 at 00:09
  • @Joe_Love I think it rectified somewhat of the issue but now it's telling me after restarting the server... – bigREDcode Dec 12 '14 at 19:45
  • `LOG: could not open temporary-files directory "pg_tblspc/.keep/PG_9.3_201306121/pgsql_tmp": Not a directory LOG: could not open tablespace directory "pg_tblspc/.keep/PG_9.3_201306121": Not a directory LOG: database system was interrupted while in recovery at 2014-12-12 13:42:00 CST HINT: This probably means that some data is corrupted and you will have to use the last backup for recovery. LOG: database system was not properly shut down; automatic recovery in progress FATAL: could not open directory "pg_stat": No such file or directory` – bigREDcode Dec 12 '14 at 19:46
  • Those directories are in my postgresql directory though since I recreated them! – bigREDcode Dec 12 '14 at 19:46
  • Check the file/directory ownership and permissions.. try 777 for perms just to see if that clears it up – Joe Love Dec 12 '14 at 19:47
  • If that's not it, the the postmaster is looking in the wrong base folder and you'll need to make sure it starts in the right folder by passing in the -pgdata parameter – Joe Love Dec 12 '14 at 19:49
  • @Joe_Love when I list the file/directory ownership/perms with `ls -l` it states `drwx------ 23 coreyburkley admin 782 Nov 18 04:15 base` for the base folder. I believe the date correlates of when I made the upgrade to Yosemite so there's something to be noted about that. I don't know what you mean for passing the right folder through the -pgdata parameter. Would I do that through my text editor as well within the base folder? – bigREDcode Dec 12 '14 at 20:03
  • Nevermind about the -pgdata, I no longer think that's the issue. Usually, postgres runs as a user. (perhaps postgres). In this instance, if the user is not coreyburkley, it will have no access to any of the folders/files with the permissions you mentioned. Again, if it were me, I'd chmod 777 * -R in the directory of your DB (assuming this is a new DB or a Non-production DB, it won't really matter much)-- I'm only saying this to help debug. Once we figure out the issue, we can get a more restrictive permission that's more secure – Joe Love Dec 12 '14 at 20:24