PXE批量自動部署linux系統內容

來源:互聯網
上載者:User

標籤:ade   algo   初始化   ip地址   cps   批量   eth0   httpd   lis   

1、基礎網路建設與搭建DHCP服務

1)配置靜態IP地址並重起網卡

cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0TYPE=EthernetONBOOT=yesNM_CONTROLLED=yesBOOTPROTO=staticIPADDR=10.0.0.4NETMASK=255.255.255.0GATEWAY=10.0.0.2/etc/init.d/network restartifconfig eth0

2)安裝配置DHCP服務

yum -y install dhcpvim /etc/dhcp/dhcpd.confdefault-lease-time 600;max-lease-time 7200;ddns-update-style none;option domain-name-servers 202.106.0.20;   #DNS地址可配置2個用逗號分隔ignore client-updates;subnet 10.0.0.0 netmask 255.255.255.0 {  range 10.0.0.100 10.0.0.150;              #宣告擷取位址區段  option subnet-mask 255.255.255.0;         #子網  option routers 10.0.0.2;                  #擷取網關地址  next-server 10.0.0.4;                     #重點配置PEX地址  filename "pxelinux.0";                    #核心檔案名稱

#配置開機自啟動
chkconfig --add dhcpd
chkconfig dhcpd on
chkconfig --list dhcpd
#查看DHCP監聽連接埠好UDP 67
netstat -lntup|grep 67

2、搭建TFTP服務

yum -y install tftp-server tftp

vim /etc/xinetd.d/tftp#配置TFTP設定檔:service tftp{        socket_type             = dgram        protocol                = udp        wait                    = yes        user                    = root        server                  = /usr/sbin/in.tftpd        server_args             = -s /tftpboot          #修改TFTP服務類別目錄        disable                 = no                    #修改為no,啟動TFTP        per_source              = 11        cps                     = 100 2        flags                   = IPv4}

#配置自啟動
chkconfig tftp on
chkconfig --list tftp
chkconfig --list xinetd
#重啟動xinetd服務,TFTP是由xinetd服務啟動並執行
/etc/init.d/xinetd restart
netstat -lntup|grep 69 ;netstat -a|grep tftp
udp 0 0 0.0.0.0:69 0.0.0.0:* 1877/xinetd
udp 0 0 *:tftp
#TFTP連接埠號碼為UDP的69
#測試下載
mkdir /tftpboot
cd /tftpboot/
touch test.txt
ls
test.txt
cd ..
tftp 10.0.0.4 -c get test.txt
ls #下載成功!
test.txt

3、搭建HTTP服務

yum -y install httpd
#配置自啟動
chkconfig --add httpd
chkconfig httpd on
chkconfig --list httpd
#啟動http服務
/etc/init.d/httpd start
netstat -lntup|grep 80

#使用瀏覽器測試
http://10.0.0.4

4、組建PXE服務環境

1)安裝syslinux包
yum -y install syslinux
#如不安裝syslinux包就沒有pxelinux.0檔案
find / -type f -name "pxelinux.0"
/usr/share/syslinux/pxelinux.0
#將pxelinux.0拷貝到tftp服務類別目錄
cp /usr/share/syslinux/pxelinux.0 /tftpboot/
#在tftp服務類別目錄下建立pxelinux.cfg目錄
mkdir /tftpboot/pxelinux.cfg -p
2)掛載linux系統硬碟,拷貝linux核心,初始化鏡像檔案
mkdir -p /media/cdrom
mount -t iso9660 -o loop /dev/sr0 /media/cdrom
cd /media/cdrom/images/pxeboot
cp vmlinuz initrd.img /tftpboot/
cd /tftpboot/
ls
initrd.img pxelinux.0 pxelinux.cfg vmlinuz
#配置啟動菜單檔案,將系統內建的開機檔案拷貝到TFTP目錄下改名為
cp /media/cdrom/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
#修改啟動菜單檔案

cat default default auto   #指定預設啟動項prompt 0       #為0時不選擇自動按預設安裝,為1時可選擇選項安裝label auto     #配置選項auto  kernel vmlinuz   #指定核心  append initrd=initrd.img ks=http://10.0.0.4/ks.cfg devfs=nomount ramdisk_size=8192   #指定自動安裝檔案ks.cfglabel linux text  kernel vmlinuz  append initrd=initrd.img devfs=nomount ramdisk_size=8192label rescue  kernel vmlinuz  append initrd=initrd.img rescue#重啟動TFTP服務載入配置/etc/init.d/xinetd restart

5、建立kickstart檔案

1)安裝system-config-kickstart
yum -y install system-config-kickstart
#注意安裝案頭服務才能啟動KICKSTART,建立開機檔案
/usr/bin/system-config-kickstart

cat ks.cfg#platform=x86, AMD64, or Intel EM64T#version=DEVEL# Firewall configuration關閉防火牆firewall --disabled# Install OS instead of upgrade 安裝系統install# Use network installation  使用網路安裝,這裡配置http擷取安裝包url --url="http://192.168.146.128/"key --skip# Root password  配置ROOT密碼rootpw --iscrypted $1$jIsDXG2F$EGT.VAhEBlZ/ww9GNOTo7.# System authorization information 系統授權資訊auth  --useshadow  --passalgo=md5# Use graphical install 圖形安裝graphical# System keyboard 配置鍵盤keyboard us# System language 配置系統語言lang en_US# SELinux configuration 關閉selinuxselinux --disabled# Do not configure the X Window System 不安裝圖形介面skipx# Installation logging level 安裝系統日誌記錄層級logging --level=info# Reboot after installation 安裝完重新引導reboot# System timezone  #配置時區timezone  Asia/Shanghai# Network information 配置網路為自動擷取network  --bootproto=dhcp --device=eth0 --onboot=on# System bootloader configuration 系統引導程式配置bootloader --location=mbr# Clear the Master Boot Record 清除主引導記錄zerombr# Partition clearing information 分區資訊clearpart --all  # Disk partitioning information  指定分區大小part swap --fstype="swap" --size=2048part /boot --fstype="ext4" --size=200part / --fstype="ext4" --grow --size=1%packages@base@compat-libraries@debugging@development%end

#將應答指令碼拷貝到http目錄,並賦予許可權
cp ks.cfg /var/www/html/
chown apache.apache /var/www/html/ks.cfg

6、啟動客戶機安裝

注意:客戶機要和伺服器在同一個區域網路內
如果使用vmware做實驗,需要關閉VMware內建的DHCP功能

排除思路:
1)客戶機是否擷取IP地址,可查看網路和DHCP服務
2)查看連結TFTP是否正常
如連結正常在擷取IP地址後會顯示:
TFTP prefix:
trying to load: pxelinux.cfg/default ok
然後載入核心:
loading vmlinuz........
loading initrd.img.........
3)載入完核心後會連結下載安裝系統檔案,如tfp,http擷取等

PXE批量自動部署linux系統內容

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.