1 | .. -*- coding: utf-8-with-signature-unix; fill-column: 73; -*- |
---|
2 | .. -*- indent-tabs-mode: nil -*- |
---|
3 | |
---|
4 | ********************* |
---|
5 | How To Run Tahoe-LAFS |
---|
6 | ********************* |
---|
7 | |
---|
8 | Introduction |
---|
9 | ============ |
---|
10 | |
---|
11 | This is how to run a Tahoe-LAFS client or a complete Tahoe-LAFS grid. |
---|
12 | First you have to install the Tahoe-LAFS software, as documented in |
---|
13 | :doc:`Installing Tahoe-LAFS <../Installation/install-tahoe>`. |
---|
14 | |
---|
15 | The ``tahoe`` program in your virtualenv's ``bin`` directory is used to |
---|
16 | create, start, and stop nodes. Each node lives in a separate base |
---|
17 | directory, in which there is a configuration file named ``tahoe.cfg``. |
---|
18 | Nodes read and write files within this base directory. |
---|
19 | |
---|
20 | A grid consists of a set of *storage nodes* and *client nodes* running |
---|
21 | the Tahoe-LAFS code. There is also an *introducer node* that is |
---|
22 | responsible for getting the other nodes talking to each other. |
---|
23 | |
---|
24 | If you're getting started we recommend you try connecting to the `public test |
---|
25 | grid`_ as you only need to create a client node. When you want to create your |
---|
26 | own grid you'll need to create the introducer and several initial storage |
---|
27 | nodes (see the note about small grids below). |
---|
28 | |
---|
29 | |
---|
30 | Being Introduced to a Grid |
---|
31 | -------------------------- |
---|
32 | |
---|
33 | A collection of Tahoe servers is called a Grid and usually has 1 |
---|
34 | Introducer (but sometimes more, and it's possible to run with zero). The |
---|
35 | Introducer announces which storage servers constitute the Grid and how to |
---|
36 | contact them. There is a secret "fURL" you need to know to talk to the |
---|
37 | Introducer. |
---|
38 | |
---|
39 | One way to get this secret is using traditional tools such as encrypted |
---|
40 | email, encrypted instant-messaging, etcetera. It is important to transmit |
---|
41 | this fURL secretly as knowing it gives you access to the Grid. |
---|
42 | |
---|
43 | An additional way to share the fURL securely is via `magic |
---|
44 | wormhole`_. This uses a weak one-time password and a server on the |
---|
45 | internet (at `wormhole.tahoe-lafs.org`) to open a secure channel between |
---|
46 | two computers. In Tahoe-LAFS this functions via the commands `tahoe |
---|
47 | invite` and `tahoe create-client --join`. A person who already has access |
---|
48 | to a Grid can use `tahoe invite` to create one end of the `magic |
---|
49 | wormhole`_ and then transmits some JSON (including the Introducer's |
---|
50 | secret fURL) to the other end. `tahoe invite` will print a one-time |
---|
51 | secret code; you must then communicate this code to the person who will |
---|
52 | join the Grid. |
---|
53 | |
---|
54 | The other end of the `magic wormhole`_ in this case is `tahoe |
---|
55 | create-client --join <one-time code>`, where the person being invited |
---|
56 | types in the code they were given. Ideally, this code would be |
---|
57 | transmitted securely. It is, however, only useful exactly once. Also, it |
---|
58 | is much easier to transcribe by a human. Codes look like |
---|
59 | `7-surrender-tunnel` (a short number and two words). |
---|
60 | |
---|
61 | |
---|
62 | Running a Client |
---|
63 | ---------------- |
---|
64 | |
---|
65 | To construct a client node, run “``tahoe create-client``”, which will create |
---|
66 | ``~/.tahoe`` to be the node's base directory. Acquire the ``introducer.furl`` |
---|
67 | (see below if you are running your own introducer, or use the one from the |
---|
68 | `TestGrid page`_), and write it to ``~/.tahoe/private/introducers.yaml`` |
---|
69 | (see :ref:`introducer-definitions`). Then use “``tahoe run ~/.tahoe``”. |
---|
70 | After that, the node should be off and running. The first thing |
---|
71 | it will do is connect to the introducer and get itself connected to all other |
---|
72 | nodes on the grid. |
---|
73 | |
---|
74 | Some Grids use "magic wormhole" one-time codes to configure the basic |
---|
75 | options. In such a case you use ``tahoe create-client --join |
---|
76 | <one-time-code>`` and do not have to do any of the ``tahoe.cfg`` editing |
---|
77 | mentioned above. |
---|
78 | |
---|
79 | By default, “``tahoe create-client``” creates a client-only node, that |
---|
80 | does not offer its disk space to other nodes. To configure other behavior, |
---|
81 | use “``tahoe create-node``” or see :doc:`configuration`. |
---|
82 | |
---|
83 | The “``tahoe run``” command above will run the node in the foreground. |
---|
84 | ``tahoe --help`` gives a summary of all commands. |
---|
85 | |
---|
86 | |
---|
87 | Running a Server or Introducer |
---|
88 | ------------------------------ |
---|
89 | |
---|
90 | To build either a storage server node, or an introducer node, you'll need |
---|
91 | a way for clients to connect to it. The simplest case is when the |
---|
92 | computer is on the public internet (e.g. a "VPS" virtual private server, |
---|
93 | with a public IP address and a DNS hostname like ``example.net``). See |
---|
94 | :doc:`servers` for help with more complex scenarios, using the ``--port`` |
---|
95 | and ``--location`` arguments. |
---|
96 | |
---|
97 | To construct an introducer, create a new base directory for it (the name |
---|
98 | of the directory is up to you), ``cd`` into it, and run “``tahoe |
---|
99 | create-introducer --hostname=example.net .``” (but using the hostname of |
---|
100 | your VPS). Now run the introducer using “``tahoe run .``”. After it |
---|
101 | starts, it will write a file named ``introducer.furl`` into the |
---|
102 | ``private/`` subdirectory of that base directory. This file contains the |
---|
103 | URL the other nodes must use in order to connect to this introducer. |
---|
104 | |
---|
105 | You can distribute your Introducer fURL securely to new clients by using |
---|
106 | the ``tahoe invite`` command. This will prepare some JSON to send to the |
---|
107 | other side, request a `magic wormhole`_ code from |
---|
108 | ``wormhole.tahoe-lafs.org`` and print it out to the terminal. This |
---|
109 | one-time code should be transmitted to the user of the client, who can |
---|
110 | then run ``tahoe create-client --join <one-time-code>``. |
---|
111 | |
---|
112 | Storage servers are created the same way: ``tahoe create-node |
---|
113 | --hostname=HOSTNAME .`` from a new directory. You'll need to provide the |
---|
114 | introducer FURL (either as a ``--introducer=`` argument, or by editing |
---|
115 | the ``tahoe.cfg`` configuration file afterwards) to connect to the |
---|
116 | introducer of your choice. |
---|
117 | |
---|
118 | See :doc:`configuration` for more details about how to configure |
---|
119 | Tahoe-LAFS. |
---|
120 | |
---|
121 | .. _public test grid: https://tahoe-lafs.org/trac/tahoe-lafs/wiki/TestGrid |
---|
122 | .. _TestGrid page: https://tahoe-lafs.org/trac/tahoe-lafs/wiki/TestGrid |
---|
123 | .. _#937: https://tahoe-lafs.org/trac/tahoe-lafs/ticket/937 |
---|
124 | .. _magic wormhole: https://magic-wormhole.io/ |
---|
125 | |
---|
126 | |
---|
127 | Multiple Instances |
---|
128 | ------------------ |
---|
129 | |
---|
130 | Running multiple instances against the same configuration directory isn't supported. |
---|
131 | This will lead to undefined behavior and could corrupt the configuration or state. |
---|
132 | |
---|
133 | We attempt to avoid this situation with a "pidfile"-style file in the config directory called ``running.process``. |
---|
134 | There may be a parallel file called ``running.process.lock`` in existence. |
---|
135 | |
---|
136 | The ``.lock`` file exists to make sure only one process modifies ``running.process`` at once. |
---|
137 | The lock file is managed by the `lockfile <https://pypi.org/project/lockfile/>`_ library. |
---|
138 | If you wish to make use of ``running.process`` for any reason you should also lock it and follow the semantics of lockfile. |
---|
139 | |
---|
140 | If ``running.process`` exists then it contains the PID and the creation-time of the process. |
---|
141 | When no such file exists, there is no other process running on this configuration. |
---|
142 | If there is a ``running.process`` file, it may be a leftover file or it may indicate that another process is running against this config. |
---|
143 | To tell the difference, determine if the PID in the file exists currently. |
---|
144 | If it does, check the creation-time of the process versus the one in the file. |
---|
145 | If these match, there is another process currently running and using this config. |
---|
146 | Otherwise, the file is stale -- it should be removed before starting Tahoe-LAFS. |
---|
147 | |
---|
148 | Some example Python code to check the above situations: |
---|
149 | |
---|
150 | .. literalinclude:: check_running.py |
---|
151 | |
---|
152 | |
---|
153 | |
---|
154 | |
---|
155 | |
---|
156 | A note about small grids |
---|
157 | ------------------------ |
---|
158 | |
---|
159 | By default, Tahoe-LAFS ships with the configuration parameter |
---|
160 | ``shares.happy`` set to 7. If you are using Tahoe-LAFS on a grid with |
---|
161 | fewer than 7 storage nodes, this won't work well for you — none of your |
---|
162 | uploads will succeed. To fix this, see :doc:`configuration` to learn how |
---|
163 | to set ``shares.happy`` to a more suitable value for your grid. |
---|
164 | |
---|
165 | |
---|
166 | Development with Docker |
---|
167 | ----------------------- |
---|
168 | |
---|
169 | If you want to stand up a small local test environment, you can install |
---|
170 | `Docker`_ and `Docker Compose`_. Once you have cloned the repository, run |
---|
171 | ``docker-compose up`` from the project's root directory. This will start a |
---|
172 | introducer, server, and a client configured to connect to them. After the |
---|
173 | containers start, you can access the WUI by navigating to |
---|
174 | ``http://localhost:3456`` in your browser. |
---|
175 | |
---|
176 | .. _Docker: https://docs.docker.com/ |
---|
177 | .. _Docker Compose: https://docs.docker.com/compose/ |
---|
178 | |
---|
179 | Do Stuff With It |
---|
180 | ================ |
---|
181 | |
---|
182 | This is how to use your Tahoe-LAFS node. |
---|
183 | |
---|
184 | The WUI |
---|
185 | ------- |
---|
186 | |
---|
187 | Point your web browser to `http://127.0.0.1:3456`_ — which is the URL of the |
---|
188 | gateway running on your own local computer — to use your newly created node. |
---|
189 | |
---|
190 | Create a new directory (with the button labelled “create a directory”). |
---|
191 | Your web browser will load the new directory. Now if you want to be |
---|
192 | able to come back to this directory later, you have to bookmark it, or |
---|
193 | otherwise save a copy of the URL. If you lose the URL to this directory, |
---|
194 | then you can never again come back to this directory. |
---|
195 | |
---|
196 | .. _http://127.0.0.1:3456: http://127.0.0.1:3456 |
---|
197 | |
---|
198 | |
---|
199 | The CLI |
---|
200 | ------- |
---|
201 | |
---|
202 | Prefer the command-line? Run “``tahoe --help``” (the same command-line |
---|
203 | tool that is used to start and stop nodes serves to navigate and use the |
---|
204 | decentralized file store). To get started, create a new directory and |
---|
205 | mark it as the 'tahoe:' alias by running “``tahoe create-alias tahoe``”. |
---|
206 | Once you've done that, you can do “``tahoe ls tahoe:``” and “``tahoe cp |
---|
207 | LOCALFILE tahoe:foo.txt``” to work with your file store. The Tahoe-LAFS |
---|
208 | CLI uses similar syntax to the well-known scp and rsync tools. See |
---|
209 | :doc:`frontends/CLI` for more details. |
---|
210 | |
---|
211 | |
---|
212 | To backup a directory full of files and subdirectories, run “``tahoe backup |
---|
213 | LOCALDIRECTORY tahoe:``”. This will create a new LAFS subdirectory inside the |
---|
214 | “tahoe” LAFS directory named “Archive”, and inside “Archive”, it will create |
---|
215 | a new subdirectory whose name is the current date and time. That newly |
---|
216 | created subdirectory will be populated with a snapshot copy of all files and |
---|
217 | directories currently reachable from LOCALDIRECTORY. Then ``tahoe backup`` |
---|
218 | will make a link to that snapshot directory from the “tahoe” LAFS directory, |
---|
219 | and name the link “Latest”. |
---|
220 | |
---|
221 | ``tahoe backup`` cleverly avoids uploading any files or directories that |
---|
222 | haven't changed, and it also cleverly deduplicates any files or directories |
---|
223 | that have identical contents to other files or directories that it has |
---|
224 | previously backed-up. This means that running ``tahoe backup`` is a nice |
---|
225 | incremental operation that backs up your files and directories efficiently, |
---|
226 | and if it gets interrupted (for example by a network outage, or by you |
---|
227 | rebooting your computer during the backup, or so on), it will resume right |
---|
228 | where it left off the next time you run ``tahoe backup``. |
---|
229 | |
---|
230 | See :doc:`frontends/CLI` for more information about the ``tahoe backup`` |
---|
231 | command, as well as other commands. |
---|
232 | |
---|
233 | As with the WUI (and with all current interfaces to Tahoe-LAFS), you |
---|
234 | are responsible for remembering directory capabilities yourself. If you |
---|
235 | create a new directory and lose the capability to it, then you cannot |
---|
236 | access that directory ever again. |
---|
237 | |
---|
238 | |
---|
239 | The SFTP frontend |
---|
240 | ----------------- |
---|
241 | |
---|
242 | You can access your Tahoe-LAFS grid via any SFTP_ client. See |
---|
243 | :doc:`frontends/FTP-and-SFTP` for how to set this up. On most Unix |
---|
244 | platforms, you can also use SFTP to plug Tahoe-LAFS into your computer's |
---|
245 | local filesystem via ``sshfs``, but see the `FAQ about performance |
---|
246 | problems`_. |
---|
247 | |
---|
248 | The SftpFrontend_ page on the wiki has more information about using SFTP with |
---|
249 | Tahoe-LAFS. |
---|
250 | |
---|
251 | .. _SFTP: https://en.wikipedia.org/wiki/SSH_file_transfer_protocol |
---|
252 | .. _FAQ about performance problems: https://tahoe-lafs.org/trac/tahoe-lafs/wiki/FAQ#Q23_FUSE |
---|
253 | .. _SftpFrontend: https://tahoe-lafs.org/trac/tahoe-lafs/wiki/SftpFrontend |
---|
254 | |
---|
255 | |
---|
256 | The WAPI |
---|
257 | -------- |
---|
258 | |
---|
259 | Want to program your Tahoe-LAFS node to do your bidding? Easy! See |
---|
260 | :doc:`frontends/webapi`. |
---|
261 | |
---|
262 | |
---|
263 | Socialize |
---|
264 | ========= |
---|
265 | |
---|
266 | You can chat with other users of and hackers of this software on the |
---|
267 | #tahoe-lafs IRC channel at ``irc.libera.chat``, or on the `tahoe-dev mailing |
---|
268 | list`_. |
---|
269 | |
---|
270 | .. _tahoe-dev mailing list: https://lists.tahoe-lafs.org/mailman/listinfo/tahoe-dev |
---|
271 | |
---|
272 | |
---|
273 | Complain |
---|
274 | ======== |
---|
275 | |
---|
276 | Bugs can be filed on the Tahoe-LAFS "Trac" instance, at |
---|
277 | https://tahoe-lafs.org/trac/ . |
---|
278 | |
---|
279 | You can also "fork" the repo and submit Pull Requests on Github: |
---|
280 | https://github.com/tahoe-lafs/tahoe-lafs . |
---|