kickstart自动化系统安装

                          kickstart自动化linux系统安装

一、系统环境


 redhate 6.3

IP:10.240.240.210,  Gateway: 10.240.240.1


二 、使用yum方式安装软件包


 yum install -y tftp* xinetd "*dhcp*" nfs-utils-*


三、配置dhcp服务器


 配置DHCP服务器的配置文件

 [root@localhost tftpboot]# vi /etc/dhcpd.conf  

  # DHCP Server Configuration file.

  #   see /usr/share/doc/dhcp*/dhcpd.conf.sample

  #   see 'man 5 dhcpd.conf'

  ddns-update-style interim;

  ignore client-updates;

  filename "/pxelinux.0";

  next-server 10.240.240.210;

  allow booting;

  allow bootp;


  subnet 10.240.240.0 netmask 255.255.255.0 {


  # --- default gateway

          option routers                  10.240.240.1;

          option subnet-mask              255.255.255.0;


          option nis-domain               "jiayuan.com";

          option domain-name              "jiayuan.com";

          option domain-name-servers      10.240.210.98;


          option time-offset              -18000; # Eastern Standard Time

  #       option ntp-servers              10.240.210.98;

  #       option netbios-name-servers     10.240.210.98;

  # --- 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 10.240.240.220 10.240.240.240;

          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 207.175.42.254;

         }

  }


四、配置tftp服务器

  配置tftp服务器的配置文件

  [root@localhost tftpboot]# 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             = -u nobody -s /tftpboot #指定目录

       disable                 = no  #将yes改为no

       per_source              = 11

       cps                     = 100 2

       flags                   = IPv4

  }


五、配置NFS服务器,添加共享目录

  [root@localhost ~]# vi /etc/exports  

  /mnt/cdrom *(ro,sync)

  /tftpboot *(ro,sync)

