How to startup the database server?

Started by Jason Maover 13 years ago7 messagesgeneral
Jump to latest
#1Jason Ma
rosegun38@gmail.com

Hi all,
I am a freshman of PostgreSQL, My env: PG 8.4 on CentOS,I follow the
document in the offical site to startup the db server. Here's what I do
below, the database cluster is ready, but I can't start the database server.

[root@testbox ~]# service postgresql initdb
Data directory is not empty! [FAILED]

[root@testbox ~]# service postgresql start
Starting postgresql service: [FAILED]

-bash-4.1$ postgres -D /var/lib/pgsql/data
-bash-4.1$ ps -ef |grep postgres
root 2710 2585 0 21:52 pts/1 00:00:00 su - postgres
postgres 2711 2710 0 21:52 pts/1 00:00:00 -bash
postgres 2752 2711 0 21:55 pts/1 00:00:00 ps -ef
postgres 2753 2711 0 21:55 pts/1 00:00:00 grep postgres

-bash-4.1$ postgres -D /var/lib/pgsql/data > binlog 2>&1 &
-bash-4.1$ ps -ef |grep postgres
root 2710 2585 0 21:52 pts/1 00:00:00 su - postgres
postgres 2711 2710 0 21:52 pts/1 00:00:00 -bash
postgres 2768 2711 1 21:59 pts/1 00:00:00 ps -ef
postgres 2769 2711 0 21:59 pts/1 00:00:00 grep postgres

I wonder why I can't start the database? Do I have some place to see the
log file. Hope anybody can help me. Thanks.
--
Best wishes,

Jason Ma

#2Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Jason Ma (#1)
Re: How to startup the database server?

On 12/19/2012 06:06 AM, Jason Ma wrote:

Hi all,
I am a freshman of PostgreSQL, My env: PG 8.4 on CentOS,I follow the
document in the offical site to startup the db server. Here's what I do
below, the database cluster is ready, but I can't start the database server.

[root@testbox ~]# service postgresql initdb
Data directory is not empty! [FAILED]

Well this means there already something in the data directory, most
likely the result of a previous initdb.
Is that indeed the case?

[root@testbox ~]# service postgresql start
Starting postgresql service: [FAILED]

-bash-4.1$ postgres -D /var/lib/pgsql/data
-bash-4.1$ ps -ef |grep postgres
root 2710 2585 0 21:52 pts/1 00:00:00 su - postgres
postgres 2711 2710 0 21:52 pts/1 00:00:00 -bash
postgres 2752 2711 0 21:55 pts/1 00:00:00 ps -ef
postgres 2753 2711 0 21:55 pts/1 00:00:00 grep postgres

-bash-4.1$ postgres -D /var/lib/pgsql/data > binlog 2>&1 &
-bash-4.1$ ps -ef |grep postgres
root 2710 2585 0 21:52 pts/1 00:00:00 su - postgres
postgres 2711 2710 0 21:52 pts/1 00:00:00 -bash
postgres 2768 2711 1 21:59 pts/1 00:00:00 ps -ef
postgres 2769 2711 0 21:59 pts/1 00:00:00 grep postgres

I wonder why I can't start the database? Do I have some place to see the
log file. Hope anybody can help me. Thanks.

I do not use CentOS/RH so I am of limited use here. For some pointers see:

http://wiki.postgresql.org/wiki/PostgreSQL_on_RedHat_Linux

From there the log would seem to be in /var/lib/pgsql

--
Best wishes,

Jason Ma

