I have inherited a tomcat application running on RHEL that connects to a local postgres database. We have a total of 8 servers in multiple states running this. Each server actually has two different postgres databases on it. Each day we switch back and forth from one database to the other and the non-live database then gets replaced with new data to switch back the next day.
We are using redir to redirect the database connection in the application. By stopping the redir and re-starting it forwarding he new port we are able to point to the newest data.
The problem comes in when trying to stop the redir and getting FIN_WAITs which can cause a delay of up to a minute. Is there any way to use a redir so that existing connections continue to point to the old location but new ones point to the new port?
-m state
and-m conntrack
modules and the iptables documentation. I can't guarantee this approach will work as-is. You might have to use it in combination with packet tagging / labels and then label tests in thePREROUTING
rules if you can't use conntrack/state directly in thenat
table. Despite being somewhat out of date, check out the Linux Advanced Routing and Traffic Control HOWTO (lartc.org); it might have some guidance.