彩运网网址-彩运网网上登录

批量部署Linux操作系统systemimager 使用

说明

systemimager 可以把一个所有软件都安装完成的系统(黄金客户端)镜像到server 端, 在通过PXE 启动,再同过rsync同步到裸机上

我使用的是Ubuntu 8.10服务器,IP地址是192.168.0.100,作为SystemImager服务器,和一个Ubuntu 8.10系统(可以是一个服务器或桌面系统,取决于你想要备份什么),IP地址是192.168.0.101(这里指的是“客户端”)。此IP地址可静态指定的或通过DHCP指派,当我创建镜像时,我将使用ip切换技术,这意味着,如果客户端有一个静态IP地址,在你恢复镜像时,恢复后的系统将具有完全相同的IP地址,如果客户端通过DHCP获得IP,恢复系统将从DHCP得到其它IP,则使恢复后的IP可以是不同的。

因为systemimager大部分由perl编写,所有需要一些依赖包

在整个教程中,我假设你已经以root用户登录到这两个系统,输入:

perl-AppConfig

sudo su

perl-XML-SAX

我将使用最新的稳定版SystemImager(写本文的时候是4.0.2),它还不可以从Ubuntu 8.10的升级库中获得(在8.10升级库中的版本是3.2.3,使用这个版本时,当我尝试恢复系统时,我无法从启动介质启动)。

perl-XMLSimpel

请记住,SystemImager使用rsync,这意味着,任何人在系统恢复期间都可以访问你在服务器上的镜像,除非你在rsyncd配置中限制使用某些IP地址。因此,当你在Internet上做系统备份和恢复时,你应该小心一点(或通过隧道SSH使用rsync,但这是不属于本教程的范畴了),但对本地网络这应该能够很好工作。

主程序 ----服务器端

在镜像服务器上安装SystemImager

systemconfigurator

服务端:

systemimager-common

在镜像服务器上,您可以如下安装SystemImager:

systemimager-server

apt-get install syslinux libappconfig-perl mkisofs binutilswget http://heanet.dl.sourceforge.net/sourceforge/systemimager/systemimager-boot-i386-standard_4.0.2_all.debwget http://heanet.dl.sourceforge.net/sourceforge/systemimager/systemimager-common_4.0.2_all.debwget http://heanet.dl.sourceforge.net/sourceforge/systemimager/systemimager-initrd-template-i386_4.0.2_all.debwget http://heanet.dl.sourceforge.net/sourceforge/systemimager/systemimager-server_4.0.2_all.debwget http://heanet.dl.sourceforge.net/sourceforge/systemconfig/systemconfigurator_2.2.11-1_all.debdpkg -i systemimager-* systemconfigurator_2.2.11-1_all.deb

systemimager-x84-64boot-standard

在黄金客户端上安装SystemImager

systemimager-x84-64initrd_template

客户端:

所有程序均可以在www.rpmfind.net中找到

在黄金客户端上,您可以如下安装SystemImager:

服务器端安装完成后会有以下命令

apt-get install libappconfig-perlwget http://heanet.dl.sourceforge.net/sourceforge/systemimager/systemimager-client_4.0.2_all.debwget http://heanet.dl.sourceforge.net/sourceforge/systemimager/systemimager-common_4.0.2_all.debwget http://heanet.dl.sourceforge.net/sourceforge/systemimager/systemimager-initrd-template-i386_4.0.2_all.debwget http://heanet.dl.sourceforge.net/sourceforge/systemconfig/systemconfigurator_2.2.11-1_all.debdpkg -i systemimager-* systemconfigurator_2.2.11-1_all.deb

[root@localhost ~]# si_
si_addclients           si_mkautoinstalldisk    si_mkdhcpstatic         si_pcp
si_clusterconfig        si_mkautoinstallscript  si_mkrsyncd_conf        si_psh
si_cpimage              si_mkbootpackage        si_monitor              si_pushinstall
si_getimage             si_mkbootserver         si_monitortk            si_pushoverrides
si_lsimage              si_mkclientnetboot      si_mvimage              si_pushupdate
si_mkautoinstallcd      si_mkdhcpserver         si_netbootmond          si_rmimage
这说明服务器端已经安装完成了

在您创建了一个镜像前,您应该检查的/etc/fstab使用预设值取代所有relatime事件。如果你不这样做,恢复进程将有可能失败,因为启动镜像内核不知道relatime选项。

下一步来安装黄金客户端,

vi /etc/fstab

彩运网网址,需要的安装程序为

我原来的fstab看起来像这样:

systemconfigurator

# /etc/fstab: static file system information.

systemimager-common

#

systemimager-client

#

systemimager-x84-64initrd_template

proc /proc proc defaults 0 0

安装完成后命令

# /dev/sda1

[root@mysql1 ~]# si_
si_lsimage        si_prepareclient       si_updateclient

