首頁>技術>

了解kickstart

what's kickstart

kickstart 是使⽤⼀個標準的站點為⼀些機器安裝統⼀配置的linux 作業系統。

kickstart的配置⽂件的獲得⽅式:

⼿動寫⼊使⽤GUI system-config-kickstart ⼯具使⽤標準的Red Hat安裝程式Anacondaanaconda-ks.cfg⽂件

每次CentOS linux 系統安裝完畢後,Anaconda將會在ROOT家⽬錄下⽣成⼀個anaconda-ks.cfg⽂件,使⽤它可以完成相同設定的⾃動安裝,也可以⽤system-config-kickstart⼯具進⾏編輯該⽂件進⾏修改。對anaconda-ks.cfg⽂件修改可以⽣成⾃⼰需要的系統安裝⾃應答⽂件。

kickstart⽂件

kickstart⽂件可以包含系統安裝所有需要的互動,也包含系統安裝前需要執⾏的指令碼及系統安裝後執⾏的指令碼。

kickstart部署實驗圖部署環境:

selinux關閉,防⽕牆關閉

Server:192.168.2.100

部署步驟

Step 1 配置dnf源

[root@localhost ~]# cat server.repo [serverApp]name=appenabled=1gpgcheck=0baseurl=file:///mnt/AppStream[serverOS]name=osenabled=1gpgcheck=0baseurl=file:///mnt/BaseOS

Step 2 安裝軟體包

