Kickstart无人值守安装CentOS

前端之家收集整理的这篇文章主要介绍了Kickstart无人值守安装CentOS前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

一、准备工作

[root@kickstart~]#iptables-nL
ChainINPUT(policyACCEPT)
targetprotoptsourcedestination
ChainFORWARD(policyACCEPT)
targetprotoptsourcedestination
ChainOUTPUT(policyACCEPT)
targetprotoptsourcedestination
[root@kickstart~]#getenforce
Disabled
[root@kickstart~]#crontab-l
0****/usr/sbin/ntpdate210.72.145.4464.147.116.229time.nist.gov
[root@kickstart~]#hostname
kickstart.contoso.com

相关服务器及服务说明如下:

角色 IP地址 服务 说明
Kickstart服务器 192.168.49.201 apache,dhcp,tftp,kickstart VMware NAT网络
Centos客户端 192.168.49.4
待安装操作系统,pxe启动

二、安装过程

1、挂载CentOS 6.5系统盘

[root@kickstart~]#mount/dev/sr0/mnt
mount:blockdevice/dev/sr0iswrite-protected,mountingread-only
[root@kickstart~]#mount
/dev/sda3on/typeext4(rw)
procon/proctypeproc(rw)
sysfson/systypesysfs(rw)
devptson/dev/ptstypedevpts(rw,gid=5,mode=620)
tmpfson/dev/shmtypetmpfs(rw)
/dev/sda1on/boottypeext4(rw)
noneon/proc/sys/fs/binfmt_misctypebinfmt_misc(rw)
/dev/sr0on/mnttypeiso9660(ro)

2、安装apache并启动服务

[root@kickstart~]#yum-yinstallhttpd
[root@kickstart~]#rpm-qa|grephttpd
httpd-tools-2.2.15-59.el6.centos.x86_64
httpd-2.2.15-59.el6.centos.x86_64
[root@kickstart~]#/etc/init.d/httpdstart

待服务启动后,将/mnt下的光盘文件拷贝到/var/www/html中去(当然也可以省略这一步,可以配置apache的根目录为/mnt即可,这里为了不去修改apache配置所以添加该步骤):

