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

[经验分享] 使用PXE+DHCP+Apache+Kickstart系统自动化安装

[复制链接]

尚未签到

发表于 2018-11-18 11:15:08 | 显示全部楼层 |阅读模式
使用PXE+DHCP+Apache+Kickstart系统自动化安装







一:apache平台,共享镜像和Kickstart生成文件
1:安装配置apache服务
yum install http   
systemctl start httpd
systemctl enable httpd
systemctl stop firewalld
systemctl disable firewalld/默认发布目录:/var/www/html

2:挂载镜像到默认发布目录
mount /home/kiosk/Desktop/ftp/镜像/iso/rhel-server-7.2-x86_64-dvd.iso /var/www/html/rh    el7.2/二:安装配置dhcp
dhcp主要为在l系统网卡启动时,分配dhcp的

yum install -y dhcp
vim /etc/dhcp/dhcpd.conf
cp /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf
~~~~~~~~~~~
  7 option domain-name "example.com";
  8 option domain-name-servers 114.114.114.114;        ##此处位dns地址
  9  
10 default-lease-time 600;
11 max-lease-time 7200;
12  
13 # Use this to enble / disable dynamic dns updates globally.
14 #ddns-update-style none;
15  
16 # If this DHCP server is the official DHCP server for the local
17 # network, the authoritative directive should be uncommented.
18 #authoritative;
19  
20 # Use this to send dhcp log messages to a different log file (you also
21 # have to hack syslog.conf to complete the redirection).
22 log-facility local7;
23  
24 # No service will be given on this subnet, but declaring it helps the  
25 # DHCP server to understand the network topology.
26  
27 #subnet 10.152.187.0 netmask 255.255.255.0 {
28 #}
29  
30 # This is a very basic subnet declaration.
31  
32 subnet 172.25.254.0 netmask 255.255.255.0 {
33   range 172.25.254.120 172.25.254.130;  #地址池
34   option routers 172.25.254.20;          #网关
35 }                                                   
~~~~~~~~~~~
systemctl restart dhcp  

三:配置pxe

  PXE启动原理
  当计算机引导时,BIOS把 PXE Client 调入内存中执行,然后由 PXE Client 将放置在远端的文件通过网络下载到本地运行。
  1:安装tftp,
yum install -y tftp-server
默认发布目录:/var/lib/tftpboot  2:搭建pxe环境
cp /var/www/html/rhel7.2/isolinux/* /var/lib/tftpboot/
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
mkdir /var/lib/tftpboot/pxelinux.cfg
cp /var/lib/tftpboot/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
[root@server tftpboot]# ls
boot.cat  grub.conf   isolinux.bin  memtest     pxelinux.cfg  TRANS.TBL    vesamenu.c32
boot.msg  initrd.img  isolinux.cfg  pxelinux.0  splash.png    upgrade.img  vmlinuz3:搭建好pxe环境后,分析一下网卡启动的过程,首先dhcp寻找ip ,这时候读dhcp文件/etc/dhcp/dhcpd.conf文件,接下来应该让他读pxe的default文件从而进行安装,所以将下来要干什么写到/etc/dhcp/dhcpd.conf 文件。
next-server 172.25.254.20;
filename "pxelinux.0";4:启动服务
systemctl restart dhcpd
systemctl start tftp四:kickstart将安装设置过程生成文件


在红帽中,安装系统设置过程是个特别麻烦耗费时间的事情,在安装过程中,机器会给大家询问许多安装配置问题,kickstart将所有的问题生成一个ks.cfg文件,在安装过程中,直接调用这个文件,很快完成安装
1:安装kickstart
yum install -y system-config-kickstart.noarch

2:图形界面回答安装配置问题,生成ks.cfg 文件

system-config-kickstart     ##生成文件打开图形界面命令

3:图形界面回答问题,配置虚拟机服务
basic configuiation       ##主要设置语言,时区密码等
reboot system after installation                                           ##安装后重新启动系统
perform installation in text mode (graphical is default)                                          ##在文本模式进行安装(图形是默认的)

installation method       ##安装模式,主要为了设置安装镜像的来源

perform new installation                        
执行新的安装
upgrade an existing installation                        
升级现有安装
  安装根源    installation source -->http server  172.25.254.20    http directory  /rhel7.2
  boot loader options

  install type
install new boot loader                                           ##安装新的引导装载程序
  install options(装置选项)
  install boot loader on master boot record                        
在主引导记录安装引导装载程序
install boot loader on first sector of the boot partition                        
在引导分区的第一扇区上安装引导加载程序
  master boot record(主引导记录)
  clear master boot record                      ###清除主引导记录
remove all existing partitions                          ##删除所有现有的分区
  
preserve existing partitions                                           ##保留现有的分区
  disk label(磁盘标签)
initialize the disk label                                          ##初始化磁盘标签
  add  /boot  200

  add swap  500
  add  /          剩余空间
  network configuration   

  添加网卡和dhcp/ip
  authentication认证;      

  post-installation script    #最后安装的脚本
  
  安装前脚本:以%pre开始,以%end结束;
  安装后脚本:以%post开始,以%end/结束;
  


  完成完设置后,左上角有个file,将生成的ks.cfg 文件保存,建议保存在apache的发布目录/var/www/html/里面,方便其他虚拟机或者真机的安装。
  4:处理生成的ks.cfg文件
  %packages
@base  

  %end     
5:将ks.cfg文件运用到系统安装中
vim /var/lib/tftpboot/pxelinux.cfg/default
61 label linux
62   menu label ^Install Red Hat Enterprise Linux 7.2
63   kernel vmlinuz
64   append initrd=initrd.img repo=http://172.25.254.20/rhel7.2 ks=http://172.25.254.20/ks.cfg q    uiet  五:测试
  设置系统启动从网卡启动,启动所有服务,
  由于电脑一些问题,没法上传测试图片,后续有问题继续更

                                                          

                                                        





运维网声明 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-636522-1-1.html 上篇帖子: [LAMP]Apache虚拟主机 下篇帖子: Centos6下SVN服务器(结合Apache)的搭建
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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