1. 程式人生 > >部署kickstart無人值守

部署kickstart無人值守

con devel html span rgs div config pxelinux bug

部署kickstart無人值守

環境介紹:使用一臺虛擬機模擬DHCP/TFTP/HTTP服務器,虛擬機ip地址為172.16.1.61,網卡為eth0

1.準備環境,確保selinux和iptables關閉   cat /etc/redhat-release   CentOS release 6.8 (Final)   uname -r   2.6.32-642.el6.x86_64   getenforce   Disabled   /etc/init.d/iptables status   iptables: Firewall is not running. 2.部署DHCP服務   yum install -y dhcp
  cat >>/etc/dhcp/dhcpd.conf<<EOF   subnet 172.16.1.0 netmask 255.255.255.0 {   range 172.16.1.101 172.16.1.200;   option subnet-mask 255.255.255.0;   default-lease-time 21600;   max-lease-time 43200;   next-server 172.16.1.61;   filename "/pxelinux.0";   }   EOF   /etc/init.d/dhcpd start   echo /etc/init.d/dhcpd start >>/etc/rc.local
  netstat -lntup|grep dhcp 3.部署TFTP服務   yum install -y tftp-server   #修改配置文件中 disable = yes 為 no   sed -i ‘14s/no/yes/‘ /etc/xinetd.d/tftp   #配置文件中 server_args = -s /var/lib/tftpboot 指定目錄,保持默認,不用修改   /etc/init.d/xinetd start   echo /etc/init.d/xinetd start >>/etc/rc.local   netstat -lntup|grep xinetd 4.配置HTTP服務,yum安裝apache服務(沒有編譯需求)   yum -y install httpd
  sed -i "227i ServerName 127.0.0.1:80" /etc/httpd/conf/httpd.conf   /etc/init.d/httpd start   echo /etc/init.d/httpd start >>/etc/rc.local   netstat -lntup|grep httpd   mkdir /var/www/html/centos-6.7 -p   mount /dev/cdrom /var/www/html/centos-6.7/   df -h|grep centos   /dev/sr0 3.7G 3.7G 0 100% /var/www/html/centos-6.7   # /var/www/html 是yum安裝apache的html默認路徑   # 掛載cdrom時,保證cdrom已經連接,否則會失敗   #生產環境不使用掛載光驅(速度有限),而是將鏡像復制到 /var/www/html/centos-6.7 目錄下 5.配置支持PXE啟動程序   安裝pxe引導配置syslinux   yum -y install syslinux   復制啟動菜單程序文件   cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/   復制光盤中開機啟動菜單等內容   cp -a /var/www/html/centos-6.7/isolinux/* /var/lib/tftpboot/   新建一個pxelinux.cfg的目錄   mkdir -p /var/lib/tftpboot/pxelinux.cfg   cp /var/www/html/centos-6.7/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default 6.創建ks.cfg文件,閱讀kickstart配置文件的手冊。用任何一個文本編輯器都可以創建你自己的kickstart配置文件。   cat >>/var/www/html/ks_config/centos-6.7-ks.cfg<<EOF   # Kickstart Configurator for CentOS 6.7 by me   install   url --url="http://172.16.1.61/centos-6.7/"   text   lang en_US.UTF-8   keyboard us   zerombr   bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"   network --bootproto=dhcp --device=eth0 --onboot=yes --noipv6 --hostname=CentOS6   timezone --utc Asia/Shanghai   authconfig --enableshadow --passalgo=sha512   rootpw --iscrypted $6$n6EHz.alzANnwlZ1$6Ih2fxe.bokADnuFaeRvRdFNo9mYHFpR4C.vvqoByxafiTm4d9F   Zdx2dwW4UaIQbQXX.T3i4e6p.tTA6DDIyu.   clearpart --all --initlabel   part /boot --fstype=ext4 --asprimary --size=200   part swap --size=1024   part / --fstype=ext4 --grow --asprimary --size=200   firstboot --disable   selinux --disabled   firewall --disabled   logging --level=info   reboot   %packages [email protected] [email protected] [email protected] [email protected]   tree   nmap   sysstat   lrzsz   dos2unix   telnet   %end   EOF 7.整合編輯default配置文件   vim /var/lib/tftpboot/pxelinux.cfg/default   default ks   prompt 0   label ks   kernel vmlinuz   append initrd=initrd.img ks=http://172.16.1.61/ks_config/centos-6.7-ks.cfg ksdevice=eth0 8.新建一臺沒有系統的虛擬器,設置eth0網卡與本機模式均為NAT即可,然後開機即可進入自動安裝

部署kickstart無人值守