You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/bookkeeperConfig.textile
+21-81Lines changed: 21 additions & 81 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,102 +16,42 @@ h1. Abstract
16
16
17
17
This document contains information about deploying, administering and mantaining BookKeeper. It also discusses best practices and common problems.
18
18
19
-
As BookKeeper is still a prototype, this article is likely to change significantly over time.
19
+
h1. Running a BookKeeper instance
20
20
21
-
h1. System requirements
21
+
h2. System requirements
22
22
23
-
p. A typical BookKeeper installation comprises a set of bookies and a set of ZooKeeper replicas. The exact number of bookies depends on the quorum mode, desired throughput, and number of clients using this installation simultaneously. The minimum number of bookies is three for self-verifying (stores a message authentication code along with each entry) and four for generic (does not store a message authentication codewith each entry), and there is no upper limit on the number of bookies. Increasing the number of bookies, in fact, enables higher throughput.
23
+
p. A typical BookKeeper installation comprises a set of bookies and a set of ZooKeeper replicas. The exact number of bookies depends on the quorum mode, desired throughput, and number of clients using this installation simultaneously. The minimum number of bookies is three for self-verifying (stores a message authentication code along with each entry) and four for generic (does not store a message authentication code with each entry), and there is no upper limit on the number of bookies. Increasing the number of bookies will, in fact, enable higher throughput.
24
24
25
-
p. For performance, we require each server to have at least two disks. It is possible to run a bookie with a single disk, but performance will be significantly lower in this case. Of course, it works with one disk, but performance is significantly lower.
25
+
p. For performance, we require each server to have at least two disks. It is possible to run a bookie with a single disk, but performance will be significantly lower in this case.
26
26
27
-
p. For ZooKeeper, there is no constraint with respect to the number of replicas. Having a single machine running ZooKeeper in standalone mode is sufficient for BookKeeper. For resilience purposes, it might be a good idea to run ZooKeeper in quorum mode with multiple servers. Please refer to the ZooKeeper documentation for detail on how to configure ZooKeeper with multiple replicas
27
+
p. For ZooKeeper, there is no constraint with respect to the number of replicas. Having a single machine running ZooKeeper in standalone mode is sufficient for BookKeeper. For resilience purposes, it might be a good idea to run ZooKeeper in quorum mode with multiple servers. Please refer to the ZooKeeper documentation for detail on how to configure ZooKeeper with multiple replicas.
28
28
29
-
h1. Running bookies
29
+
h2. Running bookies
30
30
31
31
p. To run a bookie, we execute the following command:
32
32
33
-
@ bookkeeper-server/bin/bookkeeper bookie
33
+
@bookkeeper-server/bin/bookkeeper bookie@
34
34
35
-
p. The configuration parameters, which can be set in bookkeeper-server/conf/bkenv.sh
35
+
p. The configuration parameterscan be set in bookkeeper-server/conf/bk_server.conf.
36
36
37
-
* BOOKIE_PORT: Port number that the bookie listens on;
38
-
* BOOKIE_ZOOKEEPER: Comma separated list of ZooKeeper servers with a hostname:port format;
39
-
* BOOKIE_TXN_LOGDIR: Path for Log Device (stores bookie write-ahead log);
40
-
* BOOKIE_DATA_DIR: Path for Ledger Device (stores ledger entries);
37
+
The important parameters are:
38
+
* @bookiePort@, Port number that the bookie listens on;
39
+
* @zkServers@, Comma separated list of ZooKeeper servers with a hostname:port format;
40
+
* @journalDir@, Path for Log Device (stores bookie write-ahead log);
41
+
* @ledgerDir@, Path for Ledger Device (stores ledger entries);
41
42
42
-
p. Ideally, @/path_to_log_device/@ and @/path_to_ledger_device/@ are each in a different device.
43
+
p. Ideally, @journalDir@ and @ledgerDir@ are each in a different device. See "BookKeeper Configuration Parameters":./bookkeeperConfigParams.html for a full list of configuration parameters.
43
44
44
-
h1. Bookie Configuration
45
45
46
-
p. Bookie server stores its data in multiple ledger directories and its journal files in a journal directory. Ideally, storing journal files in a separate directory than data files would increase throughput and decrease latency.
46
+
h3. Logging
47
47
48
-
h2. Journal Configuration
48
+
BookKeeper uses "slf4j":http://www.slf4j.org for logging, with the log4j bindings enabled by default. To enable logging from a bookie, create a log4j.properties file and point the environment variable BOOKIE_LOG_CONF to the configuration file. The path to the log4j.properties file must be absolute.
49
49
50
-
p. Journal directory has one kind of files in it:
50
+
@export BOOKIE_LOG_CONF=/tmp/log4j.properties@
51
+
@bookkeeper-server/bin/bookkeeper bookie@
51
52
52
-
* {timestamp}.txn - holds transactions executed in the bookie server.
53
+
h2. Setting up a test ensemble
53
54
54
-
p. Before persisting ledger index and data to disk, a bookie ensures that the transaction that represents the update is written to a journal in non-volatile storage. A new journal file is created using current timestamp when a bookie starts or an old journal file reaches its maximum size.
55
+
Sometimes it is useful to run a ensemble of bookies on your local machine for testing. We provide a utility for doing this. It will set up N bookies, and a zookeeper instance locally. The data on these bookies and of the zookeeper instance are not persisted over restarts, so obviously this should never be used in a production environment. To run a test ensemble of 10 bookies, do the following.
55
56
56
-
p. A bookie supports journal rolling to remove old journal files. In order to remove old journal files safely, bookie server records LastLogMark in Ledger Device, which indicates all updates (including index and data) before LastLogMark has been persisted to the Ledger Device.
57
-
58
-
p. LastLogMark contains two parts:
59
-
60
-
* LastLogId - indicates which journal file the transaction persisted.
61
-
* LastLogPos - indicates the position the transaction persisted in LastLogId journal file.
62
-
63
-
p. You may use following settings to further fine tune the behavior of your Bookie servers. Currently these configuration settings are set using Java system properties.
64
-
65
-
* journalMaxSizeMB
66
-
** journal file size limitation. when a journal reaches this limitation, it will be closed and new journal file be created.
67
-
68
-
* journalMaxBackups
69
-
** how many old journal files whose id is less than LastLogMark 's journal id.
70
-
71
-
bq. NOTE: keeping number of old journal files would be useful for manually recovery in special case.
72
-
73
-
h1. ZooKeeper Metadata
74
-
75
-
p. For BookKeeper, we require a ZooKeeper installation to store metadata, and to pass the list of ZooKeeper servers as parameter to the constructor of the BookKeeper class ( @org.apache.bookkeeper.client,BookKeeper@ ). To setup ZooKeeper, please check the "ZooKeeper documentation":index.html.
76
-
77
-
p. BookKeeper provides two mechnaisms to organize its metadata in ZooKeeper.
78
-
79
-
* FlatLedgerManager : All ledger metadata are placed as children in a single zookeeper path.
80
-
* HierarchicalLedgerManager : All ledger metadata are partitioned into 2-level znodes.
81
-
82
-
h2. Flat Ledger Manager
83
-
84
-
p. All ledgers' metadata are put in a single zookeeper path, created using zookeeper sequential node, which can ensure uniqueness of ledger id. Each ledger node is prefixed with 'L'.
85
-
86
-
p. Bookie server manages its owned active ledgers in a hash map. So it is easy for bookie server to find what ledgers are deleted from zookeeper and garbage collect them. And its garbage collection flow is described as below:
87
-
88
-
* Fetch all existing ledgers from zookeeper (*zkActiveLedgers*).
89
-
* Fetch all ledgers currently active within the Bookie (*bkActiveLedgers*).
90
-
* Loop over *bkActiveLedgers* to find those ledgers which do not exist in *zkActiveLedgers* and garbage collect them.
91
-
92
-
h2. Hierarchical Ledger Manager
93
-
94
-
p. Hierarchical Ledger Manager first obtains a global unique id from ZooKeeper using a EPHEMERAL_SEQUENTIAL znode.
95
-
96
-
p. Since ZooKeeper sequential counter has a format of %10d -- that is 10 digits with 0 (zero) padding, i.e. "<path>0000000001", HierarchicalLedgerManager splits the generated id into 3 parts :
p. These 3 parts are used to form the actual ledger node path used to store ledger metadata:
101
-
102
-
@ {ledgers_root_path}/{level1}/{level2}/L{level3}
103
-
104
-
p. E.g. Ledger 0000000001 is split into 3 parts 00, 0000, 00001, which is stored in znode /{ledgers_root_path}/00/0000/L0001. So each znode could have at most 10000 ledgers, which avoids the problem of the child list being larger than the maximum ZooKeeper packet size.
105
-
106
-
p. Bookie server manages its active ledgers in a sorted map, which simplifies access to active ledgers in a particular (level1, level2) partition.
107
-
108
-
p. Garbage collection in bookie server is processed node by node as follows:
109
-
110
-
* Fetching all level1 nodes, by calling zk#getChildren(ledgerRootPath).
111
-
** For each level1 nodes, fetching their level2 nodes :
112
-
** For each partition (level1, level2) :
113
-
*** Fetch all existed ledgers from zookeeper belonging to partition (level1, level2) (*zkActiveLedgers*).
114
-
*** Fetch all ledgers currently active in the bookie which belong to partition (level1, level2) (*bkActiveLedgers*).
115
-
*** Loop over *bkActiveLedgers* to find those ledgers which do not exist in *zkActiveLedgers*, and garbage collect them.
116
-
117
-
bq. NOTE: Hierarchical Ledger Manager is more suitable to manage large number of ledgers existed in BookKeeper.
0 commit comments