xlog文件vproxy文件夹可以删么除吗

PostgreSQL的pg_xlog文件数计算和在线清理
PostgreSQL的pg_xlog文件数计算和在线清理
postgresql的pg_xlog是记录事务信息用的,类似oracle的redo信息,也叫wal日志(write ahead log),就是在写数据到磁盘里成为固定数据之前,先写入到日志里,然后一定条件下触发调用fsync()将此数据刷到磁盘。好处不多说,下面主要看看postgresql通常会保留多少个pg_xlog文件,以及如何在线清理。&
一、环境及参数
postgresql 9.2.4(单台,未做流复制)
vmware 6.0
centos 6.2
postgres=# show checkpoint_ & --设置相对大一点,默认太小,防止频繁checkpoint
checkpoint_segments
---------------------
postgres=# show checkpoint_
checkpoint_timeout
--------------------
postgres=# show checkpoint_completion_
checkpoint_completion_target
------------------------------
postgres=# show wal_keep_ & & --未开启流复制预留xlog参数
&wal_keep_segments&
-------------------
postgres=# show archive_ & & & & & & --关闭归档
archive_mode&
--------------
理论上合理的pg_xlog一般在(2+checkpoint_completion_target)*checkpoint_segment+1左右浮动,但是高并发环境下如果checkpoint_segment设置比较大,且checkpoint较少被触发的时候,pg_xlog下会存有很多的事务日志,严重会耗掉磁盘存储,所以设置checkpoint_segment的大小要视磁盘容量和每个pg_xlog文件的大小来看,有些时候需要手工调整参数来收缩。&
二、测试过程:&
1.模拟pg_xlog文件增长&
模拟大数据量载入,开启多个窗口插入数据,每个窗口插入1000W数据,可以看到pg_xlog增长很多,原来只有8个文件
postgres=# create table tbl_kenyon(id int,cname varchar(50),remark text);
CREATE TABLE
postgres=# insert into tbl_kenyon select generate_series(1,),'kenyon good boy',md5(generate_series('kenyon good boy');
postgres=# insert into tbl_kenyon select generate_series(1,),'kenyon good boy',md5('kenyon good boy');
postgres=# insert into tbl_kenyon select generate_series(1,),'kenyon good boy',md5('kenyon good boy');
postgres=# insert into tbl_kenyon select generate_series(1,),'kenyon good boy',md5('kenyon good boy');
postgres=# insert into tbl_kenyon select generate_series(1,),'kenyon good boy',md5('kenyon good boy');
postgres=# insert into tbl_kenyon select generate_series(1,),'kenyon good boy',md5('kenyon good boy');
此时检查pg_xlog下面的文件数量
[postgres@localhost pg_xlog]$ ll
total 4063240
-rw------- &1 postgres postgres
Jul 14 23:05 F
-rw------- &1 postgres postgres
Jul 14 23:13
-rw------- &1 postgres postgres
Jul 14 23:18
-rw------- &1 postgres postgres
Jul 14 23:25
-rw------- &1 postgres postgres
Jul 14 22:42
-rw------- &1 postgres postgres
Jul 14 22:42
-rw------- &1 postgres postgres
Jul 14 22:44
-rw------- &1 postgres postgres
Jul 14 22:44
-rw------- &1 postgres postgres
Jul 14 22:43
-rw------- &1 postgres postgres
Jul 14 22:44
-rw------- &1 postgres postgres
Jul 14 22:44
-rw------- &1 postgres postgres
Jul 14 22:44 A
-rw------- &1 postgres postgres
Jul 14 22:43 B
-rw------- &1 postgres postgres
Jul 14 22:44 C
-rw------- &1 postgres postgres
Jul 14 22:43 D
-rw------- &1 postgres postgres
Jul 14 22:44 E
-rw------- &1 postgres postgres
Jul 14 22:44
-rw------- &1 postgres postgres
Jul 14 22:43
-rw------- &1 postgres postgres
Jul 14 22:44
-rw------- &1 postgres postgres
Jul 14 22:43
-rw-------. 1 postgres postgres
Jul 14 22:44
-rw------- &1 postgres postgres
Jul 14 22:44
-rw------- &1 postgres postgres
Jul 14 22:44
-rw------- &1 postgres postgres
Jul 14 22:43
-rw------- &1 postgres postgres
Jul 14 22:44
-rw------- &1 postgres postgres
Jul 14 22:45
-rw------- &1 postgres postgres
Jul 14 22:45 A
-rw------- &1 postgres postgres
Jul 14 22:44 B
-rw------- &1 postgres postgres
Jul 14 22:43 C
-rw------- &1 postgres postgres
Jul 14 22:45 D
-rw------- &1 postgres postgres
Jul 14 22:43 E
-rw------- &1 postgres postgres
Jul 14 22:43 F
-rw------- &1 postgres postgres
Jul 14 22:44
-rw------- &1 postgres postgres
Jul 14 22:44
-rw------- &1 postgres postgres
Jul 14 22:44
-rw------- &1 postgres postgres
Jul 14 22:43
-rw------- &1 postgres postgres
Jul 14 22:45
-rw------- &1 postgres postgres
Jul 14 22:45
-rw------- &1 postgres postgres
Jul 14 22:45
-rw------- &1 postgres postgres
Jul 14 22:45
-rw------- &1 postgres postgres
Jul 14 22:45
-rw------- &1 postgres postgres
Jul 14 22:45
-rw------- &1 postgres postgres
Jul 14 22:45 A
-rw------- &1 postgres postgres
Jul 14 22:46 B
-rw------- &1 postgres postgres
Jul 14 22:45 C
-rw------- &1 postgres postgres
Jul 14 22:46 D
-rw------- &1 postgres postgres
Jul 14 22:46 E
-rw------- &1 postgres postgres
Jul 14 22:45 F
-rw------- &1 postgres postgres
Jul 14 22:46
-rw------- &1 postgres postgres
Jul 14 22:45
-rw------- &1 postgres postgres
Jul 14 22:45
-rw------- &1 postgres postgres
Jul 14 22:45
-rw------- &1 postgres postgres
Jul 14 22:45
-rw------- &1 postgres postgres
Jul 14 22:45
-rw------- &1 postgres postgres
Jul 14 22:45
-rw------- &1 postgres postgres
Jul 14 22:46
-rw------- &1 postgres postgres
Jul 14 22:45
-rw------- &1 postgres postgres
Jul 14 22:46
-rw-------. 1 postgres postgres
Jul 14 22:46 A
-rw------- &1 postgres postgres
Jul 14 22:46 B
-rw------- &1 postgres postgres
Jul 14 22:46 C
-rw------- &1 postgres postgres
Jul 14 22:56 D
drwx------. 2 postgres postgres & & 4096 Jun 12 23:19 archive_status
[postgres@localhost pg_xlog]$ ll|wc -l
2.模拟pg_xlog文件清理&
这类文件对DB是很重要的,不能手工直接清理。每个文件64MB,是编译时--with-wal-segsize时指定的,或者登陆查看&
postgres=# show wal_segment_ &
wal_segment_size&
------------------
要收缩这个事务日志空间,减少事务日志数,可以调整参数 checkpoint_segments,本次调为3&
postgres=# show checkpoint_
&checkpoint_segments&
---------------------
postgres=#
CHECKPOINT
&xlog文件有可能不是立即减少的,如果想模拟立即减少,可以模拟数据库频繁checkpoint,如重新做上述的大数据库加载或者更新操作,此时去看pg_xlog的文件数,能看到在减少了,开启两个窗口操作:
postgres=# insert into tbl_kenyon select generate_series(1,),'kenyon good boy',md5('kenyon good boy');
postgres=# insert into tbl_kenyon select generate_series(1,2000000),'kenyon good boy',md5('kenyon good boy');
INSERT 0 2000000
[postgres@localhost pg_xlog]$ ll|wc -l
[postgres@localhost pg_xlog]$ ll|wc -l
[postgres@localhost pg_xlog]$ ll|wc -l
[postgres@localhost pg_xlog]$ ll|wc -l
[postgres@localhost pg_xlog]$ ll|wc -l
[postgres@localhost pg_xlog]$ ll|wc -l
[postgres@localhost pg_xlog]$ ll|wc -l
[postgres@localhost pg_xlog]$ ll|wc -l
[postgres@localhost pg_xlog]$ ll|wc -l
[postgres@localhost pg_xlog]$ ll|wc -l
[postgres@localhost pg_xlog]$ ll|wc -l
后续发生的checkpoint,将会逐步收缩pg_xlog的文件数量,直到满足条件为止。
如果是流复制,还有wal_keep_segments这个参数也要考虑一下。后续。&
checkpoint_segments (integer)
Maximum number of log file segments between automatic WAL checkpoints (each segment
is normally 16 megabytes). The default is three segments. Increasing this parameter can increase
the amount of time needed for crash recovery. This parameter can only be set in the
postgresql.conf file or on the server command line.
(window.slotbydup=window.slotbydup || []).push({
id: '2467140',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467141',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467142',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467143',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467148',
container: s,
size: '1000,90',
display: 'inlay-fix'Log是什么文件 可以删除吗?
Log是什么文件 可以删除吗?
学习啦【电脑技巧】 编辑:楚焕
  Log是什么文件 可以删除吗?很多朋友们都不知道系统中出现的.Log扩展名的文件是什么,针对此问题,下面小编就为大家来说明一下吧!
  一般文本处理软件都可以打开此类型的文件,比如Windwos自带的记事本就可以打开Log文件,Log文件本身没有危害,只是占用多一点点硬盘空间而己。大部分的log可以从文件名看出它的作用,比如uninstall.log或是error.log,当然前者通常是软件安装过程中生成的记录,以便将来卸载的时候可以提供给卸载程序使用,后者通常是用来记录一些软件运行中的错误信息等等。
  通俗的说,Log文件就是日志文件,记录的是操作系统或者软件的一些处理记录,在Windows电脑,软件以及服务器中非常常见。Log文件对于普通用户来说,并没有什么用,但是对于一些技术人员来说,Log文件具有很大的参考价值。比如Windows系统出现问题,一些技术人员可以通过查看Log日常文件,检查是否有一些报错记录,然后根据其报错,找到问题的根源。
  Log文件可以删除吗?
  上面提到,Log文件文件跟系统以及软件等没有直接关联,说白了就是系统或者软件产生的记录文件,类似于记事本文本,删除了不会影响系统或者软件本身的正常使用。
本文已影响 人
[Log是什么文件 可以删除吗?]相关的文章
看过本文的人还看了
1530人看了觉得好
2240人看了觉得好
1251人看了觉得好
【电脑技巧】图文推荐}

我要回帖

更多关于 xlog qq 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信