感谢支持
我们一直在努力

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

Cobbler是什么?

Cobbler(补鞋匠)集成了PXE、DHCP、DNS、Kickstart服务管理和yum仓库管理工具,相对之前的 Kickstart 更加快捷、方便的批量布署Red Hat、CentOS类系统

测试环境:

VMware® Workstation : 9.0.0 build-812388

操作系统 : CentOS 5.6 32位

 

一.安装epel源
 

  1. [root@server1 ~]# wget http://dl.Fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
  2. [root@server1 ~]# rpm -ivh epel-release-5-4.noarch.rpm
  3. warning: epel-release-5-4.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6
  4. Preparing… ########################################### [100%]
  5. 1:epel-release ########################################### [100%]
  6. [root@server1 ~]#

安装epel源的好处
就是epel这个项目是由fedora维护的,在维护的这个源中包含许多软件,包括ntop,nagios之类的,也就是说,你安装了epel源就可以直接用yum install ntop来安装了,不过这个应该针对红帽企业版Linux(RHEL)及其衍生发行版(比如CentOS、Scientific Linux)系统,Ubuntu这类的应该不行。
 

二.安装与配置cobbler
 

1.安装cobbler和一些必须的包,并设置开机自动启动
 

  1. [root@server1 ~]# yum -y install cobbler httpd rsync tftp-server xinetd dhcp Python-ctypes pykickstart cman
  2. cobbler-2.2.2-1.el5.rf.noarch from rpmforge has depsolving problems
  3. > Missing Dependency: python-netaddr is needed by package cobbler-2.2.2-1.el5.rf.noarch (rpmforge)
  4. cobbler-2.2.2-1.el5.rf.noarch from rpmforge has depsolving problems
  5. > Missing Dependency: mod_wsgi is needed by package cobbler-2.2.2-1.el5.rf.noarch (rpmforge)
  6. Error: Missing Dependency: python-netaddr is needed by package cobbler-2.2.2-1.el5.rf.noarch (rpmforge)
  7. Error: Missing Dependency: mod_wsgi is needed by package cobbler-2.2.2-1.el5.rf.noarch (rpmforge)
  8. You could try using –skip-broken to work around the problem
  9. You could try running: package-cleanup –problems
  10. package-cleanup –dupes
  11. rpm -Va –nofiles –nodigest

我的系统需要安装这2个包。
 

  1. [root@server1 ~]# wget ftp://rpmfind.net/linux/epel/5/i386/python-netaddr-0.5.2-1.el5.noarch.rpm
  2. [root@server1 ~]# rpm -ivh python-netaddr-0.5.2-1.el5.noarch.rpm
  3. warning: python-netaddr-0.5.2-1.el5.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6
  4. Preparing… ########################################### [100%]
  5. 1:python-netaddr ########################################### [100%]
  6. [root@server1 ~]# wget ftp://rpmfind.net/linux/epel/5/i386/mod_wsgi-3.2-2.el5.i386.rpm
  7. [root@server1 ~]# rpm -ivh mod_wsgi-3.2-2.el5.i386.rpm
  8. warning: mod_wsgi-3.2-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6
  9. Preparing… ########################################### [100%]
  10. 1:mod_wsgi ########################################### [100%]

安装完成2个上面的包之后再次安装
 

  1. [root@server1 ~]# yum -y install cobbler httpd rsync tftp-server xinetd dhcp python-ctypes pykickstart cman
  2. …中间省略
  3. [root@server1 ~]# chkconfig httpd on
  4. [root@server1 ~]# chkconfig cobblerd on
  5. [root@server1 ~]# chkconfig dhcpd on
  6. [root@server1 ~]# chkconfig xinetd on
  7. [root@server1 ~]#/etc/init.d/iptables stop
  8. [root@server1 ~]#chkconfig –level 35 iptables off

服务控制脚本
 

  1. [root@server1 ~]#chmod +x /etc/init.d/cobbler_all
  2. 用法:/etc/init.d/cobbler_all start|stop|startus|sync

