首页 > 其他分享 >安装审计pgaudit

安装审计pgaudit

时间:2022-12-05 15:57:35浏览次数:76  
标签:审计 rhel7 x86 pgauditlogtofile 64 pgaudit 安装 log

 

1.查看安装的版本pgaudit

[root@localhost ~]# yum list pgaudit*
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
 * base: mirrors.163.com
 * epel: mirror-jp.misakamikoto.network
 * extras: mirrors.163.com
 * updates: mirrors.163.com
Available Packages
pgaudit12_10.x86_64                                            1.2.4-1.rhel7                              pgdg10     
pgaudit13_11.x86_64                                            1.3.4-1.rhel7                              pgdg11     
pgaudit14_12.x86_64                                            1.4.3-1.rhel7                              pgdg12     
pgaudit15_13.x86_64                                            1.5.2-1.rhel7                              pgdg13     
pgaudit16_14.x86_64                                            1.6.2-1.rhel7                              pgdg14     
pgaudit17_15.x86_64                                            1.7.0-1.rhel7                              pgdg15     
pgaudit_analyze.x86_64                                         1.0.7-1.rhel7                              pgdg-common
pgaudit_analyze.noarch                                         1.0.8-1.rhel7                              pgdg-common
pgauditlogtofile-10.x86_64                                     1.0-1.rhel7                                pgdg10     
pgauditlogtofile-11.x86_64                                     1.0-1.rhel7                                pgdg11     
pgauditlogtofile-12.x86_64                                     1.0-1.rhel7                                pgdg12     
pgauditlogtofile-13.x86_64                                     1.0-1.rhel7                                pgdg13     
pgauditlogtofile_10.x86_64                                     1.5.6-1.rhel7                              pgdg10     
pgauditlogtofile_11.x86_64                                     1.5.6-1.rhel7                              pgdg11     
pgauditlogtofile_11-llvmjit.x86_64                             1.5.6-1.rhel7                              pgdg11     
pgauditlogtofile_12.x86_64                                     1.5.6-1.rhel7                              pgdg12     
pgauditlogtofile_12-llvmjit.x86_64                             1.5.6-1.rhel7                              pgdg12     
pgauditlogtofile_13.x86_64                                     1.5.6-1.rhel7                              pgdg13     
pgauditlogtofile_13-llvmjit.x86_64                             1.5.6-1.rhel7                              pgdg13     
pgauditlogtofile_14.x86_64                                     1.5.6-1.rhel7                              pgdg14     
pgauditlogtofile_14-llvmjit.x86_64                             1.5.6-1.rhel7                              pgdg14     
pgauditlogtofile_15.x86_64                                     1.5.6-2.rhel7                              pgdg15     
pgauditlogtofile_15-llvmjit.x86_64                             1.5.6-2.rhel7                              pgdg15

 

2.安装相应的版本
yum install pgaudit14_12.x86_64

 

3.修改配置参数
#修改shared_preload_libraries参数,后面追加pgaudit后重启实例,其他插件请忽略
su - postgres
[postgres@localhost data]$ vi /opt/pg12/data/postgresql.conf
[postgres@localhost data]$ shared_preload_libraries = 'pg_repack,pg_squeeze,pgaudit' # (change requires restart)

然后重新启动pg
[root@localhost ~]# systemctl stop postgresql-12
[root@localhost ~]# systemctl start postgresql-12

 

4.创建插件
#进入数据库,使用超级用户创建插件
postgres=# create extension pgaudit;
CREATE EXTENSION

 

5.可配置参数

postgres=# select name,setting from pg_settings where name like 'pgaudit%';
            name            | setting 
----------------------------+---------
 pgaudit.log                | none
 pgaudit.log_catalog        | on
 pgaudit.log_client         | off
 pgaudit.log_level          | log
 pgaudit.log_parameter      | off
 pgaudit.log_relation       | off
 pgaudit.log_statement_once | off
 pgaudit.role               | 
(8 rows)

 

6.设置会话级别
su - postgres
[postgres@localhost pg_wal]$ psql
set pgaudit.log = 'all';
set pgaudit.log_relation = on;
set pgaudit.log_client=on;
select name,setting,source from pg_settings where name like 'pgaudit%';

