Обсуждение: Re: Could Not Connect To Server

Поиск
Список
Период
Сортировка

Re: Could Not Connect To Server

От
"David G. Johnston"
Дата:
On Thu, Apr 23, 2020 at 11:18 AM Dummy Account <dummyaccount4u@mail.com> wrote:

Trying to start the server, I navigate too: /Library/PostgreSQL/12/bin

from bin, I ran: sudo -u postgres ./pg_ctl start -D /Library/PostgreSQL/12/data

pg_ctl: could not start server
 

What do the logs say...


When I ran the status command instead of start, it of course eluded to not running.
I mention all of this with the caveat that I did recently restore from a backup because I replaced my HDD with a SSD.


You should be very specific as to how you restored your database from backup because there is a good chance this wasn't done properly and you presently have a corrupted database on your hard drive.

David J.
 

Re: Could Not Connect To Server

От
"David G. Johnston"
Дата:
On Thu, Apr 23, 2020 at 11:48 AM Dummy Account <dummyaccount4u@mail.com> wrote:
But here they are:
 
waiting for server to start....2020-04-22 15:57:51.766 CDT [5255] LOG:  starting PostgreSQL 12.2 on x86_64-apple-darwin, compiled by Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn), 64-bit
2020-04-22 15:57:51.766 CDT [5255] LOG:  listening on IPv6 address "::", port 5432
2020-04-22 15:57:51.766 CDT [5255] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2020-04-22 15:57:51.768 CDT [5255] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-04-22 15:57:51.782 CDT [5255] LOG:  redirecting log output to logging collector process
2020-04-22 15:57:51.782 CDT [5255] HINT:  Future log output will appear in directory "log".

And the relevant content from the log directory log file?

 stopped waiting
pg_ctl: could not start server
 
You might be misunderstanding where I said restore, I did not backup the database, I restored an Operating System because I changed out my hard drive for a solid state drive; therefore, I had to restore my Operating System from Time Machine/(backup).


And was that Time Machine backup made while the server was offline?  If not, and you didn't take any explicit steps to backup and restore the database itself, then your database may be corrupted and thus unable to boot.  The log file should indicate whether that is the case.

David J.

Re: Could Not Connect To Server

От
Rob Sargent
Дата:


On 4/23/20 1:12 PM, Dummy Account wrote:
 
Hi David,
 
When I backed-up, I don't know if the server was offline?  I can say that I was not running pgAdmin.  For instance, I backed up the Operating System and all of its applications.  If I go run other application, including other servers, they work.  As a matter of fact, if I boot into the old hard drive while it is outside of the laptop, it still works just as it did before I took it out of the laptop.
 
As far as your question of "And the relevant content from the log directory log file?": what are you asking for?  That is the entire and complete log after that command.
 
Thanks, I appreciate the help.
 
Sent: Thursday, April 23, 2020 at 1:55 PM
From: "David G. Johnston" <david.g.johnston@gmail.com>
To: "Dummy Account" <dummyaccount4u@mail.com>
Cc: "pgsql-general" <pgsql-general@postgresql.org>
Subject: Re: Could Not Connect To Server
On Thu, Apr 23, 2020 at 11:48 AM Dummy Account <dummyaccount4u@mail.com> wrote:
But here they are:
 
waiting for server to start....2020-04-22 15:57:51.766 CDT [5255] LOG:  starting PostgreSQL 12.2 on x86_64-apple-darwin, compiled by Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn), 64-bit
2020-04-22 15:57:51.766 CDT [5255] LOG:  listening on IPv6 address "::", port 5432
2020-04-22 15:57:51.766 CDT [5255] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2020-04-22 15:57:51.768 CDT [5255] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-04-22 15:57:51.782 CDT [5255] LOG:  redirecting log output to logging collector process
2020-04-22 15:57:51.782 CDT [5255] HINT:  Future log output will appear in directory "log".
 
And the relevant content from the log directory log file?
 
 stopped waiting