UUID=70d7109c-82d3-4bfa-8faa-554b1aae8935 / ext3 relatime,errors=remount-ro 0 1

黄金客户端已经安装完成,在客户端上启动同步服务

# /dev/sda5

[root@localhost ~]# si_prepareclient --server 192.168.1.1

UUID=6d6205a6-c5dc-4790-a3c0-9823879c3484 none swap sw 0 0

Welcome to the SystemImager si_prepareclient command.  This command may modify
the following files to prepare your golden client for having it's 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-4.1.6 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/fileO0rkKZ: 
   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 "si_prepareclient --help" for command line options. 
  
Continue? (y/[n]): y  #输入“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 si_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  #再次输入"y"。
 
 
-rw-r--r-- 1 root root 1855956 Apr 10 21:31 /etc/systemimager/boot/kernel
  
Starting or re-starting rsync as a daemon..... 
done! 
  
This client is ready to have its image retrieved.  You must now run  
the "si_getimage" command on your imageserver. 
  
Your client has been successfully prepared.  Boot kernel (copied from
this Linux distribution) and an initrd.img (generated by the 
initrd_template package) can be found in /etc/systemimager/boot. 
  
Automatically create configuration file for systemconfigurator: 
  >> /etc/systemconfig/systemconfig.conf
客户端服务启动完成
服务器端抓取客户端系统镜像

/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0

基本的语法是:“si_getimage -golden-client [client_hostname] -image [image_name]”
[root@localhost ~]#si_getimage --golden-client 192.168.1.2 -image vfast_backup  
--post-install reboot  --directory /systemimager/

正如你在第6行看到有一个relatime。因此,我修改如下:

This program will get the "vfast_backup" system image from "192.168.1.2" 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 "si_getimage --help" for command line options.     Continue? ([y]/n):y  #输入"y"继续黄金客户端开始复制文件到镜像服务器,如下所示:
usr/share/zoneinfo/right/Navajo => usr/share/zoneinfo/right/US/Mountain  usr/share/zoneinfo/right/America/Denver => usr/share/zoneinfo/right/US/Mountain  usr/share/zoneinfo/right/America/Shiprock => usr/share/zoneinfo/right/US/Mountain  usr/share/zoneinfo/right/America/Los_Angeles => usr/share/zoneinfo/right/US/Pacific  usr/share/zoneinfo/right/Pacific/Pago_Pago => usr/share/zoneinfo/right/US/Samoa  usr/share/zoneinfo/right/Pacific/Samoa => usr/share/zoneinfo/right/US/Samoa     sent 3524467 bytes  received 3232535951 bytes  1941830.43 bytes/sec  total size is 3411616325  speedup is 1.05  ------------- vfast_backup IMAGE RETRIEVAL FINISHED -------------     Press <Enter> to continue... 复制完成后,提示按“Enter”键继续,键入“Enter”后,需要让我们选择为克隆客户端选择获取IP地址的方式。有以下三种方式供大家选择:
l DHCP:服务器安装完成后会使用DHCP获得IP,非静态
l STATIC:安装过程中使用的IP会成为安装客户端的静态IP
l REPLICANT:安装后不会配置网络,作为备份或者快速恢复单机的机制
 根据实际情况选择,这里我选择使用DHCP,直接回车即可。
There are three 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 si_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]:    #直接回车You have chosen method 1 for assigning IP addresses. 接下来,让我们确认配置以及马上配置si_clusterconfig命令,直接回车即可。到此,整个黄金客户端镜像制作完成。可以到存储镜像的目录查看创建好的镜像。
Are you satisfied? ([y]/n):   Would you like to run the "si_clusterconfig" utility now? (y/[n]): y

# /etc/fstab: static file system information.

彩运网网址 1

#

#

proc /proc proc defaults 0 0

# /dev/sda1

UUID=70d7109c-82d3-4bfa-8faa-554b1aae8935 / ext3 defaults,errors=remount-ro 0 1

# /dev/sda5

UUID=6d6205a6-c5dc-4790-a3c0-9823879c3484 none swap sw 0 0

/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0

在镜像创建完毕后,您可以将其更回原样,但无论什么时候在镜像服务器更新镜像时,你必须再次替换relatime。

在镜像服务器上创建一个黄金客户端的镜像

客户端:

为了将黄金客户端的镜像推送到镜像服务器,你应该关闭黄金客户端的所有防火墙,或至少允许连接到tcp 873端口(rsync使用)。现在,在黄金客户端,运行下面的命令:

si_prepareclient --server 192.168.0.100

服务端:

在镜像服务器上,运行:

si_getimage -golden-client 192.168.0.101 -image my_golden_client -ip-assignment replicant

本文由彩运网网址发布于网络安全,转载请注明出处:批量部署Linux操作系统systemimager 使用

相关阅读