在当前库下的操作语句都会记录到log_directory参数定义的目录中,注意切换到其他库执行的这种情况不会记录.

 

7.数据库级别的设置
vi /opt/pg12/data/postgresql.conf
后面添加如下参数:

pgaudit.log = 'all'
pgaudit.log_relation = on
pgaudit.log_client=on

 

然后重新启动pg
[root@localhost ~]# systemctl stop postgresql-12
[root@localhost ~]# systemctl start postgresql-12

 

[postgres@localhost pg_wal]$ psql
psql (12.13)
Type "help" for help.

postgres=# select name,setting,source from pg_settings where name like 'pgaudit%';
            name            | setting |       source       
----------------------------+---------+--------------------
 pgaudit.log                | all     | configuration file
 pgaudit.log_catalog        | on      | default
 pgaudit.log_client         | on      | configuration file
 pgaudit.log_level          | log     | default
 pgaudit.log_parameter      | off     | default
 pgaudit.log_relation       | on      | configuration file
 pgaudit.log_statement_once | off     | default
 pgaudit.role               |         | default
(8 rows)

 

标签:审计,rhel7,x86,pgauditlogtofile,64,pgaudit,安装,log
From: https://www.cnblogs.com/hxlasky/p/16952512.html

相关文章

  • centos7 离线(内网环境无外网) 安装docker
    1.环境1.centos7内网环境无外网连接,yum安装会失效,采用离线安装包方式安装docker 2.下载安装包1.百度网盘:链接:https://pan.baidu.com/s/1ArPt-NhjtdKTBW3I4BE-......
  • go bin安装
    首先进入gopath的安装路径,在\go\src\github.com运行Git终端输入gitclonehttps://github.com/gin-gonic/gin.gitgin-gonic/gin 如果报错,执行gitconfighttp.sslVerify......
  • Mac 下erlang及rabbitmq安装
    ---------------------------------------1、首先,安装Homebrew安装Homebrew遇到的问题参考这个链接2、安装erlang环境brewinstallerlang3、安装rabbitmqbrewinstallr......
  • Ubuntu20.04 编译安装 CPython3.10.8(WSL2)
    CPython,由C编写的python发行版,通过在github下载源代码,通过cmake进行打包安装1.ubuntu安装编译工具:sudoapt-get installlibssl-devzlib1g-devlibbz2-devlibreadl......
  • VMware Fusion 13虚拟机如何安装win 11教程
    VM虚拟机如何安装win11?还不知道如何在VMwareFusion13虚拟机中安装win11的朋友,下面就和小编一起来了解一下!VMwareFusion13虚拟机1、运行VMwareFusion13虚拟机,在......
  • CodeSmith部署安装以及编写MySQL模板的时候无法获取description
    最近需要使用VS2015开发新项目,由于考虑到后期的扩展性,打算使用EF的codefirst模式来编写,但是前期又设计好了数据库结构,不想大动干戈的去重新写代码,网上搜索了说用“EntityF......
  • gitlab安装使用,备份和升级
    安装依赖yuminstall-ycurlopenssh-serverpostfixwget 安装gitlab组件 yumlocalinstall-yxxx自动帮忙解决依赖 最新版本1)下载wgethttps://mirrors.tuna.tsing......
  • 安装vue脚手架出现错误:npm ERR code ETIMEDOUT npm ERR syscall connect
    npm安装淘宝映像报npmERR!具体如下C:\Users\admin>npminstall-g@vue/clinpmERR!codeENOTFOUNDnpmERR!syscallgetaddrinfonpmERR!errnoENOTFOUNDnpmERR!netwo......
  • Linux系统zabbix_agentd客户端安装与配置
    官网下载zabbix安装包(zabbix安装包里包含了zabbix_agentd客户端安装包,我们只选择zabbix_agentd客户端安装) zbbix官网下载地址:  http://www.zabbix.com/download ......
  • xp下安装ror+mysql最新心得
    话说不少前辈也说了,ROR最好在LINUX上跑,这个道理是知道的,但对于不用ROR开发的偶,单单扫下盲的话,就打算用WINDOW上算了,不过还是感受到在XP上装ROR......