六、复制pxelinux.0、initrd.img、vmlinuz、isolinux/*.msg 到/tftpboot/目录下


1、正常情况下linux系统没有安装syslinux包,需要安装syslinux包

  yum install -y syslinux

  syslinux包安装完后会在/usr/share/syslinux/

  先 cp -r /usr/share/syslinux/ /usr/lib/


2、新建一个/mnt/cdrom目录,把镜像的iso文件挂载到/mnt/cdrom下


3、如果没有/tftpboot/目录先建立一个

  mkdir /tftpboot/

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

  cp /mnt/cdrom/images/pxeboot/{initrd.img,vmlinuz} /tftpboot/  

  cp /mnt/cdrom/isolinux/*.msg /tftpboot

4、配置default文件

 mkdir /tftpboot/pxelinux.cfg

 touch /tftpboot/pxelinux.cfg/default

 vi /tftpboot/pxelinux.cfg/default

  default linux

  prompt 1

  timeout 600

  display boot.msg

  label linux

    kernel vmlinuz

    append initrd=initrd.img nofb text  ks=nfs:10.240.240.210:/tftpboot/ks.cfg

 label text

   kernel vmlinuz

   append initrdinitrd=initrd.img text

 label ks

   kernel vmlinuz

   append ks initrdinitrd=initrd.img

 label local

   localboot 1

 label memtest86

   kernel memtest

   append -


Pxe已经完成了,想用ks完成全自动安装的可以往下看。


七、使用kickstarter配置安装文件。


 [root@localhost tftpboot]# pwd

  /tftpboot

 [root@localhost tftpboot]# ls

  boot.msg  initrd.img  pxelinux.0  pxelinux.cfg  vmlinuz


 [root@localhost tftpboot]# vi ks.cfg  

  install

  nfs --server=10.240.240.210 --dir=/mnt/cdrom

  text

  key --skip

  keyboard us

  lang en_US.UTF-8

  skipx

  network --device eth0 --bootproto dhcp

  rootpw root

  firewall --disabled

  authconfig --enableshadow --enablemd5

  selinux --disabled

  timezone --utc Asia/Shanghai

  bootloader --location=mbr --driveorder=sda

  zerombr yes

  clearpart --all


  part /boot --fstype ext4 --size=200

  part /     --fstype ext4 --size=20000

  part swap  --fstype swap --size=8192

  part /u01  --fstype ext4 --grow --size=200

  reboot


 

%packages

@base

@core

@server-policy

authconfig

ipmitool

OpenIPMI

openssh-clients

net-snmp

%post


rm -rf /etc/yum.repos.d/*

cat >/etc/yum.repos.d/puppet.repo <<-EOF

[puppet]

name=rhel-server-6.3-x86_64

baseurl=http://10.0.0.233/OS/rhel-server-6.3-x86_64/

enabled=1

gpgcheck=0

priority=1


[core-0]

name=core-0

baseurl=http://10.0.3.91/cobbler/ks_mirror/rhel-server-6.3-x86_64

enabled=1

gpgcheck=0

priority=1



[core-1]

name=core-1

baseurl=http://10.0.3.91/cobbler/ks_mirror/rhel-server-6.3-x86_64/Server

enabled=1

gpgcheck=0

priority=1



[core-2]

name=core-2

baseurl=http://10.0.3.91/cobbler/ks_mirror/rhel-server-6.3-x86_64/ResilientStorage

enabled=1

gpgcheck=0

priority=1



[core-3]

name=core-3

baseurl=http://10.0.3.91/cobbler/ks_mirror/rhel-server-6.3-x86_64/ScalableFileSystem

enabled=1

gpgcheck=0

priority=1



[core-4]

name=core-4

baseurl=http://10.0.3.91/cobbler/ks_mirror/rhel-server-6.3-x86_64/LoadBalancer

enabled=1

gpgcheck=0

priority=1



[core-5]

name=core-5

baseurl=http://10.0.3.91/cobbler/ks_mirror/rhel-server-6.3-x86_64/HighAvailability

enabled=1

gpgcheck=0

priority=1


EOF



#ssh-keygen -f /root/.ssh/id_rsa -N jiayuan.com

ssh-keygen -f /root/.ssh/id_rsa -N ""

cat << EOF > /root/.ssh/authorized_keys 

ssh-dss AAAAB3NzaC1kc3MAAACBAOhEPU3K5V0+0arAJAOfJpndZICISJpBLsgxK+Jfh918zKI8h1/wa2BeNh3dRn61xcxYNlYmTOhnfebqOl9BUT5pFFG263msMx9OCImZzkL8iL/u0bMDxIebGg8HkbkBUUoN3dp/gaQmbhhib9ZrNe6u63cfrehwIEhoZ/Q+h1uBAAAAFQD7IYHEVKM46u2aKVmgWHaz+pVNDQAAAIBsTetkUIFks1Mbpy0aR0ywMUn3uHjv4cGlWSFYDxdmr/YbGT2vm7Rph48IxoQ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qpDK3BSDuD2c/ggMNeqZo8toCyfbAqxb/jkg root@manager_network

ssh-dss AAAAB3NzaC1kc3MAAACBAJBa7KArcDrwytnrLbh8uWJw3pKKYNLZEhnT2+LuDUmBERFPH/VtM4rp50k3meYgxlRch/iyWSBLdIC/UeZlRZPSFinDIvGEvqKqN/r+shddZgQQZXRH2pYAP8Rb/xzj4pIPpc0V1LpEIk7LashFx/41nCJXhODnJLcPcuASwR/LAAAAFQCHViB2P3fR4ud/tYUPeSgeumbLgQAAAIBsDZo3eB3WaY9VbztVToMgqii+NsJfiJPrcdQDMOJmEgYGQ/L7BKJglfDoLMvY/rvaumKN6rE9gsPiiN4m3xnOkXaYYjOqYb2fMk3N7AfozpgMdtgfp/o9Cy0qh4keOgawpJQTxnQVr1Lc5sFAptGb4Mx19lSY4c2lFRjpRSUSIgAAAIAo/yT9iqm1dD6n9sD982FK77WgPCUZQKAb7EqYx4qA4W8+GafkvvQSPHJ/ogrA+xS9+W/Y7MCMbqLLKC+si6gbSuLOxORP1EYMHLUOkJ2jPOCwYyDt1p7ZnFXJ9LP+cWeehuyujp4r7xlazcpwBm+n1j24Q2p4uX6v7BCpt0MEXA== liutao@manager_network

EOF



八、把/tftpboot/ 目录的权限修改为最大

  chmod 777 /tftpboot/ -R


九、关闭防火墙并启动相关的服务

 1、关闭防火墙

  service iptables stop


 2、关闭selinux (关闭后重启机器)

   vi /etc/selinux/config

   SELINUX=disabled


 3、启动服务

  service dhcpd start

  service xinetd start

  service rpcbind start  

  service nfslock start

  service nfs start

 4、把上面的服务写到启动项

  vi /etc/rc.local

  service iptables stop

  service dhcpd start

  service xinetd start

  service rpcbind start  

  service nfslock start

  service nfs start


10 、kicstart的配置文件可以通过图形界面获取安装信息

   (1)、yum install system-config-kickstart*    #安装kickstart图形管理界面

   (2)、安装x server功能的Xming组件结合CRT使用执行下面的命令就会出现图形界面

          system-config-kickstart

      

你可能感兴趣的:(kickstart,自动化安装)