13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 4 ■ TAKING BACKUPS AND MANAGING DATA16 attrs => [ 'dn', 'cn', 'automountInformation' ],17 );18 my @entries = $mesg->entries;1920 foreach my $entry ( @entries ) {21 my $cn = $entry->get_value( 'cn' );22 $mesg = $ldap->modify( $entry, replace => { 'automountInformation' =>'-fstype=nfs,rw $newhome$cn' } );23 }2425 $mesg = ldap->unbindLines 05–08 set up the names for your old and new servers and the directories; edit this asappropriate for your network. Lines 09–12 open the connection to the LDAP server (see recipe 2-9 formore details on the Net::LDAPS Perl module). Lines 14–18 search for any automount entries with the oldserver name.Lines 20–23 are the ones that do the work. For each entry, the value of the directory name isretrieved ($cn; this would be jkemp for user jkemp, for example), and then the map is modified to changehomeserver:/homedisk/jkemp to newserver:/new/home/jkemp for each entry. See recipe 2-13 for a discussion of the other options in theautomountInformation line. Line 25 tidies up the LDAP connection when you’re done.After this, log in to newserver, and check that /etc/exports has this line:/new/home*.example.com(rw)Then restart the NFS server on that machine with sudo /etc/init.d/nfs-kernel-server restart,and restart autofs on all other machines across the network (sudo /etc/init.d/autofs restart).ClusterSSH (see recipe 3-20) may be useful for this. All should be well again. You can now fix homeserverin a bit less of a rush, since everyone can carry on working while you do it!4-7. Using rsync with SSH KeysYou can use the method in the previous recipe for off-site backup, as well, if you have shell access to anoff-site machine. Simply give the machine’s full name:rsync -avuz /dir/to/backup offsite.example2.com:/shared/backupdir■ Note This is probably not something you want to do for your full-site home directory, unless you have a veryfast connection to the off-site machine. However, it may be useful for some key directories.However, at this point, it still requires an ssh password, which is no good from an automation pointof view. The final stage is to set up a password-free ssh key.108Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!