服務環境:
[root@localhost ~]# uname -a #服務器必須是圖形頁面的纔可以安裝無人值守 Linux localhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
網絡環境:
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 HWADDR=00:0C:29:A3:38:13 TYPE=Ethernet UUID=c4f52fd7-10a2-4aa4-b1f6-3f093e167d9f ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static IPADDR=192.168.16.18 NETMASK=255.255.255.0 GATEWAY=192.168.16.18
要求:搭建一臺無人值守安裝linux的服務器,使客戶端在無人的情況下能夠自動安裝安裝要求視情況而定,根據要求安裝。
安裝前準備:
[root@localhost ~]# service iptables stop [root@localhost ~]# setenforce 0 setenforce: SELinux is disabled
搭建本地yum源
[root@localhost ~]# vim/etc/yum.repos.d/rhel-source.repo ……………………………………………………….省略部分………………………………………………………………………… baseurl=file:///mnt/sr0 enabled=1 gpgcheck=0 ……………………………………………………….省略部分………………………………………………………………………… [root@localhost ~]# mkdir /mnt/sr0/ [root@localhost ~]# mount /dev/cdrom/mnt/sr0/
安裝vsftpd服務
[root@localhost ~]# yum -y install vsftpd [root@localhost ~]# mkdir /var/ftp/pub/dvd #建立一個共享的文件 [root@localhost ~]# chmod 777/var/ftp/pub/dvd#給這個文件777的權限
安裝tftp
[root@localhost ~]# yum -y install tftptftp-server dhcp syslinux #安裝tftp和tftp-server是爲了有tftp配置文件,有的是安裝tftp有有的是安裝tftp-server有,dhcp服務,syslinux安裝會產生關於內核相關的引導程序 [root@localhost ~]# vi /etc/xinetd.d/tftp ……………………………………….省略部分………………………………………………………………………. server_args = -s/tftpboot #爲了簡單配置把路徑修改的簡單點 disable = no #開啓tftp服務 …………………………………………省略部分………………………………………………………………………… [root@localhost ~]# service xinetd restart #因爲tftp是基於xinetd的服務,所以重啓的時候要重啓xinetd服務 [root@localhost ~]# mkdir /tftpboot #創建tftp服務的文件 [root@localhost ~]# chmod 777 /tftpboot #給個權限
安裝dhcp服務
[root@localhost ~]# yum -y install dhcp [root@localhost ~]# cp/usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf #配置dhcp服務 cp:是否覆蓋"/etc/dhcp/dhcpd.conf"? y [root@localhost ~]# vi /etc/dhcp/dhcpd.conf …………………………………………………省略部分…………………………………………………………………… subnet 192.168.16.0 netmask 255.255.255.0 { range 192.168.16.20 192.168.16.50; #這裏初始IP不能是0,如果是0沒有被佔用導致獲取到0的主機不能找到 option domain-name-servers 192.168.16.11; #DNS option routers 192.168.16.11; #網關 default-lease-time 600; max-lease-time 7200; filename"pxelinux.0"; #指定文件名 next-server192.168.16.11; #指定tftp服務器的位置 } …………………………………………………省略部分…………………………………………………………………… [root@localhost ~]# service dhcpd restart 關閉 dhcpd: [確定] 正在啓動 dhcpd: [確定]
配置共享系統源:
[root@localhost ~]# umount /dev/cdrom #先把已經掛載好的系統盤卸載掉 [root@localhost ~]# mount /dev/cdrom/var/ftp/pub/dvd/ #把系統盤掛載到ftp共享的目錄 mount: block device /dev/sr0 iswrite-protected, mounting read-only [root@localhost ~]# service vsftpd restart [root@localhost ~]# cp/usr/share/syslinux/pxelinux.0 /tftpboot # pxelinux.0是個引導文件 [root@localhost ~]# mkdir/tftpboot/pxelinux.cfg #建立配置默認引導文件 [root@localhost ~]# cp/var/ftp/pub/dvd/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default #把系統的引導文件拷貝到共享目錄下並且必須改名爲default [root@localhost ~]# cd/tftpboot/pxelinux.cfg/ [root@localhost pxelinux.cfg]# ls default [root@localhost pxelinux.cfg]# chmod 644default #爲了不然別人更改給賦予權限 [root@localhost pxelinux.cfg]# cp/var/ftp/pub/dvd/isolinux/* /tftpboot/ #把光盤的引導相關文件都拷貝到tftp的工作目錄裏
啓動相關服務:
[root@localhost ~]# service dhcpd restart #重啓一下服務 關閉 dhcpd: [確定] 正在啓動 dhcpd: [確定] [root@localhost ~]# service vsftpd restart 關閉 vsftpd: [確定] 爲 vsftpd 啓動 vsftpd: [確定] [root@localhost ~]# service xinetd restart 停止 xinetd: [確定] 正在啓動 xinetd: [確定] [root@localhost ~]# chkconfig dhcpd on [root@localhost ~]# chkconfig vsftpd on [root@localhost ~]# chkconfig xinetd on
客戶端測試需要人工干預沒有安裝KickStart:
進入BIOS,
設置Network boot from Intel E1000爲第一啓動,保存啓動系統,進入系統。系統會獲取到IP之後自己進入共享的鏡像。安裝需要手工選擇。測試:
這個需要等待60秒。如果不想等待可以在
/tftpboot/pxelinux.cfg/default修改
#prompt 1
timeout 600 #把600修改小點就可以了
取消不用ks.cfg文件
第一步:選擇語言。第二步,選擇鍵盤方式
第三步:Installation Method,選擇URL ok---ok---ftp://192.168.16.11/pub/dvd/images/install.img ,選擇ok
下面就是安裝光驅的安裝方式安裝。
客戶端無人值守測試:
服務器安裝KickStart
[root@localhost ~]# yum installsystem-config-kickstart.noarch [root@localhost ~]# system-config-kickstart #必須在圖像桌面下運行
基本設置,在引導裝載程序選項裏可以做安裝類型、GRUB選項、安裝選項設置這裏沒有設置
安裝方法
分區信息:如果是新機可以在添加里做分區,如果不是新機要刪除現有分區。網絡配置裏可以設置本機裝機後的IP,也可以用靜態後面的配置根據自己的需要做相應的配置。
軟件包可以感覺自己需要,選擇相應的軟件包。
設置好後選擇文件保存;
把配置的文件保存到root文件夾下:
[root@localhost ~]# ls #可以看到剛剛配置的 anaconda-ks.cfg install.log.syslog 公共的 視頻 文檔 音樂 install.log ks.cfg 模板 圖片 下載 桌面
設置客戶端啓動配置文件
[root@localhost ~]# cp -a ks.cfg /var/ftp/pub/ [root@localhost ~]# vi/tftpboot/pxelinux.cfg/default ……………………………………………………省略部分…………………………………………………………………. label linux menu label ^Install or upgrade an existing system menu default kernel vmlinuz append initrd=initrd.img ks=ftp://192.168.16.18/pub/ks.cfg #指定一下
客戶機直接啓動,BIOS啓動項選擇網卡啓動
如果報錯這個不用管他直接OK
如果設置好安裝類型的話這裏就會直接安裝,我沒有設置所以要選擇
選擇使用所有空間下一步,坐等安裝完成。
如果有出現一下報錯解決方法:
如果出現以上錯誤應該看以下防火牆,還有客戶端的BIOS啓動項,
如果是上面的錯誤建議換個光盤,重新安裝