有时候并不需要部署那么多的服务器,只是几台而已,但是又没有Kickstart全自动的环境,又不想到每一台上在那点下一步下一步,就可以用半自动咯。

这里不做过多说明,ks.cfg文件是必不可少的:

 
  
  1. #platform=x86, AMD64, 或 Intel EM64T 
  2. #version=DEVEL 
  3. # Firewall configuration 
  4. #firewall --enabled 
  5. firewall --disabled 
  6. # Install OS instead of upgrade 
  7. install 
  8. # Use network installation 
  9. url --url="http://192.168.1.39/pub/rhel/6.3/i386/" 
  10. # Root password 
  11. rootpw --iscrypted $1$p2FwPn7z$Fq7pmzmu4WUvbOQz06Gif1 
  12. # System authorization information 
  13. auth  --useshadow  --passalgo=sha512 
  14. # Use text mode install 
  15. text 
  16. # System keyboard 
  17. keyboard us 
  18. # System language 
  19. lang en_US 
  20. # SELinux configuration 
  21. #selinux --enforcing 
  22. selinux --disabled 
  23. # Do not configure the X Window System 
  24. skipx 
  25. # Installation logging level 
  26. logging --level=info 
  27. # Reboot after installation 
  28. reboot 
  29. # System timezone 
  30. timezone  Asia/Shanghai 
  31. # Network information 
  32. network  --bootproto=static --device=eth0 --gateway=192.168.1.1 --ip=192.168.1.175 --nameserver=8.8.8.8 --netmask=255.255.255.0 --onboot=on 
  33. # System bootloader configuration 
  34. bootloader --location=mbr 
  35. # Clear the Master Boot Record 
  36. zerombr 
  37. # Partition clearing information 
  38. clearpart --all 
  39. # Disk partitioning information 
  40. part /boot --asprimary --fstype=ext4 --size=200 
  41. part pv.01 --size=10240 
  42. volgroup vg01 --pesize=4096 pv.01 
  43. logvol swap --name=lv_swap --vgname=vg01 --size=512 
  44. logvol / --fstype=ext4 --name=lv_root --vgname=vg01 --grow --size=1 
  45.  
  46. %post 
  47. #!/bin/bash 
  48. # Post_install Script For RHEL 6 
  49.  
  50. rm -rf /etc/yum.repo/* 
  51.  
  52. cat >/etc/yum.repo/rhel6.repo<< EOF 
  53. [base] 
  54. nameRedHat Enterprise Linux 6.3 x86 - DVD Mirror 
  55. baseurl=file:///media/cdrom 
  56. enabled=1 
  57. gpgcheck=0 
  58. EOF 
  59.  
  60. mkdir /media/cdrom 
  61. mount /dev/cdrom /media/cdrom 
  62.  
  63. yum -y remove rhnlib yum-rhn-plugin rhn-client-tools rhn-setup rhn-check rhnsd subscription-manager 
  64.  
  65. echo "set nu" >> /etc/vimrc 
  66. echo "set nu" >> /etc/virc 
  67.  
  68. ## Disables IPv6 
  69. echo "install ipv6 /bin/true" > /etc/modprobe.d/ipv6.disable.conf 
  70. echo "IPV6INIT=no>> /etc/sysconfig/network 
  71.  
  72. ## Disables services 
  73. all_services=(`chkconfig --list | grep 3:on | awk '{print $1}' | grep -Ev "network|sshd"`) 
  74. for i in ${all_services[*]} 
  75.   do 
  76.      #service $i stop 
  77.      chkconfig --level 345 $i off 
  78.   done 
  79.  
  80. echo "/usr/bin/setterm -blank 0" >> /etc/rc.local 
  81.  
  82. cat >> /etc/bashrc << EOF 
  83. export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S  " 
  84. export HISTFILESIEZE=100000 
  85. export HISTSIZE=10000 
  86. EOF 
  87. source /etc/bashrc 
  88. history -c 
  89. echo "" > ~/.bash_history 
  90. exit 
  91. %end 
  92.  
  93. %packages 
  94. @base 
  95.  
  96. %end 

 

分区是使用的LVM,针对以后的应用可能方便点,root密码是123456。上面的脚本也加入了一些优化参数在安装后脚本里,可以针对实际情况就行修改。

简单说下怎么实现半自动,起码都的一台http服务器,有个yum源吧,保证网络畅通。那光盘启动,菜单界面按Tab键,加入ks文件的路径:

使用“ks=”写具体路径就行了,可以是ftp或者http,建议http,因为部署容易些。敲回车后就自动安装了,不用去管下一步下一步了。如果没有DHCP可能以开始要首先指定下IP地址。

另外还有一个问题,实体服务器一般至少会有两个以上的网卡(现在一般都4个了),在全自动部署rhel6的时候,就会弹出一下界面进行网卡选择

必须选择网卡才能进行下面的自动安装,这是RHEL5里没有这一步。解决方法并没在ks.cfg里

看上图,解决方法在指定ks路径的时候加上"ksdevice=eth0",指定为你对应的网卡就行。当然在全自动部署的环境里,就要在default文件里在“ks=...”的后面加上ksdevice指定设备去才能实现在生产环境中实体服务器的真正的全自动部署!