PXE實作自動化部署Linux系統
- 背景說明
- 配置DHCP
- 編輯DHCP檔案(動態主機配置協議)
- tftp配置
- syslinux配置
- 配置httpd
- 配置無人值守
背景說明
- 在資料中心,一次幾十臺甚至幾百臺服務器上線,系統安裝將變得非常麻煩,系統安裝好了,還會涉及很多配置,作業量都非常大,
- 很多虛擬化平臺如VMware,FusionCompute等安裝一般通過ISO逐臺安裝,或者通過廠商工具來安裝,比較麻煩,
PXE is Pre-Boot Execution Environment # 預啟動的執行環境
PXE 通過網卡引導的技術
1.BISO支持
2.網卡支持
3.需要在BIOS中開啟;服務器BMC界面打開
部署一臺服務器,在服務器上安裝DHCP+tftp (DHCP提供動態獲取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檔案(動態主機配置協議)
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來讀取(安裝選單會顯示)
此時還沒有系統
配置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檔案具體配置如下:










轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/386762.html
標籤:其他
下一篇:JVM--JVM基礎知識