pg_ctl: could not start server
 
You might be misunderstanding where I said restore, I did not backup the database, I restored an Operating System because I changed out my hard drive for a solid state drive; therefore, I had to restore my Operating System from Time Machine/(backup).
 
 
And was that Time Machine backup made while the server was offline?  If not, and you didn't take any explicit steps to backup and restore the database itself, then your database may be corrupted and thus unable to boot.  The log file should indicate whether that is the case.
 
David J.
 
I take it you're seeing that output in the Terminal shell window.  What value does -D get when you try to start postgres?  Can we see the entire command? The "log" directory will be within the value of -D I believe.

Re: Could Not Connect To Server

От
Adrian Klaver
Дата:
On 4/23/20 12:12 PM, Dummy Account wrote:
> Hi David,
> When I backed-up, I don't know if the server was offline?  I can say 
> that I was not running pgAdmin.  For instance, I backed up the Operating 
> System and all of its applications.  If I go run other application, 
> including other servers, they work.  As a matter of fact, if I boot into 
> the old hard drive while it is outside of the laptop, it still works 
> just as it did before I took it out of the laptop.
> As far as your question of "And the relevant content from the log 
> directory log file?": what are you asking for?  That *is* the entire and 
> complete log after that command.

Those are the messages sent to the screen. There are also messages sent 
to the Postgres server log. Not sure where the OS X install puts that, 
but I would start under /Library/PostgreSQL/12/data.

> Thanks, I appreciate the help.
> *Sent:* Thursday, April 23, 2020 at 1:55 PM
> *From:* "David G. Johnston" <david.g.johnston@gmail.com>
> *To:* "Dummy Account" <dummyaccount4u@mail.com>
> *Cc:* "pgsql-general" <pgsql-general@postgresql.org>
> *Subject:* Re: Could Not Connect To Server
> On Thu, Apr 23, 2020 at 11:48 AM Dummy Account <dummyaccount4u@mail.com 
> <mailto:dummyaccount4u@mail.com>> wrote:
> 
>     But here they are:
> 
>     waiting for server to start....2020-04-22 15:57:51.766 CDT [5255]
>     LOG:  starting PostgreSQL 12.2 on x86_64-apple-darwin, compiled by
>     Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn), 64-bit
>     2020-04-22 15:57:51.766 CDT [5255] LOG:  listening on IPv6 address
>     "::", port 5432
>     2020-04-22 15:57:51.766 CDT [5255] LOG:  listening on IPv4 address
>     "0.0.0.0", port 5432
>     2020-04-22 15:57:51.768 CDT [5255] LOG:  listening on Unix socket
>     "/tmp/.s.PGSQL.5432"
>     2020-04-22 15:57:51.782 CDT [5255] LOG:  redirecting log output to
>     logging collector process
>     2020-04-22 15:57:51.782 CDT [5255] HINT:  Future log output will
>     appear in directory "log".
> 
> And the relevant content from the log directory log file?
> 
>       stopped waiting
>     pg_ctl: could not start server
>     You might be misunderstanding where I said restore, I did not backup
>     the database, I restored an Operating System because I changed out
>     my hard drive for a solid state drive; therefore, I had to restore
>     my Operating System from Time Machine/(backup).
> 
> And was that Time Machine backup made while the server was offline?  If 
> not, and you didn't take any explicit steps to backup and restore the 
> database itself, then your database may be corrupted and thus unable to 
> boot.  The log file should indicate whether that is the case.
> David J.


-- 
Adrian Klaver
adrian.klaver@aklaver.com



Re: Could Not Connect To Server

От
Rob Sargent
Дата:


On 4/23/20 1:32 PM, Dummy Account wrote:
 
Hey David,
 
Can you tell me the exact name of the log file?  Then I can search for it.
 
Thanks
 
Apparently in your case it is called "log".  I don't have version 12, but  version 9's start up name "pg_log" and that is the name of the file in the data directory.  Starting at /Library/PostgreSQL/12 as suggested is a good bet

