zoukankan      html  css  js  c++  java
  • pxe批量部署


    功能:

      批量全自动安装操作系统
    方法:
      dhcp 自动分配IP
      tftp 微系统 用来安装系统
      httpd 网络源

    操作流程:

    #检查环境

    getenforce	            	#检查selinux
    systemctl status firewalld	    	#检查防火墙

    #配置yum源(光盘源)

    rm -rf /etc/yum.repos.d/*.re     #删除官方源
    mkdir /iso               #创建挂载点
    mount /dev/cdrom /iso          #挂载光盘
    vim /etc/yum.repos.d/iso.repo      #编辑源文件
    #########
    [iso]
    name=iso
    baseurl=file:///iso
    enabled=1
    gpgcheck=0
    ############
    yum clean all               #清楚缓存
    yum makecache               #生成缓存

    #安装并配置dhcp

    yum install dhcp -y	                 #安装dhcp服务
    cd /etc/dhcp/	                    #进入dhcp目录
    cat /usr/share/doc/dhcp*/dhcpd.conf.example |grep -v "#" |grep -v '^$' > dhcpd.conf       #从模板复制配置文件的内容
    vim dhcpd.conf	                    #编辑配置文件
    ###############
    option domain-name "example.org";
    option domain-name-servers ns1.example.org, ns2.example.org;
    default-lease-time 600;
    max-lease-time 7200;
    log-facility local7;	               #系统默认数值,保留
    
    subnet 192.168.10.0 netmask 255.255.255.0 {	                             #自己的子网和掩码(必须自己有相同网段的IP)
    range 192.168.10.180 192.168.10.200;	     #自动分配IP范围
    option routers 192.168.10.100;	          #路由,写本机IP
    filename "pxelinux.0";	               #安装引导文件
    next-server 192.168.10.100;	          #去哪找引导文件,本机IP
    }
    ##########################
    systemctl restart dhcpd	#重启dhcp

    #安装并配置tftp

    yum -y install tftp-server xinetd	#安装tftp xinetd
    vim /etc/xinetd.d/tftp
    #################	
    server_args = -s /tftpboot    	#tftp工作目录
    disable = no	                #关闭禁用
    #########################
    systemctl restart xinetd	     #启动xinetd 

    #安装并配置httpd

    yum -y install httpd syslinux	          #安装httpd syslinux
    rm -rf /etc/httpd/conf.d/welcome.conf	     #删除httpd欢迎页
    cd /var/www/html/	
    mkdir iso	                    #建立光盘挂载点
    mount /dev/cdrom /var/www/html/iso/	      #在httpd工作目录下挂载光盘
    vim /etc/fstab	                    #永久生效
    ##############
    /dev/cdrom /var/www/html/iso iso9660 defaults 0 0
    ##############
    cd /var/www/html/iso/isolinux	          #进入光盘
    cp vmlinuz /tftpboot/	               #复制启动文件
    cp initrd.img /tftpboot/
    mkdir /tftpboot/pxelinux.cfg
    cp isolinux.cfg /tftpboot/pxelinux.cfg/default
    cp /usr/share/syslinux/pxelinux.0 /tftpboot/

    #编辑模板文件

    cd /tftpboot/pxelinux.cfg			#进入tftp工作目录
    vim default				     #编辑默认文件
    ############
    default ks					#修改默认的启动label
    
    label ks					#定义label				
    menu label ^Install CentOS 7
    kernel vmlinuz
    append initrd=initrd.img  method=http://192.168.10.100/iso   ks=http://192.168.10.100/ks.cfg   devfs=nomount   #添加光盘位置和ks文件位置
    ###################
    
    cd
    cp anaconda-ks.cfg /var/www/html/ks.cfg  	#复制装机记录文件
    cd /var/www/html/
    vim ks.cfg
    ###################
    删除cdrom
    install
    url --url="http://192.168.10.100/iso"		#光盘地址
    #####################
    chmod 644 ks.cfg				#给ks文件所有用户可读  

    #重启服务添加防火墙

    systemctl enable dhcpd xinetd httpd
    systemctl restart dhcpd xinetd httpd
    netstat -anp|grep dhcpd
    netstat -anp|grep xinetd
    firewall-cmd --add-port=67/udp --permanent
    firewall-cmd --add-port=69/udp --permanent
    firewall-cmd --add-port=80/tcp --permanent
    firewall-cmd --reload
    

      

    作者:无荨

    -------------------------------------------

    个性签名:学IT,就要做到‘活到老学到老’!

    如果觉得这篇文章对你有小小的帮助的话,别忘记点个“推荐”哦!

  • 相关阅读:
    页面布局
    序列化和反序列化
    虚方法、抽象类
    方法的重载 、重写
    C#委托与事件
    C#中的反射
    SQL用法
    Ubuntu:Unable to locate package ***
    Django 使用mysql 所遇到问题一:Error loading MySQLdb module
    python collection 中的队列
  • 原文地址:https://www.cnblogs.com/twoo/p/11633421.html
Copyright © 2011-2022 走看看