1 This is a step-by-step guide to installing OpenAFS and setting up an AFS cell
2 on CentOS 7, and presumably RedHat Enterprise Linux 7, and anything from that
3 same family. It is current as of OpenAFS version 1.8.3 on CentOS 7.
5 This document is based on [[InstallingOpenAFSonRHEL]] and includes information from
6 the [Unix Quick Start Guide](http://docs.openafs.org/QuickStartUnix/).
12 When setting up an AFS cell on the internet, the convention is to user your
13 internet domain name for your Kerberos realm and AFS cell name. The Kerberos
14 realm name should be uppercase and the AFS cell name should be lowercase.
16 Note, it is possible to create a AFS cell with a different name than the
17 Kerberos realm (or even use a single Kerberos realm in multiple cells). See
18 the documentation for the OpenAFS `krb.conf` server configuration file for
19 details on mapping realms to cell names.
23 A minimal OS install is sufficient.
25 For a simple installation, you may use a single server to host the Kerberos
26 KDC, OpenAFS database server, and OpenAFS fileserver. For a production
27 environment, it is recommended that the Kerberos KDC be deployed on a
28 dedicated, secure server, the OpenAFS database servers be deployed on three
29 separate machines, and multiple file servers deployed as needed.
33 An important thing to keep in mind is that you'll need at least one partition
34 on the file server to store volumes for AFS. This will be mounted at
35 `/vicepa`. If you have multiple partitions they can be mounted at `/vicepb`,
36 `/vicepc`, etc. The file server uses file-based storage (not block based).
37 `ext3`, `ext4`, and `xfs` are commonly used filesystems on the vicep
40 Clients should have a dedicated partition for the file cache. The cache
41 partition is traditionally mounted at `/usr/vice/cache`.
45 DNS should be working correctly for forward and reverse name lookups before you
46 begin the Kerberos and OpenAFS installation. `bind` can be installed if you
47 need a local DNS server. Use `system-config-bind` to add a zone and entries.
49 Servers need at least one IPv4 interface that is accessible by the AFS clients.
50 IPv6 interfaces are not yet supported.
54 Kerberos, and therefore OpenAFS, requires good clock synchronization between
55 clients and servers. As CentOS 7 enables `chronyd` for time synchronization
56 out of the box, it is unlikely you will need to make a change.
60 The default firewall settings on RHEL will block the network ports used by
61 Kerberos and OpenAFS. You will need to adjust the firewall rules on the
62 servers to allow traffic on these ports.
64 On the Kerberos server, open udp ports 88 and 646:
66 # firewall-cmd --zone=public --add-port=88/udp
67 # firewall-cmd --zone=public --add-port=646/udp
68 # firewall-cmd --runtime-to-permanent
70 On the OpenAFS database servers, open the udp ports 7002, 7003, and 7007:
72 # firewall-cmd --zone=public --add-port=7002/udp
73 # firewall-cmd --zone=public --add-port=7003/udp
74 # firewall-cmd --zone=public --add-port=7007/udp
75 # firewall-cmd --runtime-to-permanent
77 On the OpenAFS file servers, open the udp ports 7000, 7005, and 7007:
79 # firewall-cmd --zone=public --add-port=7000/udp
80 # firewall-cmd --zone=public --add-port=7005/udp
81 # firewall-cmd --zone=public --add-port=7007/udp
82 # firewall-cmd --runtime-to-permanent
84 OpenAFS clients use udp port 7001. Open udp port 7001 on any system that will
85 have the OpenAFS client installed.
87 # firewall-cmd --zone=public --add-port=7001/udp
88 # firewall-cmd --runtime-to-permanent
90 ## Installing Kerberos
92 Install the Kerberos server and client packages with the command:
94 # yum install -y krb5-server krb5-workstation krb5-libs
96 Replace every instance of `EXAMPLE.COM` with your realm name in the following
100 * `/var/kerberos/krb5kdc/kdc.conf`
101 * `/var/kerberos/krb5kdc/kadm5.acl`
103 Replace every instance of the example hostname `kerberos.example.com` with
104 the actual hostname of your Kerberos server in the file `/etc/krb5.conf`.
106 Create the Kerberos database using the `krb5_util` command. You will be
107 prompted for a master principal password. Choose a password, keep it secret,
110 # /usr/sbin/kdb5_util create -s
112 Start the Kerberos servers.
114 # systemctl start krb5kdc
115 # systemctl start kadmin
116 # systemctl enable krb5kdc
117 # systemctl enable kadmin
119 ## Installing OpenAFS servers
121 ### Installing servers
123 The OpenAFS source tarballs are available on the OpenAFS website. You will
124 need to build the source RPM with a script provided in the source tarball, and
125 then build the RPMs using the `rpmbuild` command. There are third party
126 sources for pre-built packages, in particular the CentOS Storage SIG, but note
127 that at least with the Storage SIG's packages, configuration files are located
128 in `/etc/openafs` and servers `/usr/libexec/openafs` instead of the traditional
131 $ sudo yum install rpm-build yum-utils make perl libtool bzip2 wget
133 $ wget https://www.openafs.org/dl/openafs/<version>/openafs-<version>-src.tar.bz2
134 $ wget https://www.openafs.org/dl/openafs/<version>/openafs-<version>-doc.tar.bz2
135 $ wget https://www.openafs.org/dl/openafs/<version>/RELNOTES-<version>
136 $ wget https://www.openafs.org/dl/openafs/<version>/ChangeLog
138 $ tar xf openafs-<version>-src.tar.bz2 --strip-components=4 '*/makesrpm.pl'
139 $ perl makesrpm.pl openafs-<version>-src.tar.bz2 openafs-<version>-doc.tar.bz2 RELNOTES-<version> ChangeLog
141 $ sudo yum-builddep openafs-<version>-1.src.rpm
143 $ rpmbuild --rebuild \
144 --define "build_userspace 1" \
145 --define "build_modules 0" \
146 openafs-<version>-1.src.rpm
148 where `<version>` is the OpenAFS version you wish to install, e.g. "1.8.5".
150 Use `yum` to install the OpenAFS server packages from your your rpmbuild RPMS directory:
152 # yum install -y openafs-<version>-1.el7.x86_64.rpm openafs-server-<version>-1.el7.x86_64.rpm openafs-docs-<version>-1.el7.x86_64.rpm openafs-krb5-<version>-1.el7.x86_64.rpm
154 Create the Kerberos AFS service key and export it to a keytab file:
156 # cellname=<cellname>
157 # kadmin.local -q "addprinc -randkey -e aes256-cts-hmac-sha1-96:normal,aes128-cts-hmac-sha1-96:normal afs/${cellname}"
158 # kadmin.local -q "ktadd -k /usr/afs/etc/rxkad.keytab -e aes256-cts-hmac-sha1-96:normal,aes128-cts-hmac-sha1-96:normal afs/${cellname}"
160 where `<cellname>` is the name of your cell. Make note of the key version number (kvno) as it is needed for the next step where it shows `<kvno>`.
162 # asetkey add rxkad_krb5 <kvno> 18 /usr/afs/etc/rxkad.keytab afs/${cellname}
163 # asetkey add rxkad_krb5 <kvno> 17 /usr/afs/etc/rxkad.keytab afs/${cellname}
166 If your Kerberos REALM name is different from your cell name add your upper case
167 REALM name in /usr/afs/etc/krb.conf, else you will not know why your cell does not work!
169 Start the OpenAFS servers:
171 # systemctl start openafs-server
172 # systemctl enable openafs-server
174 Check the server log `/usr/afs/logs/BosLog` to verify the OpenAFS `bosserver`
175 process started. Set the cell name with the command:
177 # bos setcellname localhost ${cellname} -localauth
179 ### Starting the database services
181 The `ptserver` process stores the AFS users and group names in your cell. The
182 `vlserver` process stores the file server locations of the AFS volumes in your
183 cell. Start the OpenAFS database processes with the commands:
185 # bos create localhost ptserver simple -cmd /usr/afs/bin/ptserver -localauth
186 # bos create localhost vlserver simple -cmd /usr/afs/bin/vlserver -localauth
188 Check the log files `BosLog`, `PTLog`, `VLLog` in the `/usr/afs/logs`
189 directory to verify the `ptserver` and `vlserver` started.
191 ### Starting the file server
193 Start the file server. This is a rather long command line.
195 # bos create localhost \
197 "/usr/afs/bin/dafileserver -L" \
198 "/usr/afs/bin/davolserver -p 64 -log" \
199 "/usr/afs/bin/salvageserver" \
200 "/usr/afs/bin/dasalvager -parallel all32" \
203 Check the servers logs `BosLog`, `FileLog`, `VolserLog`, and `SalsrvLog`, in
204 `/usr/afs/logs' to verify the file server started. At this point the OpenAFS
205 server processes should be running.
207 ### Creating the admin account
209 Create a user account for Kerberos and AFS administration.
212 # kadmin.local -q "addprinc ${myname}/admin"
213 Enter password: <password>
214 Re-enter password: <password>
215 # pts createuser ${myname}.admin -localauth
216 # pts adduser ${myname}.admin system:administrators -localauth
217 # bos adduser localhost ${myname}.admin -localauth
219 where `<myname>` is your user name and `<password>` is your chosen password.
221 The admin principal can be any name you want. The recommended practice is to
222 create two principals for admins: one for your normal user, and an additional
223 admin account. For example, I may have `steve` and `steve/admin`. Note that for
224 Kerberos 5, the name is `steve/admin@REALM`, whereas in AFS, the name is
225 `steve.admin`. Use `steve.admin` for all AFS commands. Since this is to be an
226 administrator we will also register it as such with the `bos` server. We can give
227 it administrator rights by adding it to the group `system:administrators`. This
228 is an AFS default group. The `pts membership` command will list all the groups
229 that your user is a member of. Verify that it lists `system:administrators`.
231 ### Create the root volumes
233 At this point we need our `/vicepa` partition. You should have done this when
234 installing the operating system. If you have not, do it now, then restart the
235 fileserver with `systemctl restart openafs-server`. (If this is only a test
236 system you may create a pseudo partition without needing to create an actual
237 separate filesystem. To do this, create an empty directory called `/vicepa` and
238 then create an empty file called `/vicepa/AlwaysAttach`, then restart the file
239 server with `systemctl restart openafs-server`.)
241 Create the root volumes with the commands:
243 # vos create localhost a root.afs -localauth
244 # vos create localhost a root.cell -localauth
246 Check the volume location database to verify the two volumes are listed.
250 Finally, now that the server configuration is done, put the `bosserver` into
251 the more secure restricted mode, which disables several bos commands which are
252 strictly not needed for normal operation.
254 # bos setrestricted localhost -mode 1 -localauth
256 This completes the server side setup. At this point will need to install the
257 OpenAFS cache manager (client), setup the top level directories, and then start
258 adding files to your new cell. The cache manager may be installed on a
259 separate machine (for example, your laptop.) Also, you will no longer be using
260 the `root` user to run OpenAFS commands, but instead from this point forward
261 you should use your Kerberos credentials.
263 ## Installing OpenAFS Client
267 If installing the cache manager on an OpenAFS server, first remove the symlinks
268 created by `bosserver`. These will be in the way if the client is installed.
270 # test -h /usr/vice/etc/ThisCell && rm /usr/vice/etc/ThisCell
271 # test -h /usr/vice/etc/CellServDB && rm /usr/vice/etc/CellServDB
273 The OpenAFS kernel module must match your kernel version. Unless you are maintaining
274 a local `yum` repository that tracks every single kernel release and updates its kmod builds,
275 you will want to use the DKMS mechanism for installing the the kernel module. If
276 you are installing on a freshly patched machine, be sure to reboot before installing
277 the OpenAFS kernel module.
279 $ sudo yum install rpm-build yum-utils make perl libtool bzip2 wget
281 $ wget https://www.openafs.org/dl/openafs/<version>/openafs-<version>-src.tar.bz2
282 $ wget https://www.openafs.org/dl/openafs/<version>/openafs-<version>-doc.tar.bz2
283 $ wget https://www.openafs.org/dl/openafs/<version>/RELNOTES-<version>
284 $ wget https://www.openafs.org/dl/openafs/<version>/ChangeLog
286 $ tar xf openafs-<version>-src.tar.bz2 --strip-components=4 '*/makesrpm.pl'
287 $ perl makesrpm.pl openafs-<version>-src.tar.bz2 openafs-<version>-doc.tar.bz2 RELNOTES-<version> ChangeLog
289 $ sudo yum-builddep openafs-<version>-1.src.rpm
290 $ sudo yum install "kernel-devel-uname-r == $(uname -r)"
291 $ sudo yum install elfutils-devel
293 $ rpmbuild --rebuild openafs-<version>-1.src.rpm
295 $ sudo yum install -y dkms gcc kernel-devel kernel-headers
296 $ cd ~/rpmbuild/RPMS/x86_64
297 $ sudo yum install -y \
298 openafs-<version>-1.el7.x86_64.rpm \
299 openafs-client-<version>-1.el7.x86_64.rpm \
300 openafs-krb5-<version>-1.el7.x86_64.rpm \
301 dkms-openafs-<version>-1.el7.x86_64.rpm
303 ### Client side configuration
305 `/usr/afs/etc` is the location for the server files. We also need to configure
306 the client. The client files are located in `/usr/vice/etc`. RPM based OpenAFS
307 packages are set up in such a way that there are two `CellServDB` client
308 files in `/usr/vice/etc`: `CellServDB.dist` and `CellServDB.local`. We will
309 copy ours to the local list.
311 # cp /usr/afs/etc/CellServDB /usr/vice/etc/CellServDB.local
312 # cp /usr/afs/etc/ThisCell /usr/vice/etc/ThisCell
314 The RPM based `openafs-client` init script will combine the `CellServDB.dist`
315 and `CellServDB.local` files into the `CellServDB` file, which the cache
316 manager reads on startup.
318 ### Start the cache manager
320 Start the cache manager with the command:
322 # systemctl start openafs-client
323 # systemctl enable openafs-client
325 Run the `mount` command to verify the AFS filesystem is mounted at `/afs`.
327 Try logging in to AFS. `kinit` logs you into Kerberos (this is the normal
328 Kerberos utility). `aklog` gets you an AFS token. The `tokens` command lists
329 the tokens you have. You should see `afs@<cellname>`. If you run into problems, you
330 can use `klist` to list your Kerberos tickets, or `aklog` with the `-d` flag.
332 $ kinit <username>/admin
337 ## Setting up the cell root directory
339 Now we will set up the root directories. The root directory for the AFS
340 namespace is in the volume called `root.afs`. The root directory of your cell
341 should be in a volume called `root.cell`. You will need to set the ACLs for
342 these directories. AFS access rights are rather different from those in UNIX.
343 I suggest reading the IBM documentation for this; it still applies.
345 The cache manager is started in `-dynroot` mode on RPM-based installations.
346 This allows the cache manager to mount the AFS filesystem without the need to
347 contact the OpenAFS servers. The side-effect of `-dynroot` is the `root.afs`
348 volume cannot be accessed directly. Fortunately, we can use "magic" `.:mount`
349 directory to access the `root.afs` volume.
351 Set up the top level directories.
353 $ cellname=$(cat /usr/vice/etc/ThisCell)
355 $ cd /afs/.:mount/${cellname}:root.afs/
356 $ fs mkmount ${cellname} root.cell -cell ${cellname}
357 $ fs mkmount .${cellname} root.cell -cell ${cellname} -rw
358 $ fs setacl . system:anyuser read
360 $ cd /afs/.:mount/${cellname}:root.cell/
361 $ fs setacl . system:anyuser read
363 Replicate the root volumes so that you have read only copies. Later, if more
364 file servers are added to the cell, additional read-only copies should be made.
366 $ server=<hostname of the fileserver>
367 $ vos addsite ${server} a root.afs
368 $ vos release root.afs
369 $ vos addsite ${server} a root.cell
370 $ vos release root.cell
372 ## Adding users and volumes
374 Now that OpenAFS is installed, the site specific AFS volumes and directory
375 structure can be set up. Users should be made, along with their home
376 volumes. ACLs for the volume directories should be established.
378 This section provides an example setup. The names of the volumes and
379 directories can be specific to your needs.
381 You must first authenticate as a Kerberos/AFS admin to run the commands
382 shown in this section.
384 $ kadmin <username>/admin
387 ### Creating user accounts
389 We can create a user by registering it to Kerberos and the `ptserver` database.
390 If you use integrated login, make sure that the users' UNIX uids and pts ids
393 $ kadmin -q "addprinc <username>"
394 <enter password for username>
395 $ pts createuser <username> -id <numeric uid>
397 If you use integrated login, make sure that you add an entry to /etc/passwd or
398 whatever means you use of distributing user information.
400 ### Setting up volumes for users
402 First, we can make a top level volume to contain the mount points to volumes
403 for individuals. The IBM documentation suggests making a directory
404 `/afs/<cellname>/user` with volume name user for all of your AFS users. Some
405 sites have adopted the directory `home` instead of `user`. If you use `home`,
406 your users may feel more comfortable, as this is the convention in Linux and
409 The following commands create the `home` volume and make a read-only replica:
411 $ vos create <fileserver> a home
412 $ cd /afs/.<cellname>
413 $ fs mkmount home home
414 $ vos addsite <fileserver> a home
415 $ vos release root.cell
418 Now you can create directories for any of your users. We will not replicate
419 these volumes. By not replicating them, we force the cache manager to access a
420 read/write volume. This means that even if we access the cell through the
421 read-only volume we can still access our read/write user directories (this is
422 what you want). Maxquota 0 means that there is no size restriction to the
423 volume. You can give it a restriction if you like (the default is 5mb). Do
424 these commands for every directory you like.
426 $ vos create <fileserver> a home.<uid> -maxquota 0
427 $ cd /afs/.<cellname>/home
428 $ fs mkmount <user> home.<uid>
431 The home volume is released to make the new directories are visible from the
432 read only mount point.
436 Now that we have volumes, we should set some restrictions on those volumes.
437 If you trust the users not to make directories *world writable*, you
438 can give the user of the directory full rights.
440 $ cd /afs/.<cellname>/home
441 $ fs setacl -dir <user> -acl <user> all
443 To give the users read and write access, but not rights to change ACLs,
445 $ cd /afs/.<cellname>/home
446 $ fs setacl -dir <user> -acl <user> write