Re: Could Not Connect To Server

От
Adrian Klaver
Дата:
On 4/23/20 12:36 PM, Rob Sargent wrote:
> 
> 
> On 4/23/20 1:32 PM, Dummy Account wrote:
>> Hey David,
>> Can you tell me the exact name of the log file?  Then I can search for it.
>> Thanks
>>
> Apparently in your case it is called "log".  I don't have version 12, 

To be clear 'log' is the name of the directory that holds the logs. The 
log files themselves are named according to some pattern generally. The 
default is:

https://www.postgresql.org/docs/12/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-WHERE

log_filename
The default is postgresql-%Y-%m-%d_%H%M%S.log

> but  version 9's start up name "pg_log" and that is the name of the file 
> in the data directory.  Starting at /Library/PostgreSQL/12 as suggested 
> is a good bet
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com



Re: Fw: Re: Could Not Connect To Server

От
Adrian Klaver
Дата:
On 4/23/20 1:24 PM, Dummy Account wrote:
> Hey Everyone,
> I did find loggin.h and insallation_summary.log.  Neither of which look 
> to include the info you may want.
> Please advise as to what log file you want to see.

Did you look under:

/Library/PostgreSQL/12/data

directory for sub-directory?:

log/

And under it for log files?

> Thanks
> *Sent:* Thursday, April 23, 2020 at 2:32 PM
> *From:* "Dummy Account" <dummyaccount4u@mail.com>
> *To:* "Adrian Klaver" <adrian.klaver@aklaver.com>
> *Cc:* "David G. Johnston" <david.g.johnston@gmail.com>, "pgsql-general" 
> <pgsql-general@postgresql.org>
> *Subject:* Re: Could Not Connect To Server
> Hey David,
> Can you tell me the exact name of the log file?  Then I can search for it.
> Thanks
> *Sent:* Thursday, April 23, 2020 at 2:25 PM
> *From:* "Adrian Klaver" <adrian.klaver@aklaver.com>
> *To:* "Dummy Account" <dummyaccount4u@mail.com>, "David G. Johnston" 
> <david.g.johnston@gmail.com>
> *Cc:* "pgsql-general" <pgsql-general@postgresql.org>
> *Subject:* Re: Could Not Connect To Server
> On 4/23/20 12:12 PM, Dummy Account wrote:
>  > Hi David,
>  > When I backed-up, I don't know if the server was offline?  I can say
>  > that I was not running pgAdmin.  For instance, I backed up the Operating
>  > System and all of its applications.  If I go run other application,
>  > including other servers, they work.  As a matter of fact, if I boot into
>  > the old hard drive while it is outside of the laptop, it still works
>  > just as it did before I took it out of the laptop.
>  > As far as your question of "And the relevant content from the log
>  > directory log file?": what are you asking for?  That *is* the entire and
>  > complete log after that command.
> 
> Those are the messages sent to the screen. There are also messages sent
> to the Postgres server log. Not sure where the OS X install puts that,
> but I would start under /Library/PostgreSQL/12/data.
> 
>  > Thanks, I appreciate the help.
>  > *Sent:* Thursday, April 23, 2020 at 1:55 PM
>  > *From:* "David G. Johnston" <david.g.johnston@gmail.com>
>  > *To:* "Dummy Account" <dummyaccount4u@mail.com>
>  > *Cc:* "pgsql-general" <pgsql-general@postgresql.org>
>  > *Subject:* Re: Could Not Connect To Server
>  > On Thu, Apr 23, 2020 at 11:48 AM Dummy Account <dummyaccount4u@mail.com
>  > <mailto:dummyaccount4u@mail.com>> wrote:
>  >
>  > But here they are:
>  >
>  > waiting for server to start....2020-04-22 15:57:51.766 CDT [5255]
>  > LOG:  starting PostgreSQL 12.2 on x86_64-apple-darwin, compiled by
>  > Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn), 64-bit
>  > 2020-04-22 15:57:51.766 CDT [5255] LOG:  listening on IPv6 address
>  > "::", port 5432
>  > 2020-04-22 15:57:51.766 CDT [5255] LOG:  listening on IPv4 address
>  > "0.0.0.0", port 5432
>  > 2020-04-22 15:57:51.768 CDT [5255] LOG:  listening on Unix socket
>  > "/tmp/.s.PGSQL.5432"
>  > 2020-04-22 15:57:51.782 CDT [5255] LOG:  redirecting log output to
>  > logging collector process
>  > 2020-04-22 15:57:51.782 CDT [5255] HINT:  Future log output will
>  > appear in directory "log".
>  >
>  > And the relevant content from the log directory log file?
>  >
>  >  stopped waiting
>  > pg_ctl: could not start server
>  > You might be misunderstanding where I said restore, I did not backup
>  > the database, I restored an Operating System because I changed out
>  > my hard drive for a solid state drive; therefore, I had to restore
>  > my Operating System from Time Machine/(backup).
>  >
>  > And was that Time Machine backup made while the server was offline?  If
>  > not, and you didn't take any explicit steps to backup and restore the
>  > database itself, then your database may be corrupted and thus unable to
>  > boot.  The log file should indicate whether that is the case.
>  > David J.
> 
> 
> --
> Adrian Klaver
> adrian.klaver@aklaver.com


