Centos 6.* 下搭建pxe+dhcp+nfs+kickstart

來源:互聯網
上載者:User

標籤:

一、Linux自動安裝系統詳細工作過程。 二、配置PXE網路安裝的說明及步驟順序1)、配置NFS伺服器,用與存放Linux系統的安裝檔案。 2)、配置Tftp伺服器,用於提供用戶端Pxe引導所必須的檔案3)、配置DHCP用於給用戶端提供IP地址及其它資訊4)、配置Kickstart,用於自動應答安裝5)、使用PXE功能引導客戶機 三、安裝NFS服務及設定檔共用目錄        把安裝介質從光碟機或ISO檔案複寫服務 (FRS)器上的一個目錄,可以使用各種網路通訊協定訪問它,比如HTTP,FTP和NFS。1)、建立共用目錄,並將光碟片內容拷貝到共用目錄中。[[email protected] ~]# mkdir /data/sys -p[[email protected] ~]# rsync -avz -P /mnt /data/sys/2)、安裝配置NFS,將共用目錄發布出去[[email protected] ~]rpm -qa | grep nfs[[email protected] ~]yum -y install nfs-utils portmap[[email protected] ~]echo "/data/sys/ 192.168.0.0/24(ro,sync)" >> /etc/exports[[email protected] ~]cat /etc/exports /data/sys/ 192.168.0.0/24(ro,sync)3)、NFS、Rpcbind服務啟動[[email protected] ~]# /etc/init.d/rpcbind start
Starting rpcbind:                                          [  OK  ][[email protected] ~]# /etc/init.d/nfs start
Starting NFS services:                                        [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]4)、及開機自動啟動[[email protected] ~]#chkconfig nfs on[[email protected] ~]#chkconfig rpcbind on[[email protected] ~]#chkconfig --list nfs[[email protected] ~]#chkconfig --list rpcbind5)、檢查目錄/data/sys是否被正確共用[[email protected] ~]#[[email protected] ~]# showmount -e 127.0.0.1
Export list for 127.0.0.1:
/data/sys 192.168.0.0/24 四、安裝配置Tftp服務        在Pxe安裝過程中,客戶機通過Tftp協議從Tftp服務下載引導檔案並執行。1)、安裝Tftp服務提示:如果在Yum工具執行前進行下述處理,可以把Yum安裝的Rpm包保留下來備用。[[email protected] ~]# sed -i ‘s#keepcache=0#keepcache=1#g‘ /etc/yum.conf[[email protected] ~]#tree /var/cache/yum/base/[[email protected] ~]# yum -y install tftp-server* 2)、配置tftp服務        tftp服務由xinetd服務管理。編輯"/etc/xinetd.d/tftp"檔案,將檔案中的disable的參數值由yes改為no.[[email protected] ~]#cat /etc/xinetd.d/tftp # default: off# description: The tftp server serves files using the trivial file transfer \#       protocol.  The tftp protocol is often used to boot diskless \#       workstations, download configuration files to network-aware printers, \#       and to start the installation process for some operating systems.service tftp{        socket_type             = dgram        protocol                = udp        wait                    = yes        user                    = root        server                  = /usr/sbin/in.tftpd        server_args             = -s /var/lib/tftpboot    這裡是預設ftfp路徑,一會要把開機檔案放在這裡。        disable                 = yes    將yes改為no        per_source              = 11        cps                     = 100 2        flags                   = IPv4}    從設定檔,可以看出,/tftpboot預設為TFTP伺服器的根目錄位置,配置完成後重啟xinetd服務,使TFTP伺服器生效。[[email protected] ~]#/etc/init.d/xinetd startStarting xinetd:                                           [  OK  ]3)、PXE引導配置(bootstrap)    pxe開機映像檔案由syslinux軟體包提供,centos linux光碟片中已提供,你也可以到syslinux首頁,http://syslinux.zytor.com/下載rpm來安裝。    我們只要安裝了syslinux(預設已安裝),就會產生一個pxelinux.0,將pxelinux.0這個檔案複製到“/tftpboot”目錄即可:如果沒有,可以配置好Yum源,來安裝一下:yum -y install syslinux[[email protected] ~]#cp /usr/share/syslinux/pxelinux.0 /tftpboot[[email protected] ~]# ll /tftpboot/
total 28
-rw-r--r-- 1 root root 26828 Apr 13 21:06 pxelinux.04)、用於網路啟動的核心檔案    將Centos安裝光碟片目錄中的”images/pxeboot/{Vmlinux,initrd.img}“開機檔案複製到某個安裝目錄,比如:”/tftpboot“[[email protected] ~]#cp /mnt/images/pxeboot/initrd.img /tftpboot[[email protected] ~]#cp /mnt/images/pxeboot/vmlinuz /tftpboot[[email protected] ~]#lsinitrd.img  TRANS.TBL  vmlinuz[[email protected] tftpboot]# mkdir pxelinux.cfg
[[email protected] tftpboot]# ls
initrd.img  pxelinux.0  pxelinux.cfg  vmlinuz[[email protected] ~]#cp /data/sys/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default[[email protected] ~]#cat /tftpboot/pxelinux.cfg/defaultdefault local    這裡選擇none為預設安裝方式,文本方式為text圖形方式為default linuxprompt 1    顯示“boot:”提示符。為‘0’時則不提示,將直接啟動default參數中指定的內容。timeout 999999    使用者輸入之前的逾時時間,單位為1/10秒,顯示某個檔案的內容,注意檔案的路徑。預設是在/tftpboot目錄。也可以類似這樣“install /rhel-inst/boot.msg”這樣的,路徑+檔案名稱display boot.msgF1 boot.msg    按下‘F1’這樣的鍵後顯示的檔案。注意路徑。預設是/tftpboot。註:syslinux官方網站上說,目前只能使用F1-F10F2 options.msgF3 general.msgF4 param.msgF5 rescue.msglabel linux  kernel vmlinuz  append initrd=initrd.imglabel text  kernel vmlinuz  append ks=nfs:192.168.2.253:/data/sys/kickstart/ks.cfg initrd=initrd.img text    這裡的nfs:192.168.2.253:/data/sys/kickstart/ks.cfg 為ks.cfg所在的NFS共用路徑,後面配置kisckstart時要注意把ks.cfg放到/data/sys/kickstart/ks.cfglabel ks  kernel vmlinuz  append ks initrd=initrd.imglabel local  localboot 1label memtest86  kernel memtest  append - #‘label’指定你在‘boot:‘提示符下輸入的關鍵字。如:boot:linux[ENTER]#這個會啟動‘label linux‘下標記的Kernel和Initrd.img檔案。#這裡還定義了其它幾個關鍵字:#boot:text#boot:ks#Kernet參數指定要啟動的核心。同樣要注意路徑,預設是/tftpboot目錄。#append指定追加給核心的參數,能夠在Gurb裡使用的追加給核心的參數,在這裡也都可以用。#使用kickstart安裝。可以在ks參數後直接指定kickstart檔案的位置。特別提示:部署無人值守安裝,如果配置不當有時也會帶來嚴重負面問題,例如:別人的個人電腦或伺服器開機時可能莫名奇妙的直接被安裝了你定義的Linux系統。所以:下面的配置很關鍵:default localprompt 1timeout 999999 五、安裝及配置DHCP服務        在PXE引導安裝過程中,PXE客戶機通過DHCP服務擷取PXE客戶機的IP地址、PXE引導檔案名稱;然後客戶機在通過TFTP協議從TFTP伺服器下載引導檔案並執行,從而啟動系統安裝程式。1)、安裝DHCP軟體包[[email protected] ~]#yum -y install dhcp*2)、配置DHCP    1、修改/etc/dhcpd.conf檔案,指定IP地址等資訊。    2、在/etc/dhcp.conf中增加tftp-server需要推送給用戶端的開機檔案(bootstrap):filename"pxelinux.0";因為tftp的預設目錄是/tftpboot,所以檔案的絕對路徑就是:/tftpboot/pxelinux.0;當然也可以指定為其它路徑。    另外需要指定next-server參數,告訴用戶端在擷取到pxelinux.0檔案之後去哪裡擷取其餘的開機檔案:next-server 192.168.2.253;[[email protected] ~]#vi /etc/dhcpd.conf ddns-update-style none;ignore client-updates;allow booting;allow bootp;default-lease-time 21600;max-lease-time 43200;option routers 192.168.2.254; subnet 192.168.2.0 netmask 255.255.255.0 {        range dynamic-bootp 192.168.2.200 192.168.2.250;        next-server 192.168.2.253;        filename "/data/sys/kickstart/ks.cfg";        next-server 192.168.2.253;        filename "pxelinux.0";}[[email protected] ~]#chkconfig dhcpd on[[email protected] ~]#ps -ef | grep dhcp root     20460     1  0 22:31 ?        00:00:00 /usr/sbin/dhcpdroot     20478 18819  0 22:34 pts/3    00:00:00 grep dhcp 六、Kickstart安裝配置        通常我們在安裝作業系統的過程中,需要大量的和伺服器互動操作,為了減少互動過程,Kickstart就誕生了。使用這種Kickstart,只需要事先定義好一個Kickstart自動應答設定檔Ks.cfg(通常存放在安裝伺服器上),並讓安裝程式知道該設定檔的位置,在安裝過程中安裝程式就可以自己從該中讀取安裝配置,這樣就避免了在安裝過程中多次人機互動,從而實現無人值守的自動化安裝。        產生Kickstart設定檔的三種方法:        方法1、每安裝好一台Linux機器,Linux安裝程式都會建立一個Kickstart設定檔,記錄你的真實安裝配置。如果你希望實現和某系統類別似的安裝,可以基於該系統的Kickstart設定檔來產生自己的Kickstart設定檔。        方法2、Linux提供了一個圖形化的Kickstart組態工具。在任何一個安裝好的Linux系統運行該工具,就可以很容易地建立自己的Kickstart設定檔。Kickstart組態工具命令為redhat-config-kickstart或system-config-kickstart。        方法3、閱讀Kickstart設定檔的手冊。用任何一個文字編輯器都可以建立自己的Kickstart設定檔。[[email protected] ~]#mv anaconda-ks.cfg kickstart/ks.cfg[[email protected] ~]#cd kickstart/