--
Adrian Klaver
adrian.klaver@gmail.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Jason Ma
rosegun38@gmail.com
In reply to: Adrian Klaver (#2)
Re: How to startup the database server?

Thanks, adrian, but I have check the pgstartup.log, I got the following
messages:
.....
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

Success. You can now start the database server using:

/usr/bin/postgres -D /var/lib/pgsql/data
or
/usr/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start

runuser: cannot set groups: Operation not permitted

I tried this:

-bash-4.1$ /usr/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start
server starting
-bash-4.1$ ps -ef |grep postgres
root 2904 2585 0 22:59 pts/1 00:00:00 su - postgres
postgres 2905 2904 0 22:59 pts/1 00:00:00 -bash
postgres 2946 2905 7 23:00 pts/1 00:00:00 ps -ef
postgres 2947 2905 0 23:00 pts/1 00:00:00 grep postgres

It reported that I have started the server but that doesn't work, I think
there must be somebody has the same problem with me. Any suggestions.

Regards,
Jason

2012/12/19 Adrian Klaver <adrian.klaver@gmail.com>

On 12/19/2012 06:06 AM, Jason Ma wrote:

Hi all,
I am a freshman of PostgreSQL, My env: PG 8.4 on CentOS,I follow the
document in the offical site to startup the db server. Here's what I do
below, the database cluster is ready, but I can't start the database
server.

[root@testbox ~]# service postgresql initdb
Data directory is not empty! [FAILED]

Well this means there already something in the data directory, most likely
the result of a previous initdb.
Is that indeed the case?

[root@testbox ~]# service postgresql start
Starting postgresql service: [FAILED]

-bash-4.1$ postgres -D /var/lib/pgsql/data
-bash-4.1$ ps -ef |grep postgres
root 2710 2585 0 21:52 pts/1 00:00:00 su - postgres
postgres 2711 2710 0 21:52 pts/1 00:00:00 -bash
postgres 2752 2711 0 21:55 pts/1 00:00:00 ps -ef
postgres 2753 2711 0 21:55 pts/1 00:00:00 grep postgres

-bash-4.1$ postgres -D /var/lib/pgsql/data > binlog 2>&1 &
-bash-4.1$ ps -ef |grep postgres
root 2710 2585 0 21:52 pts/1 00:00:00 su - postgres
postgres 2711 2710 0 21:52 pts/1 00:00:00 -bash
postgres 2768 2711 1 21:59 pts/1 00:00:00 ps -ef
postgres 2769 2711 0 21:59 pts/1 00:00:00 grep postgres

I wonder why I can't start the database? Do I have some place to see the
log file. Hope anybody can help me. Thanks.

I do not use CentOS/RH so I am of limited use here. For some pointers see:

http://wiki.postgresql.org/**wiki/PostgreSQL_on_RedHat_**Linux&lt;http://wiki.postgresql.org/wiki/PostgreSQL_on_RedHat_Linux&gt;

From there the log would seem to be in /var/lib/pgsql

--

Best wishes,

Jason Ma

--
Adrian Klaver
adrian.klaver@gmail.com

--
Best wishes,

Jason Ma

#4Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Jason Ma (#3)
Re: How to startup the database server?

On 12/19/2012 07:07 AM, Jason Ma wrote:

Thanks, adrian, but I have check the pgstartup.log, I got the following
messages:
.....
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

Success. You can now start the database server using:

/usr/bin/postgres -D /var/lib/pgsql/data
or
/usr/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start

runuser: cannot set groups: Operation not permitted

Seems the database cluster was initialized. Sort of concerned by the
runuser error. What user did you run the initdb as?

I tried this:

-bash-4.1$ /usr/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start
server starting

Nothing in the logfile?

-bash-4.1$ ps -ef |grep postgres
root 2904 2585 0 22:59 pts/1 00:00:00 su - postgres
postgres 2905 2904 0 22:59 pts/1 00:00:00 -bash
postgres 2946 2905 7 23:00 pts/1 00:00:00 ps -ef
postgres 2947 2905 0 23:00 pts/1 00:00:00 grep postgres

It reported that I have started the server but that doesn't work, I
think there must be somebody has the same problem with me. Any suggestions.

I am not seeing the server running in the above. You might want to retry
the ps with post as the grep expression.

Regards,
Jason

--
Adrian Klaver
adrian.klaver@gmail.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#5Jason Ma
rosegun38@gmail.com
In reply to: Adrian Klaver (#4)
Re: How to startup the database server?

Hi,
The ps output is after the server start, I don't know why I can't see
any process after start the server. And of course I use root to initial db,
'cause we have to run this command in CentOS which you need the privilege
of root.

service postgresql start

Regards,
Jason

2012/12/19 Adrian Klaver <adrian.klaver@gmail.com>

On 12/19/2012 07:07 AM, Jason Ma wrote:

Thanks, adrian, but I have check the pgstartup.log, I got the following
messages:
.....
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

Success. You can now start the database server using:

/usr/bin/postgres -D /var/lib/pgsql/data
or
/usr/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start

runuser: cannot set groups: Operation not permitted

Seems the database cluster was initialized. Sort of concerned by the
runuser error. What user did you run the initdb as?

I tried this:

-bash-4.1$ /usr/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start
server starting

Nothing in the logfile?

-bash-4.1$ ps -ef |grep postgres

root 2904 2585 0 22:59 pts/1 00:00:00 su - postgres
postgres 2905 2904 0 22:59 pts/1 00:00:00 -bash
postgres 2946 2905 7 23:00 pts/1 00:00:00 ps -ef
postgres 2947 2905 0 23:00 pts/1 00:00:00 grep postgres

It reported that I have started the server but that doesn't work, I
think there must be somebody has the same problem with me. Any
suggestions.

I am not seeing the server running in the above. You might want to retry
the ps with post as the grep expression.

Regards,
Jason

--
Adrian Klaver
adrian.klaver@gmail.com

--
Best wishes,

Jason Ma

#6Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Jason Ma (#5)
Re: How to startup the database server?

On Wed, Dec 19, 2012 at 7:34 AM, Jason Ma <rosegun38@gmail.com> wrote:

Hi,
The ps output is after the server start, I don't know why I can't see
any process after start the server. And of course I use root to initial db,
'cause we have to run this command in CentOS which you need the privilege
of root.

Well yes and no. If you run the service command you need to run as root. If
you become the Postgres user you can run the initdb command directly as
that user. The same goes for starting.

Did you try ps -ef | grep post ?

As a test try the following:

service postgresql stop

su - to the postgres user

do:

/usr/bin/pg_ctl -D /var/lib/pgsql/data start

Note no log file. This should output to the terminal.
Report what it says.

Also check the system log to see if there is something else preventing
Postgres start. Hint, SELinux.

service postgresql start

Regards,
Jason

2012/12/19 Adrian Klaver <adrian.klaver@gmail.com>

On 12/19/2012 07:07 AM, Jason Ma wrote:

Thanks, adrian, but I have check the pgstartup.log, I got the following
messages:
.....
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

Success. You can now start the database server using:

/usr/bin/postgres -D /var/lib/pgsql/data
or
/usr/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start

runuser: cannot set groups: Operation not permitted

Seems the database cluster was initialized. Sort of concerned by the
runuser error. What user did you run the initdb as?

I tried this:

-bash-4.1$ /usr/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start
server starting

Nothing in the logfile?

-bash-4.1$ ps -ef |grep postgres

root 2904 2585 0 22:59 pts/1 00:00:00 su - postgres
postgres 2905 2904 0 22:59 pts/1 00:00:00 -bash
postgres 2946 2905 7 23:00 pts/1 00:00:00 ps -ef
postgres 2947 2905 0 23:00 pts/1 00:00:00 grep postgres

It reported that I have started the server but that doesn't work, I
think there must be somebody has the same problem with me. Any
suggestions.

I am not seeing the server running in the above. You might want to retry
the ps with post as the grep expression.

Regards,
Jason

--
Adrian Klaver
adrian.klaver@gmail.com

--
Best wishes,

Jason Ma

--
Adrian Klaver
adrian.klaver@gmail.com

#7Jan Kesten
jan@dafuer.de
In reply to: Jason Ma (#5)
Re: How to startup the database server?

Hi Jason,

sounds a bit weird. Can you check which user the database files belong
to? A 'ls -lah /var/lib/pgsql' should do the job. Then switch from root
user to the postgresql user and try to start the cluster manually with
the command line from below (put from your message):

/usr/bin/postgres -D /var/lib/pgsql/data

That sould start your instance in foreground so you should see any
errors and messages during startup.

One more thing: is SELinux enabled?

Hope that helps :-)
Jan

On 19.12.2012 16:34, Jason Ma wrote:

Hi,
The ps output is after the server start, I don't know why I can't see
any process after start the server. And of course I use root to initial
db, 'cause we have to run this command in CentOS which you need the
privilege of root.

service postgresql start

Regards,
Jason

2012/12/19 Adrian Klaver <adrian.klaver@gmail.com
<mailto:adrian.klaver@gmail.com>>

On 12/19/2012 07:07 AM, Jason Ma wrote:

Thanks, adrian, but I have check the pgstartup.log, I got the
following
messages:
.....
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

Success. You can now start the database server using:

/usr/bin/postgres -D /var/lib/pgsql/data
or
/usr/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start

runuser: cannot set groups: Operation not permitted

Seems the database cluster was initialized. Sort of concerned by the
runuser error. What user did you run the initdb as?

I tried this:

-bash-4.1$ /usr/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start
server starting

Nothing in the logfile?

-bash-4.1$ ps -ef |grep postgres
root 2904 2585 0 22:59 pts/1 00:00:00 su - postgres
postgres 2905 2904 0 22:59 pts/1 00:00:00 -bash
postgres 2946 2905 7 23:00 pts/1 00:00:00 ps -ef
postgres 2947 2905 0 23:00 pts/1 00:00:00 grep postgres

It reported that I have started the server but that doesn't work, I
think there must be somebody has the same problem with me. Any
suggestions.

I am not seeing the server running in the above. You might want to
retry the ps with post as the grep expression.

Regards,
Jason

--
Adrian Klaver
adrian.klaver@gmail.com <mailto:adrian.klaver@gmail.com>

--
Best wishes,

Jason Ma

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general