SystemImager提供了si_mkbootserver命令,利用交互的方式可以帮助我们自动的完成镜像服务器网络启动服务器的安装和配置。主要包括PxeLinux、TFTP和DHCP等服务的配置。在整个过程中会自动执行测试功能用于检查配置是否正常,如果发现错误会宣告失败并生成错误日志,根据错误提示能够方便用户快速的更正错误。
(1)执行si_mkbootserver命令后,提示我们这个脚本将要修改的配置文件以及重新启动的服务,输入“y”继续。
[root@localhost ~]# si_mkbootserver
WARNING: this script may modifythe following files:
--> /etc/services
--> /etc/inetd.conf
--> /etc/xinetd.d/tftp
Andcan restart inetd, xinetd ortftp servers.
Do you wish tocontinue(y/[n])? y
Ok, continuing...
Checking fora tftp server... found.
Checking if tftp server isH. Peter Anvin's tftp server... yup - righton!
Checking fora running inetd... Notfound.
Checking fora running xinetd... 16428.
Looking forupdate-inetd... notfound.
Backing up /etc/xinetd.d/tftp...
Moving /etc/xinetd.d/tftp to/etc/xinetd.d/tftp.si_mkbootserver.bak0...done.
Restaring xinetd ...
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
done.
Looking fora tftp client... found.
Checking forloopback interface... up.
Does tftp server work... yes.
Looking fora pxe daemon... which: nopxe in(/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin)
notfound.
(2)接下来,将要为BootServer配置Pxe,在询问“pxelinux bootloader”路径时,由于“/usr/lib/syslinux/pxelinux.0”路径是syslinux安装后的默认路径,直接回车即可。
WARNING: your bootserver will be configured without a pxe daemon!
(ignorethis warning if you're using a recent distro)
done.
What isthe path tothe pxelinux bootloader [/usr/lib/syslinux/pxelinux.0]? #直接回车
Copying /usr/lib/syslinux/pxelinux.0 to/var/lib/tftpboot/X86PC/UNDI/linux-install/linux.0 ... done.
Linking /var/lib/tftpboot/pxelinux.bin to/var/lib/tftpboot/X86PC/UNDI/linux-install/linux.0 ...done.
Copying /var/lib/tftpboot/X86PC/UNDI/linux-install/pxelinux.cfg to/var/lib/tftpboot/pxelinux.cfg...Ok, configuration complete.
(3)在询问你是否运行si_mkdhcpserver命令配置DHCP Server,这里直接输入“y”回车。si_mkdhcpserver命令能够帮助我们自动的完成对DHCP配置文件的修改,主要包含了你的域名、网段、子网掩码和将要给客户端分配的有效地址范围等信息。
Once you're DHCP server is configured, you should be all set.
Do you want torun si_mkdhcpserver toconfigure your DHCP server ([y]/n)? y 输入“y”
Welcome tothe SystemImager "si_mkdhcpserver"command. This command will
preparethis computer tobe a DHCP server bycreating a dhcpd.conf file
foruse withyour ISC DHCP server (v2 orv3).
If there isan existing file, it will be backed up withthe
.beforesystemimager extension.
Continue? (y/[n]): y
(4)程序使用了交互式的方式,询问你使用的DHCP软件包的版本、配置文件名称、输入域名、网段、子网掩码、地址池等信息,根据实际环境填写。
Trying to probe your DNS domain. Please wait...
Type your response orhit <Enter> toaccept [defaults]. If you don't
have a response, such asnofirstorsecondDNS server, just hit
<Enter> andnone will be used.
What isyour DHCP daemon major version number (2 or3)? [3]:
What isthe nameofyour DHCP daemon config file? [/etc/dhcpd.conf]:
What isyour domain name? [localdomain]:
What isyour network number? [192.168.1.0]: 172.16.0.0
What isyour netmask? [255.255.0.0]:
What isthe starting IP address foryour dhcp range? [172.16.0.1]: 172.16.0.11
What isthe ending IP address foryour dhcp range? [172.16.255.254]: 172.16.0.200
What isthe IP address ofyour firstDNS server? []:
What isthe IP address ofyour defaultgateway? [172.16.255.254]: 172.16.0.1
What isthe IP address ofyour image server? [172.16.255.254]: 172.16.0.10
What isthe IP address ofyour boot server? [172.16.255.254]: 172.16.0.10
What isthe IP address ofyour log server? []:
Use tmpfs staging onclient? (If unsure, choose "n") [n]:
Do you want touse Flamethrower (multicast) toinstall your clients? [n]:
What... isthe air-speed velocity ofan unladen swallow? []:
Wrong!!! (witha Monty Python(TM) accent...)
Press <Enter> tocontinue...
(5)下图中列出了你刚刚填写的信息,确认无误后,输入“y”完成配置。
Ahh, but seriously folks...
Here are the valuesyou have chosen:
#######################################################################
ISC DHCP daemon version: 3
ISC DHCP daemon config file: /etc/dhcpd.conf
DNS domain name: localdomain
Network number: 172.16.0.0
Netmask: 255.255.0.0
Starting IP address foryour DHCP range: 172.16.0.11
Ending IP address foryour DHCP range: 172.16.0.200
FirstDNS server:
SecondDNS server:
Third DNS server:
Defaultgateway: []
Image server: 172.16.0.10
Boot server: 172.16.0.10
Log server:
Log server port:
Flamethrower directory port:
Use tmpfs staging onclient: n
SSH files download URL:
#######################################################################
Are you satisfied? (y/[n]): y
(6)开始创建DHCP服务的配置文件,并提示使用si_mkdhcpserver命令修改该配置文件。输入“y”重新启动DHCP服务,至此,DHCP服务,pxe服务配置完成。
The dhcp server configuration file (/etc/dhcpd.conf) file has been
created foryou. Please verify it foraccuracy.
If this file does notlook satisfactory, you can run this command again
tore-createit: "si_mkdhcpserver"
WARNING!: If you have multiple physical network interfaces, be sure to
edit the init script that starts dhcpd tospecify the interface that
isconnected toyour DHCP clients. Here's an example:
Change "/usr/sbin/dhcpd"to"/usr/sbin/dhcpd eth1".
Depending onyour distribution, you may be able tosetthis withthe
"INTERFACES"variable in"/etc/default/dhcp", "/etc/default/dhcp3-server",
orsimilar, orinyour dhcpd initialization script ("/etc/init.d/dhcpd",
"/etc/init.d/dhcp3-server", orsimilar).
Also, be sure tostart orrestart your dhcpd daemon. This can usually
be done witha command like"/etc/init.d/dhcpd restart"orsimilar.
Would you likeme torestart your DHCP server software now? (y/[n]): y
Starting dhcpd: [ok]
(7)如果镜像服务器中有多个镜像的话,就要告知哪一个节点安装哪一个镜像。si_addclients为镜像的安装脚本创建符号链接。si_addclients改写镜像服务器的/etc/hosts
和/var/lib/systemimager/scripts/hosts文件。Hosts文件为自动安装客户端查阅他们的主机名提供默认的机制。
[root@localhost ~]# si_addclients
Welcome tothe SystemImager "si_addclients"utility
--------------------------------------------------------------------------------
This utility has 3 sections.
"Section 1"will ask you foryour hostname information.
"Section 2"will allow you tocreatesoftlinks fromeach client hostname to
your "master"script inthe "/var/lib/systemimager/scripts"directory.
Example: www297.sh -> web_server_image_v1.master
"Section 3"will ask you forIP address information that will be combined
withthe hostname information provided inSection1 tocreateentries in
"/etc/hosts"foreach ofthese same clients. New entries will be appended
tothe endof"/etc/hosts". If you specify new hostnames forexisting IP
addresses, those entries will be re-written inplace toreflect the new
host names.
Continue? ([y]/n): y #输入“y”,继续。
(8)在si_addclients的第一个配置部分,需要指出自动安装节点的主机名称样式。一个主机范围的字段和一个域名用来定义我们要自动安装的节点的主机名;
si_addclients -- Section 1 (hostname information)
--------------------------------------------------------------------------------
The nextseries ofquestions will be used tocreatea range ofhostnames.
You will be asked foryour domain name, the base host name, a beginning
number, andan ending number.
Forexample, if you answer:
domain name= systemimager.org
host range = www7-www11,www20
Thenthe result will be a series ofhostnames that looks likethis:
www7.systemimager.org
www8.systemimager.org
www9.systemimager.org
www10.systemimager.org
www11.systemimager.org
www20.systemimager.org
What isyour domain name? []: vfast.com
What isthe hosts range that you want me touse? []: node11-node200
I will workwithhostnames: node11-node200
inthe domain: vfast.com
Are you satisfied? (y/[n]): y
(9)在第二个配置部分,将前一部分定义的节点映射到到镜像;
si_addclients -- Section 2 (soft links to master script)
--------------------------------------------------------------------------------
Would you likeme tocreatesoft links toa "master"script so that hosts:
node11-node200
can be autoinstalled withone ofthe available images? ([y]/n): y
Here isa list ofavailable autoinstall scripts:
vfast_backup
Which script would you likethese hosts tobe installed with?
[vfast_backup]:
Your soft links have been created.
Press <Enter> tocontinue...
(10)在第三个配置部分,si_addclients命令请求IP地址范围,这个IP保存在/etc/hosts和/var/lib/systemimager/scripts/hosts文件中。当自动安装客户端启动时,它会从镜像服务器中检索后面的文件并应用它查找主机名。
si_addclients -- Section 3 (adding or modifying /etc/hosts entries)
--------------------------------------------------------------------------------
Your target machines need tobe able todetermine their host names fromtheir
IP addresses, unless their host nameisspecified ina local.cfg file.
The preferred method fordoing this iswithDNS. If you have a working DNS
that has IP address tohostname resolution properly configured foryour
target machines, thenanswer "n"here.
If you don't have a working DNS, oryou want tooverride the information in
DNS, thenanswer "y"here toaddentries tothe "/etc/hosts"file onyour
image server. Afteradding these entries, the /etc/hosts file will be
copied to"/var/lib/systemimager/scripts"whereit can be retrieved byyour
target machines.
I will ask you foryour clients' IP addresses one subnet ata time.
Would you likeme tocontinue? (y/[n]): y
si_addclients -- Section 3 (adding or modifying /etc/hosts entries -- continued...)
--------------------------------------------------------------------------------
Hostnames range is: node11-node200
What isthe IPs address range (e.g. 10.0.0.1-10.0.0.100,10.0.0.101)?
[]: 172.16.0.11-172.16.0.200
I will workwithIP addresses: 172.16.0.11-172.16.0.200
andhostnames: node11-node200
Are you satisfied? (y/[n]): y
Use ofuninitialized value inconcatenation (.) orstring at/usr/sbin/si_addclients line 552.
These entries have been added to/etc/hosts, and/etc/hosts has been copied
to/var/lib/systemimager/scripts foruse byyour auto-install clients.
Press <Enter> tocontinue...
si_addclients: successfully completed.
(11)执行si_mkclientnetboot 来制作多台要克隆机器通过网络安装的对应启动介质:
[root@localhost ~]# si_mkclientnetboot --netboot --clients node11-node200
[netboot] using the kernel andinitrd.img forarchitecture: i386
[netboot] using the flavor: standard
[root@localhost ~]#
(12)启动systemimager-server-rsyncd服务,使用rsync服务克隆系统。将以下服务设置重启自动启动。
[root@localhost ~]# /etc/init.d/systemimager-server-rsyncd start
Starting rsync daemon forsystemimager: already running.
[root@localhost ~]# chkconfig systemimager-server-rsyncd on
[root@localhost ~]# chkconfig dhcpd on
[root@localhost ~]# chkconfig xinetd on
5、克隆操作系统
最后设置客户端BIOS选择从网卡启动。具体方法因BIOS版本不同而异。
网卡中的PXE代码会联系DHCP服务器来获取IP地址以及启动镜像,然后启动镜像被载入并运行。
本文转自yjlsy 51CTO博客,原文链接:http://blog.51cto.com/baidu/309457,如需转载请自行联系原作者