ARTICLE DETAIL

资讯详情

深耕郑州网站建设与运营推广的一线实战洞察。

【赵渝强老师】高斯数据库(openGauss)的运行日志

【赵渝强老师】高斯数据库(openGauss)的运行日志 在openGauss数据库集群初始化的时候会创建一个目录通常都会使用系统配置相关的环境变量$PGDATA来表示。当数据库初始化完成后会在这个目录生成相关的子目录以及一些文件。下图就是openGauss数据库的物理结构openGauss的日志文分为运行日志、WAL预写日志和服务器日志。下面重点讨论一下openGauss的运行日志视频讲解如下视频讲解如下【赵渝强老师】高斯数据库openGauss的运行日志在默认的情况下openGauss开启了运行日志。通过查看主postgresql.conf文件的配置可以看到相关的参数设置。运行时日志一般是记录数据库服务器与数据库的状态比如各种错误信息、定位慢查询SQL、数据库的启动关闭信息、发生检查点过于频繁等的告警信息等等。该日志有.csv格式和.log格式建议使用.csv格式。因为.csv格式一般会按大小和时间自动切割。pg_log是可以被清理删除、压缩打包或者转移同时不影响数据库的正常运行。当有遇到数据库无法启动或者更改参数没有生效时第一步就可以查看运行时日志。下面展示了主参数文件postgresql.conf中关于运行日志的配置参数#---------------------------------------------------------------------------------------------# ERROR REPORTING AND LOGGING#---------------------------------------------------------------------------------------------# - Where to Log -#log_destination stderr # Valid values are combinations of# stderr, csvlog, syslog, and eventlog,# depending on platform. csvlog# requires logging_collector to be on.# This is used when logging to stderr:logging_collector on# Enable capturing of stderr and csvlog# into log files. Required to be on for# csvlogs.# (change requires restart)# These are only used if logging_collector is on:#log_directory pg_log # directory where log files are written,# can be absolute or relative to PGDATAlog_filename postgresql-%Y-%m-%d_%H%M%S.log# log file name pattern,openGauss自带的运行日志文件可以实现审计的功能一个推荐的openGauss审计日志的参数配置如下logging_collector on log_destination csvloglog_directory gs_loglog_filename openGauss-%Y-%m-%d_%H%M%S.csvlog_truncate_on_rotation on log_connections on log_disconnections on log_statement ddl log_min_duration_statement 60s log_checkpoints on log_lock_waits on deadlock_timeout 1s这里的参数设置还将死锁的超时时间设置为了1秒钟。当重启openGauss完成后尝试创建一张简单的表例如openGauss# \c scottscott# create table testaudittable as select * from emp;# 查看logs目录下生成的日志文件如下$ pwd/home/postgres/training/gaussdb/data/single_node/gs_log $ ll total8...openGauss-2026-09-15_000502.csv...openGauss-2026-09-15_000502.csv.csv# 查看日志文件openGauss-2026-09-15_000502.csv.csv的内容将得到如下的审计日志信息...2026-09-1500:05:29.516,sgnode,postgres,scott,140485827294784, [local],6967bec2.258,1,,2026-01-1500:05:22CST,13/8,0,0,BACKEND,LOG,00000,statement: create table testaudittable as select * from emp;,,,,,,,,,gsql...
返回列表