[[email protected] kickstart]# ls

 

ks.cfg

[[email protected] ~]#vi ks.cfg# Kickstart file automatically generated by anaconda. install    表示安裝系統而不是升級系統nfs --server=192.168.2.253 --dir=/data/sys        Nfs的安裝方式,--Server為Nfs的IP,--Dir為Nfs的共用路徑。也可以使用Http方式,如下:Url --Url=Http://192.168.2.253/sys/centos5.8   key --skiplang zh_CN.UTF-8或en_US.UTF8    字元集設定keyboard us    鍵盤配置network --device eth0 --bootproto dhcp --hostname localhost.com    網路設定,Eth0為第一塊網卡,結尾localhost.comnetwork --device eth1 --onboot no --bootproto dhcp    也可以同時對第二、三塊網卡設定地址。rootpw    123456    root使用者密碼,可以使用明文,安裝完成變成加密狀態。如果使用加密的方式見下#rootpw --iscrypted $1$Mbhhwc.n$9/X3ksgY6PTg8BP4wyWe71authconfig --enableshadow --enablemd5    系統認證資訊firewall --disabled    關閉防火牆    enforcing 開啟selinux --disabled     關閉防火牆timezone Asia/Shanghai    系統系統時間bootloader --location=mbr --driveorder=sda    系統引導相關配置firstboot    --disabled    禁止安裝後的agent設定loging    --level=info    設定記錄層級zerombr    清除Mbr引導資訊 ###############分區#####################clearpart --all --drives=sda    清除sda上的所有分區。如果sda不存在可能報錯,還可以用下面的用法#clearpart --linuxclearpart --all#part /boot --fstype ext3 --size=100 --ondisk=sda#part pv.2 --size=0 --grow --ondisk=sda#volgroup VolGroup00 --pesize=32768 pv.2#logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow#logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=1000 --grow --maxsize=50240##################安裝包選擇##############%packages@admin-tools@base@chinese-support@core@dialup@editors@gnome-desktop@graphical-internet@graphics@java@legacy-software-support@printing@sound-and-video@text-internet@base-xkexec-toolsiscsi-initiator-utilsfipscheckdevice-mapper-multipathsgpioemacslibsane-hpaioxorg-x11-utilsxorg-x11-server-Xnest      

Centos 6.* 下搭建pxe+dhcp+nfs+kickstart

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.