您的位置 首页 golang

PostgreSQL日志分类与管理,值得收藏

概述

PostgreSQL 有3种日志,分别是pg_log(数据库运行日志)、pg_xlog(WAL 日志,即重做日志)、pg_clog(事务提交日志,记录的是事务的元数据)。

PostgreSQL日志分类与管理,值得收藏


1、pg_log(运行日志)

该文件夹中的日志一般用来记录服务器与DB的状态,如各种Error信息,定位慢查询SQL,数据库的启动关闭信息,发生checkpoint过于频繁等的告警信息等。linux自带的路径一般在/ var /log/postgres下面。该日志有.csv格式和.log。这种日志是可以被清理删除不影响DB的正常运行。

当我们有遇到DB无法启动或者更改参数没有生效时,第一个想到的就是查看这个日志。

如果服务无法启动,该日志文件夹下的日志没有记录,建议查看操作系统的事件查看器的日志。有助于快速定位问题。


2、pg_xlog (重做日志)

该文件夹中的日志是记录的Postgresql的WAL信息,也就是一些事务日志信息(transaction log),默认单个大小是16M,源码安装的时候可以更改其大小。这些信息通常名字是类似’000000010000000000000013’这样的文件,这些日志会在 定时回滚恢复(PITR), 流复制(Replication Stream)以及归档时能被用到,这些日志是非常重要的,记录着数据库发生的各种事务信息,不得随意删除或者移动这类日志文件,不然你的数据库会有无法恢复的风险。

当归档或者流复制发生异常的时候,事务日志会不断地生成,有可能会造成磁盘空间被塞满,最终导致DB挂掉或者起不来。遇到这种情况不用慌,可以先关闭归档或者流复制功能,备份pg_xlog日志到其他地方,但请不要删除。然后删除较早时间的的pg_xlog,有一定空间后再试着启动Postgres。


3、pg_clog (事务提交日志)

pg_clog这个文件也是事务日志文件,但与pg_xlog不同的是它记录的是事务的元数据(metadata),这个日志告诉我们哪些事务完成了,哪些没有完成。这个日志文件一般非常小,但是重要性也是相当高,不得随意删除或者对其更改信息。


4、日志设置

pg_log默认是关闭的,需要设置参数启用此日志。pg_xlog和pg_clog都是强制打开的,无法关闭。

运行日志主要相关的参数如下,默认没有开启的话没有log目录,开启后会自动生成。

PostgreSQL日志分类与管理,值得收藏

PostgreSQL日志分类与管理,值得收藏

4.1.启用pg_log并配置日志参数

4.2、重启PostgreSQL即可在$PGDATA/pg_log/ 下看到新生成的日志。

PostgreSQL日志分类与管理,值得收藏


总结:

pg_log记录各种Error信息,以及服务器与DB的状态信息,可由用户随意更新删除

pg_xlog与pg_clog记录数据库的事务信息,不得随意删除更新,做物理备份时要记得备份着两个日志。

觉得有用的朋友多帮忙转发哦!后面会分享更多 devops DBA 方面的内容,感兴趣的朋友可以关注下~

PostgreSQL日志分类与管理,值得收藏

文章来源:智云一二三科技

文章标题:PostgreSQL日志分类与管理,值得收藏

文章地址:https://www.zhihuclub.com/98799.shtml

关于作者: 智云科技

热门文章

评论已关闭

37条评论

  1. All the scientific explanations make this premature ejaculation medication sound good, but does Priligy work

  2. Cialis and Viagra both treat erectile dysfunction effectively but there are some important differences between the two drugs Cialis can cause back pain, and while most side effects also occur with Viagra and Levitra, back pain appears to be significantly more common with Cialis use than with other ED medications

  3. Furthermore, in an analysis of 11 placebo-controlled randomised studies, tadalafil on-demand significantly improved IIEF-EF domain score from baseline p

  4. While it would seem prudent to limit LH exposure in all cases of COH, this appears to be more relevant in older women, who tend have higher levels of bioactive circulating LH.

  5. The directions say to apply the medication on the nodules and then rub it into the surrounding skin as well, Dr.

  6. Seton Pharmaceuticals LLC Silarx Pharmaceuticals Southwood Pharmaceuticals Sovereign Pharmaceuticals Ltd

  7. Based on reports of the successful use of 4 hydroxy tamoxifen 4 OHT to activate Cre recombinase estrogen receptor fusions in zebrafish embryos Hans et al

  8. The most common side effects of estradiol hormone replacement therapy are bloating, nausea, indigestion, headaches, vaginal bleeding, breast tenderness swelling, leg cramps, and fluid retention

  9. National Cancer Institute Breast cancer prevention PDQ Health professional version, last modified May 9, 2013 ptDNA can detect specific mutations but with the same limitations as tumor NGS

  10. Indeed, it was more effective than a second biguanide, phenformin, in inhibiting HIF1О± protein expression

  11. To confirm that the METTL3 immunoreactive band we saw in METTL3 KO U2OS cells in Fig 3B was METTL3, we used a second anti METTL3 mAb to confirm the result

  12. Until recently, mice generated by these 2 scientists were both labeled using a single lab code Bz in the Mouse Genome Informatics MGI database

  13. viagra benadryl cream jean coutu The aspiring Leo lover told the mag Гў To cut back, I recommend patients avoid adding extra salt to foods, avoid foods such as pretzels where there is visible salt, and cut back on prepared foods such as microwavable meals, canned soups and restaurant meals

  14. Red bars represent pretreatment values, and green bars indicate levels after 6 weeks of treatment The team tested four herbs commonly used to fight hot flashes and other menopausal symptoms dong quai, ginseng, black cohosh, and licorice root

  15. deflazacort decreases levels of aspirin citric acid sodium bicarbonate by increasing renal clearance

  16. Proteus is found abundantly in soil and water, and although it is part of the normal human intestinal flora along with Klebsiella species, and Escherichia coli, it has been known to cause serious infections in humans Lastly, beware of LASIK surgery that is too cheap to be legit

  17. Botanicals such as red clover and soy products are known to have mild estrogenic effects and may stimulate the growth of hormone sensitive cancers

  18. Elevated liver enzymes resulting from an interaction between Raltegravir and Panax ginseng a case report and brief review

  19. s Marshall Faulk took a different approach Sunday Shatavari combines well with Tribulus terrestris

  20. mitotane will decrease the level or effect of flibanserin by affecting hepatic intestinal enzyme CYP3A4 metabolism

  21. They use cheap and inaccurate analysis kits that you can buy online and do it themselves

  22. I hope so, David dropped a cold sentence, turned and left, My dear brother, I heard that Rogge has a good 5mg blood pressure medicine woman, can I try the taste PLoS Med 2009, 6 e1000058

网站地图