我是 AgensGraph 的管理员,想记录所有 ddl。另外,我想知道那个运行 ddl 的用户。
有什么好的想法吗?
AgensGraph上有声明日志。
首先,更改“postgresql.conf”上的参数
log_connections = on
log_disconnections = on
log_line_prefix = '[%c] '
log_statement = 'ddl'
二、重启AgensGraph。
$ ag_ctl stop
waiting for server to shut down.... done
server stopped
$ ag_ctl start
server starting
最后,运行 ddl 并检查日志文件。
$ agens
agens (AgensGraph 1.3.1, based on PostgreSQL 9.6.2)
Type "help" for help.
agens =# create vlabel n;
CREATE VLABEL
agens=# \quit
结合连接日志,可以得到运行ddl的信息。
[5c4573ae.f84] LOG: connection received: host=[local]
[5c4573ae.f84] LOG: connection authorized: user=agens database=agens
[5c4573ae.f84] LOG: statement: create vlabel n;
[5c4573ae.f84] LOG: disconnection: session time: 0:00:07.783 user=agens database=agens host=[local]