脚本内容:
 

  1. #!/bin/bash
  2. case $1 in
  3. start)
  4. /etc/init.d/httpd start
  5. /etc/init.d/xinetd start
  6. /etc/init.d/dhcpd start
  7. /etc/init.d/cobblerd start
  8. ;;
  9. stop)
  10. /etc/init.d/httpd stop
  11. /etc/init.d/xinetd stop
  12. /etc/init.d/dhcpd stop
  13. /etc/init.d/cobblerd stop
  14. ;;
  15. status)
  16. /etc/init.d/httpd status
  17. /etc/init.d/xinetd status
  18. /etc/init.d/dhcpd status
  19. /etc/init.d/cobblerd status
  20. ;;
  21. sync)
  22. cobbler sync
  23. ;;
  24. *)
  25. echo “Input error,please in put ‘start|stop|status|sync’!”;
  26. exit 2>&1 >/dev/null &
  27. ;;
  28. esac

 

相关配置文件及目录:
cobbler相关配置文件: /etc/cobbler
cobbler数据存储目录: /var/www/cobbler
dhcp配置文件: /etc/dhcpd.conf
dhcp租期缓存文件: /var/lib/dhcpd/dhcpd.leases
pxe配置文件: /tftpboot/pxelinux.cfg/default
ks模板文件: /var/lib/cobbler/kickstarts_*.ks

2.编辑vim /etc/cobbler/settings
 

  1. [root@server1 ~]# vim /etc/cobbler/settings
  2. next_server: 127.0.0.1 修改为:next_server: 192.168.0.45(是cobbler服务器的地址)
  3. server: 127.0.0.1 修改为: server: 192.168.0.45(是cobbler服务器的地址)
  4. manage_dhcp: 0 修改为 manage_dhcp: 1 (1意思就是由cobbler自动管理dhcpd)
  5. manage_rsync: 0 修改为 manage_rsync: 1 (1意思就是由cobbler自动管理rsync)

3.编辑/etc/httpd/conf/httpd.conf
 

  1. [root@server1 ~]# vim /etc/httpd/conf/httpd.conf 在LoadModule附近 添加以下行
  2. LoadModule suexec_module modules/mod_suexec.so
  3. LoadModule disk_cache_module modules/mod_disk_cache.so
  4. LoadModule file_cache_module modules/mod_file_cache.so
  5. LoadModule mem_cache_module modules/mod_mem_cache.so
  6. LoadModule cgi_module modules/mod_cgi.so
  7. LoadModule version_module modules/mod_version.so
  8. LoadModule wsgi_module modules/mod_wsgi.so < 在这里添加这行

4.启动httpd和cobbler
 

  1. [root@server1 ~]# service httpd start
  2. 启动 httpd: [确定]
  3. [root@server1 ~]# service cobblerd start
  4. Starting cobbler daemon: [确定]
  5. [root@server1 ~]#

5.编辑/etc/xinetd.d/rsync
 
 

  1. [root@server1 ~]# vim /etc/xinetd.d/rsync
  2. service rsync
  3. {
  4. disable = no 修改yes 为 no(就是启用)
  5. socket_type = stream
  6. wait = no
  7. user = root
  8. server = /usr/bin/rsync
  9. server_args = –daemon
  10. log_on_failure += USERID
  11. }

6.编辑/etc/xinetd.d/tftp
 

  1. [root@server1 ~]# vim /etc/xinetd.d/tftp
  2. service tftp
  3. {
  4. socket_type = dgram
  5. protocol = udp
  6. wait = yes
  7. user = root
  8. server = /usr/sbin/in.tftpd
  9. server_args = -s /tftpboot
  10. disable = no 修改yes 为 no(就是启用)
  11. per_source = 11
  12. cps = 100 2
  13. flags = IPv4
  14. }

7.编辑/etc/cobbler/dhcp.template
 

  1. [root@server1 ~]# vim /etc/cobbler/dhcp.template
  2. ddns-update-style interim;
  3. allow booting;
  4. allow bootp;
  5. ignore client-updates;
  6. set vendorclass = option vendor-class-identifier;
  7. subnet 192.168.0.0 netmask 255.255.255.0 {
  8. option routers 192.168.0.1;
  9. option domain-name-servers 192.168.0.1;
  10. option subnet-mask 255.255.255.0;
  11. range dynamic-bootp 192.168.0.10 192.168.0.20;
  12. filename “/pxelinux.0”;
  13. default-lease-time 21600;
  14. max-lease-time 43200;
  15. next-server $next_server;
  16. }

