介紹幾種自動化安裝服務器的方法
1.通過掛載光盤鏡像文件的方式
待安裝主機可以使用光盤裏的鏡像或者vsftpd共享出來的鏡像來安裝
2.通過pxe網絡安裝服務器
從合理性來講,讓每個主機都掛載一個光盤,顯然也不符合實際,所以實際中使用PXE網絡安裝服務器
一.kickstack自動化安裝腳本
rhel7中:
1.安裝system-config-kickstart
yum install system-config-kickstart
2.圖形制作ks文件的工具
system-config-kickstart
3.這個圖形工具是有bug的,需要手動添加某些文件內容
vim ks.cfg
%packages
@base ##軟件組
lftp ##軟件包
%end
4.檢查ks.cfg文件是否有語法錯誤
ksvalidator /mnt/ks.cfg
5.發佈ks文件
yum install vsftpd -y
systemctl start vsftpd
systemctl stop firewalld
mkdir /var/ftp/ksfile
mv ks.cfg /var/ftp/ksfile
6.檢測發佈
firefox ftp://192.168.1.33/ksfile/ks.cfg
二.通過掛載鏡像光盤方式安裝
在安裝界面按<tab>
輸入:
ks=ftp://192.168.1.33/ksfile/ks.cfg
回車
進入到自動安裝過程
注意:
使用kickstart安裝系統時環境中必須有dhcp服務器否則網絡資源訪問不到
使用網絡資源安裝系統
通過ftp服務發佈鏡像資源到網絡
訪問網絡鏡像資源
ftp://192.168.1.33/rhel7.0
更改ks.cfg
vim ks.cfg
#cdrom ##註釋使用光盤資源
url --url=“ftp://192.168.1.33/rhel7.0” ##使用網絡資源
二.pxe網絡安裝服務器
1.部署vsftpd
1.共享ks文件
2.共享安裝源
mount /dev/cdrom /var/ftp/rhel8.0/
2.搭建dhcpd服務器
分配ip等信息到客戶端
具體教程參見博客地址:
https://blog.csdn.net/chaos_oper/article/details/104332080
3.部署pxe環境
dnf install syslinux-nonlinux-6.04-1.el8.noarch -y ##獲得pxelinux.0文件
dnf install tftp-server.x86_64 ##pxelinux.0共享服務器
systemctl start tftp
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ ##共享pxelinux.0
cp /var/ftp/rhel8/isolinux/* /var/lib/tftpboot/ ##共享安裝環境所要讀取的文件
mkdir /var/lib/tftpboot/pxelinux.cfg/
cp /var/lib/tftpboot/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default ##生成pxelinux.0默認讀取文件
4.dhcpd服務配置分發pxelinux.0
vim /etc/dhcp/dhcpd.conf
1 # dhcpd.conf
2 #
3 # Sample configuration file for ISC dhcpd
4 #
5
6 # option definitions common to all supported networks...
7 option domain-name "example.com";
8 option domain-name-servers 114.114.114.114;
9
10 default-lease-time 600;
11 max-lease-time 7200;
12
13 # Use this to enble / disable dynamic dns updates globally.
14 #ddns-update-style none;
15
16 # If this DHCP server is the official DHCP server for the local
17 # network, the authoritative directive should be uncommented.
18 #authoritative;
19
20 # Use this to send dhcp log messages to a different log file (you also
21 # have to hack syslog.conf to complete the redirection).
22 log-facility local7;
23
24 # No service will be given on this subnet, but declaring it helps the
25 # DHCP server to understand the network topology.
26
27
28 # This is a very basic subnet declaration.
29
30 subnet 192.168.1.0 netmask 255.255.255.0 {
31 range 192.168.1.120 192.168.1.150;
32 option routers 192.168.1.10;
33 next-server 192.168.1.10; ##tftp服務器地址
34 filename "pxelinux.0"; ##需要讀取的文件名稱
35 }
5.設定pxelinux.cfg/default
2 timeout 50 ##安裝界面等待時間
10 menu background splash.png ##安裝界面壁紙
11 menu title Red Hat Enterprise Linux 8.0.0 ##安裝標題
61 label linux
62 menu label ^Install Red Hat Enterprise Linux 8.0.0
63 menu default ##設定默認選擇標題
64 kernel vmlinuz
65 append initrd=initrd.img repo=ftp://192.168.1.10/rhel8.0 ks=ftp://192.168.1.10/ksfile/ks.cfg ##指定安裝源和ks文件