[root@localhost ~]# dnf install dhcp-server tftp-server httpd syslinux -yapp 74 MB/s | 5.2 MB 00:00 os 75 MB/s | 2.2 MB 00:00 上次元資料過期檢查:0:00:01 前,執行於 2019年12月01日 星期日 20時49分26秒。依賴關係解決。=============================================================================================================================== 軟體包 架構 版本 倉庫 大小===============================================================================================================================Installing: httpd x86_64 2.4.37-11.module_el8.0.0+172+85fc1f40 serverApp 1.7 M tftp-server x86_64 5.2-24.el8 serverApp 50 k dhcp-server x86_64 12:4.3.6-30.el8 serverOS 529 k syslinux x86_64 6.04-1.el8 serverOS 576 k安裝依賴關係: apr x86_64 1.6.3-9.el8 serverApp 125 k apr-util x86_64 1.6.1-6.el8 serverApp 105 k centos-logos-httpd noarch 80.5-2.el8 serverApp 24 k httpd-filesystem noarch 2.4.37-11.module_el8.0.0+172+85fc1f40 serverApp 34 k httpd-tools x86_64 2.4.37-11.module_el8.0.0+172+85fc1f40 serverApp 102 k mod_http2 x86_64 1.11.3-2.module_el8.0.0+10+abf51267 serverApp 156 k syslinux-nonlinux noarch 6.04-1.el8 serverOS 551 k安裝弱的依賴: apr-util-bdb x86_64 1.6.1-6.el8 serverApp 25 k apr-util-openssl x86_64 1.6.1-6.el8 serverApp 27 kEnabling module streams: httpd 2.4 事務概要===============================================================================================================================安裝 13 軟體包總計:3.9 M安裝大小:9.9 M下載軟體包:執行事務檢查事務檢查成功。執行事務測試事務測試成功。執行事務 準備中 : 1/1  Installing : apr-1.6.3-9.el8.x86_64 1/13  執行指令碼 : apr-1.6.3-9.el8.x86_64 1/13  Installing : apr-util-bdb-1.6.1-6.el8.x86_64 2/13  Installing : apr-util-openssl-1.6.1-6.el8.x86_64 3/13  Installing : apr-util-1.6.1-6.el8.x86_64 4/13  執行指令碼 : apr-util-1.6.1-6.el8.x86_64 4/13  Installing : httpd-tools-2.4.37-11.module_el8.0.0+172+85fc1f40.x86_64 5/13  Installing : syslinux-nonlinux-6.04-1.el8.noarch 6/13  Installing : syslinux-6.04-1.el8.x86_64 7/13  執行指令碼 : httpd-filesystem-2.4.37-11.module_el8.0.0+172+85fc1f40.noarch 8/13  Installing : httpd-filesystem-2.4.37-11.module_el8.0.0+172+85fc1f40.noarch 8/13  Installing : centos-logos-httpd-80.5-2.el8.noarch 9/13  Installing : mod_http2-1.11.3-2.module_el8.0.0+10+abf51267.x86_64 10/13  Installing : httpd-2.4.37-11.module_el8.0.0+172+85fc1f40.x86_64 11/13  執行指令碼 : httpd-2.4.37-11.module_el8.0.0+172+85fc1f40.x86_64 11/13  執行指令碼 : dhcp-server-12:4.3.6-30.el8.x86_64 12/13  Installing : dhcp-server-12:4.3.6-30.el8.x86_64 12/13  執行指令碼 : dhcp-server-12:4.3.6-30.el8.x86_64 12/13  Installing : tftp-server-5.2-24.el8.x86_64 13/13  執行指令碼 : tftp-server-5.2-24.el8.x86_64 13/13  執行指令碼 : httpd-2.4.37-11.module_el8.0.0+172+85fc1f40.x86_64 13/13  執行指令碼 : tftp-server-5.2-24.el8.x86_64 13/13  驗證 : apr-1.6.3-9.el8.x86_64 1/13  驗證 : apr-util-1.6.1-6.el8.x86_64 2/13  驗證 : apr-util-bdb-1.6.1-6.el8.x86_64 3/13  驗證 : apr-util-openssl-1.6.1-6.el8.x86_64 4/13  驗證 : centos-logos-httpd-80.5-2.el8.noarch 5/13  驗證 : httpd-2.4.37-11.module_el8.0.0+172+85fc1f40.x86_64 6/13  驗證 : httpd-filesystem-2.4.37-11.module_el8.0.0+172+85fc1f40.noarch 7/13  驗證 : httpd-tools-2.4.37-11.module_el8.0.0+172+85fc1f40.x86_64 8/13  驗證 : mod_http2-1.11.3-2.module_el8.0.0+10+abf51267.x86_64 9/13  驗證 : tftp-server-5.2-24.el8.x86_64 10/13  驗證 : dhcp-server-12:4.3.6-30.el8.x86_64 11/13  驗證 : syslinux-6.04-1.el8.x86_64 12/13  驗證 : syslinux-nonlinux-6.04-1.el8.noarch 13/13 已安裝: httpd-2.4.37-11.module_el8.0.0+172+85fc1f40.x86_64 tftp-server-5.2-24.el8.x86_64  dhcp-server-12:4.3.6-30.el8.x86_64 syslinux-6.04-1.el8.x86_64  apr-util-bdb-1.6.1-6.el8.x86_64 apr-util-openssl-1.6.1-6.el8.x86_64  apr-1.6.3-9.el8.x86_64 apr-util-1.6.1-6.el8.x86_64  centos-logos-httpd-80.5-2.el8.noarch httpd-filesystem-2.4.37-11.module_el8.0.0+172+85fc1f40.noarch  httpd-tools-2.4.37-11.module_el8.0.0+172+85fc1f40.x86_64 mod_http2-1.11.3-2.module_el8.0.0+10+abf51267.x86_64  syslinux-nonlinux-6.04-1.el8.noarch 完畢!

Step 3 搭建並啟動DHCP