8.执行检查
 
 

  1. [root@server1 ~]# cobbler check
  2. The following are potential configuration items that you may want to fix:
  3. 1 : some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run ‘cobbler get-loaders’ to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely. Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The ‘cobbler get-loaders’ command is the easiest way to resolve these requirements.
  4. 2 : debmirror package is not installed, it will be required to manage debian deployments and repositories
  5. 3 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to ‘cobbler’ and should be changed, try: “openssl passwd -1 -salt ‘random-phrase-here’ ‘your-password-here'” to generate new one
  6. Restart cobblerd and then run ‘cobbler sync’ to apply changes.

修复第1条:
 

  1. [root@server1 ~]# cobbler get-loaders
  2. task started: 2012-12-09_055900_get_loaders
  3. task started (id=Download Bootloader Content, time=Sun Dec 9 05:59:00 2012)
  4. downloading http://dgoodwin.Fedorapeople.org/loaders/README to /var/lib/cobbler/loaders/README
  5. downloading http://dgoodwin.fedorapeople.org/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
  6. downloading http://dgoodwin.fedorapeople.org/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
  7. downloading http://dgoodwin.fedorapeople.org/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
  8. downloading http://dgoodwin.fedorapeople.org/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
  9. downloading http://dgoodwin.fedorapeople.org/loaders/yaboot-1.3.14-12 to /var/lib/cobbler/loaders/yaboot
  10. downloading http://dgoodwin.fedorapeople.org/loaders/pxelinux.0-3.61 to /var/lib/cobbler/loaders/pxelinux.0
  11. downloading http://dgoodwin.fedorapeople.org/loaders/menu.c32-3.61 to /var/lib/cobbler/loaders/menu.c32
  12. downloading http://dgoodwin.fedorapeople.org/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
  13. downloading http://dgoodwin.fedorapeople.org/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
  14. *** TASK COMPLETE *** <看到这就代表成功完成

第2条 不安装debian系统就不用修复
安装的话,下载debmirror这个对应版本的包进行安装

 

修复第3条:
 

  1. [root@server1 ~]# openssl passwd -1 -salt ‘thinkpad’ ‘123456’
  2. $1$thinkpad$NIq68XbeN51UgdtXiSOAE.

# thinkpad 这个是随机的数字或字母用来干扰以免被人看到 123456为root密码
然后再次编辑/etc/cobbler/settings,把以上生成的密码替换原有的密码(下面红色部分)
 

  1. default_password_crypted: “$1$thinkpad$NIq68XbeN51UgdtXiSOAE.”

9.导入镜像文件

