ZooKeeper(一):数据文件

ZK里面有两个数据文件目录可以配置,

  • dataDir, The location where ZooKeeper will store the in-memory database snapshots.
  • dataLogDir, This option will direct the machine to write the transaction log to the dataLogDir rather than the dataDir.

dataDir用来存储ZKDatabase的快照文件(Snapshot File);而dataLogDir用来存储对ZKDatabase所做操作的操作日志文件(Transaction Log File),如果不配置dataLogDir,则dataLogDir=dataDir。

当我们对ZKDatabase进行操作,例如修改znode信息,操作日志便会被写入到操作日志文件。操作日志文件会一直增大,当达到snapCount个操作时,ZK便会保存一份ZKDatabase当前的数据到快照文件,并丢弃之前的操作日志文件(已经没有必要保存了),生成新的操作日志文件。snapCount配置说明如下,

  • snapCount,ZooKeeper logs transactions to a transaction log. After snapCount transactions are written to a log file a snapshot is started and a new transaction log file is created. The default snapCount is 100,000.

那么这两个文件到底有啥用?

By replaying the transaction log against fuzzy snapshots ZooKeeper gets the state of the system at the end of the log.

也就是说,这俩货是用来做快速恢复(fast recovery)用的。当我们的ZK机器挂掉了,只要数据文件还在,重启机器,将快照文件load到ZKDatabase,然后对ZKDatabase重放操作日志文件这样就能恢复到机器挂掉前的状态了。

另外快照文件需要有清除操作,当然你也可以保留所有快照,但没那个必要。下面是两个跟自动清除相关的配置,

  • autopurge.purgeInterval, The time interval in hours for which the purge task has to be triggered. Set to a positive integer (1 and above) to enable the auto purging. Defaults to 0.
  • autopurge.snapRetainCount, When enabled, ZooKeeper auto purge feature retains the autopurge.snapRetainCount most recent snapshots and the corresponding transaction logs in the dataDir and dataLogDir respectively and deletes the rest. Defaults to 3. Minimum value is 3.

参考资料

时间: 2024-08-06 20:08:49

ZooKeeper(一):数据文件的相关文章

Hadoop(一):数据文件

QuickStart 晚上照着官方文档把玩了一下hadoop,本机伪分布式启动,这里记录一下. 首先是下载当前stable版本的hadoop,现在是2.6.0版本. 然后设置免输入密码ssh登录,hadoop中需要使用, $ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa $ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys $ ssh-add ~/.ssh/id_dsa 修改etc/hadoop/hadoop-e

误删除innodb ibdata数据文件-之恢复

今天在群里看到有人说不熟悉innodb把ibdata(数据文件)和ib_logfile(事务日志)文件误删除了.不知道怎么解决.当时我也不知道怎么办.后来查阅相关资料.终找到解决方法.其实恢复也挺简单的.我们不知道的时候就觉得难了.谁说不是这样呢? 下面我们就来模拟生产环境下,人为删除数据文件和重做日志文件.然后详细说明恢复步骤. 1.用sysbench模拟数据的写入,如下所示: [[email protected] ~]# sysbench --test=oltp --oltp-table-s

【表空间支持的最大数据文件大小的算法】【数据库限制】【数据文件文件头保留数据块数】

本地管理表空间中设置不同大小的db_block_size时数据文件头保留空间相应例如以下:--?? db_block_size=2KB,文件头保留32个数据块,即64KB. db_block_size=4KB.文件头保留16个数据块,即64KB. db_block_size=8KB,文件头保留8个数据块,即64KB. db_block_size=16KB,文件头保留4个数据块.即64KB. db_block_size=32KB,文件头保留4个数据块.即128KB. --为什么不是64kb? 默认

第十四篇:获取系统数据文件信息

前言 在 Linux 中,系统数据文件大都不能直接用编辑的方式读取.如此设计一方面是从安全性考虑,另一方面则是从文件检索效率考虑.本文将以口令文件 passwd 为例讲解读取 Linux 中系统数据文件的方法. 基本步骤 1. 包含读写该系统数据文件的专用头文件 ( 如读写口令文件要包含 pwd.h 组文件则是 grp.h ) 2. 使用 set 函数打开文件        3. 使用 get 函数读取下一个记录        4. 使用 end 函数关闭此文件 另,如果数据文件支持某种形式的关

更改数据文件名字或者路径

1 数据文件的状态设置为offline状态表空间置为offlineSQL> select file_name,tablespace_name from dba_data_files;SQL> alter tablespace users offline;SQL> select name,status from v$datafile; NAME                                               STATUS---------------------

Oracle更改数据文件位置

方法一:offline表空间 1.offline表空间:alter tablespace tablespace_name offline:2.复制数据文件到新的目录:3.rename修改表空间,并修改控制文件:4.online表空间: 1.offline表空间zeroneSQL> select name from v$datafile;NAME-----------------------------------------------------------------------------

APUE读书笔记-第六章 系统数据文件和信息

昨天看完了,今天来看看第六章.感觉第六章的内容不是非常重要.简单看看吧 6.2 口令文件 口令文件其实就是/etc文件夹下的passwd文件,但处于安全性的考虑,我们无法直接读取它.就是通过直接限制权限的方式对其进行保护,passwd文件具体权限如下: -rw-r--r-- 1 root root 可以看到只有root用户具有读写权限,与root同组的用户与其他用户仅具有读权限. 不过为了解决以上问题,Linux中给出了一系列数据结构与函数帮助我们操纵口令文件,首先是关键数据结构,定义位于/in

oracle查看表空间下数据文件

下面两个数据字典视图就知道了.查看有哪些表空间:select * from dba_tablespaces;查看有哪些数据文件在哪个表空间中:select * from dba_data_files; select * from dba_tablespace_groups;

CentOS6.5修改mysql数据文件路径

1.停止mysql服务 service mysql stop 2.移动数据文件位置(保留原文件权限) cp -a /var/lib/mysql /mysqldata 3.修改/etc/my.cnf [client] socket=/mysqldata/mysql/mysql.sock [mysqld] socket=/mysqldata/mysql/mysql.sock log_error=/var/log/mysql/mysql_error.log 4.修改/etc/init.d/mysql