zoukankan      html  css  js  c++  java
  • 运维自动化工具 Kickstart


    简介:

    批量安装操作系统工具之 Kickstart ,RedHat 早前推出的产品( 不多说了,现在都玩 Cobbler 啦 )。

    测试环境:CentOS 6.6 x86_64 minimal

    一、安装软件包

    shell > yum -y install dhcp tftp-server syslinux nfs-utils kickstart

    二、配置 DHCP

    shell > cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
    cp:是否覆盖"/etc/dhcp/dhcpd.conf"? y
    
    shell > vim /etc/dhcp/dhcpd.conf
    
    # dhcpd.conf
    # option definitions common to all supported networks...
    option domain-name-servers 192.168.214.2, 202.106.46.151;
    # A slightly different configuration for an internal subnet.
    subnet 192.168.214.0 netmask 255.255.255.0 {
    range 192.168.214.100 192.168.214.120;
    option routers 192.168.214.2;
    option subnet-mask 255.255.255.0;
    filename "/pxelinux.0";
    default-lease-time 600;
    max-lease-time 7200;
    }

    三、配置 tftp

    shell > vim /etc/xinetd.d/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 ## 原为 yes
    per_source = 11
    cps = 100 2
    flags = IPv4
    }

    四、pxelinux.0

    shell > cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
    shell > mount /dev/cdrom /mnt/
    shell > cp /mnt/isolinux/* /var/lib/tftpboot/
    shell > cd /var/lib/tftpboot/
    shell > mkdir pxelinux.cfg
    shell > mv isolinux.cfg pxelinux.cfg/default

    五、配置 NFS

    shell > vim /etc/exports
    
    /mnt 192.168.0.0/24(ro,sync)

    六、最后的调整

    shell > chkconfig --add nfs
    shell > chkconfig --add dhcpd
    shell > chkconfig --add xinetd
    shell > chkconfig --add rpcbind
    shell > chkconfig --level 35 nfs on
    shell > chkconfig --level 35 dhcpd on
    shell > chkconfig --level 35 xinetd on
    shell > chkconfig --level 35 rpcbind on
    
    shell > exportfs -ar
    shell > service dhcpd restart
    关闭 dhcpd: [确定]
    正在启动 dhcpd: [确定]
    shell > service xinetd restart
    停止 xinetd: [确定]
    正在启动 xinetd: [确定]
    shell > service rpcbind restart
    停止 rpcbind: [确定]
    正在启动 rpcbind: [确定]
    shell > service nfs restart
    关闭 NFS 守护进程: [确定]
    关闭 NFS mountd: [确定]
    关闭 NFS 服务: [确定]
    Shutting down RPC idmapd: [确定]
    启动 NFS 服务: [确定]
    启动 NFS mountd: [确定]
    启动 NFS 守护进程: [确定]
    正在启动 RPC idmapd: [确定]
    
    shell > setenforce 0
    shell > service iptables stop

    七、测试 PXE 引导安装

    1、客户机设置从网络引导(其实不用设置,本地找不到自然会去网络找),就可以看到安装界面

    2、选择语言( Chinese Simplified )

    3、OK

    4、选择键盘( us )OK

    5、选择媒体位置( NFS Directory )OK

    6、配置网络( 默认即可 )OK

    7、设置 NFS 服务( NFS server name: 192.168.214.10 ## NFS 服务器地址
                               CentOS directroy: /mnt ## ISO 存放位置 )OK

    8、这里出现正常的安装界面,证明没有问题( 跟光盘安装一模样即可 )

    ## 这是实现了 PXE 引导安装,想要无人干预还得配置 Kickstart !

    八、安装桌面环境

    ## 以下操作直接在虚拟机中执行,非终端连接 !(不是必要的)

    shell > yum grouplist | grep -iP "(x window system|desktop)"
    
    Desktop
    X Winsow System

    ## 其中搜索出来的这两个包是我们需要安装的。

    shell > yum update ## 首先需要更新一下 yum
    
    shell > yum -y groupinstall "X Window System"
    
    shell > yum -y groupinstall "Desktop"
    
    shell > yum -y groupinstall "Chinese Support" ## 安装中文支持
    
    shell > init 5

    ## 现在已经进入桌面环境

    1、设置字体(不是必须的)

    ## 打开终端时,默认显示的字体简直难看到极致,中间还有空格乱入,对处女座来说根本忍不了!

    系统--首选项--外观--字体--( 将等宽字体改为 AR PL UKai CN )--确定即可

    2、安装软件包 system-config-kickstart

    shell > yum -y install system-config-kickstart
    
    shell > system-config-kickstart ## 启动 Kickstart 配置程序

    ## 接下来就全是鼠标点点点啦 !

    ·基本配置
                     默认语言 :简体中文,也可以默认 ( English )
                     键盘 :默认即可
                     时区 :Asia/Shanghai ,按实际情况来
                     UTC 时钟 :勾选
                     根口令 :123456
                     确认根口令:123456
                     根口令加密:默认是勾上的,不用管

                     高级配置
                           安装后重新引导系统:勾选
    ·安装方法
                     执行新安装:勾选
                     选择 NFS :
                           NFS 服务器:192.168.214.10
                           NFS 目录 :/mnt ## NFS 共享的 ISO 存放目录
    ·引导装载程序选项

                     安装类型
                           安装新引导装载程序:勾选
                     安装选项
                           在主引导记录(MBR)上安装引导装载程序
    ·分区信息
                     主引导记录
                           清除主引导记录:勾选
                     分区
                           删除所有现存分区:勾选
                     磁盘标签
                           初始化磁盘标签:勾选
                     布局
                           添加分区( 跟装真机一样 )
    ·网络配置
                     添加网络设备--网络设备(eth0)--网络类型(DHCP)--确认即可
    ·验证
                     默认
    ·防火墙配置
                     全部禁用
    ·显示配置
                     安装图形环境:不勾选(如果不想安装的话)
                     禁用
    ·软件包选择
                     默认
    ·预安装脚本
                     默认
    ·安装后脚本
                     默认

    选择--文件--保存--(将文件保存到 /root 目录下,文件名为 ks.cfg)

    shell > mkdir /nfsdir
    
    shell > cp ks.cfg /nfsdir
    
    shell > chown 777 /nfsdir/ks.cfg
    
    shell > vim /etc/exports
    
    /mnt 192.168.214.0/24(ro,sync)
    /nfsdir 192.168.214.0/24(ro,sync) ## 添加共享目录
    
    shell > exportfs -ar
    
    shell > vim /var/lib/tftpboot/pxelinux.cfg/default
    
    default vesamenu.c32
    #prompt 1
    timeout 50
    
    display boot.msg
    
    menu background splash.jpg
    menu title Welcome to CentOS 6.6!
    menu color border 0 #ffffffff #00000000
    menu color sel 7 #ffffffff #ff000000
    menu color title 0 #ffffffff #00000000
    menu color tabmsg 0 #ffffffff #00000000
    menu color unsel 0 #ffffffff #00000000
    menu color hotsel 0 #ff000000 #ffffffff
    menu color hotkey 7 #ffffffff #ff000000
    menu color scrollbar 0 #ffffffff #00000000
    
    label linux
    menu label ^Install or upgrade an existing system
    menu default
    kernel vmlinuz
    append ks=nfs:192.168.214.10:/nfsdir/ks.cfg initrd=initrd.img
    label vesa
    menu label Install system with ^basic video driver
    kernel vmlinuz
    append initrd=initrd.img xdriver=vesa nomodeset
    label rescue
    menu label ^Rescue installed system
    kernel vmlinuz
    append initrd=initrd.img rescue
    label local
    menu label Boot from ^local drive
    localboot 0xffff
    label memtest86
    menu label ^Memory test
    kernel memtest
    append -

    ## 其中,timeout 50 ( 这个参数原为 600 ,就是一进去系统时那个选择模式的时间,我们不想等待太长时间所以调为 5 秒 )

    ## 在第一个 label 中加入了:ks=nfs:192.168.214.10:/nfsdir/ks.cfg ( 定义 ks.cfg 路径 )

    label linux
    menu label ^Install or upgrade an existing system
    menu default
    kernel vmlinuz
    append ks=nfs:192.168.214.10:/nfsdir/ks.cfg initrd=initrd.img

    ## 下面贴一下 ks.cfg 的文件内容( 不需要修改 )

    shell > vim /nfsdir/ks.cfg
    
    #platform=x86, AMD64, 或 Intel EM64T
    #version=DEVEL
    # Firewall configuration
    firewall --disabled
    # Install OS instead of upgrade
    install
    # Use NFS installation media
    nfs --server=192.168.214.10 --dir=/mnt
    # Root password
    rootpw --iscrypted $1$56NxQt/e$3fz.wnuWl7Ak7q9TIpwl0.
    # System authorization information
    auth --useshadow --passalgo=sha512
    # Use graphical install
    graphical
    # System keyboard
    keyboard us
    # System language
    lang zh_CN
    # SELinux configuration
    selinux --disabled
    # Do not configure the X Window System
    skipx
    # Installation logging level
    logging --level=info
    # Reboot after installation
    reboot
    # System timezone
    timezone --isUtc 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 /boot --fstype="ext4" --size=200
    part swap --fstype="swap" --size=1024
    part / --fstype="ext4" --grow --size=1

    4、重新启动服务,测试无人值守

    ## 执行第 六 步操作

    ## 现在客户机只需开机( 引导方式为网络引导,其实不用设置,自己会去找的),即可 !

    ## 经测试没问题 !

  • 相关阅读:
    页面元素定位-CSS元素基本定位
    自动化测试理论知识以及相关框架
    flask自学
    关于测试报告的一些理解
    jenkins、k8s、docker学习
    常用装饰器
    正则
    pycharm设置展示运行结果行数以及python一些好用的模块
    python相关知识点3,线程锁、单例模式
    python相关知识点2(各种内置方法)
  • 原文地址:https://www.cnblogs.com/wangxiaoqiangs/p/5354995.html
Copyright © 2011-2022 走看看