SystemImager”(下)
在《自动安装Linux系统之“SystemImager”》中,我们已经完成镜像服务器和黄金客户端的安装并成功的制作了一份黄金客户端镜像。本文接下来介绍如何配置镜像服务器和要安装系统的客户端,最终完成客户端的自动安装。
SystemImager支持从PXE、CD、USB或硬盘等方法完成自动安装操作系统,这里主要介绍使用PXE方式安装。这就需要安装DHCP服务器来给客户端提供IP地址以及其它信息;安装TFTP服务器完成客户端使用TFTP协议下载引导文件并执行。
在镜像服务器上,依次执行如下命令完成DHCP和TFTP的安装:
[root@ localhost Server]# rpm -ivh dhcp-3.0.5-13.el5.i386.rpm[root@ localhost Server]# rpm -ivh tftp-server-0.42-3.1.i386.rpm
4、配置SystemImager服务
SystemImager提供了si_mkbootserver命令,利用交互的方式可以帮助我们自动的完成镜像服务器网络启动服务器的安装和配置。主要包括PxeLinux、TFTP和DHCP等服务的配置。在整个过程中会自动执行测试功能用于检查配置是否正常,如果发现错误会宣告失败并生成错误日志,根据错误提示能够方便用户快速的更正错误。
(1)执行si_mkbootserver命令后,提示我们这个脚本将要修改的配置文件以及重新启动的服务,输入“y”继续。
[root@localhost ~]# si_mkbootserverWARNING: this script may modify the following files:--> /etc/services--> /etc/inetd.conf--> /etc/xinetd.d/tftpAnd can restart inetd, xinetd or tftp servers.Do you wish to continue (y/[n])? yOk, continuing...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... 16428.Looking for update -inetd... not found.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 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.
(2)接下来,将要为BootServer配置Pxe,在询问“pxelinux bootloader”路径时,由于“/usr/lib/syslinux/pxelinux.0”路径是syslinux安装后的默认路径,直接回车即可。
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]? #直接回车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 to run si_mkdhcpserver to configure your DHCP server ([y]/n)? y 输入“y”Welcome to the SystemImager "si_mkdhcpserver" command. This command willprepare this computer to be a DHCP server by creating a dhcpd.conf filefor 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
(4)程序使用了交互式的方式,询问你使用的DHCP软件包的版本、配置文件名称、输入域名、网段、子网掩码、地址池等信息,根据实际环境填写。
Trying to probe your DNS domain. Please wait...Type your response or hit <Enter> to accept [defaults]. If you don'thave 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]:What is the name of your DHCP daemon config file? [/etc/dhcpd.conf]:What is your domain name ? [localdomain]:What is your network number? [192.168.1.0]: 172.16.0.0What is your netmask? [255.255.0.0]:What is the starting IP address for your dhcp range? [172.16.0.1]: 172.16.0.11What is the ending IP address for your dhcp range? [172.16.255.254]: 172.16.0.200What is the IP address of your first DNS server? []:What is the IP address of your default gateway? [172.16.255.254]: 172.16.0.1What is the IP address of your image server? [172.16.255.254]: 172.16.0.10What is the IP address of your boot server? [172.16.255.254]: 172.16.0.10What 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 <Enter> to continue ...
(5)下图中列出了你刚刚填写的信息,确认无误后,输入“y”完成配置。
Ahh, but seriously folks...Here are the values you have chosen:#######################################################################ISC DHCP daemon version: 3ISC DHCP daemon config file: /etc/dhcpd.confDNS domain name : localdomainNetwork number: 172.16.0.0Netmask: 255.255.0.0Starting IP address for your DHCP range: 172.16.0.11Ending IP address for your DHCP range: 172.16.0.200First DNS server:Second DNS server:Third DNS server:Default gateway: []Image server: 172.16.0.10Boot server: 172.16.0.10Log server:Log server port:Flamethrower directory port:Use tmpfs staging on client: nSSH 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 beencreated for you. Please verify it for accuracy.If this file does not look satisfactory, you can run this command againto re- create it: "si_mkdhcpserver"WARNING!: If you have multiple physical network interfaces, be sure toedit the init script that starts dhcpd to specify the interface thatis 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 usuallybe 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]): yStarting dhcpd: [ok]
(7)如果镜像服务器中有多个镜像的话,就要告知哪一个节点安装哪一个镜像。si_addclients为镜像的安装脚本创建符号链接。si_addclients改写镜像服务器的/etc/hosts
和/var/lib/systemimager/scripts/hosts文件。Hosts文件为自动安装客户端查阅他们的主机名提供默认的机制。
[root@localhost ~]# si_addclientsWelcome 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 toyour "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 combinedwith the hostname information provided in Section 1 to create entries in"/etc/hosts" for each of these same clients. New entries will be appendedto the end of "/etc/hosts" . If you specify new hostnames for existing IPaddresses, those entries will be re-written in place to reflect the newhost names.Continue ? ([y]/n): y #输入“y”,继续。
(8)在si_addclients的第一个配置部分,需要指出自动安装节点的主机名称样式。一个主机范围的字段和一个域名用来定义我们要自动安装的节点的主机名;
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 beginningnumber, and an ending number.For example, if you answer:domain name = systemimager.orghost range = www7-www11,www20Then the result will be a series of hostnames that looks like this:www7.systemimager.orgwww8.systemimager.orgwww9.systemimager.orgwww10.systemimager.orgwww11.systemimager.orgwww20.systemimager.orgWhat is your domain name ? []: vfast.comWhat is the hosts range that you want me to use? []: node11-node200I will work with hostnames: node11-node200in the domain: vfast.comAre you satisfied? (y/[n]): y
(9)在第二个配置部分,将前一部分定义的节点映射到到镜像;
si_addclients -- Section 2 (soft links to master script)--------------------------------------------------------------------------------Would you like me to create soft links to a "master" script so that hosts:node11-node200can be autoinstalled with one of the available images? ([y]/n): yHere is a list of available autoinstall scripts:vfast_backupWhich script would you like these hosts to be installed with ?[vfast_backup]:Your soft links have been created.Press <Enter> to continue ...
(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 to be able to determine their host names from theirIP 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 DNSthat has IP address to hostname resolution properly configured for yourtarget machines, then answer "n" here.If you don't have a working DNS, or you want to override the information inDNS, then answer "y" here to add entries to the "/etc/hosts" file on yourimage server. After adding these entries, the /etc/hosts file will becopied to "/var/lib/systemimager/scripts" where it can be retrieved by yourtarget machines.I will ask you for your clients' IP addresses one subnet at a time .Would you like me to continue ? (y/[n]): ysi_addclients -- Section 3 (adding or modifying /etc/hosts entries -- continued...)--------------------------------------------------------------------------------Hostnames range is : node11-node200What is the IPs address range (e.g. 10.0.0.1-10.0.0.100,10.0.0.101)?[]: 172.16.0.11-172.16.0.200I will work with IP addresses: 172.16.0.11-172.16.0.200and hostnames: node11-node200Are you satisfied? (y/[n]): yUse of uninitialized value in concatenation (.) or string at /usr/sbin/si_addclients line 552.These entries have been added to /etc/hosts, and /etc/hosts has been copiedto /var/lib/systemimager/scripts for use by your auto-install clients.Press <Enter> to continue ...si_addclients: successfully completed.
(11)执行si_mkclientnetboot 来制作多台要克隆机器通过网络安装的对应启动介质:
[root@localhost ~]# si_mkclientnetboot --netboot --clients node11-node200[netboot] using the kernel and initrd.img for architecture: i386[netboot] using the flavor: standard[root@localhost ~]#
(12)启动systemimager-server-rsyncd服务,使用rsync服务克隆系统。将以下服务设置重启自动启动。
[root@localhost ~]# /etc/init.d/systemimager-server-rsyncd startStarting rsync daemon for systemimager: 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
,如需转载请自行联系原作者