> CentOS > CentOS服务器 > 环境配置 >

利用Cobbler批量快速网络安装CentOS(3)


13.为导入的CentOS5.6镜像文件使用新的配置文件
 
  1. [root@server1 ~]# cobbler profile edit --name=centos5.6-i386 --distro=centos5.6-i386 --kickstart=/var/lib/cobbler/kickstarts/centos5.6-i386.ks 
/var/lib/cobbler/kickstarts/centos5.6-i386.ks 内容如下,红色部分为修改或者添加的:
 
 
  1. #platform=x86, AMD64, or Intel EM64T 
  2. # System authorization information 
  3. auth --useshadow --enablemd5 
  4.  
  5. # System bootloader configuration 
  6. bootloader --location=mbr
  7.  
  8. # Partition clearing information 
  9. clearpart --all --initlabel 
  10.  
  11. # Use text mode install 
  12. text 
  13.  
  14. # Firewall configuration 
  15. firewall --disable 
  16.  
  17. # Run the Setup Agent on first boot 
  18. firstboot --disable 
  19.  
  20. # System keyboard 
  21. keyboard us 
  22.  
  23. # System language 
  24. lang zh_CN.UTF-8 
  25.  
  26. # Use network installation 
  27. url --url=$tree 
  28.  
  29. # If any cobbler repo definitions were referenced in the kickstart profile, include them here. 
  30. $yum_repo_stanza 
  31.  
  32. # Network information 
  33. $SNIPPET('network_config') 
  34.  
  35. # Reboot after installation 
  36. reboot 
  37.  
  38. #Root password 
  39. rootpw --iscrypted $default_password_crypted 
  40.  
  41. # SELinux configuration 
  42. selinux --disabled 
  43.  
  44. # Do not configure the X Window System 
  45. skipx 
  46.  
  47. # System timezone 
  48. timezone Asia/Shanghai 
  49.  
  50. # Install OS instead of upgrade 
  51. install 
  52.  
  53. # Clear the Master Boot Record 
  54. zerombr 
  55.  
  56. # Allow anaconda to partition the system as needed 
  57. # autopart 
  58.  
  59. #NO LVM 这里的分区没有配置LVM 
  60. part /boot --bytes-per-inode=4096--fstype="ext3"--size=200
  61. part swap --bytes-per-inode=4096--fstype="swap"--size=800
  62. part /  --bytes-per-inode=4096--fstype="ext3"--size=5000
  63. part /data  --bytes-per-inode=4096--fstype="ext3" --grow --size=1
  64.  
  65. #LVM Setting 这的分区有配置LVM 
  66. #part /boot --bytes-per-inode=4096--fstype="ext3"--size=200
  67. #part swap --bytes-per-inode=4096--fstype="swap"--size=800
  68. #part pv.01 --size=1 --grow 
  69. #volgroup myvg pv.01 
  70. #logvol / --vgname=myvg--size=5000--name=rootvol--bytes-per-inode=4096--fstype="ext3"
  71. #logvol /data --vgname=myvg--size=1 --grow --name=datavol--bytes-per-inode=4096--fstype="ext3"
  72.  
  73. # network configure 
  74. network --bootproto=dhcp--device=eth0 --noipv6 --onboot=on --hostname=test.com 
  75. # network --bootproto=static--device=eth1--ip=192.168.1.2 --netmask=255.255.255.0 --gateway=192.168.1.1 --noipv6 --onboot=on 
  76.  
  77. %pre 
  78. $SNIPPET('log_ks_pre') 
  79. $SNIPPET('kickstart_start') 
  80. $SNIPPET('pre_install_network_config') 
  81. # Enable installation monitoring 
  82. $SNIPPET('pre_anamon') 
  83.  
  84. %packages 
  85. #$SNIPPET('func_install_if_enabled') 
  86. #$SNIPPET('puppet_install_if_enabled') 
  87. @base 
  88. @editors 
  89. @development-libs 
  90. @development-tools 
  91. @x-software-development 
  92. @system-tools 
  93. @text-internet 
  94. @chinese-support 
  95. imake 
  96. expect 
  97.  
  98. %post 
  99. $SNIPPET('log_ks_post') 
  100. # Start yum configuration 
  101. $yum_config_stanza 
  102. # End yum configuration 
  103. $SNIPPET('post_install_kernel_options') 
  104. $SNIPPET('post_install_network_config') 
  105. $SNIPPET('func_register_if_enabled') 
  106. $SNIPPET('puppet_register_if_enabled') 
  107. $SNIPPET('download_config_files') 
  108. $SNIPPET('koan_environment') 
  109. $SNIPPET('RedHat_register') 
  110. $SNIPPET('cobbler_register') 
  111. # Enable post-install boot notification 
  112. $SNIPPET('post_anamon') 
  113. # Start final steps 
  114. $SNIPPET('kickstart_done') 
  115. # End final steps 
  116.  
  117. %post 
  118. echo "ulimit -SHn 102400" >> /etc/rc.local 
  119.  
  120. sed -i 's/HISTSIZE\=1000/HISTSIZE\=50/' /etc/profile 
  121. sed -i "s/ca::ctrlaltdel:\/sbin\/shutdown -t3 -r now/#ca::ctrlaltdel:\/sbin\/shutdown -t3 -r now/" /etc/inittab 
  122. sed -i '48,50 s/^/#/' /etc/inittab 
  123. /sbin/init q 
  124.  
  125. sed -i "8 s/^/alias vi='vim'/" /root/.bashrc 
  126.  
  127. cat >> /root/.vimrc <<EOF
  128. syntax on 
  129. set number 
  130. set autoindent 
  131. set shiftwidth=4
  132. set encoding=utf-8 fileencodings=ucs-bom,utf-8,cp936 
  133. EOF 
  134.  
  135. sed -i -e '74 s/^/#/' -i -e '76 s/^/#/' /etc/ssh/sshd_config 
  136. sed -i "s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config 
  137. sed -i -e '44 s/^/#/' -i -e '48 s/^/#/' /etc/ssh/sshd_config 
  138.  
  139. for i in `ls /etc/rc3.d/S*` 
  140. do 
  141. CURSRV=`echo $i|cut -c 15-` 
  142. echo $CURSRV 
  143. case $CURSRV in 
  144. crond | irqbalance | microcode_ctl | network | random | sshd | syslog | local ) 
  145. echo "Base services, Skip!" 
  146. ;; 
  147. *) 
  148. echo "change $CURSRV to off" 
  149. chkconfig --level 235 $CURSRV off 
  150. service $CURSRV stop 
  151. ;; 
  152. esac 
  153. done 
  154.  
  155. true > /etc/sysctl.conf 
  156. cat >> /etc/sysctl.conf <<EOF
  157. kernel.sysrq = 0
  158. kernel.core_uses_pid = 1
  159. kernel.msgmnb = 65536
  160. kernel.msgmax = 65536
  161. kernel.shmmax = 68719476736
  162. kernel.shmall = 4294967296
  163.  
  164. net.core.wmem_default = 8388608
  165. net.core.rmem_default = 8388608
  166. net.core.rmem_max = 16777216
  167. net.core.wmem_max = 16777216
  168. net.core.netdev_max_backlog = 262144
  169. net.core.somaxconn = 262144
  170.  
  171. net.ipv4.ip_forward = 0
  172. net.ipv4.conf.default.rp_filter = 1
  173. net.ipv4.conf.default.accept_source_route = 0
  174. net.ipv4.tcp_syncookies = 1
  175. net.ipv4.tcp_max_tw_buckets = 6000
  176. net.ipv4.tcp_sack = 1
  177. net.ipv4.tcp_window_scaling = 1
  178. net.ipv4.tcp_rmem = 4096 87380 4194304 
  179. net.ipv4.tcp_wmem = 4096 16384 4194304 
  180. net.ipv4.tcp_max_orphans = 3276800
  181. net.ipv4.tcp_max_syn_backlog = 262144
  182. net.ipv4.tcp_timestamps = 0
  183. net.ipv4.tcp_synack_retries = 1
  184. net.ipv4.tcp_syn_retries = 1
  185. net.ipv4.tcp_tw_recycle = 1
  186. net.ipv4.tcp_tw_reuse = 1
  187. net.ipv4.tcp_mem = 94500000 915000000 927000000 
  188. net.ipv4.tcp_fin_timeout = 1
  189. net.ipv4.tcp_keepalive_time = 1200
  190. net.ipv4.ip_local_port_range = 1024 65535 
  191. EOF 
  192. /sbin/sysctl -p 
修改完成后,重启cobblerd,然后cobbler sync做一次同步,再次新建虚拟机测试。
 
14.错误收集:
[root@server1 ~]# service dhcpd start
启动 dhcpd: [失败]
 
查看/var/log/message 看到启动dhcp的过程中发现以下错误,
Dec 9 06:19:23 server1 dhcpd: ** You must add a global ddns-update-style statement to /etc/dhcpd.conf.
Dec 9 06:19:23 server1 dhcpd: To get the same behaviour as in 3.0b2pl11 and previous
Dec 9 06:19:23 server1 dhcpd: versions, add a line that says "ddns-update-style ad-hoc;"
Dec 9 06:19:23 server1 dhcpd: Please read the dhcpd.conf manual page for more information. **
主要原因是:
文件/etc/cobbler/settings里面
manage_dhcp: 0 没有修改为1 造成的
修改为1之后,
重启cobblerd,然后做一次 cobbler sync(cobbler会把dhcp.template里面的内容复制到了/etc/dhcpd.conf),就会自动的把dhcpd启动起来.

(责任编辑:IT)