批量部署Linux机器(RedHat5.4/CentOS5.3)

批量部署Linux机器(RedHat5.4/CentOS5.3):系统:centos5/redhat5软件包:wget 或wget 1、syslinux编译安装,pxe启动目录和文件创建tar zxvf syslinux-3.86.tar.gzcd syslinux-3.86makemkdir /tftpboot/pxelinux.cfg -pmkdir /tftpboot/ks -pmkdir /tftpboot/centos5.3mkdir /tftpboot/redhat5.4chmod 755 /tftpboot#cd gpx/gpxelinux.0 /tftpboot#cp gpx/pxelinux.gpxe /tftpboot#cp com32/menu/*.c32 /tftpboot/pxelinux.cfg#cp com32/modules/reboot.c32 /tftpboot/pxelinux.cfg#cp com32/modules/chain.c32 /tftpboot/pxelinux.cfg复制安装盘isolinux目录下的两个重要文件vmlinuz和initrd.img到TFTP根目录/tftpboot下cp /data/centos5.3/isolinux/vmlinuz /tftpboot/centos5.3cp /data/centos5.3/isolinux/initrd.img /tftpboot/centos5.3cp /data/redhat5.4/isolinux/vmlinuz /tftpboot/redhat5.4cp /data/redhat5.4/isolinux/initrd.img /tftpboot/redhat5.4

复制安装盘isolinux目录下的所有.msg文件(boot.msg,initrd.msg,param.msg,general.msg,options.msg,rescue.msg)到TFTP根目录/tftpboot下命令:cp /data/centos5.3/isolinux/*.msg /tftpboot/centos5.3/cp /data/redhat5.4/isolinux/*msg /tftpboot/redhat5.4/复制isolinux目录下的isolinux.cfg文件为tftpboot/pxelinux.cfg下的defaultcp /data/centos5.3/isolinux.cfg /tftpboot/pxelinux.cfg/default

2、dhcpd配置yum -y install dhcp dhcp-devel编辑DHCP配置文件/etc/dhcpd.conf,可以从/usr/share/doc/dhcp*/dhcpd.conf.sample将这个配置文件的样例复制过来,这样编辑起来会更快些dhcpd.conf配置的有关说明:

parameters(参数):ddns-update-style 配置DHCP-DNS互动更新模式default-lease-time 指定缺省租赁时间的长度,单位是秒max-lease-time 指定最大租赁时间长度,单位是秒hardware 指定网卡接口类型和MAC地址server-name 通知DHCP客户服务器名称get-lease-hostnames flag 检查客户端使用的IP地址fixed-address ip 分配给客户端一个固定的地址authritative 拒绝不正确的IP地址的要求

declarations(声明):shared-network 用来告知是否一些子网络分享相同网络subnet 描述一个IP地址是否属于该子网range 起始IP 终止IP 提供动态分配IP 的范围host 主机名称 参考特别的主机group 为一组参数提供声明allow unknown-clients或deny unknown-client 是否动态分配IP给未知的使用者allow bootp或deny bootp 是否响应激活查询allow booting或deny booting 是否响应使用者查询filename 开始启动文件的名称,应用于无盘工作站next-server 设置服务器从引导文件中装如主机名,应用于无盘工作站

option(选项):subnet-mask 为客户端设定子网掩码domain-name 为客户端指明DNS名字domain-name-servers 为客户端指明DNS服务器IP地址host-name 为客户端指定主机名称routers 为客户端设定默认网关broadcast-address 为客户端设定广播地址ntp-server 为客户端设定网络时间服务器IP地址time-offset 为客户端设定和格林威治时间的偏移时间,,单位是秒。

命令:cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcpd.confvim /etc/dhcpd.conf#————–global——————————————option domain-name-servers 192.168.1.199;ddns-update-style none;default-lease-time 14400;max-lease-time 43200;#———-tftp——————————————ignore client-updates;allow booting;allow bootp;class “pxeclients”{ match if substring(option vendor-class-identifier,0,9) = “PXEClient”; filename “gpxelinux.0”; next-server 192.168.1.199;}#———-subnet———————————————subnet 192.168.1.0 netmask 255.255.255.0 { option routers 192.168.1.1; option subnet-mask 255.255.255.0; range dynamic-bootp 192.168.1.200 192.168.1.254;}

检查文件/var/lib/dhcpd/dhcpd.leases,文件存在即可

如果考虑到安全问题,在多网卡的机器上可以编辑/etc/sysconfig/dhcpd文件来制定DHCP服务在那个设备上启动命令:vim /etc/sysconfig/dhcpd编辑内容为:# Command line options hereDHCPDARGS=eth0重启DHCP服务service dhcpd restart或/etc/rc.d/ini.d/dhcpd restart

3、tftp配置yum -y install xinetd tftp tftp-server编辑TFTP的配置文件vim /etc/xinetd.d/tftp# default: off# description: The tftp server serves files using the trivial file transfer \# protocol. The tftp protocol is often used to boot diskless \# workstations, download configuration files to network-aware printers, \# and to start the installation process for some operating systems.service tftp{ socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -u nobody -s /tftpboot disable = no per_source = 11 cps = 100 2 flags = IPv4}重启TFTP服务需要重启xinetd这个守护服务service xinetd restart

