Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f7ytf-00066R-ET for pgsql-admin@arkaria.postgresql.org; Mon, 16 Apr 2018 07:49:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f7ytd-0002JR-QP for pgsql-admin@arkaria.postgresql.org; Mon, 16 Apr 2018 07:49:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f7ytd-0002JI-JI for pgsql-admin@lists.postgresql.org; Mon, 16 Apr 2018 07:49:53 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f7yta-0006Fv-Hp for pgsql-admin@lists.postgresql.org; Mon, 16 Apr 2018 07:49:52 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id A10014120C; Mon, 16 Apr 2018 09:49:48 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id PhacJvopZk5C; Mon, 16 Apr 2018 09:49:46 +0200 (CEST) Message-ID: <1523858878.2304.5.camel@cybertec.at> Subject: Re: How to tell if PGSQL 8.4 is in standby mode From: Laurenz Albe To: TSG , pgsql-admin@lists.postgresql.org In-Reply-To: <002701d3d529$76a8dd70$63fa9850$@telium.ca> References: <002701d3d529$76a8dd70$63fa9850$@telium.ca> Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Date: Mon, 16 Apr 2018 08:07:58 +0200 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk TSG wrote: > I have a PostgreSQL 8.4 database that I'm am trying to start in standby mode > (I am shipping my own logs from the active DB). I think my standby DB is in > standby/recovery mode but I'm not sure how to tell. I probably don't have to tell you that you shouldn't be using 8.4. > First of all, pg_controldata says the database is "shut down": Don't know offhand if that is significant or not ... > But that contradicts the status command output: > > [root@node2 pgsql]# sudo -u postgres pg_ctl status -D /var/lib/pgsql/data > pg_ctl: server is running (PID: 35852) > /usr/bin/postgres "-D" "/var/lib/pgsql/data" > > > And when I try to start the database it says it's already running: > > [root@node2 pgsql]# sudo -u postgres pg_ctl start -D /var/lib/pgsql/data > pg_ctl: another server might be running; trying to start server anyway > [2018-04-15 23:06:11 GMT] FATAL: lock file "postmaster.pid" already exists > [2018-04-15 23:06:11 GMT] HINT: Is another postmaster (PID 35852) running in data directory "/var/lib/pgsql/data"? > pg_ctl: could not start server > Examine the log output. ... but that convinces me that the server is running. > And I can see that my recovery.conf is still in place: > > [root@node2 pgsql]# cat data/recovery.conf > restore_command='pg_standby -r 10 -t /var/run/myapp.trigger /var/lib/pgsql/data/myapp-archive "%f" "%p"' > And finally, I see an every growing list of files in the archive directory. > > So, is there a way to tell if the wal (archive) files are being applied to the database? You might want to look into the PostgreSQL log file if there are messages that tell you what is going on. Also, you can use "ps" to see if there is an instance of "pg_standby" running. If yes, what WAL file is it working on? Is that WAL file present? You can use "strace" to attach to the "pg_standby" process and see what it is doing. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com