update gerrit list
[openafs-wiki.git] / admin / InstallingOpenAFSonRHEL.mdwn
1 This is a step-by-step guide to installing OpenAFS and setting up an AFS cell
2 on RedHat Enterprise Linux, Fedora, or CentOS.  This guide is current as of
3 OpenAFS version 1.6.21 on CentOS 6.  For CentOS 7, see [[InstallingOpenAFSonCentOS7]].
4
5 This document is based on [[Steven Pelley's guide for installing OpenAFS 1.4.x on Fedora|FedoraAFSInstall]].
6
7 [[!toc levels=1]]
8
9 ## Differences from older guides
10
11 ### Non-DES Kerberos service key
12
13 As of OpenAFS version 1.6.5, non-DES encryption keys are supported and should
14 be used for the long term AFS service key. The `asetkey` program is no longer
15 needed to import the Kerberos service key. The OpenAFS servers read a Kerberos
16 keytab file directly. Special changes to the Kerberos configuration files to
17 allow weak crypto and weak enctypes are no longer needed.
18
19 The OpenAFS `kaserver` should not be used in new installations. This guide
20 shows how to install MIT Kerberos.
21
22 ### -noauth server mode
23
24 Older versions of OpenAFS required the `-noauth` flag to be used when first
25 setting up the system. This entailed starting the `bosserver` in `-noauth` mode
26 to disable authorization during the initial setup.  Modern versions of OpenAFS
27 can be installed without the `-noauth`, making the initial setup more secure
28 and without the need to restart the server processes.
29
30 ### -dynroot client mode
31
32 This guide assumes the OpenAFS cache manager is started with `-dynroot` mode
33 enabled, which is the default these days.  This guide shows how to create the
34 initial top level AFS volumes when the cache manager is in `-dynroot` mode.
35
36 ### Recommended options
37
38 This guide recommends using the `bosserver` restricted mode to improve security.
39
40 The default options for the fileserver are rather out of date for modern
41 hardware. This guide provides some examples of more suitable options for
42 the fileserver.
43
44 This guide shows how to setup the Demand Attach Fileserver.
45
46 ## Naming conventions
47
48 When setting up an AFS cell on the internet, the convention is to user your
49 internet domain name for your Kerberos realm and AFS cell name.  The Kerberos
50 realm name should be uppercase and the AFS cell name should be lowercase.
51
52 Note, it is possible to create a AFS cell with a different name than the
53 Kerberos realm (or even use a single Kerberos realm in multiple cells).  See
54 the documentation for the OpenAFS `krb.conf` server configuration file for
55 details on mapping realms to cell names.
56
57 ## Server setup
58
59 A minimal OS install is sufficient.
60
61 For a simple installation, you may use a single server to host the Kerberos
62 KDC, OpenAFS database server, and OpenAFS fileserver.  For a production
63 environment, it is recommended that the Kerberos KDC be deployed on a
64 dedicated, secure server, the OpenAFS database servers be deployed on three
65 separate machines, and multiple file servers deployed as needed.
66
67 ### Disk Partitions
68
69 An important thing to keep in mind is that you'll need at least one partition
70 on the file server to store volumes for AFS.  This will be mounted at
71 `/vicepa`. If you have multiple partitions they can be mounted at `/vicepb`,
72 `/vicepc`, etc.  The file server uses file-based storage (not block based).
73 `ext3`, `ext4`, and `xfs` are commonly used filesystems on the vicep
74 partitions.
75
76 Clients should have a dedicated partition for the file cache. The cache
77 partition is traditionally mounted at `/usr/vice/cache`.
78
79 ### Networking
80
81 DNS should be working correctly for forward and reverse name lookups before you
82 begin the Kerberos and OpenAFS installation.  `bind` can be installed if you
83 need a local DNS server.  Use `system-config-bind` to add a zone and entries.
84
85 Servers need at least one IPv4 interface that is accessible by the AFS clients.
86 IPv6 interfaces are not yet supported.
87
88 ### Time keeping
89
90 Kerberos, and therefore OpenAFS, requires good clock synchronization between
91 clients and servers. Be sure to install and configure `ntp` and verify the
92 clocks are automatically kept in sync.
93
94     # yum install -y ntp
95     # service ntpd start
96     # chkconfig ntpd on
97
98 ### Firewall
99
100 The default firewall settings on RHEL will block the network ports used by
101 Kerberos and OpenAFS.  You will need to adjust the firewall rules on the
102 servers to allow traffic on these ports.
103
104 On the Kerberos server, open udp ports 88 and 646:
105
106     # iptables -A INPUT -p udp --dport 88 -j ACCEPT
107     # iptables -A INPUT -p udp --dport 646 -j ACCEPT
108     # service iptables save
109
110 On the OpenAFS database servers, open the udp ports 7002, 7003, and 7007:
111
112     # iptables -A INPUT -p udp --dport 7002 -j ACCEPT
113     # iptables -A INPUT -p udp --dport 7003 -j ACCEPT
114     # iptables -A INPUT -p udp --dport 7007 -j ACCEPT
115     # service iptables save
116
117 On the OpenAFS file servers, open the udp ports 7000, 7005, and 7007:
118
119     # iptables -A INPUT -p udp --dport 7000 -j ACCEPT
120     # iptables -A INPUT -p udp --dport 7005 -j ACCEPT
121     # iptables -A INPUT -p udp --dport 7007 -j ACCEPT
122     # service iptables save
123
124 OpenAFS clients use udp port 7001. Open udp port 7001 on any system that will
125 have the OpenAFS client installed.
126
127     # iptables -A INPUT -p udp --dport 7001 -j ACCEPT
128     # service iptables save
129
130 ### SELinux
131
132 Ideally, SELinux should be kept in enforcing mode. SELinux may be set to
133 enforcing for the OpenAFS client, but unfortunately, for the servers, there are
134 still several [issues][1] remaining before the servers can run out the box with
135 SELinux in enforcing mode.
136
137 For test installations, SELinux can be set into permissive mode, which will
138 print warnings instead of blocking:
139
140     # setenforce 0
141     # sed -i -e 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
142
143 See [this report][1] for workarounds if you need to run in enforcing mode.
144
145 [1]: https://bugzilla.redhat.com/show_bug.cgi?id=1136396
146
147 ## Installing Kerberos
148
149 Install the Kerberos server and client packages with the command:
150
151     # yum install -y krb5-server krb5-workstation krb5-libs
152
153 Replace every instance of `EXAMPLE.COM` with your realm name in the following
154 configuration files:
155
156   * `/etc/krb5.conf`
157   * `/var/kerberos/krb5kdc/kdc.conf`
158   * `/var/kerberos/krb5kdc/kadm5.acl`
159
160 Replace every instance of the example hostname `kerberos.example.com` with
161 the actual hostname of your Kerberos server in the file `/etc/krb5.conf`.
162
163 Create the Kerberos database using the `krb5_util` command. You will be
164 prompted for a master principal password. Choose a password, keep it secret,
165 and keep it safe.
166
167     # /usr/sbin/kdb5_util create -s
168
169 Start the Kerberos servers.
170
171     # service krb5kdc start
172     # service kadmin start
173     # chkconfig krb5kdc on
174     # chkconfig kadmin on
175
176 ## Installing OpenAFS servers
177
178 ### Installing servers
179
180 OpenAFS RPM packages for RHEL 6 are available on the [[OpenAFS]] website. The
181 packages may be installed using `yum`.  First, install the repository
182 definition with
183
184     # version=<version>
185     # rpm -i http://openafs.org/dl/openafs/${version}/openafs-release-rhel-${version}-1.noarch.rpm
186
187 where `<version>` is the OpenAFS version you wish to install, e.g. "1.6.21".
188
189 Use `yum` to install the OpenAFS server packages:
190
191     # yum install -y openafs openafs-server openafs-docs openafs-krb5
192
193 Create the Kerberos AFS service key and export it to a keytab file:
194
195     # cellname=<cellname>
196     # kadmin.local -q "addprinc -randkey afs/${cellname}"
197     # kadmin.local -q "ktadd -k /usr/afs/etc/rxkad.keytab afs/${cellname}"
198
199 where `<cellname>` is the name of your cell.
200
201 If your Kerberos REALM name is different from your cell name add your upper case
202 REALM name in /usr/afs/etc/krb.conf, else you will not know why your cell does not work!
203
204 Start the OpenAFS servers:
205
206     # service openafs-server start
207
208 Check the server log `/usr/afs/logs/BosLog` to verify the OpenAFS `bosserver`
209 process started.  Set the cell name with the command:
210
211     # bos setcellname localhost ${cellname} -localauth
212
213 ### Starting the database services
214
215 The `ptserver` process stores the AFS users and group names in your cell. The
216 `vlserver` process stores the file server locations of the AFS volumes in your
217 cell.  Start the OpenAFS database processes with the commands:
218
219     # bos create localhost ptserver simple -cmd /usr/afs/bin/ptserver -localauth
220     # bos create localhost vlserver simple -cmd /usr/afs/bin/vlserver -localauth
221
222 Check the log files `BosLog`, `PTLog`, `VLLog` in the `/usr/afs/logs`
223 directory to verify the `ptserver` and `vlserver` started.
224
225 ### Starting the file server
226
227 Start the file server. This is a rather long command line.
228
229     # bos create localhost \
230        dafs dafs -cmd \
231        "/usr/afs/bin/dafileserver -p 123 -L -busyat 200 -rxpck 2000 -cb 4000000 -vattachpar 128 -vlruthresh 1440 -vlrumax 8 -vhashsize 11" \
232        "/usr/afs/bin/davolserver -p 64 -log" \
233        "/usr/afs/bin/salvageserver" \
234        "/usr/afs/bin/dasalvager -parallel all32" \
235        -localauth
236
237 Check the servers logs `BosLog`, `FileLog`, `VolserLog`, and `SalsrvLog`, in
238 `/usr/afs/logs' to verify the file server started.  At this point the OpenAFS
239 server processes should be running.
240
241 ### Creating the admin account
242
243 Create a user account for Kerberos and AFS administration.
244
245     # myname=<username>
246     # kadmin.local -q "addprinc ${myname}/admin"
247     Enter password: <password>
248     Re-enter password: <password>
249     # pts createuser ${myname}.admin -localauth
250     # pts adduser ${myname}.admin system:administrators -localauth
251     # bos adduser localhost ${myname}.admin -localauth
252
253 where `<myname>` is your user name and `<password>` is your chosen password.
254
255 The admin principal can be any name you want.  The recommended practice is to
256 create two principals for admins: one for your normal user, and an additional
257 admin account. For example, I may have `steve` and `steve/admin`. Note that for
258 Kerberos 5, the name is `steve/admin@REALM`, whereas in AFS, the name is
259 `steve.admin`. Use `steve.admin` for all AFS commands.  Since this is to be an
260 administrator we will also register it as such with the `bos` server. We can give
261 it administrator rights by adding it to the group `system:administrators`. This
262 is an AFS default group. The `pts membership` command will list all the groups
263 that your user is a member of. Verify that it lists `system:administrators`.
264
265 ### Create the root volumes
266
267 At this point we need our `/vicepa` partition.  You should have done this when
268 installing the operating system. If you have not, do it now, then restart the
269 fileserver with `service openafs-server restart`.  (If this is only a test
270 system you may create a pseudo partition without needing to create an actual
271 separate filesystem. To do this, create an empty directory called `/vicepa` and
272 then create an empty file called `/vicepa/AlwaysAttach`, then restart the file
273 server with `service openafs-server restart`.)
274
275 Create the root volumes with the commands:
276
277     # vos create localhost a root.afs -localauth
278     # vos create localhost a root.cell -localauth
279
280 Check the volume location database to verify the two volumes are listed.
281
282     # vos listvldb
283
284 Finally, now that the server configuration is done, put the `bosserver` into
285 the more secure restricted mode, which disables several bos commands which are
286 strictly not needed for normal operation.
287
288     # bos setrestricted localhost -mode 1 -localauth
289
290 This completes the server side setup. At this point will need to install the
291 OpenAFS cache manager (client), setup the top level directories, and then start
292 adding files to your new cell.  The cache manager may be installed on a
293 separate machine (for example, your laptop.)  Also, you will no longer be using
294 the `root` user to run OpenAFS commands, but instead from this point forward
295 you should use your Kerberos credentials.
296
297 ## Installing OpenAFS Client
298
299 ### Kernel Module
300
301 If installing the cache manager on an OpenAFS server, first remove the symlinks
302 created by `bosserver`. These will be in the way if the client is installed.
303
304     # test -h /usr/vice/etc/ThisCell && rm /usr/vice/etc/ThisCell
305     # test -h /usr/vice/etc/CellServDB && rm /usr/vice/etc/CellServDB
306
307 Install the OpenAFS client with yum:
308
309     # yum install -y openafs openafs-client openafs-krb5 kmod-openafs
310
311 You may need to reboot you system if the kernel version was updated.
312
313 The OpenAFS kernel module must match your kernel version.  If a pre-built
314 module is not available for the kernel version you are running, the yum install
315 of kmod-openafs will fail.  If this happens, then you may use
316 [DKMS to build and install|RpmClientInstallationWithDKMS]] a kernel module
317 that matches your kernel version.
318
319     # yum install -y dkms gcc
320     # yum install -y openafs openafs-client openafs-krb5 dkms-openafs
321
322 Alternately, you can build the kernel module from the source rpm.  You will
323 need to download the OpenAFS SRPM file from OpenAFS.org, install the
324 `kernel-devel` package that matches your kernel version, and the necessary
325 build tools.  Use the `rpmbuild` command to build the kernel module.
326
327     # rpmbuild --rebuild -bb \
328         --define 'build_userspace 0' \
329         --define 'build_modules 1' \
330         openafs-<version>-1.src.rpm
331
332 ### Client side configuration
333
334 `/usr/afs/etc` is the location for the server files. We also need to configure
335 the client. The client files are located in `/usr/vice/etc`. RPM based OpenAFS
336 packages are set up in such a way that there are two `CellServDB` client
337 files in `/usr/vice/etc`: `CellServDB.dist` and `CellServDB.local`. We will
338 copy ours to the local list.
339
340     # cp /usr/afs/etc/CellServDB /usr/vice/etc/CellServDB.local
341     # cp /usr/afs/etc/ThisCell /usr/vice/etc/ThisCell
342
343 The RPM based `openafs-client` init script will combine the `CellServDB.dist`
344 and `CellServDB.local` files into the `CellServDB` file, which the cache
345 manager reads on startup.
346
347 ### Start the cache manager
348
349 Start the cache manager with the command:
350
351     # service openafs-client start
352
353 Run the `mount` command to verify the AFS filesystem is mounted at `/afs`.
354
355 Try logging in to AFS. `kinit` logs you into Kerberos (this is the normal
356 Kerberos utility). `aklog` gets you an AFS token.  The `tokens` command lists
357 the tokens you have. You should see `afs@<cellname>`. If you run into problems, you
358 can use `klist` to list your Kerberos tickets, or `aklog` with the `-d` flag.
359
360     $ kinit <username>/admin
361     <password>
362     $ aklog
363     $ tokens
364
365 ## Setting up the cell root directory
366
367 Now we will set up the root directories.  The root directory for the AFS
368 namespace is in the volume called `root.afs`. The root directory of your cell
369 should be in a volume called `root.cell`. You will need to set the ACLs for
370 these directories.  AFS access rights are rather different from those in UNIX.
371 I suggest reading the IBM documentation for this; it still applies.
372
373 The cache manager is started in `-dynroot` mode on RPM-based installations.
374 This allows the cache manager to mount the AFS filesystem without the need to
375 contact the OpenAFS servers. The side-effect of `-dynroot` is the `root.afs`
376 volume cannot be accessed directly.  Fortunately, we can use "magic" `.:mount`
377 directory to access the `root.afs` volume.
378
379 Set up the top level directories.
380
381     $ cellname=$(cat /usr/vice/etc/ThisCell)
382     
383     $ cd /afs/.:mount/${cellname}:root.afs/
384     $ fs mkmount ${cellname} root.cell -cell ${cellname}
385     $ fs mkmount .${cellname} root.cell -cell ${cellname} -rw
386     $ fs setacl . system:anyuser read
387     
388     $ cd /afs/.:mount/${cellname}:root.cell/
389     $ fs setacl . system:anyuser read
390
391 Replicate the root volumes so that you have read only copies.  Later, if more
392 file servers are added to the cell, additional read-only copies should be made.
393
394     $ server=<hostname of the fileserver>
395     $ vos addsite ${server} a root.afs
396     $ vos release root.afs
397     $ vos addsite ${server} a root.cell
398     $ vos release root.cell
399
400 ## Adding users and volumes
401
402 Now that OpenAFS is installed, the site specific AFS volumes and directory
403 structure can be set up. Users should be made, along with their home
404 volumes. ACLs for the volume directories should be established.
405
406 This section provides an example setup. The names of the volumes and
407 directories can be specific to your needs.
408
409 You must first authenticate as a Kerberos/AFS admin to run the commands
410 shown in this section.
411
412     $ kadmin <username>/admin
413     $ aklog
414
415 ### Creating user accounts
416
417 We can create a user by registering it to Kerberos and the `ptserver` database.
418 If you use integrated login, make sure that the users' UNIX uids and pts ids
419 match.
420
421     $ kadmin -q "addprinc <username>"
422     <enter password for username>
423     $ pts createuser <username> -id <numeric uid>
424
425 If you use integrated login, make sure that you add an entry to /etc/passwd or
426 whatever means you use of distributing user information.
427
428 ### Setting up volumes for users
429
430 First, we can make a top level volume to contain the mount points to volumes
431 for individuals. The IBM documentation suggests making a directory
432 `/afs/<cellname>/user` with volume name user for all of your AFS users. Some
433 sites have adopted the directory `home` instead of `user`.  If you use `home`,
434 your users may feel more comfortable, as this is the convention in Linux and
435 most UNIXes.
436
437 The following commands create the `home` volume and make a read-only replica:
438
439     $ vos create <fileserver> a home
440     $ cd /afs/.<cellname>
441     $ fs mkmount home home
442     $ vos addsite <fileserver> a home
443     $ vos release root.cell
444     $ vos release home
445
446 Now you can create directories for any of your users. We will not replicate
447 these volumes. By not replicating them, we force the cache manager to access a
448 read/write volume. This means that even if we access the cell through the
449 read-only volume we can still access our read/write user directories (this is
450 what you want). Maxquota 0 means that there is no size restriction to the
451 volume. You can give it a restriction if you like (the default is 5mb). Do
452 these commands for every directory you like.
453
454     $ vos create <fileserver> a home.<uid> -maxquota 0
455     $ cd /afs/.<cellname>/home
456     $ fs mkmount <user> home.<uid>
457     $ vos release home
458
459 The home volume is released to make the new directories are visible from the
460 read only mount point.
461
462 ### Setting ACLs
463
464 Now that we have volumes, we should set some restrictions on those volumes.
465 If you trust the users not to make directories *world writable*, you
466 can give the user of the directory full rights.
467
468     $ cd /afs/.<cellname>/home
469     $ fs setacl -dir <user> -acl <user> all
470
471 To give the users read and write access, but not rights to change ACLs,
472
473     $ cd /afs/.<cellname>/home
474     $ fs setacl -dir <user> -acl <user> write
475