4、nfs配置:yum -y install nfs-utils nfs-utils-lib

编辑NFS的配置文件命令:vim /etc/exports/tftpboot *(ro,sync)/data/centos5.3 *(ro,sync)

重启nfs服务:service nfs restartservice portmap restart

或者可以不必重启整个服务,用下面命令更新NFS服务exportfs -arv

检查目录设置是否正确:showmount -e localhost

只需要根据自己业务定义cfg文件:

/tftpboot/ks下的ceentos5.3.cfg和redhat5.4.cfg

#########/tftpboot/pxelinux.cfg/default#######

default ct53_32prompt 1timeout 600display boot.msgF1 boot.msgF2 options.msgF3 general.msgF4 param.msgF5 rescue.msglabel linux kernel vmlinuz append initrd=initrd.img label text kernel vmlinuz append initrd=initrd.img text label local localboot 1label memtest86 kernel memtest append –

label ct53_32 kernel centos5.3/vmlinuz append initrd=centos5.3/initrd.img ks=nfs:192.168.1.199:/tftpboot/ks/ct53_32.cfg devfs=nomount ramdisk_size=4096 nofb textlabel rh54_32 kernel redhat5.4/vmlinuz append initrd=redhat5.4/initrd.img ks=nfs:192.168.1.199:/tftpboot/ks/rh54_32.cfg devfs=nomount ramdisk_size=4096 nofb text

############/tftpboot/ks/rh54_32.cfg#############

# Kickstart file automatically generated by anaconda.

installnfs –server=192.168.1.199 –dir=/data/redhat5.4lang en_US.UTF-8langsupport –default=en_US.UTF-8 en_US.UTF-8keyboard uskey –skipnetwork –bootproto=dhcp –device=eth0 –onboot=onrootpw –iscrypted $1$XPr0sv0o$1.XsUW0h36ZdWetQOefR21firewall –disabledselinux –disabledauthconfig –enableshadow –enablemd5timezone Asia/Shanghaibootloader –location=mbr#diskclearpart –all –initlabel part /boot –fstype ext3 –size=100 part / –fstype ext3 –size=12000part swap –fstype swap –size=1024

%packages@admin-tools@editors@base@system-tools@dialup@server-cfg@development-tools@ruby@text-internetnet-snmp

%post/sbin/chkconfig –level 2345 anacron off/sbin/chkconfig –level 2345 apmd off/sbin/chkconfig –level 2345 atd off/sbin/chkconfig –level 2345 gpm off/sbin/chkconfig –level 2345 httpd off/sbin/chkconfig –level 2345 identd off/sbin/chkconfig –level 2345 ipchains off/sbin/chkconfig –level 2345 isdn off/sbin/chkconfig –level 2345 keytable off/sbin/chkconfig –level 2345 kudzu off/sbin/chkconfig –level 2345 linuxconf off/sbin/chkconfig –level 2345 lpd off/sbin/chkconfig –level 2345 netfs off/sbin/chkconfig –level 2345 nfslock off/sbin/chkconfig –level 2345 pcmcia off/sbin/chkconfig –level 2345 portmap off/sbin/chkconfig –level 2345 random off/sbin/chkconfig –level 2345 rawdevices off/sbin/chkconfig –level 2345 rhnsd off/sbin/chkconfig –level 2345 sgi_fam off/sbin/chkconfig –level 2345 sshd off/sbin/chkconfig –level 2345 xfs off/sbin/chkconfig –level 2345 xinetd off/sbin/chkconfig –level 2345 cups off/sbin/chkconfig –level 2345 hpoj off/sbin/chkconfig –level 2345 mdmpd off/sbin/chkconfig –level 2345 firstboot off/sbin/chkconfig –level 2345 arptables_jf off/sbin/chkconfig –level 2345 mdmonitor off/sbin/chkconfig –level 2345 smartd off/sbin/chkconfig –level 2345 messagebus off/sbin/chkconfig –level 2345 acpid off/sbin/chkconfig –level 2345 avahi-daemon off/sbin/chkconfig –level 2345 rpcsvcgssd off/sbin/chkconfig –level 2345 rpcgssd off/sbin/chkconfig –level 2345 rpcidmapd off/sbin/chkconfig –level 2345 irqbalance on/sbin/chkconfig –level 2345 bluetooth off/sbin/chkconfig –level 2345 psacct on/sbin/chkconfig –level 2345 sshd on/sbin/chkconfig –level 2345 snmpd on

echo “* */5 * * * /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1” >> /etc/crontabecho “nameserver 202.106.46.151”>/etc/resolv.confecho “nameserver 202.106.196.115”>>/etc/resolv.conf

人,都有不能称心如意的时候,都有愿望落空的窘迫,

批量部署Linux机器(RedHat5.4/CentOS5.3)

相关文章:

你感兴趣的文章:

标签云: