- 論壇徽章:
- 0
|
Systemimager+PXE快速安裝多臺(tái)機(jī)器
腸子(changzi100)
mailto:changzi100@yahoo.com.cn
實(shí)驗(yàn)環(huán)境:
server:CentOS5.1(192.168.1.63)用來(lái)作鏡像服務(wù)器。
client:虛擬機(jī)N臺(tái),將其中一臺(tái)作為golden-client,用si_getimage抽取鏡像。
以上golden-client端的準(zhǔn)備以及抽取鏡像操作省掉了,在筆者另外兩個(gè)實(shí)驗(yàn)中有介紹,具體步驟可以參見(jiàn)下面兩個(gè)鏈接。
用SystemImager克隆系統(tǒng)(一)
用SystemImager克隆系統(tǒng)(二)
注意:(在SystemImager(3.4以上)中,所有的命令都要加
上"si_",所以getimage將要寫(xiě)成si_getimage,
prepareclient要寫(xiě)成si_prepareclient,mkautoinstalldiskette寫(xiě)成
si_mkautoinstalldiskette等.)
軟件要求:systemimager軟件
下載
注意:systemimager是用perl編寫(xiě)的,所以要求一些perl模塊。如AppConfig,MLDBM,XML-Simple,可以自己下載安裝。
實(shí)驗(yàn)步驟:
前提是已經(jīng)做完鏡像
一,si_mkbootserver制作啟動(dòng)服務(wù)器
# 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... 3262.
Looking for update-inetd... not found.
Backing up /etc/xinetd.d/tftp...
Moving /etc/xinetd.d/tftp to /etc/xinetd.d/tftp.si_mkbootserver.bak1...done.
Restaring xinetd ...
停止 xinetd: [確定]
啟動(dòng) 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]?
Backing up /var/lib/tftpboot/pxelinux.cfg...
Moving /var/lib/tftpboot/pxelinux.cfg to /var/lib/tftpboot/pxelinux.cfg.si_mkbootserver.bak24...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
Trying to probe your DNS domain. Please wait...
Type your response or hit to accept [defaults]. If you don't
have a response, such as no first or second DNS server, just hit
and none will be used.
What is your DHCP daemon major version number (2 or 3)? [3]:
What is the name of your DHCP daemon config file? [/etc/dhcpd.conf]:
What is your domain name? []: changzi.centos
What is your network number? [192.168.1.0]:
What is your netmask? [255.255.255.0]:
What is the starting IP address for your dhcp range? [192.168.1.1]: 192.168.1.50
What is the ending IP address for your dhcp range? [192.168.1.254]: 192.168.1.80
What is the IP address of your first DNS server? []:
What is the IP address of your default gateway? [192.168.1.254]: 192.168.1.1
What is the IP address of your image server? [192.168.1.254]: 192.168.1.63
What is the IP address of your boot server? [192.168.1.254]: 192.168.1.63
What is the IP address of your log server? []:
Use tmpfs staging on client? (If unsure, choose "n") [n]:
Do you want to use Flamethrower (multicast) to install your clients? [n]:
What... is the air-speed velocity of an unladen swallow? []:
Wrong!!! (with a Monty Python(TM) accent...)
Press 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: changzi.centos
Network number: 192.168.1.0
Netmask: 255.255.255.0
Starting IP address for your DHCP range: 192.168.1.50
Ending IP address for your DHCP range: 192.168.1.80
First DNS server:
Second DNS server:
Third DNS server:
Default gateway: 192.168.1.1
Image server: 192.168.1.63
Boot server: 192.168.1.63
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
關(guān)閉 dhcpd: [確定]
啟動(dòng) dhcpd: [確定]
二,si_addclients加入主機(jī)名與IP對(duì)應(yīng)
# si_addclients
筆者在此將主機(jī)名設(shè)置成www50-www80
對(duì)應(yīng)的IP地址為192.168.1.50-192.168.1.80
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? []: changzi.centos
What is the hosts range that you want me to use? []: www50-www80
I will work with hostnames: www50-www80
in the domain: changzi.centos
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:
www50-www80
can be autoinstalled with one of the available images? ([y]/n): y
Here is a list of available autoinstall scripts:
backup
Which script would you like these hosts to be installed with?
[backup]:
Your soft links have been created.
Press to continue...
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: www50-www80
What is the IPs address range (e.g. 10.0.0.1-10.0.0.100,10.0.0.101)?
[]:192.168.1.50-192.168.1.80
I will work with IP addresses: 192.168.1.50-192.168.1.80
and hostnames: www50-www80
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 to continue...
si_addclients: successfully completed.
三,si_mkclientnetboot制作啟動(dòng)媒介
考慮到安裝N臺(tái)機(jī)器,如果量較大的話最好還是用PXE的方法,當(dāng)然網(wǎng)卡要支持,如果不支持的話還是用USB或是CD制作啟動(dòng)媒介。所以筆者用來(lái)進(jìn)行實(shí)驗(yàn)的是虛擬機(jī)。
# si_mkclientnetboot --netboot --clients www50-www80
[netboot] using the kernel and initrd.img for architecture: i386
[netboot] using the flavor: standard
以上在Server端已經(jīng)完成工作了。
在以上步驟中出現(xiàn)問(wèn)題可以google一下,我遇到的問(wèn)題無(wú)非是perl模塊的一些東西,總之是缺少什么軟件就下載安裝什么軟件。另外記得要把防火墻關(guān)掉。
最后一步是啟動(dòng)虛擬機(jī)。即可安裝,速度還是很快的,我安裝了兩臺(tái)虛擬機(jī)。
鏡像大。
# du -sh backup/
1.6G backup/
服務(wù)器是P4 1.7/256M,100Mbits網(wǎng)絡(luò),另一臺(tái)P4 2.8/1G裝上兩個(gè)虛擬機(jī),每個(gè)分256M內(nèi)存,同時(shí)進(jìn)行安裝,12分鐘左右。
如有問(wèn)題可以mailto:changzi100@yahoo.com.cn
本文來(lái)自ChinaUnix博客,如果查看原文請(qǐng)點(diǎn):http://blog.chinaunix.net/u1/56880/showart_1751691.html |
|