What Would Happen if I got NO "localhost" entry in my /etc/hosts ?
statistics and autovacuum would be disabled: # /usr/local/pgsql/bin/postgres -i -p 15432 -D data LOG: could not resolve "localhost": no address associated with name LOG: disabling statistics collector for lack of working socket WARNING: autovacuum not started because of misconfiguration HINT: Enable the "track_counts" option. LOG: database system was shut down at 2011-10-27 09:42:14 GMT LOG: database system is ready to accept connections So let's fix it: diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index b468797..fc0f0e7 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -143,6 +143,7 @@ extern bool synchronize_seqscans; extern bool fullPageWrites; extern int ssl_renegotiation_limit; extern char *SSLCipherSuites; +extern char *StatisticsCollectorListenAddress; #ifdef TRACE_SORT extern bool trace_sort; @@ -3052,6 +3053,16 @@ static struct config_string ConfigureNamesString[] = }, { + {"statistics_collector_listen_address", PGC_POSTMASTER, QUERY_TUNING_OTHER, + gettext_noop("Sets the host name or IP address for statistics collector listen to."), + NULL + }, + &StatisticsCollectorListenAddress, + "localhost", + NULL, NULL, NULL + }, + + { {"custom_variable_classes", PGC_SIGHUP, CUSTOM_OPTIONS, gettext_noop("Sets the list of known custom variable classes."), NULL, diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index 1d80c31..13ac5a9 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -117,6 +117,7 @@ int pgstat_track_activity_query_size = 1024; * Built from GUC parameter * ---------- */ +char *StatisticsCollectorListenAddress = NULL; char *pgstat_stat_filename = NULL; char *pgstat_stat_tmpname = NULL; @@ -323,12 +324,12 @@ pgstat_init(void) hints.ai_addr = NULL; hints.ai_canonname = NULL; hints.ai_next = NULL; - ret = pg_getaddrinfo_all("localhost", NULL, &hints, &addrs); + ret = pg_getaddrinfo_all(StatisticsCollectorListenAddress, NULL, &hints, &addrs); if (ret || !addrs) { ereport(LOG, - (errmsg("could not resolve \"localhost\": %s", - gai_strerror(ret)))); + (errmsg("could not resolve \"%s\": %s", + StatisticsCollectorListenAddress,gai_strerror(ret)))); goto startup_failed; } @@ -371,7 +372,7 @@ pgstat_init(void) { ereport(LOG, (errcode_for_socket_access(), - errmsg("could not bind socket for statistics collector: %m"))); + errmsg("could not bind socket for statistics_collector_listen_address(%s): %m",StatisticsCollectorListenAddress))); closesocket(pgStatSock); pgStatSock = PGINVALID_SOCKET; continue; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 0f1745f..630b8fd 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -259,6 +259,7 @@ # - Other Planner Options - +#statistics_collector_listen_address = 'localhost' # should bind to loopback interface #default_statistics_target = 100 # range 1-10000 #constraint_exclusion = partition # on, off, or partition #cursor_tuple_fraction = 0.1 # range 0.0-1.0 Tests: 1.NO localhost entry: # grep localhost /etc/hosts # grep statistics_collector_listen_address data/postgresql.conf #statistics_collector_listen_address = 'localhost' # should bind to loopback interface # /usr/local/pgsql/bin/postgres -i -p 5432 -D data LOG: could not resolve "localhost": no address associated with name LOG: disabling statistics collector for lack of working socket WARNING: autovacuum not started because of misconfiguration HINT: Enable the "track_counts" option. LOG: database system was shut down at 2011-10-27 09:43:18 GMT LOG: database system is ready to accept connections 2.Normal circumstance: # echo 127.0.0.1 localhost > /etc/hosts # grep localhost /etc/hosts 127.0.0.1 localhost # grep statistics_collector_listen_address data/postgresql.conf #statistics_collector_listen_address = 'localhost' # should bind to loopback interface # /usr/local/pgsql/bin/postgres -i -p 5432 -D data LOG: database system was shut down at 2011-10-27 09:48:32 GMT LOG: database system is ready to accept connections LOG: autovacuum launcher started 3./etc/hosts misconfigurated: # echo 127.0.0.44 localhost > /etc/hosts # grep localhost /etc/hosts 127.0.0.44 localhost # grep statistics_collector_listen_address data/postgresql.conf #statistics_collector_listen_address = 'localhost' # should bind to loopback interface # /usr/local/pgsql/bin/postgres -i -p 5432 -D data LOG: could not bind socket for statistics_collector_listen_address(localhost): Can't assign requested address LOG: disabling statistics collector for lack of working socket WARNING: autovacuum not started because of misconfiguration HINT: Enable the "track_counts" option. LOG: database system was shut down at 2011-10-27 09:52:10 GMT LOG: database system is ready to accept connections 4.statistics_collector_listen_address set to IP address: # grep localhost /etc/hosts 127.0.0.44 localhost # grep statistics_collector_listen_address data/postgresql.conf statistics_collector_listen_address = '127.0.0.1' # should bind to loopback interface # /usr/local/pgsql/bin/postgres -i -p 5432 -D data LOG: database system was shut down at 2011-10-27 10:03:56 GMT LOG: database system is ready to accept connections LOG: autovacuum launcher started 5.statistics_collector_listen_address misconfigurated: # grep statistics_collector_listen_address data/postgresql.conf statistics_collector_listen_address = '127.0.0.W' # should bind to loopback interface # /usr/local/pgsql/bin/postgres -i -p 5432 -D data LOG: could not resolve "127.0.0.W": no address associated with name LOG: disabling statistics collector for lack of working socket WARNING: autovacuum not started because of misconfiguration HINT: Enable the "track_counts" option. LOG: database system was shut down at 2011-10-27 10:10:12 GMT LOG: database system is ready to accept connections 6.NO such address: # grep statistics_collector_listen_address data/postgresql.conf statistics_collector_listen_address = '127.0.0.77' # should bind to loopback interface # /usr/local/pgsql/bin/postgres -i -p 5432 -D data LOG: could not bind socket for statistics_collector_listen_address(127.0.0.77): Can't assign requested address LOG: disabling statistics collector for lack of working socket WARNING: autovacuum not started because of misconfiguration HINT: Enable the "track_counts" option. LOG: database system was shut down at 2011-10-27 10:11:34 GMT LOG: database system is ready to accept connections All Tests Passed. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs