Project

General

Profile

AFS Server » History » Version 3

Joseph Foley, 2015-11-13 23:43
afs object storage

1 1 Joseph Foley
h1. AFS Server
2
3
4
{{toc}}
5
6
h2. Tasks
7
8
h2. Desired Hardware
9
10
* Drobo (automated raid system with iSCSI) http://www.drobo.com/products/business/b1200i/index.php#!prettyPhoto
11
12
h2. Instructions
13
14
* [[devnet-documentation:AFS_Client_Installation]]
15
* [[How To Add Users]]
16
17
h3. Guides/links
18
19
* OpenAFS Official Documentation http://docs.openafs.org/
20
* OpenAFS Detailed Guide http://techpubs.spinlocksolutions.com/dklar/afs.html
21
* slapd documentation https://help.ubuntu.com/community/OpenLDAPServer
22
* Kerberos/LDAP on Ubuntu (outdated) http://bobcares.com/blog/?p=435
23
* OpenAFS on Ubuntu (outdated) http://bobcares.com/blog/?p=501
24
* IBM AFS 3.6 Documentation http://www-01.ibm.com/software/stormgmt/afs/manuals/Library/unix/en_US/HTML/index.htm
25
* Interrealm AFS http://www.cs.cmu.edu/~help/afs/cross_realm.html
26
* AFS on Linux Presentation http://www.dia.uniroma3.it/~afscon09/docs/wiesand.pdf
27
* mod_waklog (apache integration with AFS) [[mod_waklog]]
28
* Kerberos and DNS http://www.faqs.org/faqs/kerberos-faq/general/section-47.html
29
* Adding another fileserver https://lists.openafs.org/pipermail/openafs-info/2006-September/023495.html
30
* Kerberos and AFS tutorial (Secure endpoints) http://www.secure-endpoints.com/talks/Kerberos_Tutorial_BPW2007.pdf
31 3 Joseph Foley
* Object storage:
32
** http://workshop.openafs.org/afsbpw08/talks/thu_3/OpenAFS+ObjectStorage.pdf
33
** http://www.dia.uniroma3.it/~afscon09/docs/reuter.pdf
34 1 Joseph Foley
* Key security issues
35
** http://openafs.org/pages/security/OPENAFS-SA-2013-003.txt
36
** http://www.openafs.org/pages/security/install-rxkad-k5-1.6.txt
37
38
h3. Getting started
39
40
* Install Ubuntu 12.04LTS
41
* Install Kerberos KDC (directions at [[Kerberos]])
42
* Setup DNS autodiscovery
43
<pre>
44
dev.ru.is.		IN	AFSDB	1 afsdb1.dev.ru.is.
45
</pre>
46
47
* Ubuntu
48
** client configuration is in @/etc/openafs@
49
** server configuration is in @/etc/openafs/server@
50
* CentOS
51
** client configuration is in @/var/vice/etc@ (the traditional)
52
** server configuration is in @/usr/afs/etc@
53
54
55
h3. Client
56
57
*Important!  Do this first!*
58
59 2 Joseph Foley
see [[AFS_Client_Installation]]
60 1 Joseph Foley
61
h3. Server
62
63
# Packages
64
<pre>sudo apt-get install openafs-krb5 openafs-{fileserver,dbserver}</pre>
65
66
h3. Keys and accounts
67
68
# Add entries to @/etc/openafs/CellServDB@ and @/etc/openafs/server/CellServDB@
69
## Note that the AFS cell *MUST* be lowercase
70
<pre>
71
>dev.ru.is			# Reykjavik University
72
130.208.209.37			#afsdb1.dev.objid.net 
73
130.208.209.39			#afsdb2.dev.objid.net 
74
130.208.209.40			#afsdb3.dev.objid.net 
75
</pre>
76
# Edit your @/etc/krb5.conf@
77
<pre>       
78
[libdefaults]
79
dns_lookup_kdc = true
80
dns_lookup_realm = true
81
82
[realms]
83
DEV.RU.IS = {
84
                kdc = kerberos.dev.ru.is
85
                kdc = kerberos-1.dev.ru.is
86
                kdc = kerberos-2.dev.ru.is
87
                admin_server = kerberos.dev.ru.is
88
</pre>
89
90
# Add principal “afs/dev.ru.is” and import the key to /etc/openafs/afs.keytab.  This is also a good time to setup the normal keytab.  Replace HOSTNAME with the reverse resolvable hostname.  If this is on greenqloud, you will need to make both the external name and the internal and add it to the keytab.
91
## WARNING:  If you run the kadmin, it will increment the kerberos version number, which will not allow the new servers to talk to the old.  Instead, copy the afs.keytab using scp to all of the machines!
92
<pre>
93
kadmin.local
94
kadmin: addprinc -policy service -randkey -e des-cbc-crc:normal afs/dev.ru.is
95
kadmin: ktadd -k /etc/openafs/afs.keytab -e des-cbc-crc:normal afs/dev.ru.is
96
kadmin: ank -policy host -randkey host/HOSTNAME
97
kadmin: ktadd host/HOSTNAME
98
kadmin: ank -policy host -randkey host/HOSTNAME
99
kadmin: ktadd host/INTERNALHOSTNAME
100
</pre>
101
# Remember the KVNO (key version number)
102
<pre>klist -ke /etc/openafs/afs.keytab</pre>
103
# Import the secret key into the AFS system.  Replace KVNO with the version number
104
<pre>asetkey add KVNO /etc/openafs/afs.keytab afs/dev.ru.is
105
</pre>
106
#Now test with bos (afs-fileserver must be running, possibly restarted)
107
<pre>sudo service openafs-fileserver restart
108
sudo bos listkeys afsdb1 -localauth
109
#key 3 has cksum 2586520638
110
#Keys last changed on Fri Mar 30 02:10:25 2012.
111
#All done.
112
</pre> 
113
# Setup kerberized root shell access.  Replace my principal with yours or add it to the list.
114
<pre>
115
sudo vi /root/.krb5login
116
foley@DEV.RU.IS
117
</pre>
118
# Test
119
<pre>ksu</pre>
120
121
h3. Partitions for vice (AFS cell)
122
123
# Make the partitions in your filesystem (as an image)
124
<pre>cd /home
125
sudo dd if=/dev/zero of=vicepa.img bs=100M count=80   # (8 GB partition)
126
sudo mkfs.ext4 vicepa.img
127
sudo sh -c "echo '/home/vicepa.img /vicepa ext4 defaults,loop 0 2' >> /etc/fstab"
128
sudo tune2fs -c 0 -i 0 -m 0 vicepa.img
129
</pre>
130
# Now we mount it
131
<pre>sudo mkdir -p /vicepa
132
sudo mount /vicepa
133
</pre>
134
To add more disks, see [[AFS Server#Adding-More-disks|Adding More disks]]
135
136
137
h3. Firewall settings
138
139
# Need to poke holes in the firewall also (http://security.fnal.gov/cookbook/KerberosPorts.html)
140
## Login to the firewall  @bridge.objid.net@
141
## Open these ports in @/etc/shorewall/rules@
142
<pre>## AFS and kerberos 
143
## From http://security.fnal.gov/cookbook/KerberosPorts.html
144
ACCEPT all    net:130.208.209.37-130.208.209.40 tcp,udp 88 #krb
145
ACCEPT all    net:130.208.209.37-130.208.209.40 tcp 749
146
ACCEPT all    net:130.208.209.37-130.208.209.40 tcp,udp 464
147
ACCEPT all    net:130.208.209.37-130.208.209.40 udp 749,4444
148
ACCEPT all    net:130.208.209.37-130.208.209.40 udp 9878
149
ACCEPT all    net:130.208.209.37-130.208.209.40 udp 7000:7007
150
151
</pre>
152
153
h3. Make the new cell
154
155
# If you get issues with the case on the afs cell (all UPPERCASE is bad)
156
## sudo dpkg-reconfigure openafs-client
157
## sudo dpkg-reconfigure openafs-fileserver
158
# Make the Cell!
159
<pre>sudo afs-newcell</pre>
160
## Yes, we meet the requirements
161
##Principal: root/admin
162
## If you have problems with the ip address in the CellServDB, make sure it matches in @/etc/hosts@!
163
## If you see issues about network connections, you probably have an orphan process or something running on that port.
164
## if you have to clear out the user database, it is in @/etc/openafs/server/ThisUser@
165
166
h3. Testing out the cell and making the root volume
167
168
# Test out kinit and tokens
169
<pre>sudo su # (We want to switch to the root user)
170
171
kinit root/admin
172
173
Password for root/admin@SPINLOCK.HR: PASSWORD
174
175
aklog
176
</pre>
177
## if you get errors, it means that weak crypto is not enabled
178
# Check out your tokens with @kinit -5f@ and @tokens@
179
# Now create the root volume
180
<pre>afs-rootvol
181
...
182
4) The AFS client must be running pointed at the new cell.
183
Do you meet these conditions? (y/n) y
184
185
You will need to select a server (hostname) and AFS partition on which to
186
create the root volumes.
187
188
What AFS Server should volumes be placed on? gryla.dev.objid.net
189
What partition? [a] a
190
</pre>
191
# Everything should now be happy!
192
# Add the update server to distribute config files over encrypted channel
193
<pre>sudo bos create localhost upserveretc simple  "/usr/lib/openafs/upserver  -crypt /etc/openafs" -localauth </pre>
194
# Add the backup server (database servers need this process)
195
<pre>sudo bos create localhost buserver simple "/usr/lib/openafs/buserver" -localauth</pre>
196
h3. Standard partitions
197
198
# Now we create some of the "standard" partitions.  This is based upon the MIT configuration.  Note that these all start with very small quota! and are their own "class".  You will need to schedule backup partitions for them individually.  Note that you will need to go to the read-write of the root which is /afs/.dev.ru.is
199
<pre>
200
cd /afs/.dev.ru.is
201
vos create afsdb1 a activity
202
vos create afsdb1 a course
203
vos create afsdb1 a project
204
vos create afsdb1 a software
205
vos create afsdb1 a system
206
vos create afsdb1 a dept
207
vos create afsdb1 a org
208
vos create afsdb1 a reference
209
</pre>
210
# Now we mount them in the root area
211
<pre>
212
fs mkmount activity activity
213
fs mkmount course course
214
fs mkmount project project
215
fs mkmount software software
216
fs mkmount system system
217
fs mkmount dept dept
218
fs mkmount org org
219
fs mkmount reference reference
220
</pre>
221
# Finally, since this is a read-only volume, we have to "release" it
222
<pre>vos release root.cell</pre>
223
# And check to make sure the new directories show up in /afs/dev.ru.is
224
225
h3. Administrative users
226
227
* Login to the kerberos server as root and create an afsadm user
228
<pre>kadmin.local
229
addprinc addprinc -policy user <user>/afsadm
230
quit</pre>
231
* If you need super-super user capability, you will need to run this command with root/admin
232
<pre>kinit root/admin
233
aklog
234
bos adduser afsdb1 <user>/afsadm
235
</pre>
236
* Now you are a super-super user and can make the afs server dance.  Sometimes it takes a few minutes for the protection database to update, so you might have to wait.  Unfortunately, you are not done, you still need to add them to the group system:administrators so they can do other useful operations.
237
* Create an equivalent user to the Kerberos user
238
<pre>pts createuser <user>.afsadm</pre>
239
* Add them to the group system:administrators.  You may need to wait for the ptserver to sync up
240
<pre>pts adduser <user>.afsadm system:administrators</pre>
241
242
243
h3. Backup partitions
244
245
* Create all backup partitions everywhere!
246
<pre> vos backupsys </pre>
247
* Automate backup of user partitions at 1:00 and the temp partition at 0:01
248
<pre>bos create afsdb1 backupusers cron -cmd "/usr/bin/vos backupsys -prefix user -localauth" "1:00"
249
bos create afsdb1 backuptemp cron -cmd "/usr/bin/vos backupsys -prefix temp -localauth" "0:01"
250
</pre>
251
* now go create Oldfiles in the appropriate places
252
<pre>cd /afs/dev.ru.is/user/f/fo/foley
253
fs mkmount Oldfiles user.foley.backup
254
</pre>
255
256
h3. Adding More disks
257
258
http://docs.openafs.org/AdminGuide/ch03s08.html
259
260
# Get administrator tickets and tokens/var/lib/openafs/local
261
<pre> kinit <something>/afsadm; aklog
262
</pre>
263
# format and partition them with ext4 and give them a useful name for later.  For example
264
## figure out the next /vicep?? name, in this case it is /vicepb
265
<pre>fdisk /dev/sdb1
266
mkfs.ext4 -L grylavicepb /dev/sdb1</pre>
267
# Add the appropriate entry to /etc/fstab
268
<pre>echo "/dev/sdb1 /vicepb ext4 defaults 0 2" >> /etc/fstab</pre>
269
# See if it gets mounted properly
270
<pre>sudo mount -a </pre>
271
# Kick the fs service to get it to rescan and notice the disk
272
<pre>bos restart <machine name>  fs</pre>
273
# it should now show up  on the list of partitions
274
<pre>vos listpart afsdb1</pre>
275
# now you can make new volumes
276
277
h3. Multihomed servers
278
279
It can be a problem if one of the network interfaces is on a private network (like gryla).  You can restrict which network interfaces the server interfaces by putting NetInfo and NetRestrict files in @/var/lib/openafs/local@
280
281
More info at http://docs.openafs.org/AdminGuide/ch03s09.html
282
283
h3. Installing another server
284
285
These instructions were from examining the afs-newcell script by Sam Hartmans. Make sure you are logged in as root.
286
*Also, make sure that you do not have the hostname as 127.0.0.1 in /etc/hosts!*
287
# Stop the client
288
<pre>service openafs-client stop</pre>
289
# Stop the server
290
<pre>service openafs-fileserver stop</pre>
291
# Copy the afs.keytab from a running server
292
<pre>scp root@gryla.dev.ru.is:/etc/openafs/server/afs.keytab /etc/openafs/server/afs.keytab</pre>
293
# Install the key
294
<pre>asetkey add 3 /etc/openafs/server/afs.keytab afs/dev.ru.is</pre>
295
# Edit the CellServDB in @/etc/openafs/server/CellServDB@ and append it to the end of @/etc/openafs/CelServDB@ if it isn't already in there.
296
# Secure, but possibly database corrupting:
297
## STart up the server
298
<pre> service openafs-fileserver start </pre>
299
## Add the admin user through bos
300
<pre>bos adduser afscell1 root.admin -localauth</pre>
301
## Create initial protection database by hand.  Bit of a hack
302
<pre>pt_util -p /var/lib/openafs/db/prdb.DB0 -w</pre>
303
### start typing in these commands exactly.  Note the space before the last line!
304
<pre>root.admin 128/20 1 -204 -204
305
system:administrators 130/20 -204 -204 -204
306
 root.admin 1</pre>
307
## start up the ptserver and vlserver
308
<pre>bos create afscell1 ptserver simple /usr/lib/openafs/ptserver -localauth
309
bos create afscell1 vlserver simple /usr/lib/openafs/vlserver -localauth
310
</pre>
311
# Less secure, but more traditional
312
## Shutdown the server
313
<pre> service openafs-fileserver stop </pre>
314
## Startup in noauth mode
315
<pre>/usr/sbin/bosserver -noauth</pre>
316
## Add the admin user through bos
317
<pre>bos adduser localhost root.admin -noauth</pre>
318
## Protection database and vlserver
319
<pre>bos create localhost ptserver simple /usr/lib/openafs/ptserver -noauth
320
bos create localhost vlserver simple /usr/lib/openafs/vlserver -noauth
321
</pre>
322
## Make sure that systems:administrators has root.admin in it
323
<pre>pts membership system:administrators -noauth</pre>
324
## Kill the unauthenticated bosserver
325
<pre>pkill bosserver</pre>
326
## Start the bos server
327
<pre> service openafs-fileserver start </pre>
328
# start up the fileserver
329
<pre>bos create localhost fs fs -cmd /usr/lib/openafs/fileserver -cmd /usr/lib/openafs/volserver -cmd /usr/lib/openafs/salvager -localauth</pre>
330
# setup the backup server
331
<pre>sudo bos create localhost buserver simple "/usr/lib/openafs/buserver" -localauth</pre>
332
# setup the update clients to make /etc/openafs sync correctly every 2 hours
333
<pre>sudo bos create -server localhost -instance upclientetc -type simple -cmd "/usr/lib/openafs/upclient afsdb1.dev.ru.is -crypt -t 120 /etc/openafs"</pre>
334
# Wait for a while (30 sec) for the ubik to sync up
335
# Start up the client
336
<pre>service openafs-client start</pre>
337
# Check to make sure the servers are still running
338
<pre>bos status localhost</pre>
339
# You are ready to make volumes in the partition and mount them!
340
341
h3. Replication
342
343
It is a good idea to replicate files that are changed infrequently, particularly the root.afs and other bottom level directories.  Remember that you will need to only change things in the read-write /afs/.dev.ru.is then do a <pre>vos release <id></pre>.
344
foley has created a script example in @/afs/dev.ru.is/project/devnet/Scripts/afs-replicate-vols.sh@
345
346
# Create the replications on the various servers
347
<pre>vos addsite afsdb2.dev.ru.is a root.afs
348
vos addsite samvinna.dev.ru.is a root.afs
349
</pre>
350
# Now setup a bos job to release them on a regular schedule http://docs.openafs.org/AdminGuide/ch04s05.html
351
<pre>
352
bos create afsdb1.dev.ru.is releaserootafs cron "/usr/bin/vos release root.afs -local" 0:00
353
bos create afsdb1.dev.ru.is releaserootcell cron "/usr/bin/vos release root.cell -local" 0:00
354
</pre>
355
356
h2.  Shared keys and multiple Kerberos realms
357
358
h3.  Shared keys
359
360
Log into the servers and create matching krbtgt principals with matching KVNO.  (Make sure the kvno matches or it will not work.)
361
Copies of the magic passwords are on the servers at @/etc/krb5kdc/sharedpw.txt@
362
363
Commands for crossrealm between CS.RU.IS and DEV.RU.IS
364
<pre>kadmin.local  -e "des3-hmac-sha1:normal des-cbc-crc:v4"
365
addprinc -requires_preauth krbtgt/DEV.RU.IS@CS.RU.IS
366
addprinc -requires_preauth krbtgt/CS.RU.IS@DEV.RU.IS
367
</pre>
368
369
You will then need to modify the @/etc/krb5.conf@ files on the clients.  (or setup DNS)
370
<pre>[capath]
371
DEV.RU.IS = {
372
          CS.RU.IS = .
373
}
374
CS.RU.IS = {
375
         DEV.RU.IS = .
376
}</pre>
377
378
To test it, get keys in one realm and see if you can kvno in the other
379
<pre>kinit foley@CS.RU.IS
380
kvno foley@DEV.RU.IS</pre>
381
382
Once it is properly working, you can get service keys (such as AFS) in the other realm.
383
<pre>kinit foley@CS.RU.IS
384
aklog dev.ru.is
385
 klist
386
Ticket cache: FILE:/tmp/krb5cc_7812_A14864
387
Default principal: foley@CS.RU.IS
388
389
Valid starting    Expires           Service principal
390
17/04/2013 02:09  18/04/2013 02:09  krbtgt/CS.RU.IS@CS.RU.IS
391
17/04/2013 02:09  18/04/2013 02:09  krbtgt/DEV.RU.IS@CS.RU.IS
392
17/04/2013 02:09  18/04/2013 02:09  afs/dev.ru.is@DEV.RU.IS
393
</pre>
394
395
396
h3. Multiple realms
397
398
# put a space separated list of the valid kerberos realms to map into @/etc/openafs/server/krb.conf@ then restart.
399
** If you're feeling lazy, login to the DB servers and run:
400
<pre>cp /afs/dev.ru.is/project/devnet/SVN/Machines/AFSDB1/etc/openafs/server/krb.conf /etc/openafs/server/.
401
bos restart localhost -localauth -all
402
</pre>
403
# then add the afs service keys into the KeyList
404
405
406
h1. CentOs setup
407
408
* https://www.sit.auckland.ac.nz/Installing_OpenAFS_on_Red_Hat_distributions_including_Fedora
409
410
h2. AFS Client
411
412
# add this to /usr/vice/etc/CellServDB
413
<pre>>ru.is          #Reykjavik University
414
130.208.209.47  #njord.dev.ru.is
415
</pre>
416
417
h2. AFS Server 
418
419
# sudo yum install -y openafs-server
420
# edit /usr/afs/etc/CellServDB
421
<pre>ru.is #Reykjavik University
422
njord.dev.ru.is   130.208.209.47
423
</pre>
424
425
h1. Active Directory
426
427
Go here for the [[ActiveDirectory KDC]] setup
428
429
h1. Status
430
431
* Machines number 1, 3 and 5 on the stack above the catalyst (counted from the top) have ubuntu 10.04 installed and sshd running.
432
* root password: 100feet
433
* Number 2 and 4 are broken. 2 does not boot and 4 has errors in RAM and does not detect a disk.
434
* Network is set up and Ubuntu installed.
435
** gryla (130.208.209.37)  kerberos server, kadmin server, AFSDB server (dev.ru.is), AFSCELL server (dev.ru.is a and b)
436
** stekkjastaur (130.208.209.39)
437
** giljagaur (130.208.209.40).
438
* No proper DNS for now, so they are in Joe's dev.objid.net domain (e.g., gryla.dev.objid.net).
439
440
h1. Frequently Asked Questions
441
442
h2. I set it up, but the bos commands aren't working and the filserver isn't starting.  The FileLog says something about "Couldn't get CPS for AnyUser"
443
444
Chances are good that your keys aren't properly setup.  https://lists.openafs.org/pipermail/openafs-info/2001-December/002736.html
445
Make sure that the kvno is correct for all of the AFS keys installed on all of the servers.