SystemImager Recipe


The list of ingredients follows. See Figure 5-2 for a list of software used on the Golden Client, SystemImager server, and clone(s).

image from book
Figure 5-2: Software used on SystemImager server, Golden Client, and clone(s)

  • Computer that will become the Golden Client (with SSH client software and rsync)

  • Computer that will become the SystemImager server (with SSH server software and rsync)

  • Computer that will become a clone of the Golden Client (with a network connection to the SystemImager server and a floppy disk drive)

Install the SystemImager Server Software on the SystemImager Server

The machine you select to be the SystemImager server should have enough disk space to hold several system images. After you decide which machine to use, you can install the software using the installation program available on the download page of the SystemImager website, http://www.systemimager.org, or you can install the software using the CD-ROM included with this book. Before we can install the software, however, we need to install a few Perl modules that SystemImager depends upon for normal operation: AppConfig, MLDBM, and XML-Simple. The source code for these three Perl modules is included on the CD-ROM in tar.gz format in the chapter5/perl-modules directory. Copy them to a directory on the hard drive (/usr/local/src/ systemimager/perlmodules in the following example), and compile and install them with the commands perl Makefile.PL, make, make test, and make install.

When you have finished installing these Perl modules, you're ready to install the SystemImager server package. If you are using an RPM-based distribution such as Red Hat, you can use the RPM files included with this book. Mount the CD-ROM, switch to the chapter5 directory, and then type:

 #rpm -ivh *rpm 

Note 

Only the RPM files for i386 hardware are included on the CD-ROM. For other types of hardware, see the SystemImager website.

The RPM command may complain about failed dependencies. If the only dependencies it complains about are the Perl modules we just installed (AppConfig, which is sometimes called libappconfig, MLDBM, and XML-Simple), you can force the RPM command to ignore these dependencies and install the RPM files with the command:

 #rpm -ivh --nodeps *rpm 

Using the Installer Program From SystemImager

If you just installed the software using the CD-ROM included with this book, you can skip this section.

The list of software installed by the SystemImager install program is currently located (and downloaded each time the script runs) at http://sisuite.org/tags/stable.txt. It contains URLs to locate the common software (common to both the SystemImager client and the SystemImager server) required on the SystemImager server, and the server software. You will also see different versions of the kernel boot architecture rpms. The install script will download only the packages you specify and any dependencies they have that are also in the list (--list). For all versions of i86 hardware, the i386 boot rpm is used. You can download all available boot architectures, but normally you will only need one (to support the architecture you are using on all cluster nodes). The commands to list the available SystemImager packages are as follows:

 #wget http://sisuite.org/install #chmod +x install #./install -list Then install the packages you need using a command like this: #./install -verbose systemimager-common systemimager-server systemimager- i386boot-standard 

Note 

The installer program runs the rpm command to install the packages it downloads.

Install the SystemImager Client Software on the Golden Client

Also included on the CD-ROM with this book is the SystemImager client software. This software is located in the chapter5/client directory.

Note 

As with all of the software in this book, you can download the latest version of the SystemImager package from the Internet.

Before you can install this software, you'll need to install the Perl AppConfig module, as described in the previous step (it is located on the CD-ROM in the chapter5/perl-modules directory). Again, because the RPM program expects to find dependencies in the RPM database, and we have installed the AppConfig module from source code, you can tell the rpm program to ignore the dependency failures and install the client software with the following commands.

 #mount /mnt/cdrom #cd /mnt/cdrom/chapter5/client  #rpm -ivh --nodeps * 

You can also install the SystemImager client software using the installer program found on the SystemImager download website (http://www.systemimager.org/download).

Once you have installed the packages, you are ready to run the command:

 #/usr/sbin/prepareclient -server <servername> 

This script will launch rsync as a daemon on this machine (the Golden Client) so that the SystemImager server can gain access to its files and copy them over the network onto the SystemImager server. You can verify that this script worked properly by using the command:

 #ps -elf | grep rsync 

You should see a running rsync daemon (using the file /tmp/rsyncd.conf as a configuration file) that is waiting for requests to send files over the network.

Create a System Image of the Golden Client on the SystemImager Server

We are now ready to copy the contents of the Golden Client's disk drive(s) to the SystemImager server. The images will be stored on the SystemImager server in the /var/lib/systemimager directory. Check to make sure you have enough disk space in this directory by doing the following:

 #df -h /var/lib/systemimager 

If this is not enough space to hold a copy of the contents of the disk drive or drives on the Golden Client, use the -directory option when you use the getimage command, or change the default location for images in the /etc/systemimager/systemimager.conf file and then create a link back to it, ln -s /usr/local/systemimager /var/lib/systemimager.

Now (optionally, if you are not running the command as root) give the web user[1] permission to run the /usr/sbin/getimage command by editing the /etc/sudoers file with the visudo command and adding the following line:

 web siserver.yourdomain.com = NOPASSWD:/usr/sbin/getimage 

where siserver.yourdomain.com is the host name (see the output of the hostname command) of the SystemImager server.

We can now switch to the web user account on the SystemImager server and run the /usr/sbin/getimage command.

Logged on to the SystemImager server:

 #sudo /usr/sbin/getimage -user-ssh web -golden-client 10.1.1.2 -image backup.yourdomain.com 

In this example, the Golden Client is at IP address 10.1.1.2.

If you are logged on as root and do not need to use the SSH protocol to encrypt your network traffic, use the following command:

 #/usr/sbin/getimage -golden-client 10.1.1.2 -image backup.yourdomain.com 

Notes 
  • The -image name does not necessarily need to match the host name of the Golden Client, though this is normally how it is done.

  • You cannot get the image of a Golden Client unless it knows the IP address and host name of the image server (usually specified in the /etc/ hosts file on the Golden Client).

  • On busy networks, the getimage command may fail to complete properly due to timeout problems. If this happens, try the command a second or third time. If it still fails, you may need to run it at a time of lower network activity.

  • When the configuration changes on the backup server, you will need to run this command again, but thanks to rsync, only the disk blocks that have been modified will need to be copied over the network. (See "Performing Maintenance: Updating Clients" at the end of this chapter for more information.)

Once you answer the initial questions and the script starts running, it will spend a few moments analyzing the list of files before the copy process begins. You should then see a list of files scroll by on the screen as they are copied to the local hard drive on the SystemImager server.

When the command finishes, it will prompt you for the method you would like to use to assign IP addresses to future client systems that will be clones of the backup data server (the Golden Client). If you are not sure, select static for now.

When prompted, select y to run the addclients program (if you select n you can simply run the addclients command by itself later).

You will then be prompted for your domain name and the "base" host name you would like to use for naming future clones of the backup data server. As you clone systems, the SystemImager software automatically assigns the clones host names using the name you enter here followed by a number that will be incremented each time a new clone is made (backup1, backup2, backup3, and so forth in this example).

The script will also help you assign an IP address range to these host names so they can be added to the /etc/hosts file. When you are finished, the entries will be added to the /etc/hosts file (on the SystemImager server) and will be copied to the /var/lib/systemimager/scripts/ directory. The entries should look something like this:

 backup1.yourdomain.com backup1 backup2.yourdomain.com backup2 backup3.yourdomain.com backup3 backup4.yourdomain.com backup4 backup5.yourdomain.com backup5 backup6.yourdomain.com backup6 

and so on, depending upon how many clones you plan on adding.

Make the Primary Data Server into a DHCP Server

Normally, you will skip this section and use the static method to assign IP addresses (so that you can skip this section entirely by placing the IP address of the client on the boot floppy created in the next section). If you already use DHCP or don't want to install a DHCP server on your network, skip to the next section now.

First, we need to be sure the DHCPD and TFTPD software is loaded on the SystemImager server. On a Red Hat system, you can do this with the following commands:

 #rpm -qa | grep dhcp 

You may have the DHCP client software installed on your computer. The DHCP client software RPM package is called dhcpcd, but we need the dhcp package.

If this command does not return the version number of the currently installed DHCP software package, you will need to install it either from your distribution CD or by downloading it from the Red Hat (or Red Hat mirror) FTP site (or using the Red Hat up2date command).

Note 

As of Red Hat version 7.3, the init script to start the dhcpd server (/etc/rc.d/init.d/dhcpd) is contained in the dhcp RPM.

We are now ready to modify the DHCPD configuration file /etc/ dhcpd.conf. Fortunately, the SystemImager package includes a utility called mkdhcpserver,[2] which will ask questions and then do this automatically.

As root on the SSH server, type the command:

 #mkdhcpserver 

Once you have entered your domain name, network number, and netmask, you will be asked for the starting IP address for the DHCP range. This should be the same IP address range we just added to the /etc/hosts file.

In this example, we will not use SSH to install the clients.[3]

The IP address of the image server will also be the cluster network internal IP address of the primary data server (the same IP address as the default gateway):

 Here are the values you have chosen: ######################################################################## DNS domain name:                           yourdomain.com Network number:                            10.1.1.0 Netmask:                                   255.255.255.0 Starting IP address for your DHCP range:   10.1.1.3 Ending IP address for your DHCP range:     10.1.1.254 First DNS server: Second DNS server: Third DNS server: Default gateway:                           10.1.1.1 ImageServer:                               10.1.1.1 SSH files download URL: ####################################################################### Are you satisfied? (y/[n]): 

If all goes well, the script should ask you if you want to restart the DHCPD server. You can say no here because we will do it manually in a moment.

View the /etc/dhcpd.conf file to see the changes that this script made by typing:

 #vi /etc/dhcpd.conf 

Before we can start DHCPD for the first time, however, we need to create the leases file. This is the file that the DHCP server uses to hold a particular IP address for a MAC address for a specified lease period (as controlled by the /etc/dhcpd.conf file). Make sure this file exists by typing the command:

 #touch /var/lib/dhcp/dhcpd.leases 

Now we are ready to stop and restart the DHCP server, but as the script warns, we need to make sure it is running on the proper network interface card. Use the ifconfig -a command and determine what the eth number is for your cluster network (the 10.1.1.x network in this example).

If you have configured your primary data server as described in this chapter, you will want DHCP to run on the eth1 interface, so we need to edit the DHCPD startup script and modify the daemon line as follows.

 #vi /etc/rc.d/init.d/dhcpd 

Change the line that reads:

 daemon /usr/sbin/dhcpd 

so it looks like this:

 daemon /usr/sbin/dhcpd eth1 

Also, (optionally) you can configure the system to start DHCP automatically each time the system boots (see Chapter 1). For improved security and to avoid conflicts with any existing DHCP servers on your network, however, do not do this (just start it up manually when you need to clone a system).

Now manually start DHCPD with the command:

 #/etc/init.d/dhcpd start 

(The command service dhcpd start does the same thing on a Red Hat system.)

Make sure the server starts properly by checking the messages log with the command:

 #tail /var/log/messages 

You should see DHCP reporting the "socket" or network card and IP address it is listening on with messages that look like this:

 dhcpd: Listening on Socket/eth1/10.1.1.0 dhcpd: Sending on Socket/eth1/10.1.1.0 dhcpd: dhcpd startup succeeded 

Create a Boot Floppy for the Golden Client

We are now ready to create a floppy diskette that can be used to boot a new system and automatically copy over the entire system image to the hard drive. Create a new Linux[4] boot floppy on the primary data server by placing a blank floppy in the drive and typing the SystemImager command[5]:

 #mkautoinstalldiskette 

Note 

We will not use the SSH protocol to install the Golden Client for the remainder of this chapter. If you want to continue to use SSH to install the Golden Client (not required to complete the install), see the help page information on the mkautoinstalldiskette command.

If, after the script formats the floppy, you receive the error message stating that:

 mount: fs type msdos not supported by kernel 

you need to recompile your kernel with support for the MSDOS filesystem.[6]

Note 

The script will use the superformat utility if you have the fd-utils package installed on your computer (but this package is not necessary for the mkautoinstalldiskette script to work properly).

If you did not build a DHCP server in the previous step, you should now install a local.cfg file on your floppy.[7] The local.cfg file contains the following lines:

 # # "SystemImager" - Copyright (C) Brian Elliott Finley <brian@systemimager.org> # # This is the /local.cfg file. # HOSTNAME=backup1 DOMAINNAME=yourdomain.com DEVICE=eth0 IPADDR=10.1.1.3 NETMASK=255.255.255.0 NETWORK=10.1.1.0 BROADCAST=10.1.1.255 GATEWAY=10.1.1.1 GATEWAYDEV=eth0 IMAGESERVER=10.1.1.1 

Create this file using vi on the hard drive of the image server (the file is named /tmp/local.cfg in this example), and then copy it to the floppy drive with the commands:

 #mount /mnt/floppy #cp /tmp/local.cfg /mnt/floppy #umount /mnt/floppy 

When you boot the new system on this floppy, it will use a compact version of Linux to format your hard drive and create the partitions to match what was on the Golden Client. It will then use the local.cfg file you installed on the floppy, or if one does not exist, the DHCP protocol to find the IP address it should use. Once the IP address has been established on this new system, the install process will use the rsync program to copy the Golden Client system image to the hard drive.

Also, if you need to make changes to the disk partitions or type of disk (IDE instead of SCSI, for example), you can make changes to the script file that will be downloaded from the image server and run on the new system by modifying the script located in the scripts directory (defined in the /etc/systemimager/systemimager.conf file).[8] The default setting for this directory path is /var/lib/systemimager/scripts.[9] This directory should now contain a list of host names (that you specified when the addclients script in Step 3 of this recipe). All of these host-name files point to a single (real) file containing a script that will run on each clone machine at the start of the cloning process. So in this example, the directory listing would look like this:

 #ls -ls /var/lib/systemimager/scripts/backup* 

The output of this command looks like this:

 /var/lib/systemimager/backup1.sh -> backup.yourdomain.com.master /var/lib/systemimager/backup2.sh -> backup.yourdomain.com.master /var/lib/systemimager/backup3.sh -> backup.yourdomain.com.master /var/lib/systemimager/backup4.sh -> backup.yourdomain.com.master /var/lib/systemimager/backup5.sh -> backup.yourdomain.com.master /var/lib/systemimager/backup6.sh -> backup.yourdomain.com.master /var/lib/systemimager/backup7.sh -> backup.yourdomain.com.master /var/lib/systemimager/backup.yourdomain.com.master 

Notice how all of these files are really symbolic links to the last file on the list:

 /var/lib/systemimager/backup.yourdomain.com.master 

This file contains the script, which you can modify if you need to change anything about the basic drive configuration on the clone system. It is possible, for example, to create a Golden Client that uses a SCSI disk drive and then modify this script file (changing the sd to hd and making other modifications) and then install the clone image onto a system with an IDE hard drive. (The script file contains helpful comments for making disk partition changes.)

This kind of modification is tricky, and you need the right type of kernel configuration (the correct drivers) on the original Golden Client to make it all work, so the easiest configuration by far is to match the hardware on the Golden Client and any clones you create.

Start rsync as a Daemon on the Primary Data Server

You'll need to start rsync as a daemon on the SystemImager server and point it at the rsync configuration file created and maintained by the SystemImager programs in the /etc/systemimager directory. The SystemImager installation procedure should have created the init script /etc/init.d/systemimager-server-rsyncd. This script starts rsync as a daemon (rsync stays running in the background waiting for the cloning processes to start on a new system) when you enter the command:

 #/etc/init.d/systemimager-server-rsyncd start 

(Or service systemimager-server-rsyncd start on Red Hat systems.)

You can also start rsync manually with the command:

 #rsync --daemon --config=/etc/systemimager/rsyncd.conf 

rsync gets its configuration from the file /etc/systemimager/rsyncd.conf. This file tells the rsync daemon to report its error messages to the file /var/ log/systemimager/rsyncd. Examine this log now with the command:

 #tail -f /var/log/systemimager/rsyncd 

This should show log file entries indicating that rsync was successfully started (press CTRL-C to break out of this command).

Install the Golden Client System Image on the New Clone

Connect your new clone system to the network and boot it from the floppy disk you just created. After it boots from this floppy, it will use the local.cfg file to set its IP address information or contact the DHCP server and receive the next IP address you have configured for your clones.

This newly connected virginal clone machine will then use an rsync command such as the following to pull down the Golden Client system image:

 rsync -av -bwlimit=10000 -numeric-ids 10.1.1.1::backup.yourdomain.com/ /a/ 

This command is asking the 10.1.1.1 machine (the SystemImager server) to send all of the files it has for the backup.yourdomain.com image. How does rsync running on the SystemImager server know which files to send? It examines the /etc/systemimager/rsyncd.conf file for an entry such as the following.

 [backup.yourdomain.com]     path = /var/lib/systemimager/images/backup.yourdomain.com 

This allows the rsync program to resolve the rsync module name backup. yourdomain.com into the path /var/lib/systemimager/images/backup.yourdomain.com to find the correct list of files.

You can watch what is happening during the cloning process by running the tcpdump command on the server (see Appendix B) or with the command:

 #tail -f /var/log/systemimager/rsyncd 

To see the network queues, type:

 #netstat -tn 

When rsync is finished copying the Golden Client image to the new system's hard drive, the installation process runs System Configurator to customize the boot image (especially the network information) that is now stored on the hard drive so that the new system will boot with its own host and network identity.

When the installation completes, the system will begin beeping to indicate it is ready to have the floppy removed and the power cycled. Once you do this, you should have a newly cloned system.

image from book
WHEN THE SYSTEMIMAGER BOOT FLOPPY FAILS

If the system does not boot properly, you can use the Linux shell prompt left by the SystemImager client software to test network connectivity to the SystemImager server using the ping and telnet commands. You can also use the sample rsync command above to test the configuration before rebooting on the floppy once you have resolved the network communication issues.

If you see an error message indicating you have exceeded the size of the disk drive when the SystemImager software attempts to write the partition information to the new hard drive, you should check the output of the dmesg command on both the original machine and from the shell prompt after the system fails to install from the floppy. From the output of the dmesg command, you can determine the raw size of the disk drives connected to the original machine (the Golden Client) and the new clone. If the disk drive is smaller on the new clone, you need to modify the installation script on the image server (the installation script is copied down to the clone after the system boots from the floppy, so there is no need to rebuild the floppy). By default, scripts are stored in the /var/lib/systemimager/scripts directory (see the /etc/systemimager/systemimager.conf file for the location on your system).

image from book

Post-Installation Notes

The system cloning process modifies the Red Hat network configuration file /etc/sysconfig/network. Check to make sure this file contains the proper network settings after booting the system. (If you need to make changes, you can rerun the network script with the command service network restart, or better yet, test with a clean reboot.)

Check to make sure the host name of your newly cloned host is in its local /etc/host file (the LPRng daemon called lpd, for example, will not start if the host name is not found in the hosts file).

Configure any additional network interface cards. On Red Hat systems, the second Ethernet interface card is configured using the file /etc/sysconfig/network-scripts/ifcfg-eth1, for example.

If you are using SSH, you need to create new SSH keys for local users (see the ssh-keygen command in the previous chapter) and for the host (on Red Hat systems, this is accomplished by removing the /etc/ssh/ssh_host* files). Note, however, the simplest and easiest configuration to administer is one that uses the same SSH keys on all cluster nodes. (When a client computer connects to the cluster using SSH, they will always see the same SSH host key, regardless of which cluster node they connect to, if all cluster nodes use the same SSH configuration.)

If you started a DHCP server, you can turn it back off until the next time you need to clone a system:

 #/etc/rc.d/init.d/dhcpd stop 

Finally, you will probably want to kill the rsync daemon started by the prepareclient command on the Golden Client.

[1]Or any account of your choice. The command to create the web user was provided in Chapter 4.

[2]Older versions of SystemImager used the command makedhcpserver.

[3]If you really need to create a newly cloned system at a remote location by sending your system image over the Internet, see the SystemImager manual online at http://systemimager.org for instructions.

[4]This boot floppy will contain a version of Linux that is designed for the SystemImager project, called Brian's Own Embedded Linux or BOEL. To read more about BOEL, see the following article at LinuxDevices.com (http://www.linuxdevices.com/articles/AT9049109449.html).

[5]Older versions of SystemImager used the command makeautoinstalldiskette.

[6]In the make menuconfig screen, this option is under the Filesystems menu. Select (either as M for modular or * to compile it directly into the kernel) the DOS FAT fs support option and the MSDOS fs support option will appear. Select this option as well; then recompile the kernel (see Chapter 3).

[7]You can also do this when you execute the mkautoinstalldiskette command. See mkautoinstalldiskette -help for more information.

[8]See "How do I change the disk type(s) that my target machine(s) will use?" in the SystemImager FAQ for more information.

[9]/tftpboot/systemimager in older versions of SystemImager.



The Linux Enterprise Cluster. Build a Highly Available Cluster with Commodity Hardware and Free Software
Linux Enterprise Cluster: Build a Highly Available Cluster with Commodity Hardware and Free Software
ISBN: 1593270364
EAN: 2147483647
Year: 2003
Pages: 219
Authors: Karl Kopper

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net