-- 
Adrian Klaver
adrian.klaver@aklaver.com



Re: Fw: Re: Could Not Connect To Server

От
Adrian Klaver
Дата:
On 4/23/20 1:37 PM, Dummy Account wrote:
>  From the Finder, I think that is the same a File Explorer on Widows. 
>   From Finder, it's locked; I cannot access it.  Could I use the command 
> line and change ownership or access privledges?  And then get access?

Why not from the command line use a text editor to view the file(s)?

> Thanks



-- 
Adrian Klaver
adrian.klaver@aklaver.com



Re: Fw: Re: Could Not Connect To Server

От
Rob Sargent
Дата:


On 4/23/20 3:26 PM, Adrian Klaver wrote:
On 4/23/20 1:37 PM, Dummy Account wrote:
 From the Finder, I think that is the same a File Explorer on Widows.   From Finder, it's locked; I cannot access it.  Could I use the command line and change ownership or access privledges?  And then get access?

Why not from the command line use a text editor to view the file(s)?

Thanks

Does this work for you in a terminal?
sudo su - postgres
<your login password>
cd /Library/PostgreSQL
find . -name log
From your first post, that ought to find the "log" mentioned in the output (and possible more than one if you have multiple installations).  As Peter pointed out that's a directory.  The logs will be in there.
cd <dir found from find command>
ls -ltr
Should show the most recent file last.  That's likely the file of interest.





Re: Fw: Re: Could Not Connect To Server

От
Adrian Klaver
Дата:
On 4/23/20 3:03 PM, Dummy Account wrote:
> I cannot login into a postgres role via command line.
> Issue #1.
> I have never done it before via command line, so maybe I am doing it 
> incorrectly.
> I have been attempting to go:
> su - postgres
> Then it prompts me for the password.
> Unfortunately, none of the passwords that I think would pertain to 
> Postgres or PgAdmin work.
> What does work, is the "master password" that I use to log into the 
> pgAdmin Graphical User Interface.
> I would think that one would work, but it does not.

What did you use to do?:

sudo -u postgres ./pg_ctl start -D /Library/PostgreSQL/12/data


