PXE如何實現自動化部署Linux系統(tǒng)介紹
背景說明
在數據中心,一次幾十臺甚至幾百臺服務器上線,系統(tǒng)安裝將變得非常麻煩,系統(tǒng)安裝好了,還會涉及很多配置,工作量都非常大。很多虛擬化平臺如VMware,FusionCompute等安裝一般通過ISO逐臺安裝,或者通過廠商工具來安裝,比較麻煩。
PXE is Pre-Boot Execution Environment # 預啟動的執(zhí)行環(huán)境
PXE 通過網卡引導的技術
1.BISO支持
2.網卡支持
3.需要在BIOS中開啟;服務器BMC界面打開
部署一臺服務器,在服務器上安裝DHCP+tftp (DHCP提供動態(tài)獲取IP)
網卡DCHP獲取信息
DHCP除了分配ip地址 還能提供引導程序的名字和tftp的server的地址
引導程序加載到內存,根據配置文件來引導
思路:
配置yum源
關閉防火墻和selinux
安裝dhcp,tftp-server,htppd,syslinux包
配置dhcp,tftp-server,并啟動服務
安裝system-config-kickstart包,并生成ks無人值守腳本
配置引導菜單
配置DHCP
掛載光盤
mount /dev/cdrom /media
配置yum源
. `vim dvd.repo [development] #定義后期選包 name=centos baseurl=file:///media gpgcheck=0 enabled=1`
編輯DHCP文件(動態(tài)主機配置協(xié)議)
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf #拷貝模板,覆蓋掉conf文件
vim /etc/dhcp/dhcpd.conf #全局配置和子配置二選一,
全局配置 # option definitions common to all supported networks...
7 option domain-name "example.org";
8 option domain-name-servers ns1.example.org, ns2.example.org;
9
10 default-lease-time 600;
11 max-lease-time 7200;
12 next-server 192.168.100.10; #指定tftpserver在哪里
13 filename "/pxelinux.0"; #網絡引導程序文件
# 子配置 A slightly different configuration for an internal subnet.
47 #子網配置
48 subnet 192.168.100.0 netmask 255.255.255.0 {
49 range 192.168.100.11 192.168.100.30; #DHCP地址池的范圍
50 option domain-name-servers 192.168.100.2; #DNS地址 (可以設置)
51 option domain-name "example.com"; #域名地址
52 option routers 192.168.100.1; #網關地址
53 option broadcast-address 192.168.100.255; #廣播地址
54 default-lease-time 600; #租約期 獲取到的ip存活多長時間
55 max-lease-time 7200; #租約期到期,在的話就還可以用,不在自動回收
56 }
tftp配置
[root@pxeserver ~]# 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 = -s /var/lib/tftpboot
disable = no ##yes修改為no
per_source = 11
cps = 100 2
flags = IPv4
}
syslinux配置
yum provides "*/pxelinux.0" ##查找此文件屬于那個軟件包 yum install -y syslinux #安裝syslinux cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ #復制pxelinux.0文件到tftp根目錄下面 mkdir -p /var/lib/tftpboot/pxelinux.cfg #安放default配置文件 cp /media/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default ##開機文件cp到pxeLinux.cfg目錄下 cp /media/isolinux/* /var/lib/tftpboot/ #cp安放iso文件,default來讀取(安裝菜單會顯示) 此時還沒有系統(tǒng) 配置default文件 menu separator # insert an empty line menu separator # insert an empty line label linux menu label ^Install CentOS 7.5 #菜單目錄 kernel vmlinuz #內核文件 append initrd=initrd.img ks=http://192.168.100.10/ks/ks.cfg
配置httpd
yum install -y httpd systemctl start httpd systemctl enable httpd mkdir -p /var/www/html/centos cp -rfv /media/* /var/www/html/centos/ [root@pxe-server ~]# cat /etc/yum.repos.d/dvd.repo [development] #定義后期選包 name=centos baseurl=http://192.168.100.10/centos gpgcheck=0 enabled=1
配置無人值守
yum install -y system-config-kickstart system-config-kickstart #啟動
ks.cfg文件具體配置如下:










到此這篇關于PXE如何實現自動化部署Linux系統(tǒng)介紹的文章就介紹到這了,更多相關PXE自動化部署Linux內容請搜索本站以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持本站!
版權聲明:本站文章來源標注為YINGSOO的內容版權均為本站所有,歡迎引用、轉載,請保持原文完整并注明來源及原文鏈接。禁止復制或仿造本網站,禁止在非maisonbaluchon.cn所屬的服務器上建立鏡像,否則將依法追究法律責任。本站部分內容來源于網友推薦、互聯(lián)網收集整理而來,僅供學習參考,不代表本站立場,如有內容涉嫌侵權,請聯(lián)系alex-e#qq.com處理。
關注官方微信