update gerrit list
[openafs-wiki.git] / admin / InstallingOpenAFSonCentOS7.mdwn
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.
4
5 This document is based on [[InstallingOpenAFSonRHEL]] and includes information from 
6 the [Unix Quick Start Guide](http://docs.openafs.org/QuickStartUnix/).
7
8 [[!toc levels=1]]
9
10 ## Naming conventions
11
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.
15
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.
20
21 ## Server setup
22
23 A minimal OS install is sufficient.
24
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.
30
31 ### Disk Partitions
32
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
38 partitions.
39
40 Clients should have a dedicated partition for the file cache. The cache
41 partition is traditionally mounted at `/usr/vice/cache`.
42
43 ### Networking
44
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.
48
49 Servers need at least one IPv4 interface that is accessible by the AFS clients.
50 IPv6 interfaces are not yet supported.
51
52 ### Time keeping
53
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.
57
58 ### Firewall
59
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. 
63
64 On the Kerberos server, open udp ports 88 and 646:
65
66     # firewall-cmd --zone=public --add-port=88/udp
67     # firewall-cmd --zone=public --add-port=646/udp
68     # firewall-cmd --runtime-to-permanent
69
70 On the OpenAFS database servers, open the udp ports 7002, 7003, and 7007:
71
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
76
77 On the OpenAFS file servers, open the udp ports 7000, 7005, and 7007:
78
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
83
84 OpenAFS clients use udp port 7001. Open udp port 7001 on any system that will
85 have the OpenAFS client installed.
86
87     # firewall-cmd --zone=public --add-port=7001/udp
88     # firewall-cmd --runtime-to-permanent
89
90 ## Installing Kerberos
91
92 Install the Kerberos server and client packages with the command:
93
94     # yum install -y krb5-server krb5-workstation krb5-libs
95
96 Replace every instance of `EXAMPLE.COM` with your realm name in the following
97 configuration files:
98
99   * `/etc/krb5.conf`
100   * `/var/kerberos/krb5kdc/kdc.conf`
101   * `/var/kerberos/krb5kdc/kadm5.acl`
102
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`.
105
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,
108 and keep it safe.
109
110     # /usr/sbin/kdb5_util create -s
111
112 Start the Kerberos servers.
113
114     # systemctl start krb5kdc
115     # systemctl start kadmin
116     # systemctl enable krb5kdc
117     # systemctl enable kadmin
118
119 ## Installing OpenAFS servers
120
121 ### Installing servers
122
123 OpenAFS source RPM packages are available on the OpenAFS website. You will need to build the
124 RPMs using the `rpmbuild` command.  There are third party sources for pre-built packages, in particular
125 the CentOS Storage SIG, but note that at least with the Storage SIG's packages, configuration files are
126 located in `/etc/openafs` and servers `/usr/libexec/openafs` instead of the traditional paths.
127
128     # curl -O http://openafs.org/dl/openafs/<version>/openafs-<version>-1.src.rpm
129     # yum install ncurses-devel flex bison automake autoconf libtool perl-devel perl-ExtUtils-Embed krb5-del
130     # rpmbuild --rebuild -bb \
131         openafs-<version>-1.src.rpm
132
133 where `<version>` is the OpenAFS version you wish to install, e.g. "1.8.3".
134
135 Use `yum` to install the OpenAFS server packages from your your rpmbuild RPMS directory:
136
137     # 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
138
139 Create the Kerberos AFS service key and export it to a keytab file:
140
141     # cellname=<cellname>
142     # kadmin.local -q "addprinc -randkey -e aes256-cts-hmac-sha1-96:normal,aes128-cts-hmac-sha1-96:normal afs/${cellname}"
143     # 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}"
144
145 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>`.
146
147     # asetkey add rxkad_krb5 <kvno> 18 /usr/afs/etc/rxkad.keytab afs/${cellname}
148     # asetkey add rxkad_krb5 <kvno> 17 /usr/afs/etc/rxkad.keytab afs/${cellname}
149
150
151 If your Kerberos REALM name is different from your cell name add your upper case
152 REALM name in /usr/afs/etc/krb.conf, else you will not know why your cell does not work!
153
154 Start the OpenAFS servers:
155
156     # systemctl start openafs-server
157     # systemctl enable openafs-server
158
159 Check the server log `/usr/afs/logs/BosLog` to verify the OpenAFS `bosserver`
160 process started.  Set the cell name with the command:
161
162     # bos setcellname localhost ${cellname} -localauth
163
164 ### Starting the database services
165
166 The `ptserver` process stores the AFS users and group names in your cell. The
167 `vlserver` process stores the file server locations of the AFS volumes in your
168 cell.  Start the OpenAFS database processes with the commands:
169
170     # bos create localhost ptserver simple -cmd /usr/afs/bin/ptserver -localauth
171     # bos create localhost vlserver simple -cmd /usr/afs/bin/vlserver -localauth
172
173 Check the log files `BosLog`, `PTLog`, `VLLog` in the `/usr/afs/logs`
174 directory to verify the `ptserver` and `vlserver` started.
175
176 ### Starting the file server
177
178 Start the file server. This is a rather long command line.
179
180     # bos create localhost \
181        dafs dafs -cmd \
182        "/usr/afs/bin/dafileserver -L" \
183        "/usr/afs/bin/davolserver -p 64 -log" \
184        "/usr/afs/bin/salvageserver" \
185        "/usr/afs/bin/dasalvager -parallel all32" \
186        -localauth
187
188 Check the servers logs `BosLog`, `FileLog`, `VolserLog`, and `SalsrvLog`, in
189 `/usr/afs/logs' to verify the file server started.  At this point the OpenAFS
190 server processes should be running.
191
192 ### Creating the admin account
193
194 Create a user account for Kerberos and AFS administration.
195
196     # myname=<username>
197     # kadmin.local -q "addprinc ${myname}/admin"
198     Enter password: <password>
199     Re-enter password: <password>
200     # pts createuser ${myname}.admin -localauth
201     # pts adduser ${myname}.admin system:administrators -localauth
202     # bos adduser localhost ${myname}.admin -localauth
203
204 where `<myname>` is your user name and `<password>` is your chosen password.
205
206 The admin principal can be any name you want.  The recommended practice is to
207 create two principals for admins: one for your normal user, and an additional
208 admin account. For example, I may have `steve` and `steve/admin`. Note that for
209 Kerberos 5, the name is `steve/admin@REALM`, whereas in AFS, the name is
210 `steve.admin`. Use `steve.admin` for all AFS commands.  Since this is to be an
211 administrator we will also register it as such with the `bos` server. We can give
212 it administrator rights by adding it to the group `system:administrators`. This
213 is an AFS default group. The `pts membership` command will list all the groups
214 that your user is a member of. Verify that it lists `system:administrators`.
215
216 ### Create the root volumes
217
218 At this point we need our `/vicepa` partition.  You should have done this when
219 installing the operating system. If you have not, do it now, then restart the
220 fileserver with `systemctl restart openafs-server`.  (If this is only a test
221 system you may create a pseudo partition without needing to create an actual
222 separate filesystem. To do this, create an empty directory called `/vicepa` and
223 then create an empty file called `/vicepa/AlwaysAttach`, then restart the file
224 server with `systemctl restart openafs-server`.)
225
226 Create the root volumes with the commands:
227
228     # vos create localhost a root.afs -localauth
229     # vos create localhost a root.cell -localauth
230
231 Check the volume location database to verify the two volumes are listed.
232
233     # vos listvldb
234
235 Finally, now that the server configuration is done, put the `bosserver` into
236 the more secure restricted mode, which disables several bos commands which are
237 strictly not needed for normal operation.
238
239     # bos setrestricted localhost -mode 1 -localauth
240
241 This completes the server side setup. At this point will need to install the
242 OpenAFS cache manager (client), setup the top level directories, and then start
243 adding files to your new cell.  The cache manager may be installed on a
244 separate machine (for example, your laptop.)  Also, you will no longer be using
245 the `root` user to run OpenAFS commands, but instead from this point forward
246 you should use your Kerberos credentials.
247
248 ## Installing OpenAFS Client
249
250 ### Kernel Module
251
252 If installing the cache manager on an OpenAFS server, first remove the symlinks
253 created by `bosserver`. These will be in the way if the client is installed.
254
255     # test -h /usr/vice/etc/ThisCell && rm /usr/vice/etc/ThisCell
256     # test -h /usr/vice/etc/CellServDB && rm /usr/vice/etc/CellServDB
257
258 The OpenAFS kernel module must match your kernel version.  Unless you are maintaining
259 a local `yum` repository that tracks every single kernel release and updates its kmod builds,
260 you will want to use the DKMS mechanism for installing the the kernel module.  If
261 you are installing on a freshly patched machine, be sure to reboot before installing
262 the OpenAFS kernel module.  Assuming you are using the same set of packages built earlier:
263
264     # yum install -y dkms gcc kernel-devel kernel-headers
265     # yum install -y openafs-<version>-1.el7.x86_64.rpm openafs-client-<version>-1.el7.x86_64.rpm openafs-krb5-<version>-1.el7.x86_64.rpm dkms-openafs-<version>-1.el7.x86_64.rpm
266
267 ### Client side configuration
268
269 `/usr/afs/etc` is the location for the server files. We also need to configure
270 the client. The client files are located in `/usr/vice/etc`. RPM based OpenAFS
271 packages are set up in such a way that there are two `CellServDB` client
272 files in `/usr/vice/etc`: `CellServDB.dist` and `CellServDB.local`. We will
273 copy ours to the local list.
274
275     # cp /usr/afs/etc/CellServDB /usr/vice/etc/CellServDB.local
276     # cp /usr/afs/etc/ThisCell /usr/vice/etc/ThisCell
277
278 The RPM based `openafs-client` init script will combine the `CellServDB.dist`
279 and `CellServDB.local` files into the `CellServDB` file, which the cache
280 manager reads on startup.
281
282 ### Start the cache manager
283
284 Start the cache manager with the command:
285
286     # systemctl start openafs-client
287     # systemctl enable openafs-client
288
289 Run the `mount` command to verify the AFS filesystem is mounted at `/afs`.
290
291 Try logging in to AFS. `kinit` logs you into Kerberos (this is the normal
292 Kerberos utility). `aklog` gets you an AFS token.  The `tokens` command lists
293 the tokens you have. You should see `afs@<cellname>`. If you run into problems, you
294 can use `klist` to list your Kerberos tickets, or `aklog` with the `-d` flag.
295
296     $ kinit <username>/admin
297     <password>
298     $ aklog
299     $ tokens
300
301 ## Setting up the cell root directory
302
303 Now we will set up the root directories.  The root directory for the AFS
304 namespace is in the volume called `root.afs`. The root directory of your cell
305 should be in a volume called `root.cell`. You will need to set the ACLs for
306 these directories.  AFS access rights are rather different from those in UNIX.
307 I suggest reading the IBM documentation for this; it still applies.
308
309 The cache manager is started in `-dynroot` mode on RPM-based installations.
310 This allows the cache manager to mount the AFS filesystem without the need to
311 contact the OpenAFS servers. The side-effect of `-dynroot` is the `root.afs`
312 volume cannot be accessed directly.  Fortunately, we can use "magic" `.:mount`
313 directory to access the `root.afs` volume.
314
315 Set up the top level directories.
316
317     $ cellname=$(cat /usr/vice/etc/ThisCell)
318     
319     $ cd /afs/.:mount/${cellname}:root.afs/
320     $ fs mkmount ${cellname} root.cell -cell ${cellname}
321     $ fs mkmount .${cellname} root.cell -cell ${cellname} -rw
322     $ fs setacl . system:anyuser read
323     
324     $ cd /afs/.:mount/${cellname}:root.cell/
325     $ fs setacl . system:anyuser read
326
327 Replicate the root volumes so that you have read only copies.  Later, if more
328 file servers are added to the cell, additional read-only copies should be made.
329
330     $ server=<hostname of the fileserver>
331     $ vos addsite ${server} a root.afs
332     $ vos release root.afs
333     $ vos addsite ${server} a root.cell
334     $ vos release root.cell
335
336 ## Adding users and volumes
337
338 Now that OpenAFS is installed, the site specific AFS volumes and directory
339 structure can be set up. Users should be made, along with their home
340 volumes. ACLs for the volume directories should be established.
341
342 This section provides an example setup. The names of the volumes and
343 directories can be specific to your needs.
344
345 You must first authenticate as a Kerberos/AFS admin to run the commands
346 shown in this section.
347
348     $ kadmin <username>/admin
349     $ aklog
350
351 ### Creating user accounts
352
353 We can create a user by registering it to Kerberos and the `ptserver` database.
354 If you use integrated login, make sure that the users' UNIX uids and pts ids
355 match.
356
357     $ kadmin -q "addprinc <username>"
358     <enter password for username>
359     $ pts createuser <username> -id <numeric uid>
360
361 If you use integrated login, make sure that you add an entry to /etc/passwd or
362 whatever means you use of distributing user information.
363
364 ### Setting up volumes for users
365
366 First, we can make a top level volume to contain the mount points to volumes
367 for individuals. The IBM documentation suggests making a directory
368 `/afs/<cellname>/user` with volume name user for all of your AFS users. Some
369 sites have adopted the directory `home` instead of `user`.  If you use `home`,
370 your users may feel more comfortable, as this is the convention in Linux and
371 most UNIXes.
372
373 The following commands create the `home` volume and make a read-only replica:
374
375     $ vos create <fileserver> a home
376     $ cd /afs/.<cellname>
377     $ fs mkmount home home
378     $ vos addsite <fileserver> a home
379     $ vos release root.cell
380     $ vos release home
381
382 Now you can create directories for any of your users. We will not replicate
383 these volumes. By not replicating them, we force the cache manager to access a
384 read/write volume. This means that even if we access the cell through the
385 read-only volume we can still access our read/write user directories (this is
386 what you want). Maxquota 0 means that there is no size restriction to the
387 volume. You can give it a restriction if you like (the default is 5mb). Do
388 these commands for every directory you like.
389
390     $ vos create <fileserver> a home.<uid> -maxquota 0
391     $ cd /afs/.<cellname>/home
392     $ fs mkmount <user> home.<uid>
393     $ vos release home
394
395 The home volume is released to make the new directories are visible from the
396 read only mount point.
397
398 ### Setting ACLs
399
400 Now that we have volumes, we should set some restrictions on those volumes.
401 If you trust the users not to make directories *world writable*, you
402 can give the user of the directory full rights.
403
404     $ cd /afs/.<cellname>/home
405     $ fs setacl -dir <user> -acl <user> all
406
407 To give the users read and write access, but not rights to change ACLs,
408
409     $ cd /afs/.<cellname>/home
410     $ fs setacl -dir <user> -acl <user> write
411