> Issue #2.
> I am thinking out loud hear, there are 3 passwords:
> Operating System Admin Password: I know that.
> pgAmin password: I know that.
> PostgreSQL 12 - the server with multiple database on it.  I believe I 
> know that?
> The issue with that is, while it was not letting me connect, I selected 
> what I think was called "clear password".
> Nonetheless, I still have what pgAdmin calls the "master password".
> So even if I did remove the password for "PostgreSQL" server, would I be 
> able to reset one?
> *Sent:* Thursday, April 23, 2020 at 4:26 PM
> *From:* "Adrian Klaver" <adrian.klaver@aklaver.com>
> *To:* "Dummy Account" <dummyaccount4u@mail.com>
> *Cc:* "pgsql-general" <pgsql-general@postgresql.org>, "David G. 
> Johnston" <david.g.johnston@gmail.com>
> *Subject:* Re: Fw: Re: Could Not Connect To Server
> On 4/23/20 1:37 PM, Dummy Account wrote:
>  > From the Finder, I think that is the same a File Explorer on Widows.
>  >  From Finder, it's locked; I cannot access it.  Could I use the command
>  > line and change ownership or access privledges?  And then get access?
> 
> Why not from the command line use a text editor to view the file(s)?
> 
>  > Thanks
> 
> 
> 
> --
> Adrian Klaver
> adrian.klaver@aklaver.com


-- 
Adrian Klaver
adrian.klaver@aklaver.com



Re: Fw: Re: Could Not Connect To Server

От
"David G. Johnston"
Дата:
On Thu, Apr 23, 2020 at 3:03 PM Dummy Account <dummyaccount4u@mail.com> wrote:
 
I cannot login into a postgres role via command line.  
 
Issue #1.
I have never done it before via command line, so maybe I am doing it incorrectly.
I have been attempting to go: 
 
su - postgres

 
The "sudo" in Rob's answer wasn't optional.  Attempting to use sudo should require the OS Admin Password

David J.

 

Re: Fw: Re: Could Not Connect To Server

От
Rob Sargent
Дата:


On 4/23/20 4:19 PM, Dummy Account wrote:
This worked.
sudo su - postgres
I was now able to log into data and ls
Inside data is "log".
 
How do I open log?
and got:
LSOpenURLsWithRole() failed with erro -610
 
I then tried:
log show
and I got:
log: Could not be open local log store: The log archive format is corrupt and cannot be read
 
So that right there sounds more conducive to the OS being restored( not that I know ), all the files were likely rewritten?
 
 

"log" is another directory, correct?
cd log
ls -l
should show you the logfiles.  Use a text editor on the most recently written.

Re: Fw: Re: Re: Could Not Connect To Server

От
Rob Sargent
Дата:


On 4/23/20 4:46 PM, Dummy Account wrote:
 
I cd'd into log and listed the files.  There are many.
How should I get the log that you want.
 
 
I tried:

open -a TextEdit postgresql-2020-04-22_171300.log

I got:

LSOpenURLsWithRole() failed for the application /Applications/TextEdit.app with error -610 for the file /Library/PostgreSQL/12/data/log/postgresql-2020-04-22_171300.log.

 
That appears to me to say that, for the current user, TextEdit could not open the log file.  What was the effective user?  Were you still in a session under 'sudo su - postgres' in which case postgres can't read the log file.  If that's the case then postgres likely can't read the data files either.

Can you show the output of these commands in the data directory?
id
\ls -ltr
I ask for the "\ls" to make sure there are no funny aliases in place.

 
Sent: Thursday, April 23, 2020 at 5:19 PM
From: "Dummy Account" <dummyaccount4u@mail.com>
To: "Adrian Klaver" <adrian.klaver@aklaver.com>
Cc: "pgsql-general" <pgsql-general@postgresql.org>, "David G. Johnston" <david.g.johnston@gmail.com>
Subject: Re: Fw: Re: Could Not Connect To Server
This worked.
sudo su - postgres
I was now able to log into data and ls
Inside data is "log".
 
How do I open log?
and got:
LSOpenURLsWithRole() failed with erro -610
 
I then tried:
log show
and I got:
log: Could not be open local log store: The log archive format is corrupt and cannot be read
 
So that right there sounds more conducive to the OS being restored( not that I know ), all the files were likely rewritten?