LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-15-2014, 02:18 AM   #1
Huamin
Member
 
Registered: May 2011
Posts: 562

Rep: Reputation: 12
Problem got


Hi,
what to check, due to this problem?

[root@CentOS65x64 huamin]# service postgresql start
Starting postgresql service: [ OK ]
[root@CentOS65x64 huamin]# exit
exit
[huamin@CentOS65x64 ~]$ postgres -D /var/lib/pgsql/data
postgres cannot access the server configuration file "/var/lib/pgsql/data/postgresql.conf": Permission denied
 
Old 07-15-2014, 02:32 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726

Rep: Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706
Hi,

the error indicates that /var/lib/pgsql/data/postgresql.conf is readable by the user huamin.

Evo2.
 
Old 07-15-2014, 02:50 AM   #3
Huamin
Member
 
Registered: May 2011
Posts: 562

Original Poster
Rep: Reputation: 12
But some other people said I should not change any permissions to the folder of Postgresql.
 
Old 07-15-2014, 08:27 PM   #4
Huamin
Member
 
Registered: May 2011
Posts: 562

Original Poster
Rep: Reputation: 12
Any other help?
 
Old 07-15-2014, 08:45 PM   #5
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726

Rep: Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706
Hi,

I did not suggest that you change the permissions. I was trying to hint that is not normal to run the postgres server in the way you are trying to. Why are you trying to run the postgres server as the user "huamin"? Normally it should be run by a dedicated user (as is the case when when you start it using "service").

Evo2.
 
Old 07-15-2014, 09:21 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,807

Rep: Reputation: 6333Reputation: 6333Reputation: 6333Reputation: 6333Reputation: 6333Reputation: 6333Reputation: 6333Reputation: 6333Reputation: 6333Reputation: 6333Reputation: 6333
Quote:
Originally Posted by Huamin View Post
Any other help?
In other words there is no problem.
 
Old 07-16-2014, 12:18 AM   #7
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,366
Blog Entries: 24

Rep: Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297
Quote:
Originally Posted by Huamin View Post
Any other help?
Huamin, you marked the other thread solved then opened this one, which is not helpful to you or to those trying to help you. So let me take another pass at this one for you...

First, even after two threads it is still not at all clear what you are trying to do, or what problem you are having.

Quote:
Originally Posted by Huamin View Post
what to check, due to this problem?

[root@CentOS65x64 huamin]# service postgresql start
Starting postgresql service: [ OK ]

[root@CentOS65x64 huamin]# exit
exit
[huamin@CentOS65x64 ~]$ postgres -D /var/lib/pgsql/data
postgres cannot access the server configuration file "/var/lib/pgsql/data/postgresql.conf": Permission denied
That is correct operation on most systems! So obviously you were expecting something else...

In the blue hilighted text above, you have started the postgresql server - it is apparently running (no errors), so I will assume that you have have initialized it with initdb at some point.

So it makes no sense that you are trying to start it again in the red hilighted text! I see no reason for that - if you have some reason please explain why you are trying to start postgresql as user huamin after it is already running?

This makes me think that what you are actually trying to do is to open a postgresql client as the huamin user. If that is true then you need to use psql - not postgres. Something like...

Code:
[huamin@CentOS65x64 ~]$ psql

OR

[huamin@CentOS65x64 ~]$ psql huamin
... where huamin would be the optional default database name for the user on most systems (I am not sure about CentOS, but probably so).

So in order to help you, we need to know what you are trying to do, and we need you to stay with it in one thread until it is actually solved.

Please try to explain more precisely what you are trying to do. If you really want to start the postgresql server as user huamin, please provide more information about the actual intended use.

If you are trying to use postgresql after it has been started (blue text above) then try the psql command as above and post any errors that you receive.

Last edited by astrogeek; 07-16-2014 at 12:27 AM.
 
Old 07-16-2014, 03:48 AM   #8
Huamin
Member
 
Registered: May 2011
Posts: 562

Original Poster
Rep: Reputation: 12
Many thanks Astrogeek.

Yes, I was testing if I could open psql or not. but due to these

[root@CentOS65x64 huamin]# service postgresql start
Starting postgresql service: [ OK ]
[root@CentOS65x64 huamin]# exit
exit
[huamin@CentOS65x64 ~]$ psql
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
[huamin@CentOS65x64 ~]$ createdb postdb1
createdb: could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
[huamin@CentOS65x64 ~]$

what to adjust?
 
Old 07-16-2014, 09:48 AM   #9
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,366
Blog Entries: 24

