-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need to use a user other than postgres to register the remote servers #203
Comments
There's no requirement for having a superuser connection for any of the servers in a powa setup, if anything I would also recommend not doing that. Creating and configuring the various extensions (including pg_stat_statements) requires a superuser connection, but this is only needed for the CREATE EXTENSION and modifying
If you want the UI to be able to connect to a remote server, you also need
For the authentication, it's just a psycopg2 connection, which relies on libpq. So any authentication method should work just fine with powa, assuming you configure it as needed. You also need to remember that it's mostly powa-collector t hat needs to authenticate on all the servers, so the user that runs powa-collector needs to be configured this way. It could be either with a local |
Ok. The powa-collector is also running on the repository server and connects to the repository database as powa_adm user. Thanks |
yes, using the same powa_adm non superuser role should work, assuming that powa-collector (and possibly powa-web if you need it) can get an AD token |
I found out that even for AD user accounts, I have to mention the password while registering the server, because password still needs to be passed to the remote server which gets authenticated by AD server, instead of locally. That's the only difference. I have another question when using the powa_register_server function. Even though I'm passing regular user and not postgres in the username parameter, I still need to pass postgres as the value for dbname parameter, right? Because there will be multiple databases in the remote server, and I need to monitor all of them. Thanks |
I think that's because the configuration on the remote server side. maybe it's relying on something like ldap authentication (which does require passing a plain text password) rather than gss. or maybe pam is configured to do the same lookup against your AD? but in any case there's nothing powa can do about it, it's what the postgres server requires. you could still rely on a .pgpass file to provide the password rather than storing it in plain text in the powa database, or passing it as env variable using some secret if you rely on containers.
you need to specify the database where powa is installed. all the extensions (pg_stat_statements and other) provide cluster-wide statistic so you only need to connect on that database. note that powa v5 will change things here, as the collector can try to connect to all databases to retrieve db-local metrics (pg_stat_*), but there will be configurations to specify which db to connect on (all, none, specific list or exception list). |
Yes, it is PAM authentication enabled on the remote server. Btw, I was trying to use .pgpass file on the powa repository server with no success. I still got the fe_sendauth: no password supplied error. May be I did not configure correctly. Regarding another question I asked powa_register_server, the reason I asked if I can specify postgres as the database in the database parameter field, is because, I'm going to now register a lot of remote DB servers, and I don't want to go and find out what is the actual database name over there. And yes, all the extensions are present in all the databases including postgres. Thanks |
Looks like there was some typo in the pgpass format in last reply. |
I just tested locally and the
That shouldn't be a problem. All access done by powa (either by the collector or the UI) are read-only query, so as long as it can access pg_stat_statements and any of the configured stat extensions it will work. |
Oh yes, I mentioned the hostname as the localhost (repository server), instead of the remote server. |
I have another question. |
the only requirement is to have the same major version for powa-archivist. so for instance 4.5.x everywhere. this extension takes care of all the backward compatibility with any supported extension. for the extension without upgrade path, it's because they don't actually store any data so it's doesn't matter if you upgrade or drop/create them. it can of course be problematic if you create custom views on top of them, but if any of the datatype is changed or some column is dropped you will end up with the same problem so I think it's cleaner to always force drop/create rather than randomly forcing it. on the remote server themselves, the powa-archivist extension is only used as a way to expose a compatible interface to the various other extensions, so you can also drop and recreate it. the only exception would be if you also configured local snapshot on the remote server configuring powa in shared_preload_libraries, as then you would have stored data. but then you would also snapshot everything twice which wouldn't really make sense. |
Yes, none of the remote servers has powa in shared_preload_libraries. Only the stats extensions are mentioned. |
yes, dropping and recreating the extensions won't be a problem. you might want to do that in a transaction though, in the event of a powa snapshot happening in the middle if you don't want that snapshot to fail. |
Yes, I will have to update extensions on DB servers, so will come up with a script to do one DB at a time. |
Just to let you know that granting CONNECT and pg_read_all_stats role to the regular user did not work. Without the above privileges, the UI throws the below errors: VDAM-QA1: Error while calling public.powa_kcache_src: permission denied for table powa_databases CONTEXT: SQL statement "SELECT now(), k.queryid, k.top, k.userid, k.dbid, k.plan_reads, k.plan_writes, k.plan_user_time, k.plan_system_time, k.plan_minflts, k.plan_majflts, k.plan_nswaps, k.plan_msgsnds, k.plan_msgrcvs, k.plan_nsignals, k.plan_nvcsws, k.plan_nivcsws, k.exec_reads, k.exec_writes, k.exec_user_time, k.exec_system_time, k.exec_minflts, k.exec_majflts, k.exec_nswaps, k.exec_msgsnds, k.exec_msgrcvs, k.exec_nsignals, k.exec_nvcsws, k.exec_nivcsws FROM pg_stat_kcache() k JOIN pg_roles r ON r.oid = k.userid WHERE NOT (r.rolname = ANY (string_to_array( powa_get_guc('powa.ignored_users', ''), ','))) AND k.dbid NOT IN (SELECT oid FROM powa_databases WHERE dropped IS NOT NULL)" PL/pgSQL function powa_kcache_src(integer) line 14 at RETURN QUERY |
ah thanks for the info, I actually wanted to document the permission needed so it's good to know |
My current setup is that all the remote servers are registered using postgres as username and dbname.
The pg_hba file on the remote servers have the entry of repository server using trust authentication.
The security team does not like it, and wants to use user other than postgres which is super user.
Is it possible to use a normal user? If so, what privileges need to be granted to this user?
The plan is to use PAM authentication. If not possible, then atleast need to use password authentication for the new user.
Appreciate your advice.
Thanks
Hari
The text was updated successfully, but these errors were encountered: