Chinaunix首页 | 论坛 | 博客
  • 博客访问: 98876
  • 博文数量: 18
  • 博客积分: 2264
  • 博客等级: 大尉
  • 技术积分: 270
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-13 21:46
文章分类

全部博文(18)

文章存档

2010年(1)

2009年(1)

2008年(16)

我的朋友

分类: LINUX

2008-12-12 21:01:27

用SystemImager克隆系统(一)

实验目的:学习使用SystemImager克隆系统。

实验环境:
SystemImager服务器:CentOS5.1,IP:192.168.1.63,硬盘够大
SystemImager客户端:VM下的CentOS5.2,IP:192.168.1.67,本节点将被转化成Golden Client,即生成的映像。

软件要求:ssh,rsync
在这个网站里下载Systemimager相应的rpm包。这里都是比较新的,我用的软件是“linux企业集群”那本书的光盘里的,版本不是最新的。


实验说明:Systemimager是一个自动分发Linux安装、软件分发和产品部署的软件。SystemImager可以将集群节点之一转化为Golden Client,即成为用来构建其他所有集群节点的主映像。对于部署大量集群系统来说,Systemimager是一个很实用的软件。

实验步骤:

一,给SystemImager服务器端安装SystemImager软件

1,首先安装perl模块

# ls
AppConfig-1.55.tar.gz  MLDBM-2.01.tar.gz  XML-Simple-2.09.tar.gz
# pwd
/usr/local/src/systemimager/permodules
# tar xzvf AppConfig-1.55.tar.gz
# tar xzvf MLDBM-2.01.tar.gz
# tar xzvf XML-Simple-2.09.tar.gz
# ls
AppConfig-1.55         MLDBM-2.01         XML-Simple-2.09
AppConfig-1.55.tar.gz  MLDBM-2.01.tar.gz  XML-Simple-2.09.tar.gz
# cd AppConfig-1.55
# ls
Changes  lib  Makefile.PL  MANIFEST  README  t  TODO
用以下三个命令安装perl模块
# perl Makefile.PL
# make
# make install
另外两个模块也如是安装。

2,安装完perl模块后进行安装SystemImager服务器

# ls
systemconfigurator-2.0.9-1.noarch.rpm
systemimager-common-3.2.3-1.noarch.rpm
systemimager-i386boot-standard-3.2.3-1.noarch.rpm
systemimager-server-3.2.3-1.noarch.rpm
systeminstaller-1.04-1.noarch.rpm
# rpm -ivh *.rpm
error: Failed dependencies:
    perl-AppConfig is needed by systemconfigurator-2.0.9-1.noarch
    perl-AppConfig is needed by systemimager-server-3.2.3-1.noarch
    perl-XML-Simple is needed by systemimager-server-3.2.3-1.noarch
    libappconfig-perl is needed by systeminstaller-1.04-1.noarch
    perl-MLDBM is needed by systeminstaller-1.04-1.noarch
此处提示依赖性,是我们已经安装好的模块,所以忽略这些依赖性,用以下命令安装。
# rpm -ivh --nodeps *.rpm
Preparing...                ########################################### [100%]
   1:systeminstaller        ########################################### [ 20%]
   2:systemconfigurator     ########################################### [ 40%]
   3:systemimager-common    ########################################### [ 60%]
   4:systemimager-i386boot-s########################################### [ 80%]
   5:systemimager-server    ########################################### [100%]
停止 xinetd:[确定]
启动 xinetd:[确定]

二 ,在客户端安装Systemimager软件,用来生成映像。

# ls
systemconfigurator-2.0.9-1.noarch.rpm   systemimager-common-3.2.3-1.noarch.rpm
systemimager-client-3.2.3-1.noarch.rpm
# rpm -ivh --nodeps *.rpm
Preparing...                ########################################### [100%]
   1:systemimager-common    ########################################### [ 33%]
   2:systemconfigurator     ########################################### [ 67%]
   3:systemimager-client    ########################################### [100%]

安装完后启动程序,该脚本启动rsync作为守护进程,此处的server即为我的SystemImager服务器。
# /usr/sbin/prepareclient --server 192.168.1.63

Welcome to the SystemImager prepareclient command.  This command may modify the
following files to prepare your golden client for having its image retrieved by
the imageserver.  It will also create the /etc/systemimager directory and fill
it with information about your golden client.  All modified files will be
backed up with the .before_systemimager-3.2.3 extension.

 /etc/services:
   This file defines the port numbers used by certain software on your system.
   Entries for rsync will be added if necessary.

 /tmp/rsyncd.conf.17017:
   This is a temporary configuration file that rsync needs on your golden client
   in order to make your filesystem available to your SystemImager server.

 inetd configuration:
   SystemImager needs to run rsync as a standalone daemon on your golden client
   until it's image is retrieved by your SystemImager server.  If rsyncd is
   configured to run as a service started by inetd, it will be temporarily
   disabled, and any running rsync daemons or commands will be stopped.  Then,
   an rsync daemon will be started using the temporary configuration file
   mentioned above.
   
