Previous Article Next Article 用systemimager網路線上備份與離線還原linux系統
Posted in Linux

用systemimager網路線上備份與離線還原linux系統

用systemimager網路線上備份與離線還原linux系統 Posted on 2011 年 03 月 31 日Leave a comment

。搭配rsync將client的系統複製到server上 (線上作不用重開機)
。使用tftp、dhcp、pxe還原系統於clinet (要重開機,進pxe)

1.) 下載套件

   a.) 官方提供下載套件的程式

   b.) 執行perl程式去下載

perl systemimager.pl -v –download-only –tag stable –directory . systemconfigurator systemimager-client systemimager-common systemimager-i386boot-standard systemimager-i386initrd_template systemimager-server systemimager-bittorrent systemimager-flamethrower 

      或者到這裡一個一個下載 (如下)
         https://sourceforge.net/project/showfiles.php?group_id=259
         https://sourceforge.net/project/showfiles.php?group_id=24006

            systemconfigurator-2.2.9-1.noarch.rpm
            systemimager-bittorrent-3.8.1-1.noarch.rpm
            systemimager-client-3.8.1-1.noarch.rpm
            systemimager-common-3.8.1-1.noarch.rpm
            systemimager-flamethrower-3.8.1-1.noarch.rpm
            systemimager-i386boot-standard-3.8.1-1.noarch.rpm
            systemimager-i386initrd_template-3.8.1-1.noarch.rpm
            systemimager-server-3.8.1-1.noarch.rpm

2.) 安裝

         Server 端

yum install perl-AppConfig perl-XML-Simple perl-XML-Parser mkisofs
rpm -ivh systemconfigurator-*
rpm -ivh systemimager-common-* systemimager-server-* systemimager-i386boot-standard-*

         Client 端 (golden client)

yum install perl-AppConfig 
rpm -ivh systemconfigurator-*
rpm -ivh systemimager-common-* systemimager-client-* systemimager-i386initrd_template-*

3.) 備份
         Client 端

            執行

si_prepareclient –server 10.1.1.111

            1。10.1.1.111是server的ip
            2。防火牆必需開放 tcp:873給server可以存取,因為是使用rsync來收集成image

            一開始它會跟你說它會作那些事情
            1。動到 /etc/services檔,如果沒有搭配rsync的名稱跟port numbser 的話(我想)
            2。產生一個臨時的檔案 /tmp/fileXXX: rsyncd的conf檔 (它只允許server的ip來存取 hosts allow = 10.1.1.111/32)
            3。刪除目前有在執行的rsync相關程序,再自已用 /tmp/fileXXX這個設定去跑rsyncd,直到server 獲得資料完後為止

            所以看到continue 就直接 y
            或

