加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_宿迁站长网 (https://www.0527zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

kickstart自动化安装linux

发布时间:2016-01-19 03:18:04 所属栏目:Linux 来源:网络整理
导读:参考了51cto博客各路大神的文章,结合自己实践过程,虽中间经历了些困难挫折,最终还是成功完成配置,实现了自动化安装linux。 (重点参考灰度的BLOG, http://rr

参考了51cto博客各路大神的文章,结合自己实践过程,虽中间经历了些困难挫折,最终还是成功完成配置,实现了自动化安装linux。

(重点参考灰度的BLOG, http://rrliang.blog.51cto.com/4214966/1040863)

安装环境,虚拟机VirtualBox虚拟2台机器,一台做kickstart服务器,一台做客户端

服务器系统为CentOS 6.3 X86_64, 安装光盘为CentOS 6.3 X86_64 DVD

网卡全部配置为“内部网络”

首先,需要用到的服务有,dhcpd, httpd, xinetd, tftp, 用yum 依次安装。

vim /etc/xinetd.d/tftp 修改tftp的守护进程配置文件,红色部分为修改的地方,

service tftp  
{  
        disable                 = no  
        socket_type             = dgram  
        protocol                = udp  
        wait                    = yes  
        user                    = root  
        server                  = /usr/sbin/in.tftpd  
        server_args             = -u nobody -s /tftpboot  
        per_source              = 11  
        cps                     = 100 2  
        flags                   = IPv4  
}

vim /etc/dhcp/dhcpd.conf 修改dhcp配置文件

ddns-update-style interim; 
     
allow booting; 
allow bootp; 
ignore client-updates; 
set vendorclass = option vendor-class-identifier; 
subnet 192.168.0.0 netmask 255.255.255.0 { 
     option routers          192.168.0.1; 
     option subnet-mask         255.255.255.0; 
     range dynamic-bootp        192.168.0.10 192.168.0.50; 
     filename                "/pxelinux.0"; 
     default-lease-time         21600; 
     max-lease-time             43200; 
     next-server           192.168.0.1; 
}

   简单介绍:  
    Option routers指定网关;    
    Option domain-name-server指定DNS服务器;      
    Option subnet-mask指定掩码;      
    range dynamic-bootp指定分配给客户端的IP地址段;      
    Filename 指定启动镜像;      
    Next-server 指定TFTP服务器。

服务器的网卡ifcfg-eth0配置为静态IP:192.168.0.1, 子网掩码255.255.255.0, 网关192.168.0.1

设置开机启动服务,
chkconfig xinetd on
chkconfig dhcpd on
chkconfig httpd on

依次启动服务
service xinetd start
service dhcpd start
service httpd start

注意要关掉防火墙,selinux 设为permissive, 不然会导致PXE加载失败

挂载linux安装盘, mkdir -p /mnt/iso,  mount -o loop /dev/dvd /mnt/iso,
cp /mnt/iso/* /var/www/html, 将光盘内容全部复制到html根目录(采用httpd方式安装),
创建目录/tftpboot, 将Linux安装程序的内核、根文件系统文件及其他文件复制到tftp的根目录中,

罗列下/tftpboot目录下大概会用到的文件,
initrd.img (文件,从光盘/mnt/iso/isolinux/目录拷贝)
pxelinux.0(文件,从/usr/share/syslinux目录拷贝,若无,则须安装syslinux)
pxelinux.cfg(目录,自建,里面存放名为default的文件,该文件从/mnt/iso/isolinux/isolinux.cfg复制并改名为default)
vmlinuz (文件,从/mnt/iso/isolinux/目录拷贝)
vesamenu.c32(文件,从/mnt/iso/isolinux/目录拷贝)

注意权限,chmod +x /tftpboot/pxelinux.cfg/default

若要图形化配置kickstart, 则需安装system-config-kickstart,图形化操作较简便,未详述,
若要文本配置kickstart,则要配置ks.cfg文件,
复制/root/anaconda-ks.cfg文件方式:Red Hat操作系统,在系统安装完成后,会自动在root家目录下创建一个anaconda-ks.cfg文件,这个文件真实的记录了系统安装过程中的配置。我们可以复制这个文件,然后在其基础上进行配置
cp anaconda-ks.cfg /var/ww/html/ks.cfg
chmod +r /var/www/html/ks.cfg

(编辑:云计算网_宿迁站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!