zoukankan      html  css  js  c++  java
  • kickstart自动化安装系统

    环境:服务器192.168.10.100

    1. 安装DHCP

    yum install dhcp -y

    配置文件

    cat >> /etc/dhcp/dhcpd.conf << EOF
    allow booting;
    allow bootp;
    ddns-update-style interim;
    ignore client-updates;
    subnet 192.168.10.0 netmask 255.255.255.0 {
    option subnet-mask 255.255.255.0; #子网掩码
    option domain-name-servers 192.168.10.100;
    range dynamic-bootp 192.168.10.200 192.168.10.250; #起始IP-结束IP
    default-lease-time 21600; #默认租期
    max-lease-time 43200; #最大租期
    next-server 192.168.10.100; #告知客户端TFTP的地址
    filename "pxelinux.0"; #告知客户端下载pxelinux.0的目录
    }
    EOF

    然后启动DHCP服务

    systemctl start dhcpd && systemctl enable dhcpd && systemctl status dhcpd

    2. 安装ftp

    yum -y install tftp-server
    vim /etc/xinetd.d/tftp
    disable = no # 将yes改成no,然后启动

    启动

    systemctl start tftp.socket && systemctl status tftp.socket &&systemctl enable tftp.socket

    3.配置syslinux服务

    yum -y install syslinux

    将pxelinux.0放入到/var/lib/tftpboot/下

    cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

    4.安装http服务

    yum -y install httpd
    systemctl start httpd.service && systemctl status httpd && systemctl enable httpd

    将镜像挂载到站点目录

    mkdir -p /var/www/html/CentOS7
    mount /dev/cdrom /var/www/html/CentOS7

    然后访问验证 curl http://192.168.10.20/CentOS7/

    复制镜像到/var/lib/tftpboot/

    cp -a /var/www/html/CentOS7/isolinux/* /var/lib/tftpboot/
    mkdir -p /var/lib/tftpboot/pxelinux.cfg #用于存放客户端配置文件
    cp /var/www/html/CentOS7/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

    5.编写default文件

    vim /var/lib/tftpboot/pxelinux.cfg/default

    将第一行 default vesamenu.c32 改成default linux

    将大概64行

    label linux
      menu label ^Install CentOS 7
      kernel vmlinuz
     #append initrd=initrd.img inst.stage2=hd:LABEL=CentOSx207x20x86_64 quiet 	###改成如下
      append initrd=initrd.img inst.stage2=http://192.168.10.100/CentOS7 ks=http://192.168.10.100/ks.cfg quiet
    

    6.编写ks.cfg文件

    cp ~/anaconda-ks.cfg /var/www/html/ks.cfg
    chmod +r ks.cfg #赋权

    访问验证 curl http://192.168.10.100/ks.cfg

    拷贝文件后,再参考如下内容修改---------------

    #version=DEVEL
    # System authorization information
    auth --enableshadow --passalgo=sha512
    # Use CDROM installation media
    # cdrom
    url --url=http://192.168.10.100/CentOS7/		####改成httpd的镜像访问地址
    # Use graphical install
    graphical
    # Run the Setup Agent on first boot
    firstboot --enable
    ignoredisk --only-use=sda
    # Keyboard layouts
    keyboard --vckeymap=cn --xlayouts='cn'
    # System language
    lang zh_CN.UTF-8
    # Network information
    network  --bootproto=dhcp --device=ens33 --ipv6=auto --activate		###网卡
    network  --hostname=localhost.localdomain		#hostname
    # Root password
    rootpw --iscrypted $6$gOQwBOIU7EeGID48$ou.Ud6WCJ6AF.L58SKnvNztB/iPqoH7j3C9rZ3xzHhrdfdOalv5hof3KkgXRzNsGX50GUpJr8A0y/cUG0zUqY.
    # System services
    services --enabled="chronyd"
    # System timezone
    timezone Asia/Shanghai --isUtc
    # X Window System configuration information
    #xconfig  --startxonboot
    # System bootloader configuration
    bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
    # Partition clearing information
    clearpart --all --initlabel
    # Disk partitioning information
    autopart --type=lvm
    reboot
    
    %packages
    @^minimal
    @core
    @development
    @system-admin-tools
    chrony
    kexec-tools
    tree
    nmap
    sysstat
    lrzsz
    dos2unix
    telnet
    wget
    vim
    net-tools
    %end
    
    %addon com_redhat_kdump --enable --reserve-mb='auto'
    %end
    %anaconda
    pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
    pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
    pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
    %end
    

    7.然后客户端

    现在就可以使用PXE + Kickstart无人值守安装系统了,在生产环境中,大家只需要将配置妥当的服务器上架,接通服务器和客户端主机之间的网线,然后启动客户端主机即可。然后就开始传输光盘镜像文件并进行自动安装了—期间完全无须人工干预,直到安装完毕时才需要运维人员进行简单的初始化工作。

    8.遇到报错

    could not find kernel image vmlinuz

    解决方法

    setenforce 0 #临时解决方法
    sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
    systemctl stop firewalld && systemctl disable firewalld

  • 相关阅读:
    控制反转(IOC)/依赖注入(DI)理解
    MySQL常用命令总结
    Java继承与清理
    Java组合与继承生成的类中构造函数的执行顺序
    Java中4种权限的理解
    C# 选项卡控件
    USMART 组件移植到STM32
    c# 规范用户输入控件
    c# 图像呈现控件PictureBox
    C# 制作软件启动界面
  • 原文地址:https://www.cnblogs.com/fan-gx/p/12458869.html
Copyright © 2011-2022 走看看