<div dir="ltr">Thanks a lot Bo, it really helps.<div>By default installing postgres will generate /usr/lib/systemd/system/postgresql-12.service as:</div><div><br></div><div>...</div><div>ExecStartPre=/usr/pgsql-12/bin/postgresql-12-check-db-dir ${PGDATA}<br>ExecStart=/usr/pgsql-12/bin/postmaster -D ${PGDATA}<br>ExecReload=/bin/kill -HUP $MAINPID<br></div><div>...</div><div><br></div><div>So maybe to start postgresql automatically I just need to change from</div><div>ExecStart=/usr/pgsql-12/bin/postmaster -D ${PGDATA}  <br></div><div>to</div><div>ExecStart=/usr/pgsql-12/bin/postgresql -D ${PGDATA}  <br></div><div><br></div><div>as <a href="http://saule1508.github.io/pgpool/">http://saule1508.github.io/pgpool/</a> described (in case we use the default data directory)</div><div><br></div><div>Then for pgpool we need to check and test, pick up a good number for search_primary_node_timeout.</div><div>After that in most cases if we just rebooted those 3 servers, postgresql &amp; pgpool could start automatically.</div><div><br></div><div>Please correct me if I&#39;m wrong.</div><div>Thanks a lot.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 12, 2020 at 9:53 AM Bo Peng &lt;<a href="mailto:pengbo@sraoss.co.jp">pengbo@sraoss.co.jp</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
On Wed, 12 Aug 2020 00:28:54 +0800<br>
&quot;J.L.&quot; &lt;<a href="mailto:wantdrink@gmail.com" target="_blank">wantdrink@gmail.com</a>&gt; wrote:<br>
<br>
&gt; Hi Bo,<br>
&gt; In fact the I only start pgpool service in all servers with<br>
&gt; systemctl start pgpool<br>
&gt; <br>
&gt; And only start the postgres on the primary with<br>
&gt; systemctl start postgresql-12<br>
&gt; <br>
&gt; The postgres service started on server 2 &amp; 3 as replication is to execute<br>
&gt; pcp_recovery_node command with specify the VIP as the host the same as the<br>
&gt; official guidance:<br>
&gt; 8.3.7.1. Set up PostgreSQL standby server<br>
&gt; <br>
&gt;     # pcp_recovery_node -h 192.168.137.150 -p 9898 -U pgpool -n 1<br>
&gt;     Password:<br>
&gt;     pcp_recovery_node -- Command Successful<br>
&gt; <br>
&gt;     # pcp_recovery_node -h 192.168.137.150 -p 9898 -U pgpool -n 2<br>
&gt;     Password:<br>
&gt;     pcp_recovery_node -- Command Successful<br>
&gt; <br>
<br>
You are using &quot;pcp_recovery_node&quot; to create standby servers.<br>
Thank you for your explanation.<br>
<br>
I don&#39;t recommend automatic starting pgpool at boot.<br>
Pgpool will try to find backend servers at startup,<br>
If all the backend servers have not been started, <br>
pgpool may trigger failover and don&#39;t accept any <br>
new connections.<br>
<br>
Therefore, you need to make sure that at least one backend server is running<br>
before pgpool is started.<br>
<br>
If your backend server takes time to startup,<br>
the workaround is to set &quot;search_primary_node_timeout&quot; parameter a little longer.<br>
Default is 300 seconds.<br>
It means pgpool will keep try to search for the primary node for 300 seconds at startup.<br>
<br>
<a href="https://www.pgpool.net/docs/latest/en/html/runtime-config-failover.html#GUC-SEARCH-PRIMARY-NODE-TIMEOUT" rel="noreferrer" target="_blank">https://www.pgpool.net/docs/latest/en/html/runtime-config-failover.html#GUC-SEARCH-PRIMARY-NODE-TIMEOUT</a><br>
<br>
&gt; The configuration of pgpool is nearly the same with<br>
&gt; <a href="https://www.pgpool.net/docs/latest/en/html/example-cluster.html#EXAMPLE-CLUSTER-PRE-SETUP" rel="noreferrer" target="_blank">https://www.pgpool.net/docs/latest/en/html/example-cluster.html#EXAMPLE-CLUSTER-PRE-SETUP</a><br>
&gt; <br>
&gt; Thanks.<br>
&gt; .<br>
&gt; <br>
&gt; On Tue, Aug 11, 2020 at 10:47 PM Bo Peng &lt;<a href="mailto:pengbo@sraoss.co.jp" target="_blank">pengbo@sraoss.co.jp</a>&gt; wrote:<br>
&gt; <br>
&gt; &gt; Hi,<br>
&gt; &gt;<br>
&gt; &gt; On Sun, 9 Aug 2020 17:05:01 +0800<br>
&gt; &gt; &quot;J.L.&quot; &lt;<a href="mailto:wantdrink@gmail.com" target="_blank">wantdrink@gmail.com</a>&gt; wrote:<br>
&gt; &gt;<br>
&gt; &gt; &gt; Hi there,<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I&#39;ve installed pgpool 4.1.2 and postgresql 12.3 with watchdog based on<br>
&gt; &gt; &gt; <a href="https://www.pgpool.net/docs/latest/en/html/example-cluster.html" rel="noreferrer" target="_blank">https://www.pgpool.net/docs/latest/en/html/example-cluster.html</a>.<br>
&gt; &gt; &gt; That is 3 machines with a VIP, pgpool service + watchdog service +<br>
&gt; &gt; &gt; postgresql service running on each of them, 1 primary + 2 standby<br>
&gt; &gt; &gt; postgresql.<br>
&gt; &gt; &gt; The question is: is that possible to enable those services as auto<br>
&gt; &gt; started<br>
&gt; &gt; &gt; even if I reboot all of them?<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I checked running services on them:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; [root@primary ~]# systemctl status postgresql-12<br>
&gt; &gt; &gt; &gt; postgresql-12.service - PostgreSQL 12 database server<br>
&gt; &gt; &gt; &gt;    Loaded: loaded (/usr/lib/systemd/system/postgresql-12.service;<br>
&gt; &gt; &gt; &gt; disabled; vendor preset: disabled)<br>
&gt; &gt; &gt; &gt;    Active: active (running) since Thu 2020-07-02 22:17:35 CDT; 1<br>
&gt; &gt; months 6<br>
&gt; &gt; &gt; &gt; days ago<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; [root@secondary1 ~]# systemctl status postgresql-12<br>
&gt; &gt; &gt; &gt; postgresql-12.service - PostgreSQL 12 database server<br>
&gt; &gt; &gt; &gt;    Loaded: loaded (/usr/lib/systemd/system/postgresql-12.service;<br>
&gt; &gt; &gt; &gt; disabled; vendor preset: disabled)<br>
&gt; &gt; &gt; &gt;    Active: inactive (dead)<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; [root@secondary2 ~]# systemctl status postgresql-12<br>
&gt; &gt; &gt; &gt; postgresql-12.service - PostgreSQL 12 database server<br>
&gt; &gt; &gt; &gt;    Loaded: loaded (/usr/lib/systemd/system/postgresql-12.service;<br>
&gt; &gt; &gt; &gt; disabled; vendor preset: disabled)<br>
&gt; &gt; &gt; &gt;    Active: inactive (dead)<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; So the postgresql service on secondary 1 &amp; 2 is not started by postgresql<br>
&gt; &gt; &gt; service, they are triggered by pgpool with command like:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; /usr/pgsql-12/bin/postgres -D /var/lib/pgsql/12/data<br>
&gt; &gt;<br>
&gt; &gt; Sorry, I could not understand the configuration.<br>
&gt; &gt; May I ask how you configure pgpool to execute command above?<br>
&gt; &gt;<br>
&gt; &gt; &gt; And on the primary the ps aux shows<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; /usr/pgsql-12/bin/postmaster -D /var/lib/pgsql/12/data/<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Which means I can enable pgpool service on all 3 machines:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; systemctl enable pgpool<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; But shouldn&#39;t do the same for postgresql service like systemctl enable<br>
&gt; &gt; &gt; postgresql-12.<br>
&gt; &gt; &gt; Also I&#39;m not sure if enabling services to start automatically will lead<br>
&gt; &gt; to<br>
&gt; &gt; &gt; any issue.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Any suggestion or guidance about this is appreciated. I just want to make<br>
&gt; &gt; &gt; the DB system recover even after rebooting.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Thanks.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; --<br>
&gt; &gt; Bo Peng &lt;<a href="mailto:pengbo@sraoss.co.jp" target="_blank">pengbo@sraoss.co.jp</a>&gt;<br>
&gt; &gt; SRA OSS, Inc. Japan<br>
&gt; &gt;<br>
<br>
<br>
-- <br>
Bo Peng &lt;<a href="mailto:pengbo@sraoss.co.jp" target="_blank">pengbo@sraoss.co.jp</a>&gt;<br>
SRA OSS, Inc. Japan<br>
</blockquote></div>