Rep: Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297
Quote:
Originally Posted by Huamin View Post
Many thanks Astrogeek.

Yes, I was testing if I could open psql or not. but due to these

[root@CentOS65x64 huamin]# service postgresql start
Starting postgresql service: [ OK ]
[root@CentOS65x64 huamin]# exit
exit
[huamin@CentOS65x64 ~]$ psql
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
[huamin@CentOS65x64 ~]$ createdb postdb1
createdb: could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
[huamin@CentOS65x64 ~]$

what to adjust?
Ah - progress!

That means that the postgres service did not actually start!

First, have a look at the postgres log to see if it indicates why it failed to start. Probably something like this (may be different on CentOS)

Code:
tail -n20 /var/log/postgres
I would then guess that you have never initialized postgres, so unless the log tells you otherwise, try this (also see man initdb):

Code:
[root@....]# su postgres -c "initdb -D /var/lib/pgsql/data"

Then

[root@...]# service start postgresql

Then

[root@...]# createdb --owner huamin huamin

Then

[huamin@...]# psql huamin
Try each of those and post back any error messages that occur along the way.
 
Old 07-16-2014, 08:30 PM   #10
Huamin
Member
 
Registered: May 2011
Posts: 562

Original Poster
Rep: Reputation: 12
Thanks. Please advise to these.
[huamin@CentOS65x64 ~]$ tail -n20 /var/log/postgres
tail: cannot open `/var/log/postgres' for reading: No such file or directory
[huamin@CentOS65x64 ~]$ su
Password:
[root@CentOS65x64 huamin]# tail -n20 /var/log/postgres
tail: cannot open `/var/log/postgres' for reading: No such file or directory
[root@CentOS65x64 huamin]# su postgres -c "initdb -D /var/lib/pgsql/data"
could not change directory to "/home/huamin"
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale en_US.UTF-8.
The default database encoding has accordingly been set to UTF8.
The default text search configuration will be set to "english".

initdb: could not access directory "/var/lib/pgsql/data": Permission denied
[root@CentOS65x64 huamin]# service start postgresql
start: unrecognized service
[root@CentOS65x64 huamin]# createdb
createdb: could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
[root@CentOS65x64 huamin]# exit
exit
[huamin@CentOS65x64 ~]$ psql huamin
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
[huamin@CentOS65x64 ~]$
 
Old 07-16-2014, 09:58 PM   #11
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,807

Rep: Reputation: 6333Reputation: 6333Reputation: 6333Reputation: 6333Reputation: 6333Reputation: 6333Reputation: 6333Reputation: 6333Reputation: 6333Reputation: 6333Reputation: 6333
The CentOS default log directory is /var/lib/pgsql/data/pg_log

If the postgresql was not originally initialised you would of seen an error message when
first staring the service.

To initialize:
service postgresql initdb

I would start postgresql from the command line (as root) to see all of the messages.
/usr/bin/postgres -D /var/lib/pgsql/data
 
Old 07-16-2014, 11:06 PM   #12
Huamin
Member
 
Registered: May 2011
Posts: 562

Original Poster
Rep: Reputation: 12
I do not see the file below
[huamin@CentOS65x64 ~]$ su
Password:
[root@CentOS65x64 huamin]# ls -l /var/lib/pgsql/data/pg_log*
total 16
-rw-------. 1 postgres postgres 963 Jul 11 23:16 postgresql-Fri.log
-rw-------. 1 postgres postgres 321 Jul 14 11:58 postgresql-Mon.log
-rw-------. 1 postgres postgres 642 Jul 12 12:36 postgresql-Sat.log
-rw-------. 1 postgres postgres 188 Jul 15 12:00 postgresql-Tue.log

and have got these

[root@CentOS65x64 huamin]# service postgresql initdb
Data directory is not empty! [FAILED]
[root@CentOS65x64 huamin]# /usr/bin/postgres -D /var/lib/pgsql/data
"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise. See the documentation for
more information on how to properly start the server.
[root@CentOS65x64 huamin]# service postgresql start
Starting postgresql service: [ OK ]
[root@CentOS65x64 huamin]#
 
Old 07-16-2014, 11:25 PM   #13
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726

Rep: Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706
Hi Huamin,

when you run a command and an error message is returned, instead of just cutting and pasting it to the forum you should do other things. These things include, but are not limited to:

- Read the error messages
- Think about what they mean
- Think about what to do based on what the error means
- Read log files
- If you don't understand something, try looking it up