cp-aR/mnt/*/var/www/html
[root@kickstart~]#ll/var/www/html/
total324
-r--r--r--1rootroot14Nov292013CentOS_BuildTag
dr-xr-xr-x3rootroot4096Nov292013EFI
-r--r--r--1rootroot212Nov282013EULA
-r--r--r--1rootroot18009Nov282013GPL
dr-xr-xr-x3rootroot4096Nov292013images
dr-xr-xr-x2rootroot4096Nov292013isolinux
-rw-r--r--1rootroot1126Jul1401:58ks.cfg
dr-xr-xr-x2rootroot258048Nov292013Packages
-r--r--r--1rootroot1354Nov282013RELEASE-NOTES-en-US.html
dr-xr-xr-x2rootroot4096Nov292013repodata
-r--r--r--1rootroot1706Nov282013RPM-GPG-KEY-CentOS-6
-r--r--r--1rootroot1730Nov282013RPM-GPG-KEY-CentOS-Debug-6
-r--r--r--1rootroot1730Nov282013RPM-GPG-KEY-CentOS-Security-6
-r--r--r--1rootroot1734Nov282013RPM-GPG-KEY-CentOS-Testing-6
-r--r--r--1rootroot3380Nov292013TRANS.TBL

3、安装tftp-server,并启用tftp服务

[root@kickstart~]#yum-yinstalltftp-server
[root@kickstart~]#rpm-qa|greptftp
tftp-server-0.49-8.el6.x86_64
[root@kickstart~]#sed-i'/disable/s/yes/no/'/etc/xinetd.d/tftp
[root@kickstart~]#sed-n'/disable/p'/etc/xinetd.d/tftp
disable=no
[root@kickstart~]#/etc/init.d/xinetdstart
Startingxinetd:[OK]

4、准备pxe启动所需文件

[root@kickstart~]#cp/var/www/html/images/pxeboot/initrd.img/var/lib/tftpboot/
[root@kickstart~]#cp/var/www/html/images/pxeboot/vmlinuz/var/lib/tftpboot/
[root@kickstart~]#cp/var/www/html/isolinux/*.msg/var/lib/tftpboot/
[root@kickstart~]#cp/var/www/html/isolinux/splash.jpg/var/lib/tftpboot/
[root@kickstart~]#cp/var/www/html/isolinux/vesamenu.c32/var/lib/tftpboot/
[root@kickstart~]#mkdir/var/lib/tftpboot/pxelinux.cfg
[root@kickstart~]#cp/var/www/html/isolinux/isolinux.cfg/var/lib/tftpboot/pxelinux.cfg/default

5、安装syslinux并拷贝pxelinux.0文件

[root@kickstart~]#yum-yinstallsyslinux
Loadedplugins:fastestmirror,security
Loadingmirrorspeedsfromcachedhostfile
SettingupInstallProcess
ResolvingDependencies
-->Runningtransactioncheck
--->Packagesyslinux.x86_640:4.04-3.el6willbeinstalled
-->ProcessingDependency:syslinux-nonlinuxforpackage:syslinux-4.04-3.el6.x86_64
-->ProcessingDependency:mtoolsforpackage:syslinux-4.04-3.el6.x86_64
-->Runningtransactioncheck
--->Packagemtools.x86_640:4.0.12-1.el6willbeinstalled
--->Packagesyslinux-nonlinux.noarch0:4.04-3.el6willbeinstalled
-->FinishedDependencyResolution
DependenciesResolved
===========================================================================================
PackageArchVersionRepositorySize
===========================================================================================
Installing:
syslinuxx86_644.04-3.el6base346k
Installingfordependencies:
mtoolsx86_644.0.12-1.el6base194k
syslinux-nonlinuxnoarch4.04-3.el6base584k
TransactionSummary
===========================================================================================
Install3Package(s)
Totaldownloadsize:1.1M
Installedsize:2.5M
DownloadingPackages:
(1/3):mtools-4.0.12-1.el6.x86_64.rpm|194kB00:00
(2/3):syslinux-4.04-3.el6.x86_64.rpm|346kB00:00
(3/3):syslinux-nonlinux-4.04-3.el6.noarch.rpm|584kB00:00
-------------------------------------------------------------------------------------------
Total1.1MB/s|1.1MB00:01
Runningrpm_check_debug
RunningTransactionTest
TransactionTestSucceeded
RunningTransaction
Installing:mtools-4.0.12-1.el6.x86_641/3
Installing:syslinux-nonlinux-4.04-3.el6.noarch2/3
Installing:syslinux-4.04-3.el6.x86_643/3
Verifying:syslinux-4.04-3.el6.x86_641/3
Verifying:syslinux-nonlinux-4.04-3.el6.noarch2/3
Verifying:mtools-4.0.12-1.el6.x86_643/3
Installed:
syslinux.x86_640:4.04-3.el6
DependencyInstalled:
mtools.x86_640:4.0.12-1.el6syslinux-nonlinux.noarch0:4.04-3.el6
Complete!
[root@kickstart~]#rpm-qlsyslinux-nonlinux
/usr/share/syslinux/altmbr.bin
/usr/share/syslinux/altmbr_c.bin
/usr/share/syslinux/altmbr_f.bin
/usr/share/syslinux/cat.c32
/usr/share/syslinux/chain.c32
/usr/share/syslinux/cmd.c32
/usr/share/syslinux/config.c32
/usr/share/syslinux/cpuid.c32
/usr/share/syslinux/cpuidtest.c32
/usr/share/syslinux/disk.c32
/usr/share/syslinux/dmitest.c32
/usr/share/syslinux/elf.c32
/usr/share/syslinux/ethersel.c32
/usr/share/syslinux/gfxboot.c32
/usr/share/syslinux/gptmbr.bin
/usr/share/syslinux/gptmbr_c.bin
/usr/share/syslinux/gptmbr_f.bin
/usr/share/syslinux/gpxecmd.c32
/usr/share/syslinux/gpxelinux.0
/usr/share/syslinux/gpxelinuxk.0
/usr/share/syslinux/hdt.c32
/usr/share/syslinux/host.c32
/usr/share/syslinux/ifcpu.c32
/usr/share/syslinux/ifcpu64.c32
/usr/share/syslinux/ifplop.c32
/usr/share/syslinux/int18.com
/usr/share/syslinux/isohdpfx.bin
/usr/share/syslinux/isohdpfx_c.bin
/usr/share/syslinux/isohdpfx_f.bin
/usr/share/syslinux/isohdppx.bin
/usr/share/syslinux/isohdppx_c.bin
/usr/share/syslinux/isohdppx_f.bin
/usr/share/syslinux/isolinux-debug.bin
/usr/share/syslinux/isolinux.bin
/usr/share/syslinux/kbdmap.c32
/usr/share/syslinux/linux.c32
/usr/share/syslinux/ls.c32
/usr/share/syslinux/lua.c32
/usr/share/syslinux/mboot.c32
/usr/share/syslinux/mbr.bin
/usr/share/syslinux/mbr_c.bin
/usr/share/syslinux/mbr_f.bin
/usr/share/syslinux/memdisk
/usr/share/syslinux/memdump.com
/usr/share/syslinux/meminfo.c32
/usr/share/syslinux/menu.c32
/usr/share/syslinux/pcitest.c32
/usr/share/syslinux/pmload.c32
/usr/share/syslinux/poweroff.com
/usr/share/syslinux/pwd.c32
/usr/share/syslinux/pxechain.com
/usr/share/syslinux/pxelinux.0
/usr/share/syslinux/reboot.c32
/usr/share/syslinux/rosh.c32
/usr/share/syslinux/sanboot.c32
/usr/share/syslinux/sdi.c32
/usr/share/syslinux/sysdump.c32
/usr/share/syslinux/syslinux.com
/usr/share/syslinux/syslinux.exe
/usr/share/syslinux/syslinux64.exe
/usr/share/syslinux/ver.com
/usr/share/syslinux/vesainfo.c32
/usr/share/syslinux/vesamenu.c32
/usr/share/syslinux/vpdtest.c32
/usr/share/syslinux/whichsys.c32
[root@kickstart~]#cp/usr/share/syslinux/pxelinux.0/var/lib/tftpboot/

5、安装dhcp并启动服务

[root@kickstart~]#yum-yinstalldhcp
[root@kickstart~]#vi/etc/dhcp/dhcpd.conf
[root@kickstart~]#cat/etc/dhcp/dhcpd.conf
#
#DHCPServerConfigurationfile.
#see/usr/share/doc/dhcp*/dhcpd.conf.sample
#see'man5dhcpd.conf'
#
ddns-update-styleinterim;#设置DHCP服务器模式
ignoreclient-updates;#禁止客户端更新
log-facilitylocal7;#使用rsyslog记录日志
subnet192.168.49.0netmask255.255.255.0{
range192.168.49.3192.168.49.30;#地址池
optionrouters192.168.49.2;#网关地址
optionsubnet-mask255.255.255.0;#子网掩码
optiondomain-name-servers192.168.49.2;#设置DNS
optiondomain-name"contoso.com";#域名搜索列表
default-lease-time600;#默认租约期限(单位秒)
max-lease-time7200;#最大租约期限(单位秒)
next-server192.168.49.201;#下一个访问的服务器地址,tftp服务器地址
filename"pxelinux.0";#在next-server上需要下载的文件
}
[root@kickstart~]#servicedhcpdconfigtest
Syntax:OK
[root@kickstart~]#dhcpd
InternetSystemsConsortiumDHCPServer4.1.1-P1
Copyright2004-2010InternetSystemsConsortium.
Allrightsreserved.
Forinfo,pleasevisithttps://www.isc.org/software/dhcp/
NotsearchingLDAPsinceldap-server,ldap-portandldap-base-dnwerenotspecifiedintheconfigfile
Wrote0leasestoleasesfile.
ListeningonLPF/eth0/00:0c:29:c1:d4:3d/192.168.49.0/24
SendingonLPF/eth0/00:0c:29:c1:d4:3d/192.168.49.0/24
SendingonSocket/fallback/fallback-net
[root@kickstart~]#/etc/init.d/dhcpdstart
[root@kickstart~]#/etc/init.d/dhcpdstatus
dhcpd(pid1670)isrunning...