镜像文件会存在/var/www/cobbler/ks_mirror/ 这个目录下
 

  1. [root@server1 log]# mkdir /mnt/CentOS5.6
  2. [root@server1 log]# mount /dev/cdrom /mnt/centos5.6/
  3. mount: block device /dev/cdrom is write-protected, mounting read-only
  4. [root@server1 log]# cobbler import –path=/mnt/centos5.6/ –name=centos5.6-i386 这个进行的时间比较长
  5. task started: 2012-12-09_064244_import
  6. task started (id=Media import, time=Sun Dec 9 06:42:44 2012)
  7. Found a RedHat compatible signature: CentOS
  8. adding distros
  9. creating new distro: centos5.6-xen-i386
  10. creating new profile: centos5.6-xen-i386
  11. creating new distro: centos5.6-i386
  12. creating new profile: centos5.6-i386
  13. associating repos
  14. traversing distro centos5.6-xen-i386
  15. descent into /var/www/cobbler/ks_mirror/centos5.6-i386
  16. processing repo at : /var/www/cobbler/ks_mirror/centos5.6-i386
  17. need to process repo/comps: /var/www/cobbler/ks_mirror/centos5.6-i386
  18. looking for /var/www/cobbler/ks_mirror/centos5.6-i386/repodata/*comps*.xml
  19. running: createrepo -c cache -s sha –groupfile /var/www/cobbler/ks_mirror/centos5.6-i386/repodata/comps.xml /var/www/cobbler/ks_mirror/centos5.6-i386
  20. 2644/2644 – CentOS/boost-doc-1.33.1-10.el5.i386.rpm pm86.rpm
  21. Saving Primary metadata
  22. Saving file lists metadata
  23. Saving other metadata
  24. received on stderr: This option is deprecated
  25. traversing distro centos5.6-i386
  26. descent into /var/www/cobbler/ks_mirror/centos5.6-i386
  27. processing repo at : /var/www/cobbler/ks_mirror/centos5.6-i386
  28. need to process repo/comps: /var/www/cobbler/ks_mirror/centos5.6-i386
  29. looking for /var/www/cobbler/ks_mirror/centos5.6-i386/repodata/*comps*.xml
  30. running: createrepo -c cache -s sha –groupfile /var/www/cobbler/ks_mirror/centos5.6-i386/repodata/comps.xml /var/www/cobbler/ks_mirror/centos5.6-i386
  31. 2644/2644 – CentOS/boost-doc-1.33.1-10.el5.i386.rpm pm86.rpm
  32. Saving Primary metadata
  33. Saving file lists metadata
  34. Saving other metadata
  35. received on stderr: This option is deprecated
  36. associating kickstarts
  37. *** TASK COMPLETE *** <看到这就代表成功完成

10.修复之后重启cobblerd ,然后做文件同步
 

  1. [root@server1 ~]# service cobblerd restart
  2. Stopping cobbler daemon: [确定]
  3. Starting cobbler daemon: [确定]
  4. [root@server1 ~]# cobbler sync
  5. task started: 2012-12-09_070816_sync
  6. task started (id=Sync, time=Sun Dec 9 07:08:16 2012)
  7. running pre-sync triggers
  8. cleaning trees
  9. removing: /var/www/cobbler/images/centos5.6-i386
  10. removing: /var/www/cobbler/images/centos5.6-xen-i386
  11. removing: /tftpboot/pxelinux.cfg/default
  12. removing: /tftpboot/grub/efidefault
  13. removing: /tftpboot/grub/grub-x86_64.efi
  14. removing: /tftpboot/grub/images
  15. removing: /tftpboot/grub/grub-x86.efi
  16. removing: /tftpboot/s390x/profile_list
  17. copying bootloaders
  18. trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi –> /tftpboot/grub/grub-x86_64.efi
  19. trying hardlink /var/lib/cobbler/loaders/grub-x86.efi –> /tftpboot/grub/grub-x86.efi
  20. copying distros to tftpboot
  21. copying files for distro: centos5.6-xen-i386
  22. trying hardlink /var/www/cobbler/ks_mirror/centos5.6-i386/images/xen/vmlinuz –> /tftpboot/images/centos5.6-xen-i386/vmlinuz
  23. trying hardlink /var/www/cobbler/ks_mirror/centos5.6-i386/images/xen/initrd.img –> /tftpboot/images/centos5.6-xen-i386/initrd.img
  24. copying files for distro: centos5.6-i386
  25. trying hardlink /var/www/cobbler/ks_mirror/centos5.6-i386/images/pxeboot/vmlinuz –> /tftpboot/images/centos5.6-i386/vmlinuz
  26. trying hardlink /var/www/cobbler/ks_mirror/centos5.6-i386/images/pxeboot/initrd.img –> /tftpboot/images/centos5.6-i386/initrd.img
  27. copying images
  28. generating PXE configuration files
  29. generating PXE menu structure
  30. copying files for distro: centos5.6-xen-i386
  31. trying hardlink /var/www/cobbler/ks_mirror/centos5.6-i386/images/xen/vmlinuz –> /var/www/cobbler/images/centos5.6-xen-i386/vmlinuz
  32. trying hardlink /var/www/cobbler/ks_mirror/centos5.6-i386/images/xen/initrd.img –> /var/www/cobbler/images/centos5.6-xen-i386/initrd.img
  33. copying files for distro: centos5.6-i386
  34. trying hardlink /var/www/cobbler/ks_mirror/centos5.6-i386/images/pxeboot/vmlinuz –> /var/www/cobbler/images/centos5.6-i386/vmlinuz
  35. trying hardlink /var/www/cobbler/ks_mirror/centos5.6-i386/images/pxeboot/initrd.img –> /var/www/cobbler/images/centos5.6-i386/initrd.img
  36. rendering DHCP files
  37. generating /etc/dhcpd.conf
  38. rendering TFTPD files
  39. generating /etc/xinetd.d/tftp
  40. cleaning link caches
  41. rendering Rsync files
  42. running post-sync triggers
  43. running Python triggers from /var/lib/cobbler/triggers/sync/post/*
  44. running python trigger cobbler.modules.sync_post_restart_services
  45. running: dhcpd -t -q
  46. received on stdout:
  47. received on stderr:
  48. running: service dhcpd restart
  49. received on stdout: 关闭 dhcpd:[确定]
  50. 启动 dhcpd:[确定]
  51. received on stderr:
  52. running shell triggers from /var/lib/cobbler/triggers/sync/post/*
  53. running python triggers from /var/lib/cobbler/triggers/change/*
  54. running python trigger cobbler.modules.scm_track
  55. running shell triggers from /var/lib/cobbler/triggers/change/*
  56. *** TASK COMPLETE *** <看到这就代表成功完成

查看导入结果:
[root@server1 ~]# cobbler distro list
centos5.6-i386 <- 这是刚刚导入的镜像的名字
centos5.6-xen-i386

11.启动xinetd服务
[root@server1 ~]# service xinetd start
 
12.先使用默认的kickstart配置文件来新建虚拟机测试
/var/lib/cobbler/kickstarts/sample.ks 这个是默认的,如果不为每个导入的镜像设置单独的配置,那么就默认会使用这个

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

 

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

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

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

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

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

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

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

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

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

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

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

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

安装完成之后会自动重启,重启后系统安装好了。
默认是:
计算机名未设置
IP地址自动获取
iptables 默认是开启状态,而且是有一一些规则在里面
selinux 默认是禁用的
默认分区方式:/boot 100M 剩余的做LVM,全部分给/
 

默认安装的软件包组;
Installed Groups:
Yum Utilities
拨号联网支持
系统工具
网络服务器
邮件服务器
gcc 未安装

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. # System bootloader configuration
  5. bootloader –location=mbr
  6. # Partition clearing information
  7. clearpart –all –initlabel
  8. # Use text mode install
  9. text
  10. # Firewall configuration
  11. firewall –disable
  12. # Run the Setup Agent on first boot
  13. firstboot –disable
  14. # System keyboard
  15. keyboard us
  16. # System language
  17. lang zh_CN.UTF-8
  18. # Use network installation
  19. url –url=$tree
  20. # If any cobbler repo definitions were referenced in the kickstart profile, include them here.
  21. $yum_repo_stanza
  22. # Network information
  23. $SNIPPET(‘network_config’)
  24. # Reboot after installation
  25. reboot
  26. #Root password
  27. rootpw –iscrypted $default_password_crypted
  28. # SELinux configuration
  29. selinux –disabled
  30. # Do not configure the X Window System
  31. skipx
  32. # System timezone
  33. timezone Asia/Shanghai
  34. # Install OS instead of upgrade
  35. install
  36. # Clear the Master Boot Record
  37. zerombr
  38. # Allow anaconda to partition the system as needed
  39. # autopart
  40. #NO LVM 这里的分区没有配置LVM
  41. part /boot –bytes-per-inode=4096–fstype=“ext3”–size=200
  42. part swap –bytes-per-inode=4096–fstype=“swap”–size=800
  43. part / –bytes-per-inode=4096–fstype=“ext3”–size=5000
  44. part /data –bytes-per-inode=4096–fstype=“ext3” –grow –size=1
  45. #LVM Setting 这的分区有配置LVM
  46. #part /boot –bytes-per-inode=4096–fstype=“ext3”–size=200
  47. #part swap –bytes-per-inode=4096–fstype=“swap”–size=800
  48. #part pv.01 –size=1 –grow
  49. #volgroup myvg pv.01
  50. #logvol / –vgname=myvg–size=5000–name=rootvol–bytes-per-inode=4096–fstype=“ext3”
  51. #logvol /data –vgname=myvg–size=1 –grow –name=datavol–bytes-per-inode=4096–fstype=“ext3”
  52. # network configure
  53. network –bootproto=dhcp–device=eth0 –noipv6 –onboot=on –hostname=test.com
  54. # network –bootproto=static–device=eth1–ip=192.168.1.2 –netmask=255.255.255.0 –gateway=192.168.1.1 –noipv6 –onboot=on
  55. %pre
  56. $SNIPPET(‘log_ks_pre’)
  57. $SNIPPET(‘kickstart_start’)
  58. $SNIPPET(‘pre_install_network_config’)
  59. # Enable installation monitoring
  60. $SNIPPET(‘pre_anamon’)
  61. %packages
  62. #$SNIPPET(‘func_install_if_enabled’)
  63. #$SNIPPET(‘puppet_install_if_enabled’)
  64. @base
  65. @editors
  66. @development-libs
  67. @development-tools
  68. @x-software-development
  69. @system-tools
  70. @text-internet
  71. @chinese-support
  72. imake
  73. expect
  74. %post
  75. $SNIPPET(‘log_ks_post’)
  76. # Start yum configuration
  77. $yum_config_stanza
  78. # End yum configuration
  79. $SNIPPET(‘post_install_kernel_options’)
  80. $SNIPPET(‘post_install_network_config’)
  81. $SNIPPET(‘func_register_if_enabled’)
  82. $SNIPPET(‘puppet_register_if_enabled’)
  83. $SNIPPET(‘download_config_files’)
  84. $SNIPPET(‘koan_environment’)
  85. $SNIPPET(‘RedHat_register’)
  86. $SNIPPET(‘cobbler_register’)
  87. # Enable post-install boot notification
  88. $SNIPPET(‘post_anamon’)
  89. # Start final steps
  90. $SNIPPET(‘kickstart_done’)
  91. # End final steps
  92. %post
  93. echo “ulimit -SHn 102400” >> /etc/rc.local
  94. sed -i ‘s/HISTSIZE\=1000/HISTSIZE\=50/’ /etc/profile
  95. sed -i “s/ca::ctrlaltdel:\/sbin\/shutdown -t3 -r now/#ca::ctrlaltdel:\/sbin\/shutdown -t3 -r now/” /etc/inittab
  96. sed -i ‘48,50 s/^/#/’ /etc/inittab
  97. /sbin/init q
  98. sed -i “8 s/^/alias vi=‘vim’/” /root/.bashrc
  99. cat >> /root/.vimrc <<EOF
  100. syntax on
  101. set number
  102. set autoindent
  103. set shiftwidth=4
  104. set encoding=utf-8 fileencodings=ucs-bom,utf-8,cp936
  105. EOF
  106. sed -i -e ’74 s/^/#/’ -i -e ’76 s/^/#/’ /etc/ssh/sshd_config
  107. sed -i “s/#UseDNS yes/UseDNS no/” /etc/ssh/sshd_config
  108. sed -i -e ’44 s/^/#/’ -i -e ’48 s/^/#/’ /etc/ssh/sshd_config
  109. for i in `ls /etc/rc3.d/S*`
  110. do
  111. CURSRV=`echo $i|cut -c 15-`
  112. echo $CURSRV
  113. case $CURSRV in
  114. crond | irqbalance | microcode_ctl | network | random | sshd | syslog | local )
  115. echo “Base services, Skip!”
  116. ;;
  117. *)
  118. echo “change $CURSRV to off”
  119. chkconfig –level 235 $CURSRV off
  120. service $CURSRV stop
  121. ;;
  122. esac
  123. done
  124. true > /etc/sysctl.conf
  125. cat >> /etc/sysctl.conf <<EOF
  126. kernel.sysrq = 0
  127. kernel.core_uses_pid = 1
  128. kernel.msgmnb = 65536
  129. kernel.msgmax = 65536
  130. kernel.shmmax = 68719476736
  131. kernel.shmall = 4294967296
  132. net.core.wmem_default = 8388608
  133. net.core.rmem_default = 8388608
  134. net.core.rmem_max = 16777216
  135. net.core.wmem_max = 16777216
  136. net.core.netdev_max_backlog = 262144
  137. net.core.somaxconn = 262144
  138. net.ipv4.ip_forward = 0
  139. net.ipv4.conf.default.rp_filter = 1
  140. net.ipv4.conf.default.accept_source_route = 0
  141. net.ipv4.tcp_syncookies = 1
  142. net.ipv4.tcp_max_tw_buckets = 6000
  143. net.ipv4.tcp_sack = 1
  144. net.ipv4.tcp_window_scaling = 1
  145. net.ipv4.tcp_rmem = 4096 87380 4194304
  146. net.ipv4.tcp_wmem = 4096 16384 4194304
  147. net.ipv4.tcp_max_orphans = 3276800
  148. net.ipv4.tcp_max_syn_backlog = 262144
  149. net.ipv4.tcp_timestamps = 0
  150. net.ipv4.tcp_synack_retries = 1
  151. net.ipv4.tcp_syn_retries = 1
  152. net.ipv4.tcp_tw_recycle = 1
  153. net.ipv4.tcp_tw_reuse = 1
  154. net.ipv4.tcp_mem = 94500000 915000000 927000000
  155. net.ipv4.tcp_fin_timeout = 1
  156. net.ipv4.tcp_keepalive_time = 1200
  157. net.ipv4.ip_local_port_range = 1024 65535
  158. EOF
  159. /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启动起来.

赞(0) 打赏
转载请注明出处:服务器评测 » 利用Cobbler批量快速网络安装CentOS
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