PostgreSQL: Autovacuum 进程异常一例

今天在测试库上发现 autovacuum 无法正常启动,数据库版本 9.1.0,经查已经配置 autovacuum=on ,发现日志出现如下信息

数据库 CSVLOG

1
2
3
2012-03-08 11:14:59.017 CST,,,1155,,4f582407.483,1,,2012-03-08 11:14:15 CST,,0,LOG,00000,"could not resolve ""localhost"": Temporary failure in name resolution",,,,,,,,,""  
2012-03-08 11:14:59.017 CST,,,1155,,4f582407.483,2,,2012-03-08 11:14:15 CST,,0,LOG,00000,"disabling statistics collector for lack of working socket",,,,,,,,,""
2012-03-08 11:14:59.018 CST,,,1155,,4f582407.483,3,,2012-03-08 11:14:15 CST,,0,WARNING,01000,"autovacuum not started because of misconfiguration",,"Enable the ""track_counts"" option.",,,,,,,""

备注:注意这个ERROR,提示 autovacuum 进程没有正常启动是因为参数 track_counts 没有设置成 on,接着查看 $PGDATA/postgresql.conf, 发现 track_counts 参数已打开,并且这个参数默认是打开的,奇了怪了。

查看数据库参数

1
2
3
4
5
6
7
8
9
10
11
12
13
[postgres@pgb ~]$ psql -h 127.0.0.1  
psql (9.1.0)
mydb=> show autovacuum;
autovacuum
------------
on
(1 row)

postgres=# show track_counts;
track_counts
--------------
off
(1 row)

备注: 果然参数 track_counts 显示为 off,而在配置文件中明明是打开的,这是为啥呢?后来仔细查看 步骤1的报错,could not resolve “”localhost”,猜想可能是这里的问题。

Ping Localhost

ping localhost 不通,接着查看 /etc/hosts 文件。

查看 /etc/hosts

1
2
3
4
5
6
[root@pgb ~]# cat /etc/hosts  
# Do not remove the following line, or various programs
# that require network functionality will fail.
#127.0.0.1 pgb localhost.localdomain localhost
192.168.1.25 pg1
192.168.1.26 pgb

备注:发现 127.0.0.1 这行注释了,于是将注释拿掉,

Autovacuum 进程恢复

1
2
3
4
[postgres@pgb pg_root]$ ps -ef | grep auto  
root 2260 1 0 14:09 ? 00:00:00 automount
postgres 30865 30860 0 16:07 ? 00:00:00 postgres: autovacuum launcher process
postgres 30911 4812 0 16:19 pts/3 00:00:00 grep auto

备注:autovacuum 进程已恢复正常。

查看CSVLOG

1
2
2012-05-06 16:07:35.711 CST,,,30862,,4fa63147.788e,1,,2012-05-06 16:07:35 CST,,0,LOG,00000,"database system was shut down at 2012-05-06 16:07:23 CST",,,,,,,,,""  
2012-05-06 16:07:35.801 CST,,,30865,,4fa63147.7891,1,,2012-05-06 16:07:35 CST,,0,LOG,00000,"autovacuum launcher started",,,,,,,,,""

总结

开启 autovacuum 的步骤

  1. 设置 autovacuum = on ( 些参数默认打开 )
  2. 设置 track_counts = on ( 些参数默认打开 )
  3. 设置 /etc/hosts , 能 ping 通 localhost

原创文章,作者:254126420,如若转载,请注明出处:https://blog.ytso.com/237848.html

(0)
上一篇 2022年1月29日
下一篇 2022年1月29日

相关推荐

发表回复

登录后才能评论