6、检查相关服务运行情况并添加开机自启动

[root@kickstart~]#/etc/init.d/httpdstatus
httpd(pid1770)isrunning...
[root@kickstart~]#chkconfighttpdon
[root@kickstart~]#/etc/init.d/xinetdstatus
xinetd(pid1585)isrunning...
[root@kickstart~]#chkconfigxinetdon
[root@kickstart~]#/etc/init.d/dhcpdstatus
dhcpd(pid1670)isrunning...
[root@kickstart~]#chkconfigdhcpdon

7、准备ks.cfg文件

下面通过system-config-kickstart的图形界面进行无人值守安装设置,如果熟知ks.cfg文件的格式,可以自己写脚本来完成,当然这里只是示例。

因为system-config-kickstart需要在图形界面下操作,所以首先要在操作系统中安装图形界面:

[root@kickstarthttpd]#yum-ygroupinstall'XWindowSystem'
yum-ygroupinstall'Desktop'
yum-ygroupinstall'DesktopPlatform''DesktopPlatformDevelopment''GraphicalAdministrationTools'

然后,使用yum安装system-config-kickstart:

[root@kickstarthttpd]#yuminstallsystem-config-kickstart

最后,执行system-config-kickstart命令:

[root@kickstarthttpd]#system-config-kickstart

wKiom1lt69eyD2uAAAIYT-mw7Ns525.png-wh_50

基本设置,包含语言、时区、root密码等信息,

wKiom1lt7AfRRrqSAAFS9zBHTcc181.png-wh_50

选择安装方式和安装源,

wKiom1lt7GiCBt9pAAG7MDNeguI541.png-wh_50

选择安装类型,GRUB选项以及安装选项,

wKioL1lt7JTBqU0QAAIRNilFb5I553.png-wh_50

磁盘分区相关选项,

wKiom1lt7NLg4hHhAAExjshAgY8017.png-wh_50

网络配置选项,

wKioL1lt7OvDGcOuAAGFoW4wXvc277.png-wh_50

登录认证方式设置,有多种认证方式可选,如NIS、LDAP、Kerberos5等等,

wKioL1lt7SOALOqNAAFQBtXQI38972.png-wh_50

防火墙设置,

wKiom1lt7TSjtBaGAAEPSDn3ZEI720.png-wh_50

显示配置,

wKioL1lt7UazDf8dAAJfoQ8Olnc195.png-wh_50

选择软件包,

wKioL1lt7YCQwCNAAAFE4FeOl3I107.png-wh_50

预安装脚本,

wKioL1lt7abya8LzAAFb2xZtAZ8268.png-wh_50

安装后的处理脚本,

wKiom1lt7gSBYyq7AAFue5tmntA119.png-wh_50

选好之后,点击“File",然后在下拉菜单中选择“Save”,

wKiom1lt7lCiWqt1AAII5bM3AVo754.png-wh_50

选择文件保存位置,确定后选择save保存。

[root@kickstarthttpd]#ll/var/www/html/ks.cfg
-rw-r--r--1rootroot1126Jul1401:58/var/www/html/ks.cfg
[root@kickstarthttpd]#cat/var/www/html/ks.cfg
#platform=x86,AMD64,orIntelEM64T
#version=DEVEL
#Firewallconfiguration
firewall--disabled
#InstallOSinsteadofupgrade
install
#Usenetworkinstallation
url--url="http://192.168.49.201/"
#Rootpassword
rootpw--iscrypted$1$Y8sHozoZ$2BCNRpLHzBEab6Etd46hF1
#Systemauthorizationinformation
auth--useshadow--passalgo=sha512
#Usegraphicalinstall
graphical
#Systemkeyboard
keyboardus
#Systemlanguage
langen_US
#SELinuxconfiguration
selinux--disabled
#DonotconfiguretheXWindowSystem
skipx
#Installationlogginglevel
logging--level=info
#Rebootafterinstallation
reboot
#Systemtimezone
timezone--isUtcAsia/Chongqing
#Networkinformation
network--bootproto=dhcp--device=eth0--onboot=on
#Systembootloaderconfiguration
bootloader--location=mbr
#CleartheMasterBootRecord
zerombr
#Partitionclearinginformation
clearpart--all--initlabel
#Diskpartitioninginformation
part/boot--fstype="ext4"--size=200
partswap--fstype="swap"--size=1024
part/--fstype="ext4"--grow--size=1
%packages
@base
@chinese-support
@development
cjkuni-fonts-ghostscript
dos2unix
%end

8、修改/var/lib/tftpboot/pxelinux.cfg/default,使客户端自动加载ks.cfg配置

[root@kickstarthttpd]#vi/var/lib/tftpboot/pxelinux.cfg/default
[root@kickstarthttpd]#cat/var/lib/tftpboot/pxelinux.cfg/default
......
labellinux
menulabel^Installorupgradeanexistingsystem
menudefault
kernelvmlinuz
appendinitrd=initrd.imgks=http://192.168.49.201/ks.cfgtext
......

三、测试

创建一个VMware虚拟机,网络选择NAT模式,然后不添加启动影响,开机启动

wKiom1lt8vij7hr4AAfKZTalG4U351.png-wh_50

开机看到这个画面,很亲切啊有木有,

wKioL1lt8yDSiD0EAAAXwZ0lBpk208.png-wh_50

选择键盘类型,

wKiom1lt8znwaEDXAAAXBda8kAU624.png-wh_50

选择安装方式,

wKioL1lt82DAizZEAAAaND1sKe4804.png-wh_50

填写kickstart服务器的地址,

wKiom1lt84Cgv10fAAKPBclDZYQ613.png-wh_50

好吧,系统已经开始安装了,

wKiom1lt85fQ5uF3AAAXRiHdbrg472.png-wh_50

安装中,

wKiom1lt87DyvowaAAAXhw9RLEU249.png-wh_50

安装接近尾声,

wKioL1lt87GDbzdIAABbuCQlxeI791.png-wh_50

安装结束,使用之前设置的密码成功进入操作系统,因为没有安装图形桌面,所以就是这样的界面了,ok,至此成功结束。

原文链接:https://www.f2er.com/centos/376717.html

猜你在找的CentOS相关文章