qqruser 发表于 2018-11-29 10:08:37

RHEL5+PXE+DHCP+Apache+Kickstart安装RHCE实验室环境<转>

  原理和概念:
  1.1 什么是PXE
  严格来说,PXE 并不是一种安装方式,而是一种引导的方式。进行 PXE 安装的必要条件是要安装的计算机中包含一个 PXE 支持的网卡(NIC),即网卡中必须要有 PXE Client。PXE (Pre-boot Execution Environment)协议使计算机可以通过网络启动。协议分为 client 和 server 端,PXE client 在网卡的 ROM 中,当计算机引导时,BIOS 把 PXE client 调入内存执行,由 PXE client 将放置在远端的文件通过网络下载到本地运行。运行 PXE 协议需要设置 DHCP 服务器和 TFTP 服务器。DHCP 服务器用来给 PXE client(将要安装系统的主机)分配一个 IP 地址,由于是给 PXE client 分配 IP 地址,所以在配置 DHCP 服务器时需要增加相应的 PXE 设置。此外,在 PXE client 的 ROM 中,已经存在了 TFTP Client。PXE Client 通过 TFTP 协议到 TFTP Server 上下载所需的文件。
  1.2 什么是KickStart
  KickStart是一种无人职守安装方式。KickStart的工作原理是通过记录典型的安装过程中所需人工干预填写的各种参数,并生成一个名为 ks.cfg的文件;在其后的安装过程中(不只局限于生成KickStart安装文件的机器)当出现要求填写参数的情况时,安装程序会首先去查找 KickStart生成的文件,当找到合适的参数时,就采用找到的参数,当没有找到合适的参数时,才需要安装者手工干预。这样,如果KickStart文 件涵盖了安装过程中出现的所有需要填写的参数时,安装者完全可以只告诉安装程序从何处取ks.cfg文件,然后去忙自己的事情。等安装完毕,安装程序会根 据ks.cfg中设置的重启选项来重启系统,并结束安装。
  1.3 PXE + KickStart安装的条件
  执行 PXE + KickStart安装需要的设备为:
  · DHCP 服务器;
  · TFTP 服务器;
  · KickStart所生成的ks.cfg配置文件
  · 一台存放系统安装文件的服务器,如 NFS、HTTP 或 FTP 服务器。
  · 带有一个 PXE 支持网卡的将安装的主机;
  安装的步骤:
  一、 安装httpd
  yum -y install httpd*
  二、      挂载RHEL5的DVD光盘,并复制所有内容(文件和文件夹)到/var/www/html下
  1、mount /dev/cdrom   /mnt
  2、cp –rf   /mnt/*   /var/html/www
  三、 安装 tftp-server,并启用tftp服务,重启xinetd进程
  1、rpm -ivh tftp-server-0.39-1.i386.rpm
  2、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 #disable的直由yes变为no
  per_source            = 11
  cps                   = 100 2
  flags                = IPv4
  }
  3、service xinetd restart
  四、 配置支持PXE启动:(注意我已经把第一章光盘的内容复制到/var/www/html目录中了,所以所需要的文件我只需要从/var/ftp目录中复制 就行了,但在描述的时候,我还是表明了文件的真实的位置,比如在DVD光盘的哪个中,只是文件我是从/var/www/html目录中复制而已,大家也可 学我样偷懒)
  1、cd /tftpboot/             ————>若该文件夹已经存在则不用建立
  2、 cp /usr/lib/syslinux/pxelinux.0 /tftpboot
  3、把Linux第一张安装光盘上/image/pxeboot/initrd.img和vmlinux复制到/tftpboot/中
  cp /var/ftp/image/pxeboot/initrd.img   /tftpboot
  cp /var/ftp/image/pxeboot/vmlinux   /tftpboot
  4、 复制第一张安装光盘上isolinux/*.msg拷贝到/tftpboot目录下
  cp /var/ftp/isolinux/*.msg   /tftpboot
  5、 在tftpboot中新建一个pxelinux.cfg目录
  mkdir pxelinux.cfg
  6、 把Linux第一张安装光盘上isolinux目录中的isolinux.cfg复制到pxelinux.cfg目录中,并同时更改文件名称为default
  7、   cd pxelinux.cfg
  cp /var/ftp/isolinux/isolinux.cfg   /tftpboot/pxelinux.cfg/default
  8、 在第7小步中,我们暂时不要修改default文件,其实到达这一步骤的时候,我都就可以通过网络引导了,通过网络引导之后接下了就可以手动安装了,但是 这里面我们讨论的是无人值守安装,所谓无人值守安装就是在从引导到安装都不需要手动指定,一气呵成,我们接下来继续讲解)
  五、 安装dhcp服务,同时修改配置
  1、 rpm -ivh dhcp-3.0.1-12_EL.i386.rpm
  2、 复制配置模板文件到指定的目录中,并重命名
  cp /usr/share/doc/dhcp-3.0.1/dhcpd.conf.sample /etc/dhcpd.conf
  3、 修改配置文件,添加的一行:filename &quot;/pxelinux.0&quot;,其他的修改自己完成就行了.这文件的位置一定要注意,不然实验会失败,切记
  # vim /etc/dhcpd.conf
  ddns-update-style interim;
  ignore client-updates;
  #这几行也可以:
  ##allow booting;
  #allow bootp;
  #class &quot;pxeclients&quot; {
  #match if substring(option vendor-class-identifier, 0, 9) = &quot;PXEClient&quot;;
  #next-server 192.168.0.199;#我的dhcp服务器地址 是192.168.0.199
  #filename &quot;/pxelinux.0&quot;;
  #}
  next-server 192.168.1.14;      #PXE服务器IP地址
  filename &quot;/pxelinux.0&quot;          #注意此行的位置,写在subnet下面的话,失验失败
  subnet 192.168.1.0 netmask 255.255.255.0 {
  # --- default gateway
  option routers                192.168.1.254;
  option subnet-mask            255.255.255.0;
  option nis-domain             &quot;example.com&quot;;
  option domain-name            &quot;example.com&quot;;
  option domain-name-servers    192.168.1.254;
  option time-offset            -18000; # Eastern Standard Time
  #    option ntp-servers            192.168.1.1;
  #    option netbios-name-servers   192.168.1.1;
  # --- Selects point-to-point node (default is hybrid). Don't change this unless
  # -- you understand Netbios very well
  #    option netbios-node-type 2;
  range dynamic-bootp 192.168.1.128 192.168.1.254;
  default-lease-time 21600;
  max-lease-time 43200;
  # we want the nameserver to appear at a fixed address
  #host ns {
  #    next-server marvin.redhat.com;
  #   hardware ethernet 12:34:56:78:AB:CD;
  #   fixed-address 192.168.1.110;
  #}
  }
  4、 启动dhcp服务
  service dhcp start
  六、 安装kicksttart,同时配置kickstart
  1、 rpm -ivh system-config-kickstart-2.5.16-2.noarch.rpm
  2、 在gnome环境下配置kickstart
  system-config-kickstart
  3、 基本配置
  4、 安装方法,选择httpd安装,切记不要输入任何的帐号,我们采用的匿名安装
  5、   引导安装程序选项,不需要做更改
  6、 分区信息,创建三个分区
  7、 网络配置,我使用的静态分配地址(动态同样如此)
  8、 显示配置:
  9、 软件包的选择,我选择了Kernel Developent和Development Tools安装(但千万不要选择这两个软件包,不然的话在安装的时候会报错的,以下是我先选择安装,等一会我们来查看产生的问题,你就明白了)
  10、 其他的都是默认设置,没有做修改
  11、 生成文件ks.cfg,保存到/var/www/html下
  七、 修改/tftpboot/pxelinux.cfg/default文件,指定读取ks.cfg的方法(ks=http://192.168.1.40/ks.cfg)
  vi /tftpboot/pxelinux.cfg/default
  auth --useshadow --enablemd5
  key --skip #这行一定要,跳过注册号输入,不然实验失败
  bootloader --location=mbr
  clearpart –all –initlabel
  text
  firewall --disabled
  firstboot --disable
  keyboard us
  lang en_US
  logging --level=info
  url --url=http://192.168.1.14/
  network --bootproto=dhcp --device=eth0 --onboot=on
  reboot
  rootpw --iscrypted $1$HEJKfwF9$r1l0JoPz74ToF9NbE3Qs1
  selinux --disabled
  timezone --isUtc Asia/Shanghai
  intall
  xconfig --defaultdesktop=GNOME -depth=8 --resolution=640x480
  part swap --bytes-per-inode=4096 --fstype=&quot;swap&quot; --size=512
  part /boot --bytes-per-inode=4096 --fstype-&quot;ext3&quot; --size=200
  part / --bytes-per-inode=4096 --fstype=&quot;ext3&quot; --grow --size=1
  %packages
  @cluster-storage
  @mysql
  @development-libs
  @editors
  @text-internet
  @x-software-development
  @virtualization
  @legacy-network-server
  @dns-server
  @gnome-desktop
  @dialup
  @core
  @base
  @ftp-server
  @network-server
  @clustering
  @java-development
  @base-x
  @chinese-support
  @web-server
  @smb-server
  @printing
  @admin-tools
  @development-tools
  @graphical-internet
  kmod-gnbd-xen
  kmod-gfs-xen
  perl-Convert-ASN1
  perl-Crypt-SSLeay
  mesa-libGLU-devel
  tftp-server
  kexec-tools
  bridge-utils
  device-mapper-multipath
  ypserv
  openldap-servers
  vnc-server
  dhcp
  xorg-x11-server-Xnest
  xort-x11-server-Xvfb
  imake
  gcc-objc
  expect

页: [1]
查看完整版本: RHEL5+PXE+DHCP+Apache+Kickstart安装RHCE实验室环境<转>