您的位置:首页 > 理论基础 > 计算机网络

CentOS系统基于网络的PXE+Kickstart无人值守批量安装操作系统(二)

2015-08-19 09:55 716 查看
一、实验环境系统平台:CentOS release 6.4 yum源服务器二、准备工作挂载CentOS 6.4镜像源[TZ@localhost 桌面]$ sudo su - root[root@localhost ~]# mount -o loop /usr/local/src/CentOS-6.4-x86_64-bin-DVD1.iso /mnt/cdrom[root@localhost ~]# 三、安装配置HTTP安装并配置HTTP[TZ@localhost 桌面]$ sudo su - root[root@localhost ~]# yum -y install httpdLoaded plugins: fastestmirror, refresh-packagekit, securityLoading mirror speeds from cached hostfilebase | 4.0 kB 00:00 ... Setting up Install ProcessPackage httpd-2.2.15-26.el6.centos.x86_64 already installed and latest versionNothing to do[root@localhost ~]# 启动http服务[TZ@localhost 桌面]$ sudo su - root[root@localhost ~]# service httpd start正在启动 httpd:[root@localhost ~]# service httpd statushttpd (pid 4203) 正在运行...[root@localhost ~]# /var/www/html/ 下创建cdrom目录,并复制/mnt/cdrom/目录下光盘全部内容至http 的根目录/var/www/html/cdrom/[TZ@localhost 桌面]$ sudo su - root[root@localhost ~]# mkdir /var/www/html/cdrom[root@localhost ~]#sudo cp -rf /mnt/cdrom/* /var/www/html/cdrom[root@localhost ~]#四、安装配置TFTP[TZ@localhost 桌面]$ sudo su - root[root@localhost ~]# yum -y install tftpLoaded plugins: fastestmirror, refresh-packagekit, securityLoading mirror speeds from cached hostfileSetting up Install ProcessResolving Dependencies--> Running transaction check---> Package tftp.x86_64 0:0.49-7.el6 will be installed--> Finished Dependency ResolutionDependencies Resolved================================================================================ Package Arch Version Repository Size================================================================================Installing: tftp x86_64 0.49-7.el6 base 32 kTransaction Summary================================================================================Install 1 Package(s)Total download size: 32 kInstalled size: 45 kDownloading Packages:Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction Installing : tftp-0.49-7.el6.x86_64 1/1 Verifying : tftp-0.49-7.el6.x86_64 1/1 Installed: tftp.x86_64 0:0.49-7.el6 Complete![root@localhost ~]# 编辑tftp配置文件[TZ@localhost xinetd.d]$ sudo gedit tftpservice tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /var/lib/tftpboot disable = no per_source = 11 cps = 100 2 flags = IPv4 }将disable 设置为no启动tftp服务因为tftp服务是挂载在超级进程xinetd 下的,所以通过启动xinetd 来启动tftp服务# /etc/init.d/xinetd restart[TZ@localhost 桌面]$ sudo su - root[root@localhost ~]# service xinetd start正在启动 xinetd:[root@localhost ~]# service xinetd statusxinetd (pid 2591) 正在运行...[root@localhost ~]# 五、配置支持PXE的启动程序复制pxelinux.0 文件至/var/lib/tftpboot/ 文件夹中[root@localhost ~]#sudo cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/复制iso 镜像中的/image/pxeboot/initrd.img vmlinux /var/lib/tftpboot/ 文件夹中[root@localhost ~]#sudo cp /var/www/html/cdrom/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/复制iso 镜像中的/isolinux/*.msg /var/lib/tftpboot/ 文件夹中[root@localhost ~]#sudo cp /var/www/html/cdrom/isolinux/*.msg /var/lib/tftpboot//var/lib/tftpboot/ 中新建一个pxelinux.cfg目录[root@localhost ~]# mkdir /var/lib/tftpboot/pxelinux.cfgiso 镜像中的/isolinux 目录中的isolinux.cfg复制到pxelinux.cfg目录中,同时更改文件名称为default[root@localhost ~]#sudo cp /var/www/html/cdrom/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default修改default文件[root@localhost ~]# sudo geidt /var/lib/tftpboot/pxelinux.cfg/defaultdefault ks     prompt 1 timeout 6      display boot.msg F1 boot.msg    F2 options.msg F3 general.msg F4 param.msg F5 rescue.msg label linux kernel vmlinuz append initrd=initrd.img label text kernel vmlinuz append initrd=initrd.img text label ks kernel vmlinuz append ks=http://192.168.0.1/ks.cfg initrd=initrd.img label local localboot 1 label memtest86 kernel memtest append -六、配置DHCP安装DHCP服务[TZ@localhost 桌面]$ sudo su - root[root@localhost ~]# yum -y install dhcpLoaded plugins: fastestmirror, refresh-packagekit, securityLoading mirror speeds from cached hostfileSetting up Install ProcessPackage 12:dhcp-4.1.1-34.P1.el6.centos.x86_64 already installed and latest versionNothing to do[root@localhost ~]#修改/etc/dhcp/dhcpd.conf 配置文件[TZ@localhost dhcp]$ sudo gedit dhcpd.confddns-update-style interim;allow booting; #定义能够PXE启动allow bootp; #定义支持bootpnext-server 192.168.0.1; #TFTP Server的IP地址filename "pxelinux.0"; #bootstrap 文件(NBP) ping-check true;default-lease-time 1800;max-lease-time 7200;option domain-name-servers 192.168.0.1; subnet 192.168.0.0 netmask 255.255.255.0{ range 192.168.0.128 192.168.0.220; option routers 192.168.0.1; option broadcast-address 192.168.0.255;}启动DHCP服务[root@localhost ~]# service dhcpd start正在启动 dhcpd:[root@localhost ~]# service dhcpd statusdhcpd (pid 2595) 正在运行...[root@localhost ~]# 七、生成ks.cfg 文件安装Kickstart[root@localhost ~]# yum -y install system-config-kickstart[TZ@localhost 桌面]$ sudo su - root[root@localhost ~]# yum -y install system-config-kickstartLoaded plugins: fastestmirror, refresh-packagekit, securityLoading mirror speeds from cached hostfileSetting up Install ProcessPackage system-config-kickstart-2.8.6.5-1.el6.noarch already installed and latest versionNothing to do[root@localhost ~]# 在桌面环境下配置Kickstart




















生成ks.cfg 文件,保存在/var/www/html/ 文件夹下

可以打开/var/www/html/ks.cfg 文件进行查看并进行修改[TZ@localhost 桌面]$ sudo gedit /var/www/html/ks.cfgplatform=x86, AMD64, 或 Intel EM64T#version=DEVEL# Firewall configurationfirewall --disabled# Install OS instead of upgradeinstall# Use network installationurl --url=http://192.168.0.1/cdrom/# Root passwordrootpw --iscrypted $1$zqY6f769$q0FMjKGSjK4J81Q3/Vims/# System authorization informationauth --useshadow --passalgo=sha512# Use graphical installgraphicalfirstboot --disable# System keyboardkeyboard us# System languagelang en_US# SELinux configurationselinux --disabled# Installation logging levellogging --level=info# Reboot after installationreboot# System timezonetimezone Asia/Shanghai# Network informationnetwork --bootproto=dhcp --device=eth0 --onboot=on# System bootloader configurationbootloader --location=mbr# Clear the Master Boot Recordzerombr# Partition clearing informationclearpart --all --initlabel # Disk partitioning informationpart / --fstype="ext4" --size=8000part /boot --fstype="ext4" --size=8000part swap --fstype="ext4" --size=8000part /data --fstype="ext4" --size=1 %packages@basic-desktop@chinese-support@debugging@desktop-debugging@desktop-platform@development@fonts@general-desktop@graphical-admin-tools@graphics@input-methods@internet-applications@internet-browser@kde-desktop@legacy-x@network-tools@office-suite@performance@print-client@remote-desktop-clients@security-tools@system-admin-tools@system-management@web-server@web-servlet@x11crypto-utils %end 八、测试安装
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息