Network Card Not Listening at Startup
Network Card Not Listening at Startup
От:
Ludwig Isaac Lim <ludz_lim@yahoo.com>
Дата:
Hello: I'm running postgresql 12.9 on Amazon Linux in AWS. My listen_addresses in postgresql.conf is configured like below: listen_addresses = '172.17.1.57,localhost' However, postgresql does not listen on 172..17.1.57. I can reproduce the phenomenon by simply rebooting the server and then run netstat -tulpn [root@ip-172-17-1-206 data]# netstat -tulpn | grep 5432 tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 2605/postgres And there's nothing abnormal in the logs: 2022-02-09 15:59:36.906 UTC [2663] LOG: database system was shut down at 2022-02-09 15:59:20 UTC 2022-02-09 15:59:36.930 UTC [2605] LOG: database system is ready to accept connections I had to run: systemctl restart postgresql For 172.17.1.57 to listen [root@ip-172-17-1-206 data]# netstat -tulpn | grep 5432 tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 4289/postgres tcp 0 0 172.17.1.57:5432 0.0.0.0:* LISTEN 4289/postgres Note that 172.17.1.57 is not the primary network interface. I created the network interface and attached it to the EC2 instance. My systemd config file for postgresql (/etc/systemd/system/postgresql.service) was copied from 18.3. Starting the Database Server 18.3. Starting the Database Server 18.3. Starting the Database Server 18.3.1. Server Start-up Failures 18.3.2. Client Connection Problems Before an... Extra information ------------------------------ postgres=# select version(); version -------------------------------------------------------------------------------- PostgreSQL 12.9 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 7.3.1 20180712 (R (1 row) How do make sure that NIC will be listening every time I started/restarted the server? Thanks in advance, Ludwig Lim
Re: Network Card Not Listening at Startup
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Ludwig Isaac Lim writes: > How do make sure that NIC will be listening every time I started/restarted the server? You need to tell systemd not to start the postgresql service until the network is up. In basic cases, you can edit the postgresql.service file, or maybe better create an add-on config file something like this: $ cat /etc/systemd/system/postgresql.service.d/delay_start.conf [Unit] After=network-online.target Wants=network-online.target (The add-on file name doesn't matter, the directory name does.) I'm not certain that this will wait for custom NICs if you are doing something nonstandard to configure those, but for me it works for alternate IPs configured in /etc/sysconfig/network-scripts/ifcfg-whatever. regards, tom lane
Re: Network Card Not Listening at Startup
От:
Ludwig Isaac Lim <ludz_lim@yahoo.com>
Дата:
> On Thursday, February 10, 2022, 01:49:10 AM GMT+8, Tom Lane wrote: >> Ludwig Isaac Lim writes: >> How do make sure that NIC will be listening every time I started/restarted the server? > You need to tell systemd not to start the postgresql service > until the network is up. > In basic cases, you can edit the postgresql.service file, > or maybe better create an add-on config file something like this: > $ cat /etc/systemd/system/postgresql.service.d/delay_start.conf > [Unit] > After=network-online.target > Wants=network-online.target > (The add-on file name doesn't matter, the directory name does.) > I'm not certain that this will wait for custom NICs if you are > doing something nonstandard to configure those, but for me > it works for alternate IPs configured in > /etc/sysconfig/network-scripts/ifcfg-whatever. > regards, tom lane Thanks Tom. It works. Regards, Ludwig