Munin和postgresql 9.2

我试图build立一个服务器上使用postgresql 9.1和9.2(服务器当前正在运行9.1,已经在9.2新鲜的虚拟机上testing,以排除运行的服务器上的一些奇怪的问题的服务器上的统计数据,我不得不补丁9.2的插件由于重命名的列(例如procpid到pid),但这没有问题)。

Munin是从EPEL回购版安装的,postgres是官方的。 两者都是最新的。

当我尝试运行munin-node-configure –suggest时,我得到这个输出:

# The following plugins caused errors: # postgres_bgwriter: # Junk printed to stderr # postgres_cache_: # Junk printed to stderr # postgres_checkpoints: # Junk printed to stderr # postgres_connections_: # Junk printed to stderr # postgres_connections_db: # Junk printed to stderr # postgres_locks_: # Junk printed to stderr # postgres_querylength_: # Junk printed to stderr # postgres_scans_: # Junk printed to stderr # postgres_size_: # Junk printed to stderr # postgres_transactions_: # Junk printed to stderr # postgres_tuples_: # Junk printed to stderr # postgres_users: # Junk printed to stderr # postgres_xlog: # Junk printed to stderr 

经过大量的search,我编辑了/etc/munin/plugin-conf.d/munin-node并添加了以下内容:

 [postgres*] user postgres 

这阻止了munin-node-config抱怨stderr,并让我添加插件,但是当我在4949上telnet到服务器并尝试获取统计信息时,我只是得到“Bad exit”。 当我通过munin-run单独运行插件(例如munin-run postgres_size_ALL)时,它运行得很好。 查看/var/log/munin/munin-node.log,这是输出:

 Error output from postgres_size_ALL: DBI connect('dbname=template1','',...)failed: could not connect to server: Permission denied Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"? at /usr/share/perl5/vendor_perl/Munin/Plugin/Pgsql.pm line 377 Service 'postgres_size_ALL exited with status 1/0. 

我现在没有想法…套接字肯定存在,pg_hba.conf设置为允许所有用户/数据库从本地信任。

原来SELinux阻止了对socket的访问。

 setsebool -P allow_user_postgresql_connect on 

我刚刚有这个问题,但我不使用SELinux。 在我的系统(Gentoo Linux)上,PostgreSQL UNIX套接字受到组权限的保护,所有想要访问该套接字的用户都必须在组postgres 。 我的用户munin已经是postgres的成员(因此一切都从shell运行良好),但事实certificate,Munin是那些不隐式应用用户组的程序之一。 设置user muningroup postgres在插件configuration文件解决了我的问题。