cobbler介绍


cobbler官网:http://cobbler.github.io/
用个人的话来说就是cobbler就是一款通过网络快速安装Linux操作系统的产品。
cobbler可以配置,管理DNS和DHCP,包括软件包的更新,电源管理,配置管理流程等,类似于PXE+Kickstart。

系统实验环境介绍和准备


系统环境介绍

  1. [root@linux-node1 ~]# cat /etc/redhat-release
  2. CentOS Linux release 7.1.1503 (Core)
  3. [root@linux-node1 ~]# uname -rm
  4. 3.10.0-229.el7.x86_64 x86_64
  5. [root@linux-node1 ~]#

关闭selinux和iptables,这里不做叙述  

1、下载epel源

Cobbler的包在epel源中

复制下面下载地址

 2、安装epel源

  1. [root@linux-node1 ~]# rpm -ivh https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
  2. Retrieving https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
  3. warning: /var/tmp/rpm-tmp.cm5Tmb: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
  4. Preparing... ################################# [100%]
  5. Updating / installing...
  6. 1:epel-release-7-9 ################################# [100%]
  7. [root@linux-node1 ~]# ll /etc/yum.repos.d/epel
  8. epel.repo epel-testing.repo

  

安装cobbler环境所需的包


其中cobbler-web能让通过浏览器关闭cobbler,其实前面所需组件dhcp和tftp也都是kickstart+pxe装机时所需。cobbler功能更多。但是大体原理和kickstart一致

cobber是python语言开发的(同样由python开发的有yum和saltstack等)

  1. [root@linux-node1 ~]# yum install -y httpd dhcp tftp cobbler cobbler-web pykickstart
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. * base: mirrors.aliyun.com
  5. * epel: mirrors.ustc.edu.cn
  6. * extras: mirrors.zju.edu.cn
  7. * updates: mirrors.163.com
  8. Package httpd-2.4.6-45.el7.centos.x86_64 already installed and latest version
  9. Package 12:dhcp-4.2.5-47.el7.centos.x86_64 already installed and latest version
  10. Package tftp-5.2-13.el7.x86_64 already installed and latest version
  11. Package cobbler-2.8.0-4.el7.x86_64 already installed and latest version
  12. Package cobbler-web-2.8.0-4.el7.noarch already installed and latest version
  13. Package pykickstart-1.99.66.10-1.el7.noarch already installed and latest version
  14. Nothing to do
  15. [root@linux-node1 ~]#

安装并启动xinetd(这一段是前面遗漏补充的,放到了这里,应该在上面包一起安装的)

  1. [root@linux-node1 ~]# yum install xinetd -y
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. * base: mirrors.aliyun.com
  5. * epel: mirrors.ustc.edu.cn
  6. * extras: mirrors.cn99.com
  7. * updates: mirrors.163.com
  8. Package 2:xinetd-2.3.15-13.el7.x86_64 already installed and latest version
  9. Nothing to do
  10. [root@linux-node1 ~]# systemctl enable xinetd
  11. [root@linux-node1 ~]# systemctl start xinetd
  12. [root@linux-node1 ~]#

  

cobbler会默认在apache配置目录里创建2个文件,如下
  1. [root@linux-node1 ~]# ll /etc/httpd/conf.d/
  2. total 36
  3. -rw-r--r-- 1 root root 2926 Nov 15 02:04 autoindex.conf
  4. -rw-r--r-- 1 root root 1087 Feb 1 07:25 cobbler.conf
  5. -rw-r--r-- 1 root root 1165 Feb 1 07:26 cobbler_web.conf
  6. -rw-r--r-- 1 root root 366 Nov 15 02:05 README
  7. -rw-r--r-- 1 root root 9438 Nov 15 00:53 ssl.conf
  8. -rw-r--r-- 1 root root 1252 Nov 15 00:53 userdir.conf
  9. -rw-r--r-- 1 root root 824 Nov 15 00:53 welcome.conf
  10. [root@linux-node1 ~]#

简单查看下cobbler.conf配置文件内容

  1. [root@linux-node1 ~]# head -20 /etc/httpd/conf.d/cobbler.conf
  2. # This configuration file allows cobbler data
  3. # to be accessed over HTTP.
  4.  
  5. AliasMatch ^/cblr(?!/svc/)(.*)?$ "/var/www/cobbler$1"
  6. AliasMatch ^/cobbler_track(.*)?$ "/var/www/cobbler$1"
  7. #AliasMatch ^/cobbler(.*)?$ "/var/www/cobbler$1"
  8. Alias /cobbler /var/www/cobbler
  9. Alias /cobbler_webui_content /var/www/cobbler_webui_content
  10.  
  11. WSGIScriptAliasMatch ^/cblr/svc/([^/]*) /var/www/cobbler/svc/services.py
  12.  
  13. <Directory "/var/www/cobbler">
  14. SetEnv VIRTUALENV
  15. Options Indexes FollowSymLinks
  16. Order allow,deny
  17. Allow from all
  18. </Directory>
  19.  
  20. ProxyRequests off
  21.  
  22. [root@linux-node1 ~]#

还可以看到cobbler的api相关配置

启动httpd和cobbler,并设置开机启动

  1. [root@linux-node1 ~]# systemctl start httpd
  2. [root@linux-node1 ~]# systemctl start cobblerd
  3. [root@linux-node1 ~]# systemctl enable httpd
  4. Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
  5. [root@linux-node1 ~]# systemctl enable cobblerd
  6. Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.
  7. [root@linux-node1 ~]#

  

cobbler check检查和配置


执行cobbler  check命令,它会提示我们需要做一些配置

  1. [root@linux-node1 ~]# cobbler check
  2. The following are potential configuration items that you may want to fix:
  3.  
  4. 1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work.
  5. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
  6. 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,
  7. and should match the IP of the boot server on the PXE network.
  8. 3 : change 'disable' to 'no' in /etc/xinetd.d/tftp
  9. 4 : some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or,
  10. 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.
  11. Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi,
  12. and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
  13. 5 : enable and start rsyncd.service with systemctl
  14. 6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
  15. 7 : 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,
  16. try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
  17. 8 : fencing tools were not found, and are required to use the (optional) power management features.
  18. install cman or fence-agents to use them
  19.  
  20. Restart cobblerd and then run 'cobbler sync' to apply changes.
  21. [root@linux-node1 ~]#

(1)需要设置cobbler服务器IP地址

(2)next-server地址

(3)修改tftp配置,启用tftp

vim /etc/xinetd.d/tftp

(4)下载一些boot-loaders

它会从网上下载

  1. [root@linux-node1 ~]# cobbler get-loaders
  2. task started: 2017-04-03_165813_get_loaders
  3. task started (id=Download Bootloader Content, time=Mon Apr 3 16:58:13 2017)
  4. downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
  5. downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
  6. downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
  7. downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
  8. downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
  9. downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
  10. downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
  11. downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
  12. downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
  13. downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
  14. *** TASK COMPLETE ***
  15. [root@linux-node1 ~]#

  

(5)启动rsyncd服务并设置开机启动

  1. [root@linux-node1 ~]# systemctl start rsyncd
  2. [root@linux-node1 ~]# systemctl enable rsyncd
  3. Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
  4. [root@linux-node1 ~]#

  

(6)

提示如果是deb系统需要安装debmirror,这里我们是centos,可以不做

(7)修改模板里的密码

第7步提示说默认模板里密码是cobbler,这样装出来的系统默认root密码就都是cobbler了,你需要自定义一个不一样的密码。通过openssl生成一个加密的密码

这里设置密码为123456 ,并用cobbler字符填充到加密后的字符串里

-1:用MD5基于BSD的密钥算法。

-salt  string:用指定的字符串填充。当从终端读取一个密钥时,则填充它。

如下

  1. [root@linux-node1 ~]# openssl passwd -1 -salt 'cobbler' '123456'
  2. $1$cobbler$sqDDOBeLKJVmxTCZr52/11
  3. [root@linux-node1 ~]#

复制加密后的字符串到cobbler配置文件中替换原来的

vim /etc/cobbler/settings

重启cobblerd服务,看到配置已经完成了。下面1和2不用管

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

  

 
配置cobbler管理dhcp

 
接下来设置dhcp,最好让cobler管理dhcp
vim /etc/cobbler/settings
这里改成1,这样cobbler才能管理dhcp配置文件

修改dhcp模板文件,修改它之后,会自动生成dhcp的配置文件

vim /etc/cobbler/dhcp.template

$next_server这里不用修改,它会调用cobbler配置文件中之前设置的next_server的地址

