天天看點

Linux ❀ KickStart-無人值守部署

KickStart-無人值守部署

指令如下:

[root@web ~]# yum install dhcp xinetd tftp-server vsftpd syslinux system-config-kickstart      

1、配置DHCP服務

#修改dhcp服務配置檔案

[root@web ~]# vi /etc/dhcp/dhcpd.conf      

選項說明

#指定引導檔案

filename “pxelinux.0”;

#指定引導檔案伺服器

next-server 192.168.171.138;

配置示例

ddns-update-style interim;
ignore client-updates;
filename "pxelinux.0";
next-server 192.168.171.138;
subnet 192.168.171.0 netmask 255.255.255.0 {
        option routers 192.168.171.1;
        option subnet-mask 255.255.255.0;
        option domain-name-servers 114.114.114.114;
        range dynamic-bootp 192.168.171.200 192.168.171.254;
        default-lease-time 60;
        max-lease-time 60;
}      

#檢查DHCP服務啟用情況

[root@mail ~]# systemctl status dhcpd      

#檢查服務端口

[root@mail ~]# lsof -i:67
[root@mail ~]# lsof -i:68      

2、配置TFTP伺服器

#修改tftp配置檔案

[root@web ~]# vi /etc/xinetd.d/tftp      

#指定服務目錄

server_args = -s /tftpboot

#開啟服務開關

disable = no

#配置示例

service tftp
{
  socket_type   = dgram
  protocol    = udp
  wait      = yes
  user      = root
  server      = /usr/sbin/in.tftpd
  server_args   = -s /tftpboot
  disable     = no
  per_source    = 11
  cps     = 100 2
  flags     = IPv4
}      

#啟動服務

[root@mail ~]# systemctl restart tftp      

#在7.0系統中如果服務無法啟動,使用以下指令進行啟動

[root@mail ~]# systemctl start tftp.socket      

#檢查服務狀态

[root@mail ~]# systemctl status tftp      

#檢查服務端口狀态

[root@mail ~]# lsof -i:69      

#啟動xinetd服務

[root@mail ~]# systemctl restart xinetd      

#檢查xinetd服務

[root@mail ~]# systemctl status xinetd      

3、準備引導的相關檔案

#建立網絡引導配置檔案目錄

[root@mail ~] mkdir -p /tftpboot/pxelinux.cfg      

#複制引導檔案

[root@mail ~] cp /usr/share/syslinux/pxelinux.0 /tftpboot/      

#複制系統映像

[root@mail ~] cp /mnt/images/pxeboot/initrd.img /tftpboot/      

#複制系統核心

[root@mail ~] cp /mnt/images/pxeboot/vmlinuz /tftpboot/      

#複制引導配置檔案

[root@mail ~] cp /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default      

#變更配置檔案權限

[root@mail ~] chmod 644 /tftpboot/pxelinux.cfg/default      

#修改配置檔案

[root@mail ~] vi /tftpboot/pxelinux.cfg/default

  1   default linux   #修改預設啟動模式
  64  append initrd=initrd.img ks=ftp://192.168.171.204/ks.cfg    #修改加載的KS應答檔案      

4、準備安裝鏡像

4.1 [FTP]

#啟動FTP服務

[root@mail ~] systemctl start vsftpd      

#檢視FTP服務狀态

[root@mail ~] systemctl status vsftpd      

#檢視服務端口啟用狀态

[root@mail ~]# lsof -i:21      

#挂載系統鏡像到共享目錄

[root@mail ~] mount /dev/sr0 /var/ftp/pub/      

#可通過windows系統的浏覽器才确認服務通路情況

4.2 [HTTP]

#安裝HTTPD服務

[root@mail ~]# yum install httpd -y      

#複制系統安裝檔案到/var/www/html目錄下

[root@mail ~]# cp -r /mnt/* /var/www/html/      

#複制KS檔案到/var/www/html目錄下

[root@mail ~]# ll /var/www/html/ks.cfg      

#啟動HTTPD服務

[root@mail ~]# systemctl start httpd      

#檢查HTTPD服務狀态

[root@mail ~]# systemctl status httpd      

#檢查HTTPD服務端口

[root@mail ~]# lsof -i:80      

#可通過windows系統的浏覽器才确認服務通路情況

#注意:需要修改default檔案的ks檔案路徑

[root@mail ~] vi /tftpboot/pxelinux.cfg/default
  64  append initrd=initrd.img ks=http://192.168.171.204/ks.cfg      

#注意:需要修改KS應答檔案中的系統安裝資源目錄

[root@mail ~]# vi /var/www/html/ks.cfg 

#Use network installation
url --url="http://192.168.171.204/"      

4.3 [NFS]

#編輯NFS配置檔案

[root@mail ~]# vi /etc/exports      

#配置檔案内容如下:

[root@mail ~]# cat /etc/exports
/var/www/html *(ro)      

#啟動NFS服務

[root@mail ~]# systemctl restart nfs      

#檢查服務狀态

[root@mail ~]# systemctl status nfs      

#檢查服務端口狀态

[root@mail ~]# netstat -lntp | grep 111
[root@mail ~]# netstat -lntp | grep 2049      

#可通過其他linux主機進行遠端挂載共享目錄來測試服務啟動情況

[root@qq ~]# mount -t nfs 192.168.171.204:/var/www/html /mnt      

#注意:需要修改default檔案的ks檔案路徑

[root@mail ~] vi /tftpboot/pxelinux.cfg/default
  64   append initrd=initrd.img ks=nfs:192.168.171.204:/var/www/html/ks.cfg      

#注意:需要修改KS應答檔案中的系統安裝資源目錄

[root@mail ~]# vi /var/www/html/ks.cfg 
#Use network installation
nfs --server=192.168.171.204 --dir=/var/www/html      

5、建立KS應答檔案

[root@mail ~]# system-config-kickstart

#儲存KS應答檔案到/var/ftp目錄下
```javascript
[root@mail ~]# ll /var/ftp/ks.cfg 
-rw-r--r--. 1 root root 1253 5月   2 10:57 /var/ftp/ks.cfg

#KS應答檔案示例:
```javascript
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$nRWRHOuT$xdCld05aBEnkLkmOd5p6t0
# System timezone
timezone Asia/Shanghai
# Use FTP network installation
url --url="ftp://192.168.171.204/pub"
# Use NFS network installation
nfs --server=192.168.171.204 --dir=/var/www/html
# Use HTTP network installation
url --url="http://192.168.171.204/"
# System language
lang zh_CN
# Firewall configuration
firewall --disabled
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx

# Network information
network  --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=200
part swap --fstype="swap" --size=2000
part / --fstype="xfs" --grow --size=1

########with KDE GUI#################
%packages
@^graphical-server-environment
@base
@core
@desktop-debugging
@dial-up
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@input-methods
@internet-browser
@kde-desktop
@multimedia
@print-client
@x11
######################################
#############with minimal#############
%packages
@^minimal
######################################
%end

%addon com_redhat_kdump --disable --reserve-mb='auto'

%end      

繼續閱讀