• 使用kickstart、dchp、tftp、http,实现RHEL 5.5操作系统的无人值守自动化安装


    //
    //使用kickstart、dchp、tftp、http,实现RHEL 5.5操作系统的无人值守自动化安装
    //Server IP:192.168.10.178 操作系统:Red Hat Enterprise Linux Server release 5.5
    //
    //具体步骤如下:

    1. 安装、配置DHCP服务
    1.1 使用如下命令检查dhcp是否安装,rhel5系统默认安装dhcp-3.0.5-23.el5
    [root@localhost ~]# rpm -qa | grep dhcp
    若系统没有安装dhcp服务,先安装下面的rpm包:
    dhcp-3.0.5-23.el5.i386.rpm

    1.2 配置dhcp,修改/etc/dhcpd.conf
    [root@localhost ~]# vi /etc/dhcpd.conf

    #dhcpd.conf配置文件的例子:
    #
    # DHCP Server Configuration file.
    # see /usr/share/doc/dhcp*/dhcpd.conf.sample
    #
    ddns-update-style interim;
    ignore client-updates;
    allow booting;
    allow bootp;

    filename "pxelinux.0"; #pxelinux loader文件位置
    next-server 192.168.10.178; #tftp所在服务器ip,我的serverip

    subnet 192.168.10.0 netmask 255.255.255.0
    {
    option routers 192.168.10.1;
    option subnet-mask 255.255.255.0;
    range dynamic-bootp 192.168.10.100 192.168.10.110; #dhcp动态提供的ip地址范围
    default-lease-time 21600;
    max-lease-time 43200;
    }
    1.3 修改配置后,重启该服务
    [root@localhost ~]# /etc/init.d/dhcpd start #启动
    [root@localhost ~]# /etc/init.d/dhcpd restart #重启

    2. 安装、启用tftp服务
    2.1 确认tftp服务是否已安装,若无,请先安装。
    [root@localhost ~]# rpm -qa | grep tftp
    若tftp没有安装,先安装下面两个rpm包:
    tftp-0.49-2.i386.rpm
    tftp-server-0.49-2.i386.rpm

    2.2 安装tftp后,修改配置文件,启用该服务
    [root@localhost ~]# vi /etc/xinetd.d/tftp

    #例子:
    # default: off
    # description: The tftp server serves files using the trivial file transfer
    # protocol. The tftp protocol is often used to boot diskless
    # workstations, download configuration files to network-aware printers,
    # and to start the installation process for some operating systems.
    service tftp
    {
    socket_type = dgram
    protocol = udp
    wait = yes
    user = root
    server = /usr/sbin/in.tftpd
    server_args = -s /tftpboot
    disable = no #默认为yes,这里改为no
    per_source = 11
    cps = 100 2
    flags = IPv4
    }

    2.3 修改配置后,重启该服务
    [root@localhost ~]# /etc/init.d/xinetd start #启动
    [root@localhost ~]# /etc/init.d/xinetd restart #重启

    3. 安装、启动http服务
    3.1 确认http服务是否已安装,若无,请先安装该服务。
    [root@localhost ~]# rpm -qa | grep http

    若返回结果中,没有http包,则安装下列rpm包:
    httpd-2.2.3-43.el5.i386.rpm

    3.2 安装完成后,重启服务
    [root@localhost ~]# /etc/init.d/httpd start #启动
    [root@localhost ~]# /etc/init.d/httpd restart #重启

    4. 挂载系统镜像
    4.1 将RHEL5.5的光盘镜像rhel-server-5.5-i386-dvd.iso放置到服务器中,比如/home目录下。

    4.2 挂载iso镜像到某个目录,比如/media/rhel5_iso目录中
    [root@localhost ~]# mkdir /media/rhel5_iso #创建挂载目录
    [root@localhost ~]# mount -t iso9660 -o loop /home/rhel-server-5.5-i386-dvd.iso /media/rhel5_iso

    4.3 使用http方式提供安装源文件
    在http目录/var/www/html/下创建链接到挂在目录/media/rhel5_iso
    [root@localhost ~]# ln -s /media/rhel5_iso /var/www/html/rhel5 #创建链接
    或者
    在http目录/var/www/html/下创建文件夹,并将镜像挂载到该文件夹中
    [root@localhost ~]# mkdir /var/www/html/rhel5.5
    [root@localhost ~]# mount -t iso9660 -o loop /home/rhel-server-5.5-i386-dvd.iso /var/www/html/rhel5.5/

    5. 配置系统引导文件
    5.1 RHEL5是默认安装syslinux的,将/usr/lib/syslinux/pxelinux.0拷贝到/tftpboot/目录
    [root@localhost ~]# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/

    5.2 将系统安装镜像/media/rhel5_iso/isolinux目录下的initrd.img,vmlinuz,isolinux.cfg文件拷贝到/tftpboot/目录下
    #在/media/rhel5_iso/images/pxeboot目录下也存在上述文件中的initrd.img,vmlinuz
    [root@localhost ~]# cp /media/rhel5_iso/isolinux/initrd.img /tftpboot/
    [root@localhost ~]# cp /media/rhel5_iso/isolinux/vmlinuz /tftpboot/
    [root@localhost ~]# cp /media/rhel5_iso/isolinux/isolinux.cfg /tftpboot/

    5.3 在/tftpboot/目录下创建文件夹pxelinux.cfg,将isolinux.cfg移入pxelinux.cfg目录下并重命名为default
    [root@localhost ~]# mkdir /tftpboot/pxelinux.cfg
    [root@localhost ~]# mv /tftpboot/isolinux.cfg /tftpboot/pxelinux.cfg/default
    [root@localhost ~]# chmod 777 /tftpboot/pxelinux.cfg/default

    5.4 编辑修改/tftpboot/pxelinux.cfg/default文件
    [root@localhost pxelinux.cfg]# vi /tftpboot/pxelinux.cfg/default

    #文件内容修改如下:其中关于ks.cfg,接下来会讲到

    default linux
    prompt 1
    timeout 100
    display boot.msg
    F1 boot.msg
    F2 options.msg
    F3 general.msg
    F4 param.msg
    F5 rescue.msg
    label linux
    kernel vmlinuz
    append ks=http://192.168.10.178/ks.cfg initrd=initrd.img
    label text
    kernel vmlinuz
    append initrd=initrd.img text
    label ks
    kernel vmlinuz
    append ks initrd=initrd.img
    label local
    localboot 1
    label memtest86
    kernel memtest
    append -


    6. kickstart配置,配置文件是ks.cfg
    #kickstart是Red Hat 提供的一种安装方法,能够让你自动化大部分 Red Hat Linux 的安装任务。
    #kickstart的配置文件ks.cfg是一个文本文件,可以使用kickstart 配置器来创建它;或者手工写一个;或者使用/root/anaconda-ks.cfg文件,做些修改即可
    #关于kickstart选项可参照:http://man.ddvip.com/os/redhat9.0cut/s1-kickstart2-options.html
    #
    #将ks.cfg文件放置到http的跟目录下
    [root@localhost ~]# mv ks.cfg /var/www/html/

    #ks.cfg文件的一个例子如下,安装rhel5.5时使用的ks.cfg文件
    # Kickstart file automatically generated by anaconda.

    install #指定系统是全新安装,而不是升级或其他
    url --url=http://192.168.10.178/rhel5 #通过HTTP 从远程服务器上的安装树中安装
    key --skip #跳过输入安装序列号
    lang en_US.UTF-8 #语言选择
    keyboard us #键盘选择
    xconfig --startxonboot --defaultdesktop=GNOME #选择桌面系统
    network --device eth0 --bootproto static --ip 192.168.10.70 --netmask 255.255.255.0 --gateway 192.168.10.1 --nameserver 10.90.0.5 #设置网络
    rootpw --iscrypted $1$ixSPtHFc$0mq4QoL1B2BE6lY1yVEht/ #设置root密码,此处设置的密码是hzalcatel,经过md5加密
    #firewall --enabled --port=22:tcp
    firewall --disabled #放火墙关闭
    authconfig --enableshadow --enablemd5
    #selinux --enforcing
    selinux --disabled #selinux关闭
    timezone --utc Asia/Shanghai #时区设置
    bootloader --location=mbr #--driveorder=sda --append="rhgb quiet"
    zerombr yes
    # The following is the partition information you requested
    # Note that any partitions you deleted are not expressed
    # here so unless you clear all partitions first, this is
    # not guaranteed to work
    #以下为分区设置,可根据实际情况作相应修改
    clearpart --linux #清除所有linux分区
    part /boot --fstype ext3 --size=100
    part / --fstype ext3 --size=20000 #创建根分区,ext3格式,大小20000M
    part swap --size=512
    part /home --fstype ext3 --size=100 --grow #剩余磁盘空间分配给/home
    reboot #安装完成后,重启计算机

    #以下为定制的,需要安装的包
    %packages
    @admin-tools
    @base
    @chinese-support
    @core
    @dns-server
    @development-libs
    @development-tools
    @dialup
    @editors
    @engineering-and-scientific
    @ftp-server
    @gnome-desktop
    @gnome-software-development
    @graphical-internet
    @java
    @java-development
    @legacy-network-server
    @legacy-software-development
    @legacy-software-support
    @mysql
    @network-server
    @openfabrics-enterprise-distribution
    @sql-server
    @printing
    @ruby
    @server-cfg
    @system-tools
    @text-internet
    @web-server
    @smb-server
    @x-software-development
    @base-x
    system-config-kickstart
    tunctl
    libhbaapi
    kexec-tools
    bridge-utils
    authd
    fipscheck
    device-mapper-multipath
    fuse-libs
    sgpio
    systemtap-sdt-devel
    perl-XML-SAX
    pth
    perl-XML-Twig
    perl-XML-Dumper
    perl-TimeDate
    perl-libxml-perl
    tog-pegasus-devel
    perl-Convert-ASN1
    libstdc++44-devel
    libassuan-devel
    perl-XML-NamespaceSupport
    perl-DateManip
    libksba-devel
    fipscheck-devel
    sblim-cmpi-dhcp-devel
    perl-Crypt-SSLeay
    perl-Mozilla-LDAP
    pth-devel
    log4cpp-devel
    perl-LDAP
    perl-XML-Grove
    libpciaccess-devel
    python-imaging
    libhbaapi-devel
    python-dmidecode
    fuse-devel
    libksba
    perl-Archive-Zip
    gsl
    gcc44-c++
    gcc44-gfortran
    pexpect
    dejagnu
    imake
    java-1.6.0-openjdk-devel
    gcc-objc
    ElectricFence
    memtest86+
    gcc-gnat
    libgfortran44
    gcc44
    expect
    java-1.6.0-openjdk
    unifdef
    python-docs
    nasm
    emacs-nox
    emacs
    vim-X11
    gnuplot-emacs
    nedit
    lapack
    lam
    pvm
    xferstats
    libgnome-java
    libgtk-java
    libglade-java
    libgconf-java
    bsh-demo
    tftp-server
    gtk+
    compat-db
    openssl097a
    qt4
    compat-readline43
    compat-openldap
    compat-slang
    openmotif22
    mod_auth_mysql
    mysql-devel
    qt-MySQL
    mysql-bench
    php-mysql
    vnc-server
    dnsmasq
    dhcp
    postgresql-tcl
    unixODBC-kde
    qt-ODBC
    postgresql-contrib
    postgresql-pl
    postgresql-test
    libdbi-dbd-pgsql
    postgresql-jdbc
    postgresql-odbc
    postgresql-docs
    eruby
    ruby-ri
    system-config-bind
    system-switch-mail-gnome
    system-config-boot
    rdesktop
    tog-pegasus
    festival
    tsclient
    audit
    sysstat
    tftp
    php-odbc
    php-pear
    mod_auth_kerb
    mod_nss
    mod_auth_pgsql
    mod_auth_mysql
    mod_authz_ldap
    php-mysql
    php-pgsql
    xorg-x11-xbitmaps
    mesa-libGLw-devel
    openmotif-devel
    mesa-libGLU-devel
    xorg-x11-server-sdk
    libXp-devel
    xorg-x11-utils
    libpciaccess
    xorg-x11-server-Xnest
    xorg-x11-server-Xvfb

  • 相关阅读:
    Python iter() 函数
    Python file() 函数
    Python bin() 函数
    QTP自动化测试-打开运行报告
    mysql-笔记-数据类型
    mysql-笔记--增删改查
    mysql-笔记-命名、索引规范
    Navicat for MySQL 安装和破解
    mysql client--笔记-修改密码-登录-查看数据库-创建数据库
    安装mysql
  • 原文地址:https://www.cnblogs.com/zhrq/p/4148806.html
Copyright © 2020-2023  润新知