See "prepareclient --help" for command line options.

Continue? (y/[n]): y

*********************************** WARNING ***********************************
This utility starts an rsync daemon that makes all of your files accessible
by anyone who can connect to the rsync port of this machine.  This is the
case until you reboot, or kill the 'rsync --daemon' process by hand.  By
default, once you use getimage to retrieve this image on your imageserver,
these contents will become accessible to anyone who can connect to the rsync
port on your imageserver.  See rsyncd.conf(5) for details on restricting
access to these files on the imageserver.  See the systemimager-ssh package
for a more secure method of making images available to clients.
*********************************** WARNING ***********************************

Continue? (y/[n]): y

One or more rsync daemons appear to be running on this machine.  If you
continue, those daemons will be killed.

***********************************************************
这里有个restart是因为我之前将它启动了,如果没有启动的话此处就没有。
***********************************************************
Continue? (y/[n]): y
Signaling xinetd to restart...

Using "sfdisk" to gather information about disk:
    /dev/sda

Starting or re-starting rsync as a daemon.....
done!

This client is ready to have its image retrieved.  You must now run
the "getimage" command on your imageserver.
# ps -e |grep rsync
18064 ?        00:00:00 rsync
#
通过查看rsync进程可以判断上面的脚本是否有执行。

三,在SystemImager服务器上创建映像

服务器的存储空间要充足。
用getimage命令时可以使用-directory选项来自定义存储映像的路径。
默认是保存在/var/lib/systemimager/下。

# /usr/sbin/getimage -golden-client 192.168.1.67 -image backup.192.168.1.67

This program will get the "backup.192.168.1.67" system image from "192.168.1.67"
making the assumption that all filesystems considered part
of the system image are using ext2, ext3, jfs, FAT, reiserfs, or xfs.

This program will not get /proc, NFS, or other filesystems
not mentioned above.

*********************************** WARNING ***********************************
All files retrieved from a golden client are, by default, made accessible to
anyone who can connect to the rsync port of this machine.  See rsyncd.conf(5)
for details on restricting access to these files on the imageserver.  See the
systemimager-ssh package for a more secure (but less effecient) method of
making images available to clients.
*********************************** WARNING ***********************************

See "getimage -help" for command line options.

Continue? ([y]/n): y


*******************************************************************
先分析文件列表,然后复制文件,可以在屏幕上看到文件滚动的情形。
大约十分钟吧,这个看网速了,我用的两台机器是局域网,客户端是建
立在虚拟机上的,因为要做克隆的话要保证硬件是相同的,而我手头又
没有想同配置的机器,所以用虚拟机来做这个实验。
*******************************************************************

sent 1566569 bytes  received 1278711156 bytes  1247226.23 bytes/sec
total size is 1459212499  speedup is 1.14
------------- backup.192.168.1.67 IMAGE RETRIEVAL FINISHED -------------

Press to continue...

IP Address Assignment
---------------------

There are four ways to assign IP addresses to the client systems on an
ongoing basis:

1) DHCP
   ----------------------------------------------------------------
   A DHCP server will assign IP addresses to clients installed with
   this image.  They may be assigned a different address each time.
   If you want to use DHCP, but must ensure that your clients
   receive the same IP address each time, see "man mkdhcpstatic".

2) STATIC
   ----------------------------------------------------------------
   The IP address the client uses during autoinstall will be
   permanently assigned to that client.

3) REPLICANT
   ----------------------------------------------------------------
   Don't mess with the network settings in this image.  I'm using
   it as a backup and quick restore mechanism for a single machine.

Which method do you prefer? [1]: 1
You have chosen method 1 for assigning IP addresses.

Are you satisfied? ([y]/n): y
XMLin() requires either XML::SAX or XML::Parser at /usr/lib/systemimager/perl/SystemImager/Server.pm line 1133

查看一下服务器中的映像
# pwd
/var/lib/systemimager/images
# ls backup.192.168.1.67
bin   dev  home  lost+found  misc  net  proc  sbin     srv  tmp  var
boot  etc  lib   media       mnt   opt  root  selinux  sys  usr
# du -sh backup.192.168.1.67/
1.4G    backup.192.168.1.67/

至此克隆的第一步已经完成,在上面的几个步骤中首先是配置服务器,其次是配置客户端。
最后进行了镜像制做。

接下来就可以用镜像进行真正的克隆了,今天写到这里,有时间再做接下来的事儿。









 
阅读(1967) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~