[root@localhost ~]# vim /etc/dhcp/dhcpd.conf subnet 192.168.2.0 netmask 255.255.255.0 { option routers 192.168.2.100; range 192.168.2.10 192.168.2.20; next-server 192.168.2.100; filename "pxelinux.0";}[root@localhost ~]# systemctl start dhcpd[root@localhost ~]# systemctl status dhcpd● dhcpd.service - DHCPv4 Server Daemon Loaded: loaded (/usr/lib/systemd/system/dhcpd.service; disabled; vendor preset: disabled) Active: active (running) since Sun 2019-12-01 20:58:49 EST; 3s ago Docs: man:dhcpd(8) man:dhcpd.conf(5) Main PID: 31465 (dhcpd) Status: "Dispatching packets..." Tasks: 1 (limit: 50687) Memory: 5.0M CGroup: /system.slice/dhcpd.service └─31465 /usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid12月 01 20:58:49 localhost.localdomain dhcpd[31465]: ** Ignoring requests on virbr0. If this is not what12月 01 20:58:49 localhost.localdomain dhcpd[31465]: you want, please write a subnet declaration12月 01 20:58:49 localhost.localdomain dhcpd[31465]: in your dhcpd.conf file for the network segment12月 01 20:58:49 localhost.localdomain dhcpd[31465]: to which interface virbr0 is attached. **12月 01 20:58:49 localhost.localdomain dhcpd[31465]: 12月 01 20:58:49 localhost.localdomain dhcpd[31465]: Listening on LPF/ens33/00:0c:29:11:47:97/192.168.2.0/2412月 01 20:58:49 localhost.localdomain dhcpd[31465]: Sending on LPF/ens33/00:0c:29:11:47:97/192.168.2.0/2412月 01 20:58:49 localhost.localdomain dhcpd[31465]: Sending on Socket/fallback/fallback-net12月 01 20:58:49 localhost.localdomain dhcpd[31465]: Server starting service.12月 01 20:58:49 localhost.localdomain systemd[1]: Started DHCPv4 Server Daemon.[root@localhost ~]# netstat -antlup | grep :67udp 0 0 0.0.0.0:67 0.0.0.0:* 31465/dhcpd udp 0 0 0.0.0.0:67 0.0.0.0:* 1345/dnsmasq 

Step 4 ⽣成需要的⽂件並啟動tftp服務