Finally, post to the forum, including your interpretation or the situation and any questions you have about what the error messages, output, logs etc mean.

Evo2.
 
Old 07-18-2014, 12:59 AM   #14
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,366
Blog Entries: 24

Rep: Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297Reputation: 4297
Hello Huamin, sorry I had to be away the last 2 days.

Quote:
Originally Posted by Huamin View Post
Thanks. Please advise to these.
[huamin@CentOS65x64 ~]$ tail -n20 /var/log/postgres
tail: cannot open `/var/log/postgres' for reading: No such file or directory
[huamin@CentOS65x64 ~]$ su
Password:
[root@CentOS65x64 huamin]# tail -n20 /var/log/postgres
tail: cannot open `/var/log/postgres' for reading: No such file or directory
As noted in my last post, I am not familiar with CentOS so was unsure the exact location of the log files.

Thanks to michaelk it appears that the log files are under /var/lib/pgsql/data/pg_log.

Per your last post, it also appears that they are rotated daily.

So let's take this a single step at a time. First let's figure out how to access the current log (at any time), then lets try to start postgresql and see what appears in that log... then we can move on to the next step.

Also, as evo2 says, try to think clearly about what you see in response to a command and make sense of it. If it says that it could not do something then there may be no point in going on the the next step until we figure out what went wrong. Otherwise we will never really know what is happening.

So, about those logs. Do this (as root)...

Code:
ls -lt /var/lib/pgsql/data/pg_log*

(Sorted by timestamp, find out which is the current day's log.)

tail -n20 /var/lib/pgsql/data/(current log)
If that does not produce results, try to figure out how to get the last 20 lines from the current log, whatever it is named. And remember that if postgresql has not had activity today, there will be no log for today until you start it.

Now, lets try to start it and see what appears in the log (as root)...

Code:
service postgresql start

tail -n20 /var/lib/pgsql/data/(current log, and make sure it is the most recent timestamped log)
Paste back the results of that and we will know what to do next.
 
Old 07-18-2014, 01:43 AM   #15
Huamin
Member
 
Registered: May 2011
Posts: 562

Original Poster
Rep: Reputation: 12
Many thanks Astrogeek. Here are what I've got

[huamin@CentOS65x64 ~]$ su
Password:
[root@CentOS65x64 huamin]# ls -lt /var/lib/pgsql/data/pg_log*
total 16
-rw-------. 1 postgres postgres 188 Jul 15 12:00 postgresql-Tue.log
-rw-------. 1 postgres postgres 321 Jul 14 11:58 postgresql-Mon.log
-rw-------. 1 postgres postgres 642 Jul 12 12:36 postgresql-Sat.log
-rw-------. 1 postgres postgres 963 Jul 11 23:16 postgresql-Fri.log
[root@CentOS65x64 data]# tail -n20 /var/lib/pgsql/data/pg_log/postgresql-Tue.log
LOG: database system was shut down at 2014-07-14 11:58:17 HKT
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
LOG: received smart shutdown request
[root@CentOS65x64 data]# service postgresql start
Starting postgresql service: [ OK ]
[root@CentOS65x64 data]# ls -lt /var/lib/pgsql/data/pg_log*
total 16
-rw-------. 1 postgres postgres 188 Jul 15 12:00 postgresql-Tue.log
-rw-------. 1 postgres postgres 321 Jul 14 11:58 postgresql-Mon.log
-rw-------. 1 postgres postgres 642 Jul 12 12:36 postgresql-Sat.log
-rw-------. 1 postgres postgres 963 Jul 11 23:16 postgresql-Fri.log
[root@CentOS65x64 data]# tail -n20 /var/lib/pgsql/data/pg_log/postgresql-Tue.log
LOG: database system was shut down at 2014-07-14 11:58:17 HKT
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
LOG: received smart shutdown request
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Do I have a path problem, an Apache2 problem or a Javascript problem or any other pro rblampain Linux - Networking 0 12-29-2010 03:50 AM
Dual Boot issue (Mint 9 and Vista) problem - on Day 4 of problem... restevns Linux - Newbie 3 10-20-2010 11:26 PM
Sound Card problem(every time i install linux i have diffirent hardware problem) jacka1l Linux - Newbie 7 08-11-2005 06:10 AM
Lan configuration problem - NFS boot problem - RX&TX packets errors 242VDM242 Linux - Networking 4 11-25-2004 01:35 PM
perl problem? apache problem? cgi problem? WorldBuilder Linux - Software 1 09-17-2003 07:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration