[关闭]
@cdmonkey 2018-10-23T12:27:33.000000Z 字数 8647 阅读 928

Cobbler

运维工具


http://cobbler.github.io

一、Install

  1. [root@Node-A1 ~]# yum install -y httpd dhcp tftp cobbler cobbler-web

启动服务:

  1. [root@Node-A1 ~]# /etc/init.d/httpd start
  2. [root@Node-A1 ~]# /etc/init.d/cobblerd start
  1. [root@Node-A1 ~]# cobbler check
  2. The following are potential configuration items that you may want to fix:
  3. 1 :
  4. 2 :
  5. ...
  6. #这里显示的提示信息是当前发现的问题,当这些问题解决了才能正确的工作。
  7. Restart cobblerd and then run 'cobbler sync' to apply changes.

根据提示解决问题:

1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
  1. [root@Node-A1 ~]# vim /etc/cobbler/settings
  2. #272:
  3. next_server: 127.0.0.1 --> next_server: 172.16.1.21
  4. #384:
  5. server: 127.0.0.1 --> server: 172.16.1.21

以上两个地址(server & next_server)应修改为本服务器的地址。

3 : change 'disable' to 'no' in /etc/xinetd.d/tftp
  1. [root@Node-A1 ~]# vim /etc/xinetd.d/tftp
  2. disable = yes --> disable = no
4 : 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.
  1. [root@Node-A1 ~]# cobbler get-loaders
  2. task started: 2015-09-15_110812_get_loaders
  3. ...
  4. *** TASK COMPLETE ***
5 : change 'disable' to 'no' in /etc/xinetd.d/rsync
  1. [root@Node-A1 ~]# vim /etc/xinetd.d/rsync
  2. disable = yes --> disable = no
  3. #Restart xinetd service:
  4. [root@Node-A1 ~]# /etc/init.d/xinetd restart
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories

该条提示信息可以忽略。

7 : ksvalidator was not found, install pykickstart
  1. [root@Node-A1 ~]# yum install -y pykickstart
8 : 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
  1. #首先需要生成加密后的密码:
  2. [root@Node-A1 ~]# openssl passwd -1 -salt 'cdmonkey' '123456'
  3. $1$cdmonkey$G/SY3idUd.svpaoBDS5Gq/
  4. [root@Node-A1 ~]# vim /etc/cobbler/settings
  5. #101:
  6. default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac." -->
  7. default_password_crypted: "$1$cdmonkey$G/SY3idUd.svpaoBDS5Gq/"

该命令的用法:任意字符(random-phrase)可以随便写,这个密码就是安装完系统根用户的密码了。

9 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

该条提示信息可以忽略。

处理完上述提示信息后重启“Cobbler”服务,并重新执行检查操作:

  1. #Restart cobbler service:
  2. [root@Node-A1 ~]# /etc/init.d/cobblerd restart
  3. #Recheck:
  4. [root@Node-A1 ~]# cobbler check
  5. The following are potential configuration items that you may want to fix:
  6. 1 : debmirror package is not installed, it will be required to manage debian deployments and repositories
  7. 2 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
  8. Restart cobblerd and then run 'cobbler sync' to apply changes.

按照上面的提示,执行同步指令已同意上述变更:

  1. [root@Node-A1 ~]# cobbler sync
  2. task started: 2015-09-15_113820_sync
  3. ...
  4. *** TASK COMPLETE ***

至此为止,服务安装成功。

二、Manage DHCP