si_prepareclient –server 10.1.1.111 –yes

         Server 端

            從 client 10.1.1.113 rsync 資料 至 server 10.1.1.111 的 /var/lib/systemimager/images/ 的 my_image 目錄裡,並忽略 /media/* 
            執行

si_getimage –golden-client 10.1.1.113 –image my_image –exclude '/media/*'

         備註:
            –exclude 可以是 /directory/filename # 不 rsync 這個檔案
                            也可以是 /directory/        # 不 rsync目錄 及其目錄下的所有東西
                            也可以是 /directory/*       # 不 rsync 這個目錄下的所有東西,但仍rsync 這個目錄名稱過去

         或者           

            從 client 10.1.1.113 rsync 資料 至 server 10.1.1.111 的 /var/lib/systemimager/images/ 的 my_image 目錄裡

si_getimage –golden-client 10.1.1.113 –image my_image –post-install reboot

            systemimager 支援 ext2, ext3, jfs, FAT, reiserfs, or xfs. 格式
            不會複製 /proc, NFS, 或其它檔案系統

            如果重覆執行來取 10.1.1.113至 my_image的話,它只會更新,不會全部再copy一次

            si_getimage 完後,它會要你選擇 IP Address Assignment,這裡我選DCHP

            而 si_clusterconfig 則 n

            備註:
               –post-install reboot 用來使主機還原後自行重開機,也可用shutdown讓還原後關機
               –ip-assignment 可以是 DHCP or STATIC or REPLICANT

4.) 還原

      Server 端

         systemimager 還需要搭配 tftp server 及 dhcp server

yum install tftp-server tftp dhcp

         執行

si_mkbootserver

         開始設定 tftp, dhcp

[root@ss ~]# si_mkbootserver
WARNING: this script may modify the following files:
  –> /etc/services
  –> /etc/inetd.conf
  –> /etc/xinetd.d/tftp
And can restart inetd, xinetd or tftp servers.
Do you wish to continue (y/[n])? y
Ok, continuing…
/var/lib/tftpboot exists and is a symlink to /usr/share/systemimager/boot.
Checking for a tftp server… found.
Checking if tftp server is H. Peter Anvin's tftp server… yup – right on!
Checking for a running inetd… Not found.
Checking for a running xinetd… 1994.
Looking for update-inetd… not found.
Backing up /etc/xinetd.d/tftp…
Moving /etc/xinetd.d/tftp to /etc/xinetd.d/tftp.si_mkbootserver.bak3…done.
Restaring xinetd …
正在停止 xinetd:                                           [  確定  ]
正在啟動 xinetd:                                           [  確定  ]
done.
Looking for a tftp client… found.
Checking for loopback interface… up.
Does tftp server work… yes.
Looking for a pxe daemon… which: no pxe in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin)
not found.
WARNING: your bootserver will be configured without a pxe daemon!
         (ignore this warning if you're using a recent distro)
done.
What is the path to the pxelinux bootloader [/usr/lib/syslinux/pxelinux.0]? enter
Backing up /var/lib/tftpboot/pxelinux.cfg…
Moving /var/lib/tftpboot/pxelinux.cfg to /var/lib/tftpboot/pxelinux.cfg.si_mkbootserver.bak0…done.
Copying /var/lib/tftpboot/X86PC/UNDI/linux-install/pxelinux.cfg to /var/lib/tftpboot/pxelinux.cfg…Ok, configuration complete.
Once you're DHCP server is configured, you should be all set.
Do you want to run si_mkdhcpserver to configure your DHCP server ([y]/n)? y

Welcome to the SystemImager "si_mkdhcpserver" command.  This command will
prepare this computer to be a DHCP server by creating a dhcpd.conf file
for use with your ISC DHCP server (v2 or v3).

If there is an existing file, it will be backed up with the
.beforesystemimager extension.

Continue? (y/[n]): y

Type your response or hit <Enter> to accept [defaults].  If you don't
have a response, such as no first or second DNS server, just hit
<Enter> and none will be used.

What is your DHCP daemon major version number (2 or 3)? [3]: enter
What is the name of your DHCP daemon config file? [/etc/dhcpd.conf]:enter
What is your domain name? [ssorc.tw]:enter
What is your network number? [192.168.1.0]: 10.1.1.0
What is your netmask? [255.0.0.0]: 255.255.255.0
What is the starting IP address for your dhcp range? [10.1.1.1]: 10.1.1.101
What is the ending IP address for your dhcp range? [10.1.1.254]: 10.1.1.102
What is the IP address of your first DNS server? []: 168.95.1.1
What is the IP address of your second DNS server? []: 8.8.8.8
What is the IP address of your third DNS server? []:enter
What is the IP address of your default gateway? [10.1.1.254]: 10.1.1.111
What is the IP address of your image server? [10.1.1.254]: 10.1.1.111
What is the IP address of your boot server? [10.1.1.254]: 10.1.1.111
What is the IP address of your log server? []:enter
Use tmpfs staging on client?  (If unsure, choose "n") [n]:enter
Do you want to use Flamethrower (multicast) to install your clients? [n]:enter

What… is the air-speed velocity of an unladen swallow? []:enter

What… is the air-speed velocity of an unladen swallow? []:
Wrong!!! (with a Monty Python(TM) accent…)

Press <Enter> to continue…
Ahh, but seriously folks…
Here are the values you have chosen:

#######################################################################
ISC DHCP daemon version:                  3
ISC DHCP daemon config file:              /etc/dhcpd.conf
DNS domain name:                          ssorc.tw
Network number:                           10.1.1.0
Netmask:                                  255.255.255.0
Starting IP address for your DHCP range:  10.1.1.101
Ending IP address for your DHCP range:    10.1.1.102
First DNS server:                         168.95.1.1
Second DNS server:                        8.8.8.8
Third DNS server:
Default gateway:                          10.1.1.111
Image server:                             10.1.1.111
Boot server:                              10.1.1.111
Log server:
Log server port:
Flamethrower directory port:
Use tmpfs staging on client:              n
SSH files download URL:
#######################################################################

Are you satisfied? (y/[n]):y

The dhcp server configuration file (/etc/dhcpd.conf) file has been
created for you.  Please verify it for accuracy.

If this file does not look satisfactory, you can run this command again
to re-create it: "si_mkdhcpserver"

WARNING!:  If you have multiple physical network interfaces, be sure to
edit the init script that starts dhcpd to specify the interface that
is connected to your DHCP clients.  Here's an example:

 Change "/usr/sbin/dhcpd" to "/usr/sbin/dhcpd eth1".

Depending on your distribution, you may be able to set this with the
"INTERFACES" variable in "/etc/default/dhcp", "/etc/default/dhcp3-server",
or similar, or in your dhcpd initialization script ("/etc/init.d/dhcpd",
"/etc/init.d/dhcp3-server", or similar).

Also, be sure to start or restart your dhcpd daemon.  This can usually
be done with a command like "/etc/init.d/dhcpd restart" or similar.

Would you like me to restart your DHCP server software now? (y/[n]): y
正在啟動 dhcpd:                                            [  確定  ]

         備註: 如果出現xinetd not found,記得/etc/init.d/xinetd start

      執行

si_addclients

         設定client要還原那個 image

Welcome to the SystemImager "si_addclients" utility
——————————————————————————–

This utility has 3 sections.

"Section 1" will ask you for your hostname information.

"Section 2" will allow you to create softlinks from each client hostname to
your "master" script in the "/var/lib/systemimager/scripts" directory.

  Example: www297.sh -> web_server_image_v1.master

"Section 3" will ask you for IP address information that will be combined
with the hostname information provided in Section 1 to create entries in
"/etc/hosts" for each of these same clients.  New entries will be appended
to the end of "/etc/hosts".  If you specify new hostnames for existing IP
addresses, those entries will be re-written in place to reflect the new
host names.

Continue? ([y]/n):y

si_addclients — Section 1 (hostname information)
——————————————————————————–

The next series of questions will be used to create a range of hostnames.
You will be asked for your domain name, the base host name, a beginning
number, and an ending number.

For example, if you answer:
  domain name     = systemimager.org
  host range      = www7-www11,www20

Then the result will be a series of hostnames that looks like this:
  www7.systemimager.org
  www8.systemimager.org
  www9.systemimager.org
  www10.systemimager.org
  www11.systemimager.org
  www20.systemimager.org

What is your domain name? []: ssorc.tw
What is the hosts range that you want me to use? []: node01-node02

I will work with hostnames:  node01-node02
             in the domain:  ssorc.tw

Are you satisfied? (y/[n]):y

si_addclients — Section 2 (soft links to master script)
——————————————————————————–

Would you like me to create soft links to a "master" script so that hosts:

  node01-node02

can be autoinstalled with one of the available images? ([y]/n):y

Here is a list of available autoinstall scripts:

xxx
my_image

Which script would you like these hosts to be installed with?
[my_image]:enter

Your soft links have been created.

Press <Enter> to continue… enter

si_addclients — Section 3 (adding or modifying /etc/hosts entries)
——————————————————————————–

Your target machines need to be able to determine their host names from their
IP addresses, unless their host name is specified in a local.cfg file.

The preferred method for doing this is with DNS.  If you have a working DNS
that has IP address to hostname resolution properly configured for your
target machines, then answer "n" here.

If you don't have a working DNS, or you want to override the information in
DNS, then answer "y" here to add entries to the "/etc/hosts" file on your
image server.  After adding these entries, the /etc/hosts file will be
copied to "/var/lib/systemimager/scripts" where it can be retrieved by your
target machines.

I will ask you for your clients' IP addresses one subnet at a time.

Would you like me to continue? (y/[n]):y

si_addclients — Section 3 (adding or modifying /etc/hosts entries — continued…)
——————————————————————————–

Hostnames range is: node01-node02

What is the IPs address range (e.g. 10.0.0.1-10.0.0.100,10.0.0.101)?
[10.1.1.101-10.1.1.102]:enter
I will work with IP addresses:  10.1.1.101-10.1.1.102
                and hostnames:  node01-node02

Are you satisfied? (y/[n]): y

These entries have been added to /etc/hosts, and /etc/hosts has been copied
to /var/lib/systemimager/scripts for use by your auto-install clients.

Press <Enter> to continue… enter

si_addclients: successfully completed.

      執行

si_mkclientnetboot –netboot –clients node01-node02

      執行

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

            (記得防火牆開放 873給client)
  

      設置開機啟動

chkconfig systemimager-server-rsyncd on
chkconfig dhcpd on
chkconfig xinetd on

      Client 端
         使用pXE網路開機,就可以一路還原到完

      備註:
         遇到無法還原的情況
         因為我重新 si_getimage 至 my_image,不過我有先

si_rmiamge my_image

         刪除舊的my_image, 但仍是無法還原成功
         使用

si_mkautoinstallscript  –image my_image –force

         也不行
         我就執行如下,就ok了

si_addclients –hosts node01-node02 –ip-range 10.1.1.101-10.1.1.102 –domainname ssorc.tw –script my_image
si_mkclientnetboot –netboot –clients node01-node02

      還原後的不一樣: (明顯的)

         1。開機時核心顯示名稱為 my_image_(hd0,0)
         2。主機名稱為 node02
         3。IP為10.1.1.102
         4。其實都是在image server怎麼設定,image client就可能被還原成的樣子

ref:
http://wiki.systemimager.org/index.php/Quick_Start_HOWTO
http://www.howtoforge.com/howto_linux_systemimager
http://www.linux.com/articles/53888
http://baidu.blog.51cto.com/71938/294329
http://baidu.blog.51cto.com/71938/309457

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *