设为首页 收藏本站
查看: 616|回复: 0

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

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-8-20 11:29:50 | 显示全部楼层 |阅读模式
一、实验环境
系统平台:CentOS release 6.4 ,yum源服务器
二、准备工作
挂载CentOS 6.4镜像源
[TZ@localhost 桌面]$ sudo su - root
[iyunv@localhost ~]# mount -o loop /usr/local/src/CentOS-6.4-x86_64-bin-DVD1.iso /mnt/cdrom
[iyunv@localhost ~]#
三、安装配置HTTP
安装并配置HTTP
[TZ@localhost 桌面]$ sudo su - root
[iyunv@localhost ~]# yum -y install httpd
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
base                                                     | 4.0 kB     00:00 ...
Setting up Install Process
Package httpd-2.2.15-26.el6.centos.x86_64 already installed and latest version
Nothing to do
[iyunv@localhost ~]#
启动http服务
[TZ@localhost 桌面]$ sudo su - root
[iyunv@localhost ~]# service httpd start
正在启动 httpd:
[iyunv@localhost ~]# service httpd status
httpd (pid  4203) 正在运行...
[iyunv@localhost ~]#
在/var/www/html/ 下创建cdrom目录,并复制/mnt/cdrom/目录下光盘全部内容至http 的根目录/var/www/html/cdrom/下
[TZ@localhost 桌面]$ sudo su - root
[iyunv@localhost ~]# mkdir /var/www/html/cdrom
[iyunv@localhost ~]#sudo cp -rf  /mnt/cdrom/* /var/www/html/cdrom
[iyunv@localhost ~]#
四、安装配置TFTP
[TZ@localhost 桌面]$ sudo su - root
[iyunv@localhost ~]# yum -y install tftp
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package tftp.x86_64 0:0.49-7.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package         Arch              Version                Repository       Size
================================================================================
Installing:
tftp            x86_64            0.49-7.el6             base             32 k
Transaction Summary
================================================================================
Install       1 Package(s)
Total download size: 32 k
Installed size: 45 k
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running 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!
[iyunv@localhost ~]#
编辑tftp配置文件
[TZ@localhost xinetd.d]$ sudo gedit 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
        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
[iyunv@localhost ~]# service xinetd start
正在启动 xinetd:
[iyunv@localhost ~]# service xinetd status
xinetd (pid  2591) 正在运行...
[iyunv@localhost ~]#
五、配置支持PXE的启动程序
复制pxelinux.0 文件至/var/lib/tftpboot/ 文件夹中
[iyunv@localhost ~]#sudo cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
复制iso 镜像中的/image/pxeboot/initrd.img 和vmlinux 至/var/lib/tftpboot/ 文件夹中
[iyunv@localhost ~]#sudo cp /var/www/html/cdrom/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/
复制iso 镜像中的/isolinux/*.msg 至/var/lib/tftpboot/ 文件夹中
[iyunv@localhost ~]#sudo cp /var/www/html/cdrom/isolinux/*.msg /var/lib/tftpboot/
在/var/lib/tftpboot/ 中新建一个pxelinux.cfg目录
[iyunv@localhost ~]# mkdir  /var/lib/tftpboot/pxelinux.cfg
将iso 镜像中的/isolinux 目录中的isolinux.cfg复制到pxelinux.cfg目录中,同时更改文件名称为default
[iyunv@localhost ~]#sudo cp /var/www/html/cdrom/isolinux/isolinux.cfg  /var/lib/tftpboot/pxelinux.cfg/default
修改default文件
[iyunv@localhost ~]# sudo geidt /var/lib/tftpboot/pxelinux.cfg/default
default 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
[iyunv@localhost ~]# yum -y install dhcp
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Package 12:dhcp-4.1.1-34.P1.el6.centos.x86_64 already installed and latest version
Nothing to do
[iyunv@localhost ~]#
修改/etc/dhcp/dhcpd.conf 配置文件
[TZ@localhost dhcp]$ sudo gedit dhcpd.conf
ddns-update-style interim;
allow booting;                                         #定义能够PXE启动
allow bootp;                                            #定义支持bootp
next-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服务
[iyunv@localhost ~]# service dhcpd start
正在启动 dhcpd:
[iyunv@localhost ~]# service dhcpd status
dhcpd (pid  2595) 正在运行...
[iyunv@localhost ~]#
七、生成ks.cfg 文件
安装Kickstart
[iyunv@localhost ~]# yum -y install system-config-kickstart
[TZ@localhost 桌面]$ sudo su - root
[iyunv@localhost ~]# yum -y install system-config-kickstart
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Package system-config-kickstart-2.8.6.5-1.el6.noarch already installed and latest version
Nothing to do
[iyunv@localhost ~]#
在桌面环境下配置Kickstart
wKiom1XT4U-y57roAAKueNBMdKg761.jpg
wKioL1XT41zDt-yNAAKSTKzGJzE988.jpg
wKiom1XT4U_RjyKyAAGBp8jJHxE800.jpg
wKioL1XT41yy2AsFAAHkh6sxA10455.jpg
wKiom1XT4U-QplDEAAKIdtZTp40311.jpg
wKioL1XT41yxzyUsAAIFl6xpM5g591.jpg
wKiom1XT4VDDOVRVAAGsDqprjrw054.jpg
生成ks.cfg 文件,保存在/var/www/html/ 文件夹下
            wKiom1XT4WeThkQhAAJlb1FRaJ8364.jpg                              
可以打开/var/www/html/ks.cfg 文件进行查看并进行修改
[TZ@localhost 桌面]$ sudo gedit /var/www/html/ks.cfg
platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url=http://192.168.0.1/cdrom/
# Root password
rootpw --iscrypted $1$zqY6f769$q0FMjKGSjK4J81Q3/Vims/
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone  Asia/Shanghai
# Network information
network  --bootproto=dhcp --device=eth0 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part / --fstype="ext4" --size=8000
part /boot --fstype="ext4" --size=8000
part swap --fstype="ext4" --size=8000
part /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
@x11
crypto-utils

%end

八、测试安装



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-101589-1-1.html 上篇帖子: CentOS 安装单机性能检测软件 Monitorix 下篇帖子: linux下hwclock及clock命令详解
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表