执行cobbler sync的时候,它会自动生成dhcp的配置,并自动帮你重启dhcp
  1. [root@linux-node1 ~]# systemctl restart cobblerd
  2. [root@linux-node1 ~]# cobbler sync
  3. task started: 2017-04-03_183031_sync
  4. task started (id=Sync, time=Mon Apr 3 18:30:31 2017)
  5. running pre-sync triggers
  6. cleaning trees
  7. removing: /var/lib/tftpboot/grub/images
  8. copying bootloaders
  9. trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
  10. trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
  11. trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
  12. trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
  13. trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
  14. trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
  15. copying distros to tftpboot
  16. copying images
  17. generating PXE configuration files
  18. generating PXE menu structure
  19. rendering DHCP files
  20. generating /etc/dhcp/dhcpd.conf
  21. rendering TFTPD files
  22. generating /etc/xinetd.d/tftp
  23. cleaning link caches
  24. running post-sync triggers
  25. running python triggers from /var/lib/cobbler/triggers/sync/post/*
  26. running python trigger cobbler.modules.sync_post_restart_services
  27. running: dhcpd -t -q
  28. received on stdout:
  29. received on stderr:
  30. running: service dhcpd restart
  31. received on stdout:
  32. received on stderr: Redirecting to /bin/systemctl restart dhcpd.service
  33.  
  34. running shell triggers from /var/lib/cobbler/triggers/sync/post/*
  35. running python triggers from /var/lib/cobbler/triggers/change/*
  36. running python trigger cobbler.modules.scm_track
  37. running shell triggers from /var/lib/cobbler/triggers/change/*
  38. *** TASK COMPLETE ***
  39. [root@linux-node1 ~]#

  

查看dhcp的配置文件,已经变化了

vim /etc/dhcp/dhcpd.conf

前面的注释也可以看到提示

要修改就改模板文件,配置文件会被覆盖的

 
 
导入镜像到cobbler中

 
连接iso文件

挂载

  1. [root@linux-node1 ~]# mount /dev/cdrom /mnt
  2. mount: /dev/sr0 is write-protected, mounting read-only
  3. [root@linux-node1 ~]#

  

导入镜像到cobbler中

先查看下cobbler默认存储系统的目录,现在是没有系统镜像的状态

  1. [root@linux-node1 ~]# ll /var/www/cobbler/ks_mirror/
  2. total 0
  3. drwxr-xr-x 2 root root 6 Feb 1 07:25 config
  4. [root@linux-node1 ~]#

  

导入系统

从哪里导入,名称是什么,架构是什么

  1. [root@linux-node1 ~]# cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64
  2. task started: 2017-04-03_184305_import
  3. task started (id=Media import, time=Mon Apr 3 18:43:05 2017)
  4. Found a candidate signature: breed=redhat, version=rhel6
  5. Found a candidate signature: breed=redhat, version=rhel7
  6. Found a matching signature: breed=redhat, version=rhel7
  7. Adding distros from path /var/www/cobbler/ks_mirror/CentOS-7-x86_64:
  8. creating new distro: CentOS-7-x86_64
  9. trying symlink: /var/www/cobbler/ks_mirror/CentOS-7-x86_64 -> /var/www/cobbler/links/CentOS-7-x86_64
  10. creating new profile: CentOS-7-x86_64
  11. associating repos
  12. checking for rsync repo(s)
  13. checking for rhn repo(s)
  14. checking for yum repo(s)
  15. starting descent into /var/www/cobbler/ks_mirror/CentOS-7-x86_64 for CentOS-7-x86_64
  16. processing repo at : /var/www/cobbler/ks_mirror/CentOS-7-x86_64
  17. need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-7-x86_64
  18. looking for /var/www/cobbler/ks_mirror/CentOS-7-x86_64/repodata/*comps*.xml
  19. Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-7-x86_64/repodata
  20. *** TASK COMPLETE ***
  21. [root@linux-node1 ~]#

  

再次查看系统镜像的目录。

  1. [root@linux-node1 ~]# ll /var/www/cobbler/ks_mirror/
  2. total 4
  3. drwxr-xr-x 8 root root 4096 Apr 1 2015 CentOS-7-x86_64
  4. drwxr-xr-x 2 root root 33 Apr 3 18:45 config

  

再次导入centos6.6的系统。

重新挂载centos6.6的系统盘

  1. [root@linux-node1 ~]# mount /dev/cdrom /mnt
  2. mount: /dev/sr0 is write-protected, mounting read-only
  3. [root@linux-node1 ~]#

  

导入centos6.6系统到cobbler中

  1. [root@linux-node1 ~]# cobbler import --path=/mnt/ --name=CentOS-6-x86_64 --arch=x86_64
  2. task started: 2017-04-03_185814_import
  3. task started (id=Media import, time=Mon Apr 3 18:58:14 2017)
  4. Found a candidate signature: breed=redhat, version=rhel6
  5. Found a matching signature: breed=redhat, version=rhel6
  6. Adding distros from path /var/www/cobbler/ks_mirror/CentOS-6-x86_64:
  7. creating new distro: CentOS-6-x86_64
  8. trying symlink: /var/www/cobbler/ks_mirror/CentOS-6-x86_64 -> /var/www/cobbler/links/CentOS-6-x86_64
  9. creating new profile: CentOS-6-x86_64
  10. associating repos
  11. checking for rsync repo(s)
  12. checking for rhn repo(s)
  13. checking for yum repo(s)
  14. starting descent into /var/www/cobbler/ks_mirror/CentOS-6-x86_64 for CentOS-6-x86_64
  15. processing repo at : /var/www/cobbler/ks_mirror/CentOS-6-x86_64
  16. need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-6-x86_64
  17. looking for /var/www/cobbler/ks_mirror/CentOS-6-x86_64/repodata/*comps*.xml
  18. Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-6-x86_64/repodata
  19. *** TASK COMPLETE ***
  20. [root@linux-node1 ~]#

  

kickstart文件介绍


上传提前制作好的ks文件到系统上,下面这里是centos7的,这里如果实验的话,做好把交换分区改小点

  1. #Kickstart Configurator for cobbler by Jason Zhao
  2. #platform=x86, AMD64, or Intel EM64T
  3. #System language
  4. lang en_US
  5. #System keyboard
  6. keyboard us
  7. #Sytem timezone
  8. timezone Asia/Shanghai
  9. #Root password
  10. rootpw --iscrypted $default_password_crypted
  11. #Use text mode install
  12. text
  13. #Install OS instead of upgrade
  14. install
  15. #Use NFS installation Media
  16. url --url=$tree
  17. #System bootloader configuration
  18. bootloader --location=mbr
  19. #Clear the Master Boot Record
  20. zerombr
  21. #Partition clearing information
  22. clearpart --all --initlabel
  23. #Disk partitioning information
  24. part /boot --fstype xfs --size 1024 --ondisk sda
  25. part swap --size 16384 --ondisk sda
  26. part / --fstype xfs --size 1 --grow --ondisk sda
  27. #System authorization infomation
  28. auth --useshadow --enablemd5
  29. #Network information
  30. $SNIPPET('network_config')
  31. #network --bootproto=dhcp --device=em1 --onboot=on
  32. # Reboot after installation
  33. reboot
  34. #Firewall configuration
  35. firewall --disabled
  36. #SELinux configuration
  37. selinux --disabled
  38. #Do not configure XWindows
  39. skipx
  40. #Package install information
  41. %pre
  42. $SNIPPET('log_ks_pre')
  43. $SNIPPET('kickstart_start')
  44. $SNIPPET('pre_install_network_config')
  45. # Enable installation monitoring
  46. $SNIPPET('pre_anamon')
  47. %end
  48.  
  49. %packages
  50. @ base
  51. @ core
  52. sysstat
  53. iptraf
  54. ntp
  55. lrzsz
  56. ncurses-devel
  57. openssl-devel
  58. zlib-devel
  59. OpenIPMI-tools
  60. mysql
  61. nmap
  62. screen
  63. %end
  64.  
  65. %post
  66. systemctl disable postfix.service
  67. %end

  

下面挑一些重点说明下

这个就是在cobbler里面设置的密码,就是那个openssl生成的密码,它会引用
  1. #Root password
  2. rootpw --iscrypted $default_password_crypted

  

url=$tree 它是cobbler内部的变量
  1. #Use NFS installation Media
  2. url --url=$tree

  

bootloader安装在mbr上
  1. #System bootloader configuration
  2. bootloader --location=mbr

  

磁盘分区信息

  1. #Disk partitioning information
  2. part /boot --fstype xfs --size 1024 --ondisk sda
  3. part swap --size 16384 --ondisk sda
  4. part / --fstype xfs --size 1 --grow --ondisk sda

下面是一些要求安装的系统包

  1. %packages
  2. @ base
  3. @ core
  4. sysstat
  5. iptraf
  6. ntp
  7. lrzsz
  8. ncurses-devel
  9. openssl-devel
  10. zlib-devel
  11. OpenIPMI-tools
  12. mysql
  13. nmap
  14. screen
  15. %end

  

  

下面是现网使用的centos6的kickstart文件,装完之后,做了优化,关闭很多不必要的服务

  1. #Kickstart Configurator for cobbler by Jason Zhao
  2. #platform=x86, AMD64, or Intel EM64T
  3. key --skip
  4. #System language
  5. lang en_US
  6. #System keyboard
  7. keyboard us
  8. #Sytem timezone
  9. timezone Asia/Shanghai
  10. #Root password
  11. rootpw --iscrypted $default_password_crypted
  12. #Use text mode install
  13. text
  14. #Install OS instead of upgrade
  15. install
  16. #Use NFS installation Media
  17. url --url=$tree
  18. #System bootloader configuration
  19. bootloader --location=mbr
  20. #Clear the Master Boot Record
  21. zerombr yes
  22. #Partition clearing information
  23. clearpart --all --initlabel
  24. #Disk partitioning information
  25. part /boot --fstype ext4 --size 1024 --ondisk sda
  26. part swap --size 16384 --ondisk sda
  27. part / --fstype ext4 --size 1 --grow --ondisk sda
  28. #System authorization infomation
  29. auth --useshadow --enablemd5
  30. #Network information
  31. $SNIPPET('network_config')
  32. #network --bootproto=dhcp --device=em1 --onboot=on
  33. #Reboot after installation
  34. reboot
  35. #Firewall configuration
  36. firewall --disabled
  37. #SELinux configuration
  38. selinux --disabled
  39. #Do not configure XWindows
  40. skipx
  41. #Package install information
  42. %packages
  43. @ base
  44. @ chinese-support
  45. @ core
  46. sysstat
  47. iptraf
  48. ntp
  49. e2fsprogs-devel
  50. keyutils-libs-devel
  51. krb5-devel
  52. libselinux-devel
  53. libsepol-devel
  54. lrzsz
  55. ncurses-devel
  56. openssl-devel
  57. zlib-devel
  58. OpenIPMI-tools
  59. mysql
  60. lockdev
  61. minicom
  62. nmap
  63.  
  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

  

Cobbler 常用命令


cobbler check #检查cobbler配置

cobbler sync #同步配置到dhcp/pxe和数据目录

cobbler list #列出所有的cobbler元素

cobbler import #导入安装的系统镜像

cobbler report #列出各元素的详细信息

cobbler distro #查看导入的发行版系统信息

cobbler profile #查看配置信息

cobbler system #查看添加的系统信息

cobbler reposync #同步yum仓库到本地

查看当前配置信息

  1. [root@linux-node1 ~]# cobbler profile
  2. usage
  3. =====
  4. cobbler profile add
  5. cobbler profile copy
  6. cobbler profile dumpvars
  7. cobbler profile edit
  8. cobbler profile find
  9. cobbler profile getks
  10. cobbler profile list
  11. cobbler profile remove
  12. cobbler profile rename
  13. cobbler profile report
  14. [root@linux-node1 ~]# cobbler profile list
  15. CentOS-6-x86_64
  16. CentOS-7-x86_64
  17. [root@linux-node1 ~]#

  

查看详细配置信息,这里把centos7和centos6的配置信息都显示了

  1. [root@linux-node1 ~]# cobbler profile report
  2. Name : CentOS-7-x86_64
  3. TFTP Boot Files : {}
  4. Comment :
  5. DHCP Tag : default
  6. Distribution : CentOS-7-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
  34.  
  35. Name : CentOS-6-x86_64
  36. TFTP Boot Files : {}
  37. Comment :
  38. DHCP Tag : default
  39. Distribution : CentOS-6-x86_64
  40. Enable gPXE? : 0
  41. Enable PXE Menu? : 1
  42. Fetchable Files : {}
  43. Kernel Options : {}
  44. Kernel Options (Post Install) : {}
  45. Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks
  46. Kickstart Metadata : {}
  47. Management Classes : []
  48. Management Parameters : <<inherit>>
  49. Name Servers : []
  50. Name Servers Search Path : []
  51. Owners : ['admin']
  52. Parent Profile :
  53. Internal proxy :
  54. Red Hat Management Key : <<inherit>>
  55. Red Hat Management Server : <<inherit>>
  56. Repos : []
  57. Server Override : <<inherit>>
  58. Template Files : {}
  59. Virt Auto Boot : 1
  60. Virt Bridge : xenbr0
  61. Virt CPUs : 1
  62. Virt Disk Driver Type : raw
  63. Virt File Size(GB) : 5
  64. Virt Path :
  65. Virt RAM (MB) : 512
  66. Virt Type : kvm
  67.  
  68. [root@linux-node1 ~]#

  

可以看到有一行指定了默认的ks文件位置,需要改成自己实际文件位置

  1. Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks

  

把centos6和centos7的ks文件上传到下面目录下(文件内容和上面粘贴的一种,不过实验目的,建议虚拟内存可以改小点。这里我不更改虚拟内存了)

  1. [root@linux-node1 ~]# cd /var/lib/cobbler/kickstarts/
  2. [root@linux-node1 kickstarts]# rz -E
  3. rz waiting to receive.
  4. [root@linux-node1 kickstarts]# ls
  5. CentOS-6-x86_64.cfg esxi5-ks.cfg sample_autoyast.xml sample_esxi5.ks
  6. CentOS-7-x86_64.cfg install_profiles sample_end.ks sample.ks
  7. default.ks legacy.ks sample_esx4.ks sample_old.seed
  8. esxi4-ks.cfg pxerescue.ks sample_esxi4.ks sample.seed
  9. [root@linux-node1 kickstarts]#

  

更改centos6和centos7的ks文件位置

  1. [root@linux-node1 ~]# cobbler profile edit --name=CentOS-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7-x86_64.cfg
  2. [root@linux-node1 ~]# cobbler profile edit --name=CentOS-6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6-x86_64.cfg
  3. [root@linux-node1 ~]#

  

更改centos7的内核参数,让安装后网卡显示eth0


centos7 你想让网卡变成eth0 ,需要加内核参数
这里ks安装也需要加内核参数

通过看到有一行,关于设置内核参数的

  1. [root@linux-node1 ~]# cobbler profile report --name=CentOS-7-x86_64
  2. Name : CentOS-7-x86_64
  3. TFTP Boot Files : {}
  4. Comment :
  5. DHCP Tag : default
  6. Distribution : CentOS-7-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/CentOS-7-x86_64.cfg
  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
  34.  
  35. [root@linux-node1 ~]#

  

这一行的是关于内核参数的配置

  1. Kernel Options : {}

  

添加内核参数和查看

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

  

同步更改后的配置信息

可以看到它删除了/var/www下面的一些文件,然后重新生成

  1. [root@linux-node1 ~]# cobbler sync
  2. task started: 2017-04-03_194659_sync
  3. task started (id=Sync, time=Mon Apr 3 19:46:59 2017)
  4. running pre-sync triggers
  5. cleaning trees
  6. removing: /var/www/cobbler/images/CentOS-7-x86_64
  7. removing: /var/www/cobbler/images/CentOS-6-x86_64
  8. removing: /var/lib/tftpboot/pxelinux.cfg/default
  9. removing: /var/lib/tftpboot/grub/images
  10. removing: /var/lib/tftpboot/grub/grub-x86.efi
  11. removing: /var/lib/tftpboot/grub/grub-x86_64.efi
  12. removing: /var/lib/tftpboot/grub/efidefault
  13. removing: /var/lib/tftpboot/images/CentOS-7-x86_64
  14. removing: /var/lib/tftpboot/images/CentOS-6-x86_64
  15. removing: /var/lib/tftpboot/s390x/profile_list
  16. copying bootloaders
  17. trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
  18. trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
  19. copying distros to tftpboot
  20. copying files for distro: CentOS-7-x86_64
  21. trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-7-x86_64/vmlinuz
  22. trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-7-x86_64/initrd.img
  23. copying files for distro: CentOS-6-x86_64
  24. trying hardlink /var/www/cobbler/ks_mirror/CentOS-6-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-6-x86_64/vmlinuz
  25. trying hardlink /var/www/cobbler/ks_mirror/CentOS-6-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-6-x86_64/initrd.img
  26. copying images
  27. generating PXE configuration files
  28. generating PXE menu structure
  29. copying files for distro: CentOS-7-x86_64
  30. trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-7-x86_64/vmlinuz
  31. trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-7-x86_64/initrd.img
  32. Writing template files for CentOS-7-x86_64
  33. copying files for distro: CentOS-6-x86_64
  34. trying hardlink /var/www/cobbler/ks_mirror/CentOS-6-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-6-x86_64/vmlinuz
  35. trying hardlink /var/www/cobbler/ks_mirror/CentOS-6-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-6-x86_64/initrd.img
  36. Writing template files for CentOS-6-x86_64
  37. rendering DHCP files
  38. generating /etc/dhcp/dhcpd.conf
  39. rendering TFTPD files
  40. generating /etc/xinetd.d/tftp
  41. processing boot_files for distro: CentOS-7-x86_64
  42. processing boot_files for distro: CentOS-6-x86_64
  43. cleaning link caches
  44. running post-sync triggers
  45. running python triggers from /var/lib/cobbler/triggers/sync/post/*
  46. running python trigger cobbler.modules.sync_post_restart_services
  47. running: dhcpd -t -q
  48. received on stdout:
  49. received on stderr:
  50. running: service dhcpd restart
  51. received on stdout:
  52. received on stderr: Redirecting to /bin/systemctl restart dhcpd.service
  53.  
  54. running shell triggers from /var/lib/cobbler/triggers/sync/post/*
  55. running python triggers from /var/lib/cobbler/triggers/change/*
  56. running python trigger cobbler.modules.scm_track
  57. running shell triggers from /var/lib/cobbler/triggers/change/*
  58. *** TASK COMPLETE ***
  59. [root@linux-node1 ~]#
如果你修改文件不执行sync,修改是不生效的

测试部分


客户端启动一个未安装系统的机器。并设置网络为nat(和cobbler在一个网络)

cobbler服务器上查看下日志,后面客户机请求的时候会有dhcp请求信息(不是本次试验的重点,但是可以帮你理解dhcp请求的过程)

  1. [root@linux-node1 ~]# > /var/log/messages
  2. [root@linux-node1 ~]# tail -f /var/log/messages
 
dhcp请求的4个步骤
dhcp  discover
dhcp  offer
dhcp  request
dhcp  ack
 
启动新建的客户机。可以看到如下信息
当你不选择,它默认从本地硬盘启动,这个比较安全,防止类似kickstart方式时如果你设置网卡启动在第一项会把系统重装了

先选择安装centos7

选中,回车后显示如下,会下载kernel等安装

Cobbler服务器上查看系统日志,可以看到客户端一些请求过程

涉及dhcp和tftp

  1. [root@linux-node1 ~]# tail -f /var/log/messages
  2. Apr 3 20:00:01 linux-node1 systemd: Started Session 26 of user root.
  3. Apr 3 20:00:01 linux-node1 systemd: Starting Session 26 of user root.
  4. Apr 3 20:00:11 linux-node1 dhcpd: DHCPDISCOVER from 00:0c:29:c6:4f:61 via eth0
  5. Apr 3 20:00:12 linux-node1 dhcpd: DHCPOFFER on 192.168.58.130 to 00:0c:29:c6:4f:61 via eth0
  6. Apr 3 20:00:13 linux-node1 dhcpd: DHCPREQUEST for 192.168.58.130 (192.168.58.11) from 00:0c:29:c6:4f:61 via eth0
  7. Apr 3 20:00:13 linux-node1 dhcpd: DHCPACK on 192.168.58.130 to 00:0c:29:c6:4f:61 via eth0
  8. Apr 3 20:00:13 linux-node1 xinetd[4228]: START: tftp pid=4329 from=192.168.58.130
  9. Apr 3 20:00:14 linux-node1 in.tftpd[4330]: RRQ from 192.168.58.130 filename pxelinux.0
  10. Apr 3 20:00:14 linux-node1 in.tftpd[4330]: tftp: client does not accept options
  11. Apr 3 20:00:14 linux-node1 in.tftpd[4331]: RRQ from 192.168.58.130 filename pxelinux.0
  12. Apr 3 20:00:14 linux-node1 in.tftpd[4331]: Client 192.168.58.130 finished pxelinux.0
  13. Apr 3 20:00:14 linux-node1 in.tftpd[4332]: RRQ from 192.168.58.130 filename pxelinux.cfg/564d2e7e-ef72-685b-3635-3da2d1c64f61
  14. Apr 3 20:00:14 linux-node1 in.tftpd[4332]: Client 192.168.58.130 File not found pxelinux.cfg/564d2e7e-ef72-685b-3635-3da2d1c64f61
  15. Apr 3 20:00:14 linux-node1 in.tftpd[4333]: RRQ from 192.168.58.130 filename pxelinux.cfg/01-00-0c-29-c6-4f-61
  16. Apr 3 20:00:14 linux-node1 in.tftpd[4333]: Client 192.168.58.130 File not found pxelinux.cfg/01-00-0c-29-c6-4f-61
  17. Apr 3 20:00:14 linux-node1 in.tftpd[4334]: RRQ from 192.168.58.130 filename pxelinux.cfg/C0A83A82
  18. Apr 3 20:00:14 linux-node1 in.tftpd[4334]: Client 192.168.58.130 File not found pxelinux.cfg/C0A83A82

  

客户机系统安装完毕,登录

Cobbler自动装机--1的更多相关文章

  1. CentOS7中搭建cobbler自动装机服务

    一.实验环境 一台centos7 epel源网址 https://fedoraproject.org/wiki/EPEL?rd=Epel 使用nat模式 二.实验步骤 1.下载epel源后进行文件夹挂 ...

  2. Cobbler自动装机试验

    Cobbler自动装机简介:Cobbler是一个使用Python开发的开源项目,通过将部署系统所涉及的所有服务集中在一起,来提供一个全自动的批量快速建立Linux系统的网络安装环境.Cobbler提供 ...

  3. Cobbler自动装机--2

     自动重装工具--koan 客户机已经通过cobbler安装centos7系统完毕. 安装koan,能实现重装,安装之前先安装epel源 koan是kickstart-over-a-network的缩 ...

  4. 1. 自动化运维系列之Cobbler自动装机

    preface 我们之前批量安装操作系统的时候都是采用pxe来安装,pxe也是通过网络安装操作系统的,但是PXE依赖于DHCP,HTTP/TFTP,kicstart等支持.安装流程如下所示: 对于上面 ...

  5. Cobbler自动装机

    preface 我们之前批量安装操作系统的时候都是采用pxe来安装,pxe也是通过网络安装操作系统的,但是PXE依赖于DHCP,HTTP/TFTP,kicstart等支持.安装流程如下所示: 对于上面 ...

  6. cobbler自动装机服务简介与配置

    cobbler简介 Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装.重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等. Cobbler可以使用命令行 ...

  7. Cobbler自动部署装机 轻松解决装机烦恼

    Cobbler自动部署装机一.实验准备二.搭建步骤1.导入epel源2.安装Cobbler以及其相关服务软件包3.修改Cobbler 主配置文件4.启动相关服务并关闭防火墙和selinux5.使用co ...

  8. pxe+kickstart cobbler无人值守装机

    环境准备: 一台服务器 [root@admin tftpboot]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) [roo ...

  9. Cobbler自动部署主机系统

    Cobbler自动部署主机系统 简介: Cobbler由python语言开发,是对PXE和 Kickstart以及DHCP的封装.融合很多特性,提供了CLI和Web的管理形式.更加方便的实行网络安装. ...

随机推荐

  1. DevExpress v18.1新版亮点——CodeRush for VS篇(二)

    用户界面套包DevExpress v18.1日前正式发布,本站将以连载的形式为大家介绍各版本新增内容.本文将介绍了CodeRush for Visual Studio v18.1 的新功能,快来下载试 ...

  2. 关于ArrayList中的iterator返回的事迭代器实例问题。

    Arraylist是一个具体的类,它并没有定义它自己的iterator()方法,,它只是从AbstractList 这个抽象类中继承了iterator()这个方法,而AbstractList 中的it ...

  3. softmax与多分类

    sotfmax 函数在机器学习和深度学习中有着广泛的应用, 主要用于多分类问题. softmax 函数 1. 定义 假定数组V,那么第i个元素的softmax值为 也就是该元素的指数 除以 所有元素的 ...

  4. Linux文件系统命令 cd

    命令名:cd 功能:切换到某一个目录,后面可以跟相对路径和绝对路径. eg:cd /etc/ 表示的是进入到/etc/目录下 另外几个比较特俗的用法: cd - 切换到当前目录 cd ./ 还是当前路 ...

  5. Oracle function和procedure

    1.返回值的区别 函数有1个返回值,而存储过程是通过参数返回的,可以有多个或者没有 2. 调用的区别,函数可以在查询语句中直接调用,而存储过程必须单独调用. 函数:一般情况下是用来计算并返回一个计算结 ...

  6. ubantu 安装git

    1.安装git并配置 sudo add-apt-repository ppa:git-core/ppa sudo apt-get update sudo apt-get install git 可以使 ...

  7. ipv6地址管理

    为了彻底解决IPv4存在的问题,国际互联网工程任务组从1995年开始,着手研究开发下一代IP协议,即IPv6.可彻底解决IPv4地址不足的问题,除此之外,IPv6还采用分级地址模式.高效IP包头.主机 ...

  8. Popover 弹出框 设置top,显示有时是向下的,解决方式

    参数里面有个popper-options,官网给的值是{boundariesElement: 'body', gpuAcceleration: false },将这个加上问题就解决了.

  9. Non-technical Blog Recording on Day of Sep. 19th 2017 in Retrospection.

    Unfortunately, I heard a resignation message verbally from ESU (her name is: Su Yi in Chinese, Su fr ...

  10. java通过配置文件(Properties类)连接Oracle数据库代码示例

    import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java. ...