首先,我们如果要通过“Cobbler”来管理DHCP的话,那么需要修改对应的设置文件模板,而不再使用DHCP自身的设置文件,服务会自动生成DHCP的设置文件。

  1. [root@Node-A1 ~]# vim /etc/cobbler/dhcp.template
  2. #在此需要按照你试驾的网络情况进行设置(除此之外的内容使用默认即可):
  3. subnet 172.16.1.0 netmask 255.255.255.0 {
  4. option routers 172.16.1.2;
  5. option domain-name-servers 172.16.1.2;
  6. option subnet-mask 255.255.255.0;
  7. range dynamic-bootp 172.16.1.100 172.16.1.254;
  8. default-lease-time 21600;
  9. max-lease-time 43200;
  10. next-server $next_server;
  1. [root@Node-A1 ~]# vim /etc/cobbler/settings
  2. #242:
  3. manage_dhcp: 0 --> manage_dhcp: 1 #Allow Cobbler to manage the DHCP.
  4. #Restart cobbler service:
  5. [root@Node-A1 ~]# /etc/init.d/cobblerd restart
  6. #Sync:
  7. [root@Node-A1 ~]# cobbler sync

挂载光盘镜像文件:

  1. mount -o loop -t iso9660 /root/ISO/CentOS-6.6-x86_64-bin-DVD1.iso /mnt/cdrom/
  1. [root@Node-A1 ~]# cobbler import --path=/mnt/cdrom/ --name=CentOS-6.6-x86_64 --arch=x86_64
  2. task started: 2015-09-15_150614_import
  3. ...
  4. *** TASK COMPLETE ***

查看当前的已有的设置文件:

  1. [root@Node-A1 ~]# cobbler profile report
  2. Name : CentOS-6.6-x86_64
  3. TFTP Boot Files : {}
  4. Comment :
  5. DHCP Tag : default
  6. Distribution : CentOS-6.6-x86_64
  7. Enable gPXE? : 0
  8. Enable PXE Menu? : 1
  9. Fetchable Files : {}
  10. Kernel Options : {}
  11. Kernel Options (Post Install) : {}
  12. Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks
  13. Kickstart Metadata : {}
  14. Management Classes : []
  15. Management Parameters : <<inherit>>
  16. Name Servers : []
  17. Name Servers Search Path : []
  18. Owners : ['admin']
  19. Parent Profile :
  20. Internal proxy :
  21. Red Hat Management Key : <<inherit>>
  22. Red Hat Management Server : <<inherit>>
  23. Repos : []
  24. Server Override : <<inherit>>
  25. Template Files : {}
  26. Virt Auto Boot : 1
  27. Virt Bridge : xenbr0
  28. Virt CPUs : 1
  29. Virt Disk Driver Type : raw
  30. Virt File Size(GB) : 5
  31. Virt Path :
  32. Virt RAM (MB) : 512
  33. Virt Type : kvm

通过上面的输出可以看出,存在一个默认的Kickstart文件,我们不使用该默认的文件,而是另外指定一个Kickstart文件来使用。首先创建该文件:

  1. [root@Node-A1 ~]# cat /var/lib/cobbler/kickstarts/CentOS-6.5-x86_64.cfg
  2. #Kickstart Configurator by Jason Zhao
  3. #platform=x86, AMD64, or Intel EM64T
  4. key --skip
  5. #System language
  6. lang en_US
  7. #System keyboard
  8. keyboard us
  9. #Sytem timezone
  10. timezone Asia/Shanghai
  11. #Root password
  12. rootpw --iscrypted $default_password_crypted
  13. #Use text mode install
  14. text
  15. #Install OS instead of upgrade
  16. install
  17. #Use NFS installation Media
  18. url --url=$tree
  19. #System bootloader configuration
  20. bootloader --location=mbr
  21. #Clear the Master Boot Record
  22. zerombr yes
  23. #Partition clearing information
  24. clearpart --all --initlabel
  25. #Disk partitioning information
  26. part /boot --fstype ext4 --size 1024 --ondisk sda
  27. part swap --size 16384 --ondisk sda
  28. part / --fstype ext4 --size 1 --grow --ondisk sda
  29. #System authorization infomation
  30. auth --useshadow --enablemd5
  31. #Network information
  32. #$SNIPPET('network_config')
  33. network --bootproto=dhcp --device=eth0 --onboot=on
  34. # Reboot after installation
  35. reboot
  36. #Firewall configuration
  37. firewall --disabled
  38. #SELinux configuration
  39. selinux --disabled
  40. #Do not configure XWindows
  41. skipx
  42. #Package install information
  43. %packages
  44. @ base
  45. @ chinese-support
  46. @ core
  47. sysstat
  48. iptraf
  49. ntp
  50. e2fsprogs-devel
  51. keyutils-libs-devel
  52. krb5-devel
  53. libselinux-devel
  54. libsepol-devel
  55. lrzsz
  56. ncurses-devel
  57. openssl-devel
  58. zlib-devel
  59. OpenIPMI-tools
  60. mysql
  61. lockdev
  62. minicom
  63. nmap
  64. %post
  65. #/bin/sed -i 's/#Protocol 2,1/Protocol 2/' /etc/ssh/sshd_config
  66. /bin/sed -i 's/^ca::ctrlaltdel:/#ca::ctrlaltdel:/' /etc/inittab
  67. /sbin/chkconfig --level 3 diskdump off
  68. /sbin/chkconfig --level 3 dc_server off
  69. /sbin/chkconfig --level 3 nscd off
  70. /sbin/chkconfig --level 3 netfs off
  71. /sbin/chkconfig --level 3 psacct off
  72. /sbin/chkconfig --level 3 mdmpd off
  73. /sbin/chkconfig --level 3 netdump off
  74. /sbin/chkconfig --level 3 readahead off
  75. /sbin/chkconfig --level 3 wpa_supplicant off
  76. /sbin/chkconfig --level 3 mdmonitor off
  77. /sbin/chkconfig --level 3 microcode_ctl off
  78. /sbin/chkconfig --level 3 xfs off
  79. /sbin/chkconfig --level 3 lvm2-monitor off
  80. /sbin/chkconfig --level 3 iptables off
  81. /sbin/chkconfig --level 3 nfs off
  82. /sbin/chkconfig --level 3 ipmi off
  83. /sbin/chkconfig --level 3 autofs off
  84. /sbin/chkconfig --level 3 iiim off
  85. /sbin/chkconfig --level 3 cups off
  86. /sbin/chkconfig --level 3 openibd off
  87. /sbin/chkconfig --level 3 saslauthd off
  88. /sbin/chkconfig --level 3 ypbind off
  89. /sbin/chkconfig --level 3 auditd off
  90. /sbin/chkconfig --level 3 rdisc off
  91. /sbin/chkconfig --level 3 tog-pegasus off
  92. /sbin/chkconfig --level 3 rpcgssd off
  93. /sbin/chkconfig --level 3 kudzu off
  94. /sbin/chkconfig --level 3 gpm off
  95. /sbin/chkconfig --level 3 arptables_jf off
  96. /sbin/chkconfig --level 3 dc_client off
  97. /sbin/chkconfig --level 3 lm_sensors off
  98. /sbin/chkconfig --level 3 apmd off
  99. /sbin/chkconfig --level 3 sysstat off
  100. /sbin/chkconfig --level 3 cpuspeed off
  101. /sbin/chkconfig --level 3 rpcidmapd off
  102. /sbin/chkconfig --level 3 rawdevices off
  103. /sbin/chkconfig --level 3 rhnsd off
  104. /sbin/chkconfig --level 3 nfslock off
  105. /sbin/chkconfig --level 3 winbind off
  106. /sbin/chkconfig --level 3 bluetooth off
  107. /sbin/chkconfig --level 3 isdn off
  108. /sbin/chkconfig --level 3 portmap off
  109. /sbin/chkconfig --level 3 anacron off
  110. /sbin/chkconfig --level 3 irda off
  111. /sbin/chkconfig --level 3 NetworkManager off
  112. /sbin/chkconfig --level 3 acpid off
  113. /sbin/chkconfig --level 3 pcmcia off
  114. /sbin/chkconfig --level 3 atd off
  115. /sbin/chkconfig --level 3 sendmail off
  116. /sbin/chkconfig --level 3 haldaemon off
  117. /sbin/chkconfig --level 3 smartd off
  118. /sbin/chkconfig --level 3 xinetd off
  119. /sbin/chkconfig --level 3 netplugd off
  120. /sbin/chkconfig --level 3 readahead_early off
  121. /sbin/chkconfig --level 3 xinetd off
  122. /sbin/chkconfig --level 3 ntpd on
  123. /sbin/chkconfig --level 3 avahi-daemon off
  124. /sbin/chkconfig --level 3 ip6tables off
  125. /sbin/chkconfig --level 3 restorecond off
  126. /sbin/chkconfig --level 3 postfix off

指定kickstart文件:

  1. [root@Node-A1 ~]# cobbler profile edit --name=CentOS-6.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6.6-x86_64.cfg
  2. ---------------
  3. #Sync:
  4. [root@Node-A1 ~]# cobbler sync

注意:进行了任何的改动后都要执行同步指令。

四、Other commands

列出当前已有的镜像文件:

  1. [root@Node-A1 ~]# cobbler distro list
  2. CentOS-6.6-x86_64

五、Config Web

  1. [root@Node-A1 ~]# vim /etc/cobbler/modules.conf

Add user

  1. [root@Node-A1 ~]# htdigest /etc/cobbler/users.digest "Cobbler" cobbler
  2. Changing password for user cobbler in realm Cobbler
  3. New password:
  4. Re-type new password:
  5. ---------------------
  6. #Restart service:
  7. [root@Node-A1 ~]# /etc/init.d/httpd restart
  8. [root@Node-A1 ~]# /etc/init.d/cobblerd restart
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注