If we can not pull a database from a node during recovery, mark this node as a "culpr...
[sahlberg/ctdb.git] / doc / ctdb.1
1 .\"     Title: ctdb
2 .\"    Author: 
3 .\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/>
4 .\"      Date: 09/15/2008
5 .\"    Manual: 
6 .\"    Source: 
7 .\"
8 .TH "CTDB" "1" "09/15/2008" "" ""
9 .\" disable hyphenation
10 .nh
11 .\" disable justification (adjust text to left margin only)
12 .ad l
13 .SH "NAME"
14 ctdb - clustered tdb database management utility
15 .SH "SYNOPSIS"
16 .HP 29
17 \fBctdb [ OPTIONS ] COMMAND \.\.\.\fR
18 .HP 5
19 \fBctdb\fR [\-n\ <node>] [\-Y] [\-t\ <timeout>] [\-T\ <timelimit>] [\-?\ \-\-help] [\-\-usage] [\-d\ \-\-debug=<INTEGER>] [\-\-socket=<filename>]
20 .SH "DESCRIPTION"
21 .PP
22 ctdb is a utility to view and manage a ctdb cluster\.
23 .SH "OPTIONS"
24 .PP
25 \-n <pnn>
26 .RS 4
27 This specifies the physical node number on which to execute the command\. Default is to run the command on the deamon running on the local host\.
28 .sp
29 The physical node number is an integer that describes the node in the cluster\. The first node has physical node number 0\.
30 .RE
31 .PP
32 \-Y
33 .RS 4
34 Produce output in machine readable form for easier parsing by scripts\. Not all commands support this option\.
35 .RE
36 .PP
37 \-t <timeout>
38 .RS 4
39 How long should ctdb wait for the local ctdb daemon to respond to a command before timing out\. Default is 3 seconds\.
40 .RE
41 .PP
42 \-T <timelimit>
43 .RS 4
44 A limit on how long the ctdb command will run for before it will be aborted\. When this timelimit has been exceeded the ctdb command will terminate\.
45 .RE
46 .PP
47 \-? \-\-help
48 .RS 4
49 Print some help text to the screen\.
50 .RE
51 .PP
52 \-\-usage
53 .RS 4
54 Print useage information to the screen\.
55 .RE
56 .PP
57 \-d \-\-debug=<debuglevel>
58 .RS 4
59 Change the debug level for the command\. Default is 0\.
60 .RE
61 .PP
62 \-\-socket=<filename>
63 .RS 4
64 Specify the socketname to use when connecting to the local ctdb daemon\. The default is /tmp/ctdb\.socket \.
65 .sp
66 You only need to specify this parameter if you run multiple ctdb daemons on the same physical host and thus can not use the default name for the domain socket\.
67 .RE
68 .SH "ADMINISTRATIVE COMMANDS"
69 .PP
70 These are commands used to monitor and administrate a CTDB cluster\.
71 .SS "pnn"
72 .PP
73 This command displays the pnn of the current node\.
74 .SS "status"
75 .PP
76 This command shows the current status of the ctdb node\.
77 .sp
78 .it 1 an-trap
79 .nr an-no-space-flag 1
80 .nr an-break-flag 1
81 .br
82 node status
83 .RS
84 .PP
85 Node status reflects the current status of the node\. There are five possible states:
86 .PP
87 OK \- This node is fully functional\.
88 .PP
89 DISCONNECTED \- This node could not be connected through the network and is currently not participating in the cluster\. If there is a public IP address associated with this node it should have been taken over by a different node\. No services are running on this node\.
90 .PP
91 DISABLED \- This node has been administratively disabled\. This node is still functional and participates in the CTDB cluster but its IP addresses have been taken over by a different node and no services are currently being hosted\.
92 .PP
93 UNHEALTHY \- A service provided by this node is malfunctioning and should be investigated\. The CTDB daemon itself is operational and participates in the cluster\. Its public IP address has been taken over by a different node and no services are currnetly being hosted\. All unhealthy nodes should be investigated and require an administrative action to rectify\.
94 .PP
95 BANNED \- This node failed too many recovery attempts and has been banned from participating in the cluster for a period of RecoveryBanPeriod seconds\. Any public IP address has been taken over by other nodes\. This node does not provide any services\. All banned nodes should be investigated and require an administrative action to rectify\. This node does not perticipate in the CTDB cluster but can still be communicated with\. I\.e\. ctdb commands can be sent to it\.
96 .RE
97 .sp
98 .it 1 an-trap
99 .nr an-no-space-flag 1
100 .nr an-break-flag 1
101 .br
102 generation
103 .RS
104 .PP
105 The generation id is a number that indicates the current generation of a cluster instance\. Each time a cluster goes through a reconfiguration or a recovery its generation id will be changed\.
106 .PP
107 This number does not have any particular meaning other than to keep track of when a cluster has gone through a recovery\. It is a random number that represents the current instance of a ctdb cluster and its databases\. CTDBD uses this number internally to be able to tell when commands to operate on the cluster and the databases was issued in a different generation of the cluster, to ensure that commands that operate on the databases will not survive across a cluster database recovery\. After a recovery, all old outstanding commands will automatically become invalid\.
108 .PP
109 Sometimes this number will be shown as "INVALID"\. This only means that the ctdbd daemon has started but it has not yet merged with the cluster through a recovery\. All nodes start with generation "INVALID" and are not assigned a real generation id until they have successfully been merged with a cluster through a recovery\.
110 .RE
111 .sp
112 .it 1 an-trap
113 .nr an-no-space-flag 1
114 .nr an-break-flag 1
115 .br
116 VNNMAP
117 .RS
118 .PP
119 The list of Virtual Node Numbers\. This is a list of all nodes that actively participates in the cluster and that share the workload of hosting the Clustered TDB database records\. Only nodes that are participating in the vnnmap can become lmaster or dmaster for a database record\.
120 .RE
121 .sp
122 .it 1 an-trap
123 .nr an-no-space-flag 1
124 .nr an-break-flag 1
125 .br
126 Recovery mode
127 .RS
128 .PP
129 This is the current recovery mode of the cluster\. There are two possible modes:
130 .PP
131 NORMAL \- The cluster is fully operational\.
132 .PP
133 RECOVERY \- The cluster databases have all been frozen, pausing all services while the cluster awaits a recovery process to complete\. A recovery process should finish within seconds\. If a cluster is stuck in the RECOVERY state this would indicate a cluster malfunction which needs to be investigated\.
134 .PP
135 Once the recovery master detects an inconsistency, for example a node becomes disconnected/connected, the recovery daemon will trigger a cluster recovery process, where all databases are remerged across the cluster\. When this process starts, the recovery master will first "freeze" all databases to prevent applications such as samba from accessing the databases and it will also mark the recovery mode as RECOVERY\.
136 .PP
137 When CTDBD starts up, it will start in RECOVERY mode\. Once the node has been merged into a cluster and all databases have been recovered, the node mode will change into NORMAL mode and the databases will be "thawed", allowing samba to access the databases again\.
138 .RE
139 .sp
140 .it 1 an-trap
141 .nr an-no-space-flag 1
142 .nr an-break-flag 1
143 .br
144 Recovery master
145 .RS
146 .PP
147 This is the cluster node that is currently designated as the recovery master\. This node is responsible of monitoring the consistency of the cluster and to perform the actual recovery process when reqired\.
148 .PP
149 Only one node at a time can be the designated recovery master\. Which node is designated the recovery master is decided by an election process in the recovery daemons running on each node\.
150 .RE
151 .PP
152 Example: ctdb status
153 .PP
154 Example output:
155 .sp
156 .RS 4
157 .nf
158 Number of nodes:4
159 pnn:0 11\.1\.2\.200       OK (THIS NODE)
160 pnn:1 11\.1\.2\.201       OK
161 pnn:2 11\.1\.2\.202       OK
162 pnn:3 11\.1\.2\.203       OK
163 Generation:1362079228
164 Size:4
165 hash:0 lmaster:0
166 hash:1 lmaster:1
167 hash:2 lmaster:2
168 hash:3 lmaster:3
169 Recovery mode:NORMAL (0)
170 Recovery master:0
171       
172 .fi
173 .RE
174 .SS "ping"
175 .PP
176 This command will "ping" all CTDB daemons in the cluster to verify that they are processing commands correctly\.
177 .PP
178 Example: ctdb ping
179 .PP
180 Example output:
181 .sp
182 .RS 4
183 .nf
184 response from 0 time=0\.000054 sec  (3 clients)
185 response from 1 time=0\.000144 sec  (2 clients)
186 response from 2 time=0\.000105 sec  (2 clients)
187 response from 3 time=0\.000114 sec  (2 clients)
188       
189 .fi
190 .RE
191 .SS "ip"
192 .PP
193 This command will display the list of public addresses that are provided by the cluster and which physical node is currently serving this ip\.
194 .PP
195 Example: ctdb ip
196 .PP
197 Example output:
198 .sp
199 .RS 4
200 .nf
201 Number of addresses:4
202 12\.1\.1\.1         0
203 12\.1\.1\.2         1
204 12\.1\.1\.3         2
205 12\.1\.1\.4         3
206       
207 .fi
208 .RE
209 .SS "getvar <name>"
210 .PP
211 Get the runtime value of a tuneable variable\.
212 .PP
213 Example: ctdb getvar MaxRedirectCount
214 .PP
215 Example output:
216 .sp
217 .RS 4
218 .nf
219 MaxRedirectCount    = 3
220       
221 .fi
222 .RE
223 .SS "setvar <name> <value>"
224 .PP
225 Set the runtime value of a tuneable variable\.
226 .PP
227 Example: ctdb setvar MaxRedirectCount 5
228 .SS "listvars"
229 .PP
230 List all tuneable variables\.
231 .PP
232 Example: ctdb listvars
233 .PP
234 Example output:
235 .sp
236 .RS 4
237 .nf
238 MaxRedirectCount    = 5
239 SeqnumFrequency     = 1
240 ControlTimeout      = 60
241 TraverseTimeout     = 20
242 KeepaliveInterval   = 2
243 KeepaliveLimit      = 3
244 MaxLACount          = 7
245 RecoverTimeout      = 5
246 RecoverInterval     = 1
247 ElectionTimeout     = 3
248 TakeoverTimeout     = 5
249 MonitorInterval     = 15
250 EventScriptTimeout  = 20
251 RecoveryGracePeriod = 60
252 RecoveryBanPeriod   = 300
253       
254 .fi
255 .RE
256 .SS "lvsmaster"
257 .PP
258 This command shows which node is currently the LVSMASTER\. The LVSMASTER is the node in the cluster which drives the LVS system and which receives all incoming traffic from clients\.
259 .PP
260 LVS is the mode where the entire CTDB/Samba cluster uses a single ip address for the entire cluster\. In this mode all clients connect to one specific node which will then multiplex/loadbalance the clients evenly onto the other nodes in the cluster\. This is an alternative to using public ip addresses\. See the manpage for ctdbd for more information about LVS\.
261 .SS "lvs"
262 .PP
263 This command shows which nodes in the cluster are currently active in the LVS configuration\. I\.e\. which nodes we are currently loadbalancing the single ip address across\.
264 .PP
265 LVS will by default only loadbalance across those nodes that are both LVS capable and also HEALTHY\. Except if all nodes are UNHEALTHY in which case LVS will loadbalance across all UNHEALTHY nodes as well\. LVS will never use nodes that are DISCONNECTED, BANNED or DISABLED\.
266 .PP
267 Example output:
268 .sp
269 .RS 4
270 .nf
271 2:10\.0\.0\.13
272 3:10\.0\.0\.14
273       
274 .fi
275 .RE
276 .SS "getcapabilities"
277 .PP
278 This command shows the capabilities of the current node\. Please see manpage for ctdbd for a full list of all capabilities and more detailed description\.
279 .PP
280 RECMASTER and LMASTER capabilities are primarily used when CTDBD is used to create a cluster spanning across WAN links\. In which case ctdbd acts as a WAN accelerator\.
281 .PP
282 LVS capabile means that the node is participating in LVS, a mode where the entire CTDB cluster uses one single ip address for the entire cluster instead of using public ip address failover\. This is an alternative to using a loadbalancing layer\-4 switch\.
283 .PP
284 Example output:
285 .sp
286 .RS 4
287 .nf
288 RECMASTER: YES
289 LMASTER: YES
290 LVS: NO
291       
292 .fi
293 .RE
294 .SS "statistics"
295 .PP
296 Collect statistics from the CTDB daemon about how many calls it has served\.
297 .PP
298 Example: ctdb statistics
299 .PP
300 Example output:
301 .sp
302 .RS 4
303 .nf
304 CTDB version 1
305  num_clients                        3
306  frozen                             0
307  recovering                         0
308  client_packets_sent           360489
309  client_packets_recv           360466
310  node_packets_sent             480931
311  node_packets_recv             240120
312  keepalive_packets_sent             4
313  keepalive_packets_recv             3
314  node
315      req_call                       2
316      reply_call                     2
317      req_dmaster                    0
318      reply_dmaster                  0
319      reply_error                    0
320      req_message                   42
321      req_control               120408
322      reply_control             360439
323  client
324      req_call                       2
325      req_message                   24
326      req_control               360440
327  timeouts
328      call                           0
329      control                        0
330      traverse                       0
331  total_calls                        2
332  pending_calls                      0
333  lockwait_calls                     0
334  pending_lockwait_calls             0
335  memory_used                     5040
336  max_hop_count                      0
337  max_call_latency                   4\.948321 sec
338  max_lockwait_latency               0\.000000 sec
339       
340 .fi
341 .RE
342 .SS "statisticsreset"
343 .PP
344 This command is used to clear all statistics counters in a node\.
345 .PP
346 Example: ctdb statisticsreset
347 .SS "getdebug"
348 .PP
349 Get the current debug level for the node\. the debug level controls what information is written to the log file\.
350 .PP
351 The debug levels are mapped to the corresponding syslog levels\. When a debug level is set, only those messages at that level and higher levels will be printed\.
352 .PP
353 The list of debug levels from highest to lowest are :
354 .PP
355 EMERG ALERT CRIT ERR WARNING NOTICE INFO DEBUG
356 .SS "setdebug <debuglevel>"
357 .PP
358 Set the debug level of a node\. This controls what information will be logged\.
359 .PP
360 The debuglevel is one of EMERG ALERT CRIT ERR WARNING NOTICE INFO DEBUG
361 .SS "getpid"
362 .PP
363 This command will return the process id of the ctdb daemon\.
364 .SS "disable"
365 .PP
366 This command is used to administratively disable a node in the cluster\. A disabled node will still participate in the cluster and host clustered TDB records but its public ip address has been taken over by a different node and it no longer hosts any services\.
367 .SS "enable"
368 .PP
369 Re\-enable a node that has been administratively disabled\.
370 .SS "ban <bantime|0>"
371 .PP
372 Administratively ban a node for bantime seconds\. A bantime of 0 means that the node should be permanently banned\.
373 .PP
374 A banned node does not participate in the cluster and does not host any records for the clustered TDB\. Its ip address has been taken over by an other node and no services are hosted\.
375 .PP
376 Nodes are automatically banned if they are the cause of too many cluster recoveries\.
377 .SS "moveip <public_ip> <node>"
378 .PP
379 This command can be used to manually fail a public ip address to a specific node\.
380 .PP
381 In order to manually override the "automatic" distribution of public ip addresses that ctdb normally provides, this command only works when you have changed the tunables for the daemon to:
382 .PP
383 DeterministicIPs = 0
384 .PP
385 NoIPFailback = 1
386 .SS "unban"
387 .PP
388 This command is used to unban a node that has either been administratively banned using the ban command or has been automatically banned by the recovery daemon\.
389 .SS "shutdown"
390 .PP
391 This command will shutdown a specific CTDB daemon\.
392 .SS "recover"
393 .PP
394 This command will trigger the recovery daemon to do a cluster recovery\.
395 .SS "killtcp <srcip:port> <dstip:port>"
396 .PP
397 This command will kill the specified TCP connection by issuing a TCP RST to the srcip:port endpoint\.
398 .SS "reloadnodes"
399 .PP
400 This command is used when adding new nodes to an existing cluster and to reduce the disruption of this operation\. This command should never be used except when expanding an existing cluster\. This can only be used to expand a cluster\. To remove a node from the cluster you still need to shut down ctdb on all nodes, edit the nodes file and restart ctdb\.
401 .PP
402 Procedure:
403 .PP
404 1, To expand an existing cluster, first ensure with \'ctdb status\' that all nodes are up and running and that they are all healthy\. Do not try to expand a cluster unless it is completely healthy!
405 .PP
406 2, On all nodes, edit /etc/ctdb/nodes and add the new node as the last entry to the file\. The new node MUST be added to the end of this file!
407 .PP
408 3, Verify that all the nodes have identical /etc/ctdb/nodes files after you edited them and added the new node!
409 .PP
410 4, Run \'ctdb reloadnodes\' to force all nodes to reaload the nodesfile\.
411 .PP
412 5, Use \'ctdb status\' on all nodes and verify that they now show the additional node\.
413 .PP
414 6, Install and configure the new node and bring it online\.
415 .SS "tickle <srcip:port> <dstip:port>"
416 .PP
417 This command will will send a TCP tickle to the source host for the specified TCP connection\. A TCP tickle is a TCP ACK packet with an invalid sequence and acknowledge number and will when received by the source host result in it sending an immediate correct ACK back to the other end\.
418 .PP
419 TCP tickles are useful to "tickle" clients after a IP failover has occured since this will make the client immediately recognize the TCP connection has been disrupted and that the client will need to reestablish\. This greatly speeds up the time it takes for a client to detect and reestablish after an IP failover in the ctdb cluster\.
420 .SS "repack [max_freelist]"
421 .PP
422 Over time, when records are created and deleted in a TDB, the TDB list of free space will become fragmented\. This can lead to a slowdown in accessing TDB records\. This command is used to defragment a TDB database and pruning the freelist\.
423 .PP
424 If [max_freelist] is specified, then a database will only be repacked if it has more than this number of entries in the freelist\.
425 .PP
426 During repacking of the database, the entire TDB database will be locked to prevent writes\. If samba tries to write to a record in the database during a repack operation, samba will block until the repacking has completed\.
427 .PP
428 This command can be disruptive and can cause samba to block for the duration of the repack operation\. In general, a repack operation will take less than one second to complete\.
429 .PP
430 A repack operation will only defragment the local TDB copy of the CTDB database\. You need to run this command on all of the nodes to repack a CTDB database completely\.
431 .PP
432 Example: ctdb repack 1000
433 .PP
434 By default, this operation is issued from the 00\.ctdb event script every 5 minutes\.
435 .SS "vacuum [max_records]"
436 .PP
437 Over time CTDB databases will fill up with empty deleted records which will lead to a progressive slow down of CTDB database access\. This command is used to prune all databases and delete all empty records from the cluster\.
438 .PP
439 By default, vacuum will delete all empty records from all databases\. If [max_records] is specified, the command will only delete the first [max_records] empty records for each database\.
440 .PP
441 Vacuum only deletes records where the local node is the lmaster\. To delete all records from the entire cluster you need to run a vacuum from each node\. This command is not disruptive\. Samba is unaffected and will still be able to read/write records normally while the database is being vacuumed\.
442 .PP
443 Example: ctdb vacuum
444 .PP
445 By default, this operation is issued from the 00\.ctdb event script every 5 minutes\.
446 .SH "DEBUGGING COMMANDS"
447 .PP
448 These commands are primarily used for CTDB development and testing and should not be used for normal administration\.
449 .SS "process\-exists <pid>"
450 .PP
451 This command checks if a specific process exists on the CTDB host\. This is mainly used by Samba to check if remote instances of samba are still running or not\.
452 .SS "getdbmap"
453 .PP
454 This command lists all clustered TDB databases that the CTDB daemon has attached to\. Some databases are flagged as PERSISTENT, this means that the database stores data persistently and the data will remain across reboots\. One example of such a database is secrets\.tdb where information about how the cluster was joined to the domain is stored\.
455 .PP
456 Most databases are not persistent and only store the state information that the currently running samba daemons need\. These databases are always wiped when ctdb/samba starts and when a node is rebooted\.
457 .PP
458 Example: ctdb getdbmap
459 .PP
460 Example output:
461 .sp
462 .RS 4
463 .nf
464 Number of databases:10
465 dbid:0x435d3410 name:notify\.tdb path:/var/ctdb/notify\.tdb\.0 
466 dbid:0x42fe72c5 name:locking\.tdb path:/var/ctdb/locking\.tdb\.0 dbid:0x1421fb78 name:brlock\.tdb path:/var/ctdb/brlock\.tdb\.0 
467 dbid:0x17055d90 name:connections\.tdb path:/var/ctdb/connections\.tdb\.0 
468 dbid:0xc0bdde6a name:sessionid\.tdb path:/var/ctdb/sessionid\.tdb\.0 
469 dbid:0x122224da name:test\.tdb path:/var/ctdb/test\.tdb\.0 
470 dbid:0x2672a57f name:idmap2\.tdb path:/var/ctdb/persistent/idmap2\.tdb\.0 PERSISTENT
471 dbid:0xb775fff6 name:secrets\.tdb path:/var/ctdb/persistent/secrets\.tdb\.0 PERSISTENT
472 dbid:0xe98e08b6 name:group_mapping\.tdb path:/var/ctdb/persistent/group_mapping\.tdb\.0 PERSISTENT
473 dbid:0x7bbbd26c name:passdb\.tdb path:/var/ctdb/persistent/passdb\.tdb\.0 PERSISTENT
474       
475 .fi
476 .RE
477 .SS "catdb <dbname>"
478 .PP
479 This command will dump a clustered TDB database to the screen\. This is a debugging command\.
480 .SS "getmonmode"
481 .PP
482 This command returns the monutoring mode of a node\. The monitoring mode is either ACTIVE or DISABLED\. Normally a node will continously monitor that all other nodes that are expected are in fact connected and that they respond to commands\.
483 .PP
484 ACTIVE \- This is the normal mode\. The node is actively monitoring all other nodes, both that the transport is connected and also that the node responds to commands\. If a node becomes unavailable, it will be marked as DISCONNECTED and a recovery is initiated to restore the cluster\.
485 .PP
486 DISABLED \- This node is not monitoring that other nodes are available\. In this mode a node failure will not be detected and no recovery will be performed\. This mode is useful when for debugging purposes one wants to attach GDB to a ctdb process but wants to prevent the rest of the cluster from marking this node as DISCONNECTED and do a recovery\.
487 .SS "setmonmode <0|1>"
488 .PP
489 This command can be used to explicitely disable/enable monitoring mode on a node\. The main purpose is if one wants to attach GDB to a running ctdb daemon but wants to prevent the other nodes from marking it as DISCONNECTED and issuing a recovery\. To do this, set monitoring mode to 0 on all nodes before attaching with GDB\. Remember to set monitoring mode back to 1 afterwards\.
490 .SS "attach <dbname>"
491 .PP
492 This is a debugging command\. This command will make the CTDB daemon create a new CTDB database and attach to it\.
493 .SS "dumpmemory"
494 .PP
495 This is a debugging command\. This command will make the ctdb daemon to write a fill memory allocation map to standard output\.
496 .SS "freeze"
497 .PP
498 This command will lock all the local TDB databases causing clients that are accessing these TDBs such as samba3 to block until the databases are thawed\.
499 .PP
500 This is primarily used by the recovery daemon to stop all samba daemons from accessing any databases while the database is recovered and rebuilt\.
501 .SS "thaw"
502 .PP
503 Thaw a previously frozen node\.
504 .SH "SEE ALSO"
505 .PP
506 ctdbd(1), onnode(1)
507 \fI\%http://ctdb.samba.org/\fR
508 .SH "COPYRIGHT/LICENSE"
509 .sp
510 .RS 4
511 .nf
512 Copyright (C) Andrew Tridgell 2007
513 Copyright (C) Ronnie sahlberg 2007
514
515 This program is free software; you can redistribute it and/or modify
516 it under the terms of the GNU General Public License as published by
517 the Free Software Foundation; either version 3 of the License, or (at
518 your option) any later version\.
519
520 This program is distributed in the hope that it will be useful, but
521 WITHOUT ANY WARRANTY; without even the implied warranty of
522 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE\.  See the GNU
523 General Public License for more details\.
524
525 You should have received a copy of the GNU General Public License
526 along with this program; if not, see http://www\.gnu\.org/licenses/\.
527 .fi
528 .RE