以pg_stat_statements为例
编译扩展
cd /usr/local/pgsql/contrib/pg_stat_statements/
make && make install
启用扩展
切换为postgres用户sudo su - postgres
,运行sql命令行psql
,启用扩展
CREATE EXTENSION pg_stat_statements;
修改postgresql.conf
进入宝塔面板,修改postgres配置
shared_preload_libraries= 'pg_stat_statements'