系統:centos7.8 內存:2G cpu:1核 網卡eth33:192.168.197.128 /24
setenforce 0 #臨時關閉SELinux sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config #永久關閉SELinux(重啓生效) systemctl stop firewalld.service #臨時關閉防火牆 systemctl disable firewalld.service #永久關閉防火牆
syslinux 是引導加載程序,是一個小型的linux系統html
yum install syslinux syslinux-devel -y
node
安裝完成後,在/usr/share/syslinux中會有pexlinux.0 ,用來引導系統python
yum install httpd httpd-devel dhcp* tftp-server xinetd -y
linux
vim /etc/xinetd.d/tftp
web
只需設置disable=no,設置tftp開機自啓動,同時記錄tftp根目錄/var/lib/tftpboot,用於後續文件的存放shell
service tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /var/lib/tftpboot disable = no # 修改此項便可 per_source = 11 cps = 100 2 flags = IPv4 }
啓動服務vim
systemctl restart xinetd
centos
<!------------------------------重要--------------------------------->bash
重要:將一些文件傳至tftp目錄服務器
mkdir -p /var/lib/tftpboot cp /var/www/html/centos7.8/images/pxeboot/vmlinuz /var/lib/tftpboot cp /var/www/html/centos7.8/images/pxeboot/initrd.img /var/lib/tftpboot cp /var/www/html/centos7.8/isolinux/vesamenu.c32 /var/lib/tftpboot cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot mkdir -p /var/lib/tftpboot/pxelinux.cfg cp /var/www/html/centos7.8/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default chmod 644 /var/lib/tftpboot/pxelinux.cfg/default
拷貝完成後/var/lib/tftpboot下一共5個文件:
initrd.img pxelinux.0 vesamenu.c32 vmlinuz pxelinux.cfg/default
修改/var/lib/tftpboot/pxelinux.cfg/default
# 默認加載菜單 default vesamenu.c32 timeout 100 display boot.msg # menu 爲背景標題顏色... menu clear menu background splash.png menu title CentOS 7 menu vshift 8 menu rows 18 menu margin 8 menu helpmsgrow 15 menu tabmsgrow 13 label linux menu label ^Install CentOS Linux 7 menu default # 指定內核 kernel vmlinuz # 追加給內核參數 initrd:最小的linux系統 inst.repo:指定ks.cfg文件路徑 append initrd=initrd.img inst.repo=http://192.168.197.128/centos7.8 quiet ks=http://192.168.197.128/ks.cfg label check menu label Test this ^media & install CentOS Linux 7 kernel vmlinuz append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet
vim /etc/dhcp/dhcpd.conf
<!--提示:若是複製至vim會所有註釋,能夠複製前輸入 :set paste-->
# 動態更新DNS ddns-update-style interim; # 不容許更新DNS ignore client-updates; # tftp服務器地址 next-server 192.168.197.128; # tftp服務器根目錄下的文件名 filename "pxelinux.0"; # 容許PXE啓動 allow booting; # 容許支持bootp allow bootp; # 設置DHCP網段掩碼 subnet 192.168.197.0 netmask 255.255.255.0 { # 設置網關 option routers 192.168.197.2; # 設置掩碼 option subnet-mask 255.255.255.0; #設置dhcp服務器IP地址租用的範圍(和服務器在一個網段) range dynamic-bootp 192.168.197.150 192.168.197.200; #默認租約時間 default-lease-time 3600; #最大租約時間 max-lease-time 7200; }
綁定DHCP網卡(若是一臺服務器有多個網卡,須要指定DHCP服務器的網卡)
vim /etc/sysconfig/dhcpd
# 根據實際網卡名填寫 DHCPDARGS=eth33
輸入dhcpd 測試正常
啓動服務
systemctl restart dhcpd.service systemctl enable dhcpd.service
httpd服務主要是提供給客戶端下載須要的軟件包,因此鏡像軟件須要掛載至httpd根目錄
mkdir -p /var/www/html/centos7.8/ mount /dev/cdrom /var/www/html/centos7.8/ # 能夠cp拷貝過去,可加入開機項 # 建議服務器存放鏡像,創建軟鏈接 比mount要好 # 啓動服務 systemctl restart httpd.service systemctl enable httpd.service
測試訪問正常
ks.cfg文件是安裝操做系統的一些詳細的配置,分爲三段
因爲kickstart的參數過多,咱們使用圖形化配置,不便於出錯
首先切換到圖形化界面,因爲以前未安裝圖形化,故先安裝圖形化界面
yum groupinstall "X Window System" -y
輸入yum grouplist
查看圖形化安裝組
yum groupinstall "GNOME Desktop" "Graphical Administration Tools"
安裝完成後輸入startx便可進入圖形化
yum install system-config-kickstart -y
開始配置
<!--只要將vim /etc/yum.repos.d/CentOS-Base.repo(文件名根據實際狀況修改) 中的[base]一項 複製一份改爲[development]放置文件末尾,而後輸入yum clean all && yum makecache,重開kickstart軟件便可-->
生成的ks.cfg配置以下
#platform=x86, AMD64, or Intel EM64T #version=DEVEL # Install OS instead of upgrade install # Keyboard layouts keyboard 'us' # Root password rootpw --iscrypted $1$V.oK4NE.$RPASHZXvyHMPNqym7KwGe1 # System language lang en_US # System authorization information auth --useshadow --passalgo=sha512 # Use graphical install graphical # SELinux configuration selinux --disabled # Do not configure the X Window System skipx # Firewall configuration firewall --disabled # Network information network --bootproto=dhcp --device=ehto # Reboot after installation reboot # System timezone timezone Asia/Shanghai # Use network installation url --url="http://192.168.197.128/centos7.8" # 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=512 part / --fstype="xfs" --grow --size=1 %post echo "set hostname" hostnamectl set-hostname k8s-node03 echo " set yum" rm -rf /etc/yum.repos.d/* cat>/etc/yum.repos.d/centos7.8.repo<<EOF [base] name=centos7.8 baseurl=http://192.168.197.128/yum/centos7.8 enable=1 gpgcheck=0 EOF yum clean all yum install -y vsftp* useradd test echo Huawei12#$|passwd --stdin test %end %packages @python-web %end
測試安裝正常,且填寫的腳本也已經運行完成。
重要:centos7.3之後的要最少2G內存,否則會報錯,折騰到凌晨,哭死
報錯界面以下
桃李不言 下自成蹊