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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
07-15-2014, 02:18 AM
|
#1
|
Member
Registered: May 2011
Posts: 562
Rep: 
|
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
|
|
|
07-15-2014, 02:32 AM
|
#2
|
LQ Guru
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726
|
Hi,
the error indicates that /var/lib/pgsql/data/postgresql.conf is readable by the user huamin.
Evo2.
|
|
|
07-15-2014, 02:50 AM
|
#3
|
Member
Registered: May 2011
Posts: 562
Original Poster
Rep: 
|
But some other people said I should not change any permissions to the folder of Postgresql.
|
|
|
07-15-2014, 08:27 PM
|
#4
|
Member
Registered: May 2011
Posts: 562
Original Poster
Rep: 
|
Any other help?
|
|
|
07-15-2014, 08:45 PM
|
#5
|
LQ Guru
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726
|
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.
|
|
|
07-15-2014, 09:21 PM
|
#6
|
Moderator
Registered: Aug 2002
Posts: 26,807
|
Quote:
Originally Posted by Huamin
Any other help?
|
In other words there is no problem.
|
|
|
07-16-2014, 12:18 AM
|
#7
|
Moderator
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,366
|
Quote:
Originally Posted by Huamin
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
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.
|
|
|
07-16-2014, 03:48 AM
|
#8
|
Member
Registered: May 2011
Posts: 562
Original Poster
Rep: 
|
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?
|
|
|
07-16-2014, 09:48 AM
|
#9
|
Moderator
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,366
|
Quote:
Originally Posted by Huamin
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.
|
|
|
07-16-2014, 08:30 PM
|
#10
|
Member
Registered: May 2011
Posts: 562
Original Poster
Rep: 
|
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 ~]$
|
|
|
07-16-2014, 09:58 PM
|
#11
|
Moderator
Registered: Aug 2002
Posts: 26,807
|
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
|
|
|
07-16-2014, 11:06 PM
|
#12
|
Member
Registered: May 2011
Posts: 562
Original Poster
Rep: 
|
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]#
|
|
|
07-16-2014, 11:25 PM
|
#13
|
LQ Guru
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726
|
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.
|
|
|
07-18-2014, 12:59 AM
|
#14
|
Moderator
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,366
|
Hello Huamin, sorry I had to be away the last 2 days.
Quote:
Originally Posted by Huamin
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.
|
|
|
07-18-2014, 01:43 AM
|
#15
|
Member
Registered: May 2011
Posts: 562
Original Poster
Rep: 
|
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
|
|
|
All times are GMT -5. The time now is 09:49 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|