[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0\t\t/var/lib/tftpboot/[root@localhost ~]# cp /mnt/isolinux/{vmlinuz,ldlinux.c32,initrd.img} \t\t/var/lib/tftpboot/[root@localhost ~]# mkdir /var/lib/tftpboot/pxelinux.cfg[root@localhost ~]# vim /var/lib/tftpboot/pxelinux.cfg/default\t\t\t#生成default檔案default linuxtimeout 3label linux kernel vmlinuz append initrd=initrd.img ip=dhcp method=http://192.168.2.100/RHEL ks=http://192.168.2.100/ks.cfg[root@localhost mnt]# systemctl start tftp\t\t\t#啟動tftp服務[root@localhost mnt]# systemctl status tftp● tftp.service - Tftp Server Loaded: loaded (/usr/lib/systemd/system/tftp.service; indirect; vendor preset: disabled) Active: active (running) since Sun 2019-12-01 21:44:06 EST; 5s ago Docs: man:in.tftpd Main PID: 33477 (in.tftpd) Tasks: 1 (limit: 50687) Memory: 252.0K CGroup: /system.slice/tftp.service └─33477 /usr/sbin/in.tftpd -s /var/lib/tftpboot12月 01 21:44:06 localhost.localdomain systemd[1]: Started Tftp Server.[root@localhost mnt]# netstat -antulp | grep :69udp6 0 0 :::69 :::* 1/systemd 

Step 5 搭建並啟動http服務

[root@localhost ~]# mkdir /var/www/html/RHEL\t\t#建立軟體包存放目錄[root@localhost ~]# mount /dev/cdrom /var/www/html/RHEL\t\t#將光碟掛載到對應目錄中

Step 6 ⽣成ks.cfg⽂件

由於CentOS8.0中沒有system-config-kickstart包,所以無法通過工具生成ks檔案,需要手動生成,例子中root使用者和新建的gongjh使用者的密碼都為‘`123qwe’

如果需要自己額外指定密碼,請使用其它工具進行轉換,例如doveadm命令

cp /root/anaconda-ks.cfg /var/www/html/ks.cfg\t#生成ks.cfg檔案[root@localhost ~]# vim /var/www/html/ks.cfg#version=RHEL8ignoredisk --only-use=sdaautopart --type=lvm# Partition clearing informationclearpart --all\t\t\t#刪除所有分割槽# Use graphical installgraphicalurl --url="http://192.168.2.100/RHEL/"\t\t\t#指定安裝URL# Keyboard layoutskeyboard --vckeymap=cn --xlayouts='cn'# System languagelang zh_CN.UTF-8# Network informationnetwork --bootproto=dhcp --device=ens33 --ipv6=auto --activatenetwork --hostname=localhost.localdomain# Root password\t“`123qwe”\t\t\t#root使用者的密碼"`123qwe"rootpw --iscrypted $6$lYV8xqOfEWbJZ/8Y$YXDve/YNwljyh6BnrMHkKm.18kyUqZkHBpA4DHA/nEhXckJfNPLpclgNcQUS64XQSDZRAdlWzjPsI8sCe1dPo0# X Window System configuration informationxconfig --startxonboot# Run the Setup Agent on first boot#firstboot disable\t\t#初次啟動設定firstboot --disable# System servicesservices --enabled="chronyd"# System timezonetimezone America/New_York --isUtc#Reboot after installation\t#安裝完成後自動重啟reboot# License agreement\t\t#同意授權協議eula --agreed#Add a new user named tyschool password “`123qwe” group whell\t\t\t#普通使用者名稱字為tyschool密碼"`123qwe"user --groups=wheel --name=tyschool --password=$6$GnUoYHa8rYy7XfrK$0OSNtZwn7.mq4mTeEXQvebx8AEKMV7/PYBS0qfLXUUMJFQozCVMGZY3c0gYcfaKhkCDVQAcxCpi01A5f6a9XC. --iscrypted --gecos="tyschool_com_cn"%packages@^graphical-server-environment%end%addon com_redhat_kdump --disable --reserve-mb='auto'%end%anacondapwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notemptypwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyokpwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty%end

Step 7 修改⽂件許可權,啟動http服務

[root@localhost ~]# chmod a+r /var/www/html/ks.cfg[root@localhost ~]# systemctl start httpd[root@localhost ~]# systemctl start httpd[root@localhost ~]# systemctl status httpd● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since Sun 2019-12-01 22:00:58 EST; 10s ago Docs: man:httpd.service(8) Main PID: 33976 (httpd) Status: "Running, listening on: port 80" Tasks: 213 (limit: 50687) Memory: 40.4M CGroup: /system.slice/httpd.service ├─33976 /usr/sbin/httpd -DFOREGROUND ├─33977 /usr/sbin/httpd -DFOREGROUND ├─33978 /usr/sbin/httpd -DFOREGROUND ├─33979 /usr/sbin/httpd -DFOREGROUND └─33980 /usr/sbin/httpd -DFOREGROUND12月 01 22:00:58 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...12月 01 22:00:58 localhost.localdomain httpd[33976]: AH00558: httpd: Could not reliably determine the server's fully qualified>12月 01 22:00:58 localhost.localdomain httpd[33976]: Server configured, listening on: port 8012月 01 22:00:58 localhost.localdomain systemd[1]: Started The Apache HTTP Server.[root@localhost ~]# netstat -antlp | grep :80tcp6 0 0 :::80 :::* LISTEN 33976/httpd 

Step 8 測試

選擇⽹絡啟動

獲取IP和相關⽂件

開啟安裝程序

安裝完成後⾃動重啟

最新評論
  • BSA-TRITC(10mg/ml) TRITC-BSA 牛血清白蛋白改性標記羅丹明
  • 7 大類卷積神經網路(CNN)創新綜述