做爲中小公司的運維,常常會遇到一些機械式的重複工做。例如:有時公司同時上線幾十甚至上百臺服務器,並且須要咱們在短期內完成系統安裝。
常規的安裝方法以下所示:
① 光盤安裝系統:
一個的服務器 DVD 內置光驅百千塊,百臺服務器都配光驅就浪費了,由於一臺服務器也就開始裝系統能用的上,之後用的機會屈指可數。用 USB 外置光驅,插來插去也是十分繁瑣。
② U盤安裝系統:
仍是一樣的問題,要一臺一臺服務器插 U 盤,重複而又繁瑣。
③ 網絡安裝系統(ftp,http,nfs) :
這個方法不錯,只要服務器能聯網就能夠安裝系統了,可是還須要一臺臺服務器去敲鍵盤點鼠標。
高逼格的安裝方法:
① Kickstart
② Cobbler
什麼是PXE:
① PXE,全名 Pre-boot Execution Environment,預啓動執行環境;
② 經過網絡接口啓動計算機,不依賴本地存儲設備(如硬盤)或本地已安裝的操做系統;
③ 由 Intel 和 Systemsoft 公司於 1999 年 9 月 20 日公佈的技術;
④ Client/Server 的工做模式;
⑤ PXE 客戶端會調用網際協議(IP)、用戶數據報協議(UDP)、動態主機設定協議(DHCP)、小型文件傳輸協議(TFTP)等網絡協議;
⑥ PXE 客戶端(Client)這個術語是指機器在 PXE 啓動過程當中的角色。一個 PXE 客戶端可使一臺服務器、筆記本電腦或者其餘裝有 PXE 啓動代碼的機器(咱們電腦的網卡)。
嚴格來講,PXE 並非一種安裝方式,而是一種引導方式。進行 PXE 安裝的必要條件是在要安裝的計算機中必須包含一個 PXE 支持的網卡(NIC),即網卡中必需要有 PXE Client。PXE(Pre-boot Execution Environment) 協議可使計算機經過網絡啓動。此協議分爲 Client 端和 Server 端,而PXE Client 則在網卡的 ROM 中。當計算機引導時,BIOS 把 PXE Client 調入內存中執行,而後由PXE Client 將放置在遠端的文件經過網絡下載到本地運行。運行 PXE 協議須要設置 DHCP 服務器和TFTP 服務器。DHCP 服務器會給 PXE Client (將要安裝系統的主機) 分配一個 IP 地址,因爲是給PXE Client 分配 IP 地址,因此在配置 DHCP 服務器時須要增長 PXE 設置。此外,在 PXE Client的 ROM 中,已經存在了 TFTP Client,那麼它就能夠經過 TFTP 協議到 TFTP Server 上下載所需的文件了。
什麼是 KickStart:
KickStart 是一種無人值守的安裝方法。它的工做原理是在安裝過程當中記錄典型的須要人工干預填寫的各類參數,並生成一個名爲 ks.cfg 的文件。若是在安裝過程當中(不僅侷限於生成 KickStart 安裝文件的機器)出現要填寫參數的狀況,安裝程序首選會去查找 KickStart 生成的文件,若是找到合適的參數,就採用所找到的參數;若是沒有找到合適的參數,便須要安裝着手工干預了。因此若是KickStart 文件涵蓋了安裝過程當中可能出現的全部須要填寫的參數,那麼安裝者徹底能夠只告訴安裝程序從何處取 ks.cfg 文件,而後就去忙本身的事情。等安裝完畢,安裝程序會根據 ks.cfg 中的設置重啓系統,並結束安裝。
什麼是 Cobbler:
Cobbler 集中和簡化了經過網絡安裝操做系統須要使用到的 DHCP/TFTP 和 DNS 服務的配置。Cobbler 不只有一個命令行界面,還提供了一個 Web 界面,大大下降了使用者的入門水平。Cobbler 內置了一個輕量級配置管理系統,但它也支持和其餘配置管理系統集成,如 Puppet,暫時還不支持 SaltStack。
簡單來講,Cobbler 是對 Kickstart 的封裝,簡化安裝步驟、使用流程,下降使用者的門檻。
PXE + Kickstart 無人值守安裝操做系統完整過程:
① PXE Client 向 DHCP 發送請求:
PXE Client 從本身的 PXE 網卡啓動,經過 PXE BootROM(自啓動芯片)會以 UDP(簡單用戶數據報協議)發送一個廣播請求,向本網絡中的 DHCP 服務器索取 IP。
② DHCP服務器提供信息:
DHCP服務器收到客戶端的請求,驗證是否來至合法的 PXE Client 的請求,驗證經過它將給客戶端一個"提供"響應,這個"提供"響應中包含了爲客戶端分配的 IP 地址、pxelinux 啓動程序 (TFTP) 位置,以及配置文件所在位置。
③ PXE客戶端請求下載啓動文件:
客戶端收到服務器的"迴應"後,會迴應一個幀,以請求傳送啓動所需文件。這些啓動文件包括:pxelinux.0、pxelinux.cfg/default、vmlinuz、initrd.img 等文件。
④ Boot Server響應客戶端請求並傳送文件:
當服務器收到客戶端的請求後,他們之間以後將有更多的信息在客戶端與服務器之間做應答, 用以決定啓動參數。BootROM 由 TFTP 通信協議從 Boot Server 下載啓動安裝程序所必須的文件(pxelinux.0、pxelinux.cfg/default)。default 文件下載完成後,會根據該文件中定義的引導順序,啓動Linux 安裝程序的引導內核。
⑤ 請求下載自動應答文件:
客戶端經過 pxelinux.cfg/default 文件成功的引導 Linux 安裝內核後,安裝程序首先必須肯定你經過什麼安裝介質來安裝 linux,若是是經過網絡安裝 (NFS, FTP, HTTP),則會在這個時候初始化網絡,並定位安裝源位置。接着會讀取 default 文件中指定的自動應答文件 ks.cfg 所在位置,根據該位置請求下載該文件。
提示:這裏有個問題,在第2步和第5步初始化2次網絡了,這是因爲PXE獲取的是安裝用的內核以及安裝程序等,而安裝程序要獲取的是安裝系統所需的二進制包以及配置文件。所以PXE模塊和安裝程序是相對獨立的,PXE的網絡配置並不能傳遞給安裝程序,從而進行兩次獲取IP地址過程,但IP地址在DHCP的租期內是同樣的。
⑥ 客戶端安裝操做系統:
將 ks.cfg 文件下載回來後,經過該文件找到 OS Server,並按照該文件的配置請求下載安裝過程須要的軟件包。OS Server和客戶端創建鏈接後,將開始傳輸軟件包,客戶端將開始安裝操做系統。安裝完成後,將提示從新引導計算機。
系統環境準備:html
[root@nfs-server ~]# cat //etc/redhat-release CentOS release 6.8 (Final) [root@nfs-server ~]# uname -r 2.6.32-642.el6.x86_64 [root@nfs-server ~]# getenforce Disabled [root@nfs-server ~]# /etc/init.d/iptables status iptables:未運行防火牆。 [root@nfs-server ~]# hostname -I 192.168.24.130 [root@nfs-server ~]# ifconfig eth0|awk -F "[ :]+" 'NR==2 {print $4}' 192.168.24.130
關掉本地默認開啓的 DHCP 服務,避免干擾:python
DHCP 簡介:
DHCP (Dynamic Host Configuration Protocol,動態主機配置協議)一般被應用在大型的局域網絡環境中,主要做用是集中的管理、分配 IP 地址,使網絡環境中的主機動態的得到 IP 地址、網關地址、DNS 服務器地址等信息,並可以提高地址的使用率。
DHCP 工做流程的六個主要步驟:
DHCP 服務安裝配置:linux
[root@centos ~]# yum install dhcp -y [root@centos ~]# rpm -ql dhcp|grep "dhcpd.conf" # 查看配置文件的位置。 /etc/dhcp/dhcpd.conf /usr/share/doc/dhcp-4.1.1/dhcpd-conf-to-ldap /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /usr/share/man/man5/dhcpd.conf.5.gz [root@centos ~]# cat /etc/dhcp/dhcpd.conf # # DHCP Server Configuration file. # see /usr/share/doc/dhcp*/dhcpd.conf.sample # 能夠查看配置文件模板。 # see 'man 5 dhcpd.conf' [root@centos ~]# vim /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample # 查看模板。 [root@centos ~]# vim /etc/dhcp/dhcpd.conf # 編輯配置文件。 [root@centos ~]# cat /etc/dhcp/dhcpd.conf # 內容以下所示。 # # DHCP Server Configuration file. # see /usr/share/doc/dhcp*/dhcpd.conf.sample # see 'man 5 dhcpd.conf' # subnet 192.168.24.0 netmask 255.255.255.0 { range 192.168.24.100 192.168.24.200; # 可分配的 IP 範圍。 option subnet-mask 255.255.255.0; # 子網掩碼。 default-lease-time 21600; # 設置默認的 IP 租用期限。 max-lease-time 43200; # 設置最大的 IP 租用期限。 next-server 192.168.24.130; # 告知客戶端 TFTP 服務的 IP。 filename "/pxelinux.0"; # 告知客戶端從 TFTP 根目錄下載 pxelinux.0 文件。 }
[root@centos ~]# /etc/init.d/dhcpd start # 啓動 DHCP 服務。 Starting dhcpd: [ OK ] [root@centos ~]# netstat -lntup|grep dhcp # 查看 DHCP 服務端口。 udp 0 0 0.0.0.0:67 0.0.0.0:* 1325/dhcpd
提示:
① 原本軟件裝完後都要加入開機自啓動,但這個 Kickstart 系統就不能開機自啓動,並且用完後服務都要關閉,防止將來重啓服務器自動重裝系統了。
② 若是機器數量過多的話,注意 dhcp 服務器的 IP 地址池,不要由於耗盡 IP 而致使dhcpd 服務器沒有 IP 地址 release 的狀況。 web
TFTP 服務簡介:
TFTP(Trivial File Transfer Protocol,簡單文件傳輸協議)是 TCP/IP 協議族中的一個用來在客戶機與服務器之間進行簡單文件傳輸的協議,提供不復雜、開銷不大的文件傳輸協議。端口號爲 69。
TFTP 安裝配置:express
[root@centos ~]# yum -y install tftp-server [root@centos ~]# vim /etc/xinetd.d/tftp 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 }
這裏修改配置文件能夠用一條命令完成:bootstrap
[root@nfs-server ~]# sed -i '14s#yes#no#g' /etc/xinetd.d/tftp [root@centos ~]# /etc/init.d/xinetd start # 啓動服務。 Starting xinetd: [ OK ] [root@centos ~]# netstat -tunlp|grep 69 udp 0 0 0.0.0.0:69 0.0.0.0:* 1821/xinetd
[root@centos ~]# yum -y install httpd [root@centos ~]# sed -i "277i ServerName 127.0.0.1:80" /etc/httpd/conf/httpd.conf [root@centos ~]# /etc/init.d/httpd start Starting httpd: [ OK ] [root@centos ~]# mkdir /var/www/html/CentOS-6.8
此時須要肯定虛擬機已鏈接鏡像文件:
掛載到站點目錄上:vim
[root@centos ~]# mount /dev/cdrom /var/www/html/CentOS-6.8/ mount: block device /dev/sr0 is write-protected, mounting read-only [root@centos ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 7.1G 1.5G 5.3G 21% / tmpfs 491M 0 491M 0% /dev/shm /dev/sda1 190M 33M 147M 19% /boot /dev/sr0 3.7G 3.7G 0 100% /var/www/html/CentOS-6.8
提示:無論怎麼弄,只要把安裝光盤內容能經過 web 發佈便可。由於是演示,若是複製鏡像就有點浪費時間。但生產環境就必定要複製了,光盤讀取速度有限。
此時,經過訪問 http://192.168.132.151/CentOS-6.8/ 可獲得以下界面:centos
PXE 引導配置(bootstrap):
Syslinux 是一個功能強大的引導加載程序,並且兼容各類介質。Syslinux 是一個小型的 linux 操做系統,它的目的是簡化首次安裝 linux 的時間,並創建維護或其餘特殊用途的啓動盤。若是沒有找到 pxelinux.0 這個文件,能夠安裝一下。bash
[root@centos ~]# yum -y install syslinux [root@centos ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ # 複製啓動菜單程序文件。 [root@centos ~]# cp -a /var/www/html/CentOS-6.8/isolinux/* /var/lib/tftpboot/ [root@centos ~]# ls /var/lib/tftpboot/ # 服務器啓動菜單目錄。 boot.cat initrd.img memtest TRANS.TBL boot.msg isolinux.bin pxelinux.0 vesamenu.c32 grub.conf isolinux.cfg splash.jpg vmlinuz [root@centos ~]# mkdir -p /var/lib/tftpboot/pxelinux.cfg # 新建目錄存放客戶端配置文件。 [root@centos ~]# cp /var/www/html/CentOS-6.8/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
PXE 配置文件 default 解析:
配合虛擬機演示瞭解 default 文件(新建一個虛擬機,注意內存至少給 1G),打開電源後顯示以下界面:
接下來的畫面就是咱們熟悉的界面,輸入ESC能夠進入命令行界面:服務器
[root@centos ~]# cat /var/lib/tftpboot/pxelinux.cfg/default # 查看 default 文件。 default vesamenu.c32 # 默認加載一個菜單。 #prompt 1 # 開啓會顯示命令行 'boot: '提示符。prompt 值爲 0 時則不提示,將會直接啓動 'default' 參數中指定的內容。 timeout 600 # timeout 時間是引導時等待用戶手動選擇的時間,設爲 1可直接引導,單位爲 1/10 秒。 display boot.msg menu background splash.jpg # 菜單背景圖片、標題、顏色。 menu title Welcome to CentOS 6.8! menu color border 0 #ffffffff #00000000 menu color sel 7 #ffffffff #ff000000 menu color title 0 #ffffffff #00000000 menu color tabmsg 0 #ffffffff #00000000 menu color unsel 0 #ffffffff #00000000 menu color hotsel 0 #ff000000 #ffffffff menu color hotkey 7 #ffffffff #ff000000 menu color scrollbar 0 #ffffffff #00000000 # label 指定在 boot: 提示符下輸入的關鍵字,好比 boot:linux[ENTER],這個會啓動 label linux 下標記的 kernel 和 initrd.img 文件。 label linux # 一個標籤就是前面圖片的一行選項。 menu label ^Install or upgrade an existing system menu default kernel vmlinuz # 指定要啓動的內核。一樣要注意路徑,默認是/tftpboot目錄。 append initrd=initrd.img # 指定追加給內核的參數,initrd.img 是一個最小的 linux 系統。 label vesa menu label Install system with ^basic video driver kernel vmlinuz append initrd=initrd.img nomodeset label rescue menu label ^Rescue installed system kernel vmlinuz append initrd=initrd.img rescue label local menu label Boot from ^local drive localboot 0xffff label memtest86 menu label ^Memory test kernel memtest append -
預熱之手動網絡安裝:
① 新建一臺空白虛擬機,也不要掛載ISO鏡像,打開電源,選擇第一個選項。
② 選擇英語;
③ 選擇美式鍵盤;
④ 選擇 URL 安裝;
⑤ 輸入 http://192.168.24.130/CentOS-6.8/ 地址:
⑥ 出現此頁面後面的步驟就和光盤安裝同樣了:
一般,咱們在安裝操做系統的過程當中,須要大量的和服務器交互操做,爲了減小這個交互過程,Kickstart 就誕生了。使用這種 Kickstart,只需事先定義好一個 Kickstart 自動應答配置文件 ks.cfg(一般存放在安裝服務器上),並讓安裝程序知道該配置文件的位置,在安裝過程當中安裝程序就能夠本身從該文件中讀取安裝配置,這樣就避免了在安裝過程當中屢次的人機交互,從而實現無人值守的自動化安裝。
生成 Kickstart 配置文件的三種方法:
① 每安裝好一臺 Centos 機器,Centos 安裝程序都會建立一個 kickstart 配置文件,記錄你的真實安裝配置。若是你但願實現和某系統相似的安裝,能夠基於該系統的 kickstart 配置文件來生成你本身的kickstart 配置文件(生成的文件名字叫 anaconda-ks.cfg,位於 /root/anaconda-ks.cfg)。
② Centos 提供了一個圖形化的 kickstart 配置工具。在任何一個安裝好的 Linux 系統上運行該工具,就能夠很容易地建立你本身的 kickstart 配置文件。kickstart 配置工具命令爲 redhat-config-kickstart(RHEL3)或 system-config-kickstart(RHEL4,RHEL5)。網上有不少用 CentOS 桌面版生成 ks文件的文章,若是有現成的系統就沒什麼可說。但沒有現成的,也沒有必要去用桌面版,命令行也很簡單。
③ 閱讀 kickstart 配置文件的手冊。用任何一個文本編輯器均可以建立你本身的 kickstart 配置文件。
查看anaconda-ks.cfg 文件:
[root@centos ~]# cat anaconda-ks.cfg # Kickstart file automatically generated by anaconda. #version=DEVEL install # 告知安裝程序,這是一次全新安裝,而不是升級 upgrade。 cdrom lang en_US.UTF-8 keyboard us network --onboot no --device eth0 --bootproto dhcp --noipv6 rootpw --iscrypted $6$IgStnuEDwKSvfbm8$nCvzA6Lt/79248rswzLTAudxVb3JhwUpBid7qcoFeduQ8iphWxcu1tom.rdH5ynBGhc0KhF/h5yeAuFL7iReS0 firewall --service=ssh authconfig --enableshadow --passalgo=sha512 selinux --enforcing timezone Asia/Shanghai bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet" # The following is the partition information you requested # Note that any partitions you deleted are not expressed # here so unless you clear all partitions first, this is # not guaranteed to work #clearpart --none #part /boot --fstype=ext4 --asprimary --size=200 #part swap --asprimary --size=512 #part / --fstype=ext4 --grow --asprimary --size=200 repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100 %packages @base @compat-libraries @core @debugging @development @server-policy @workstation-policy python-dmidecode sgpio device-mapper-persistent-data systemtap-client %end
詳解 ks.cfg 文件:
官網文檔 :
CentOS6 : https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Installation_Guide/s1-kickstart2-options.html
提示:官網自帶中文版,選一下語言便可。
該文件組成大體分爲 3 段:
① 命令段 :
鍵盤類型,語言,安裝方式等系統的配置,有必選項和可選項,若是缺乏某項必選項,安裝時會中斷並提示用戶選擇此項的選項。
② 軟件包段 :
%packages
@groupname: 指定安裝的包組。
package_name: 指定安裝的包。
-package_name:指定不安裝的包。
在安裝過程當中默認安裝的軟件包,安裝軟件時會自動分析依賴關係。
③ 腳本段(可選) :
%pre:安裝系統前執行的命令或腳本 (因爲只依賴於啓動鏡像,支持的命令不多)。
%post:安裝系統後執行的命令或腳本 (基本支持全部命令)。
編寫 ks.cfg 文件:
[root@centos ~]# grub-crypt # 先生成一個密碼備用。 Password: 123456 Retype password: 123456 $6$uUftrH0Z80ZruqFa$AWKZm9TeFwzabt/IKF25hgxyfYYYGuDTxL.ev4ZV21irLhpgcH11VWe822w995Lf4TbktAGhELTx1dU32LkYM. [root@centos ~]# vim /var/www/html/ks_config/CentOS-6.8-ks.cfg [root@centos ~]# cat /var/www/html/ks_config/CentOS-6.8-ks.cfg # Kickstart Configurator for CentOS 6.7 by yao zhang install url --url="http://192.168.132.151/CentOS-6.8/" text lang en_US.UTF-8 keyboard us zerombr bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet" network --bootproto=dhcp --device=eth0 --onboot=yes --noipv6 --hostname=CentOS6 timezone --utc Asia/Shanghai authconfig --enableshadow --passalgo=sha512 rootpw --iscrypted $6$uUftrH0Z80ZruqFa$AWKZm9TeFwzabt/IKF25hgxyfYYYGuDTxL.ev4ZV21irLhpgcH11VWe822w995Lf4TbktAGhELTx1dU32LkYM. clearpart --all --initlabel part /boot --fstype=ext4 --asprimary --size=200 part swap --size=1024 part / --fstype=ext4 --grow --asprimary --size=200 firstboot --disable selinux --disabled firewall --disabled logging --level=info reboot %packages @base @compat-libraries @debugging @development tree nmap sysstat lrzsz dos2unix telnet %post wget -O /tmp/optimization.sh http://192.168.136.151/ks_config/optimization.sh &>/dev/null /bin/sh /tmp/optimization.sh %end
開機優化腳本:
[root@centos ~]# vim /var/www/html/ks_config/optimization.sh [root@centos ~]# cat /var/www/html/ks_config/optimization.sh #!/bin/bash ############################################################## # File Name: /var/www/html/ks_config/optimization.sh # Version: V1.0 # Author: yao zhang # Organization: www.zyops.com # Created Time : 2015-12-03 15:23:08 # Description: Linux system initialization ############################################################## . /etc/init.d/functions Ip=10.0.0.7 Port=80 ConfigDir=ks_config # Judge Http server is ok? PortNum=`nmap $Ip -p $Port 2>/dev/null|grep open|wc -l` [ $PortNum -lt 1 ] && { echo "Http server is bad!" exit 1 } # Defined result function function Msg(){ if [ $? -eq 0 ];then action "$1" /bin/true else action "$1" /bin/false fi } # Defined IP function function ConfigIP(){ Suffix=`ifconfig eth0|awk -F "[ .]+" 'NR==2 {print $6}'` cat >/etc/sysconfig/network-scripts/ifcfg-eth0 <<-END DEVICE=eth0 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=none IPADDR=10.0.0.$Suffix PREFIX=24 GATEWAY=10.0.0.2 DNS1=10.0.0.2 DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME="System eth0" END Msg "config eth0" } # Defined Yum source Functions function yum(){ YumDir=/etc/yum.repos.d [ -f "$YumDir/CentOS-Base.repo" ] && cp $YumDir/CentOS-Base.repo{,.ori} wget -O $YumDir/CentOS-Base.repo http://$Ip:$Port/$ConfigDir/CentOS-Base.repo &>/dev/null &&\ wget -O $YumDir/epel.repo http://$Ip:$Port/$ConfigDir/epel.repo &>/dev/null &&\ Msg "YUM source" } # Defined Hide the system version number Functions function HideVersion(){ [ -f "/etc/issue" ] && >/etc/issue Msg "Hide issue" [ -f "/etc/issue.net" ] && > /etc/issue.net Msg "Hide issue.net" } # Defined OPEN FILES Functions function openfiles(){ [ -f "/etc/security/limits.conf" ] && { echo '* - nofile 65535' >> /etc/security/limits.conf Msg "open files" } } # Defined Kernel parameters Functions function kernel(){ KernelDir=/etc [ -f "$KernelDir/sysctl.conf" ] && /bin/mv $KernelDir/sysctl.conf{,.ori} wget -O $KernelDir/sysctl.conf http://$Ip:$Port/$ConfigDir/sysctl.conf &>/dev/null Msg "Kernel config" } # Defined System Startup Services Functions function boot(){ for oldboy in `chkconfig --list|grep "3:on"|awk '{print $1}'|grep -vE "crond|network|rsyslog|sshd|sysstat"` do chkconfig $oldboy off done Msg "BOOT config" } # Defined Time Synchronization Functions function Time(){ echo "#time sync by zhangyao at $(date +%F)" >>/var/spool/cron/root echo '*/5 * * * * /usr/sbin/ntpdate time.nist.gov &>/dev/null' >>/var/spool/cron/root Msg "Time Synchronization" } # Defined main Functions function main(){ ConfigIP yum HideVersion openfiles kernel boot Time } main
整合編輯 default 配置文件:
[root@centos ~]# vim /var/lib/tftpboot/pxelinux.cfg/default [root@centos ~]# cat /var/lib/tftpboot/pxelinux.cfg/default default ks prompt 0 label ks kernel vmlinuz append initrd=initrd.img ks=http://192.168.24.130/ks_config/CentOS-6.8-ks.cfg
打開系統電源,出去喝杯水。過會回來,系統就以經裝好了。
安裝完成後驗證:
[root@CentOS6 ~]# df -h # 自動分區。 Filesystem Size Used Avail Use% Mounted on /dev/sda2 6.6G 1.4G 4.9G 22% / tmpfs 491M 0 491M 0% /dev/shm /dev/sda1 190M 34M 147M 19% /boot
[root@CentOS6 ~]# /etc/init.d/iptables status # 自動優化。 iptables: Firewall is not running. [root@CentOS6 ~]# getenforce # 自動優化。 Disabled
[root@CentOS6 ~]# ifconfig eth0|awk -F "[ :]+" 'NR==2 {print $4}' 192.168.132.153 [root@CentOS6 ~]# chkconfig --list|grep "3:on" # 自動優化。 crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off rsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off sysstat 0:off 1:on 2:on 3:on 4:on 5:on 6:off