006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

1.1 cobbler简介

  Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。

  Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。

  Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。

  Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。

  Cobbler官网http://cobbler.github.io

  在使用cobbler之前需要了解kickstart的使用: http://www.cnblogs.com/clsn/p/7833333.html

1.1.1 cobbler集成的服务

   PXE服务支持

   DHCP服务管理

   DNS服务管理(可选bind,dnsmasq)

  电源管理

  Kickstart服务支持

  YUM仓库管理

  TFTP(PXE启动时需要)

  Apache(提供kickstart的安装源,并提供定制化的kickstart配置)

注意:

    • 虚拟机网卡采用NAT模式,不要使用桥接模式,因为稍后我们会搭建DHCP服务器,在同一局域网多个DHCP服务会有冲突。
    • VMware的NAT模式的dhcp服务也关闭,避免干扰。 
      006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

1.2 安装cobbler

1.2.1 环境说明

[root@Cobbler ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core) [root@Cobbler ~]# uname -r
3.10.0-693.el7.x86_64 [root@Cobbler ~]# getenforce
Disabled [root@Cobbler ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1) [root@Cobbler ~]# hostname -I
192.168.1.230

阿里云yum源说明:

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

1.2.2 使用yum安装cobbler

yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd

cobbler:核心程序不用多解释

dhcp:负责分配客户端IP,因为客户端没有IP,所以需要dhcp服务

tftp(Trivial File Transfer Protocol,简单文件传输协议):是TCP/IP协议族中的一个用来在客户机与服务器之间进行简单文件传输的协议,提供不复杂、开销不大的文件传输服务。端口号为69。

xinetd:xinetd已经取代了inetd,并且提供了访问控制、加强的日志和资源管理功能,已经成了Red Hat 7 和 Mandrake 7.2的Internet标准超级守护进程

syslinux:syslinux是一个功能强大的引导加载程序,而且兼容各种介质。它的目的是简化首次安装Linux的时间,并建立修护或其它特殊用途的启动盘。它提供pxelinux这个文件,pxelinux.0引导文件引导vmlinux和initrd两个启动文件

httpd:可以使别的主机可以从服务端获取镜像包

  1. [root@linux-node1 ~]# rpm -ql cobbler # 查看安装的文件,下面列出部分。
  2. /etc/cobbler # 配置文件目录
  3. /etc/cobbler/settings # cobbler主配置文件,这个文件是YAML格式,Cobbler是python写的程序。
  4. /etc/cobbler/dhcp.template # DHCP服务的配置模板
  5. /etc/cobbler/tftpd.template # tftp服务的配置模板
  6. /etc/cobbler/rsync.template # rsync服务的配置模板
  7. /etc/cobbler/iso # iso模板配置文件目录
  8. /etc/cobbler/pxe # pxe模板文件目录
  9. /etc/cobbler/power # 电源的配置文件目录
  10. /etc/cobbler/users.conf # Web服务授权配置文件
  11. /etc/cobbler/users.digest # 用于web访问的用户名密码配置文件
  12. /etc/cobbler/dnsmasq.template # DNS服务的配置模板
  13. /etc/cobbler/modules.conf # Cobbler模块配置文件
  14. /var/lib/cobbler # Cobbler数据目录
  15. /var/lib/cobbler/config # 配置文件
  16. /var/lib/cobbler/kickstarts # 默认存放kickstart文件
  17. /var/lib/cobbler/loaders # 存放的各种引导程序
  18. /var/www/cobbler # 系统安装镜像目录
  19. /var/www/cobbler/ks_mirror # 导入的系统镜像列表
  20. /var/www/cobbler/images # 导入的系统镜像启动文件
  21. /var/www/cobbler/repo_mirror # yum源存储目录
  22. /var/log/cobbler # 日志目录
  23. /var/log/cobbler/install.log # 客户端系统安装日志
  24. /var/log/cobbler/cobbler.log # cobbler日志

说明:cobbler是依赖与epel源下载

1.2.3 cobbler语法检查前先启动http与cobbler

systemctl start httpd.service
systemctl start cobblerd.service
cobbler check # 检查Cobbler的配置

1.2.4 进行语法检查

[root@Cobbler ~]# cobbler check
The following are potential configuration items that you may want to fix: 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. 3 : change 'disable' to 'no' in /etc/xinetd.d/tftp 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. 5 : enable and start rsyncd.service with systemctl 6 : debmirror package is not installed, it will be required to manage debian deployments and repositories 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, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one 8 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them Restart cobblerd and then run 'cobbler sync' to apply changes.

1.2.5 解决当中的报错

命令集

sed -i 's/server: 127.0.0.1/server: 192.168.1.230/' /etc/cobbler/settings
sed -i 's/next_server: 127.0.0.1/next_server: 192.168.1.230/' /etc/cobbler/settings
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
sed -ri "/default_password_crypted/s#(.*: ).*#\1\"`openssl passwd -1 -salt 'xue' '123456'`\"#" /etc/cobbler/settings
sed -i 's#yes#no#' /etc/xinetd.d/tftp systemctl start rsyncd
systemctl enable rsyncd
systemctl enable tftp.socket
systemctl start tftp.socket
systemctl restart cobblerd.service

.3 配置DHCP
# 修改cobbler的dhcp模版,不要直接修改dhcp本身的配置文件,因为cobbler会覆盖。
[root@linux-node1 ~]# vim /etc/cobbler/dhcp.template
# 仅列出修改过的字段
……
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option domain-name-servers 192.168.1.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.1.240 192.168.1.245;
……

cobbler sync  #同步最新cobbler配置,它会根据配置自动修改dhcp等服务。

# 再看一下dhcp的配置文件。
[root@linux-node1 ~]# less /etc/dhcp/dhcpd.conf
# ******************************************************************
# Cobbler managed dhcpd.conf file
# generated from cobbler dhcp.conf template (Thu Dec 3 12:48:23 2015)
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
# overwritten.
# ******************************************************************
ddns-update-style interim;

4下载包所需的软件包

[root@Cobbler ~]# cobbler get-loaders
[root@Cobbler ~]# ls /var/lib/cobbler/loaders
COPYING.elilo elilo-ia64.efi menu.c32 yaboot
COPYING.syslinux grub-x86_64.efi pxelinux.0
COPYING.yaboot grub-x86.efi README

5启动rsync服务

[root@Cobbler ~]# systemctl start rsyncd.service
[root@Cobbler ~]# systemctl enable rsyncd.service

6 debian相关无需修改

7、修改安装完成后的root密码,设置新装系统的默认root密码123456。下面的命令来源于提示6。random-phrase-here为干扰码,可以自行设定设置新装系统的默认root密码123456。下面的命令来源于提示6。random-phrase-here为干扰码,可以自行设定

openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'
random-phrase-here 随机字符串
your-password-here 密码

示例

[root@Cobbler ~]# openssl passwd -1 -salt 'xue' '123456'
$1$CLSN$LpJk4x1cplibx3q/O4O/K/

管理dhcp,用Cobbler管理DHCP

sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings

防止重装,防止循环装系统,适用于服务器第一启动项是PXE启动。

sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings

修改dhcp模板

sed -i.ori 's#192.168.1#172.16.1#g;22d;23d' /etc/cobbler/dhcp.template

cobbler组配置文件位置

/etc/cobbler/settings

注意:修改完成之后要使用cobbler sync 进行同步,否则不生效。

1.2.6 修改之后

再次检查语法:

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

重启所有服务

systemctl restart httpd.service
systemctl restart cobblerd.service
systemctl restart dhcpd.service
systemctl restart rsyncd.service
systemctl restart tftp.socket

3. Cobbler的命令行管理

3.1 查看命令帮助

  1. [root@linux-node1 ~]# cobbler
  2. usage
  3. =====
  4. cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ...
  5. [add|edit|copy|getks*|list|remove|rename|report] [options|--help]
  6. cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help]
  7. [root@linux-node1 ~]# cobbler import --help # 导入镜像
  8. Usage: cobbler [options]
  9. Options:
  10. -h, --help show this help message and exit
  11. --arch=ARCH OS architecture being imported
  12. --breed=BREED the breed being imported
  13. --os-version=OS_VERSION
  14. the version being imported
  15. --path=PATH local path or rsync location
  16. --name=NAME name, ex 'RHEL-5'
  17. --available-as=AVAILABLE_AS
  18. tree is here, don't mirror
  19. --kickstart=KICKSTART_FILE
  20. assign this kickstart file
  21. --rsync-flags=RSYNC_FLAGS
  22. pass additional flags to rsync
  23. cobbler check 核对当前设置是否有问题
  24. cobbler list 列出所有的cobbler元素
  25. cobbler report 列出元素的详细信息
  26. cobbler sync 同步配置到数据目录,更改配置最好都要执行下
  27. cobbler reposync 同步yum仓库
  28. cobbler distro 查看导入的发行版系统信息
  29. cobbler system 查看添加的系统信息
  30. cobbler profile 查看配置信息

cobbler_web安装后无法访问,提示500

 

经查看日志

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

[root@localhost /]# rpm -qa | grep "python2-django"
python2-django-1.11.13-4.el7.noarch
Django 的版本问题
TEMPLATE_CONTEXT_PROCESSORS was deprecated in Django 1.8 and removed in Django 1.10. It's not possible to import it anymore. 解决方法
1、rpm -e --nodeps python2-django
2、yum install python2-pip
3、pip install --upgrade pip
4、pip install Django==1.8.17

3.2 导入镜像

  1. [root@linux-node1 ~]# mount /dev/cdrom /mnt/ # 挂载CentOS7的系统镜像。
  2. # 导入系统镜像
  3. [root@linux-node1 ~]# cobbler import --path=/mnt/ --name=CentOS-7.1-x86_64 --arch=x86_64
  4. # --path 镜像路径
  5. # --name 为安装源定义一个名字
  6. # --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64
  7. # 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:CentOS-7.1-x86_64,如果重复,系统会提示导入失败。
  8. [root@linux-node1 ~]# cobbler distro list # 查看镜像列表
  9. CentOS-7.1-x86_64
  10. # 镜像存放目录,cobbler会将镜像中的所有安装文件拷贝到本地一份,放在/var/www/cobbler/ks_mirror下的CentOS-7.1-x86_64目录下。因此/var/www/cobbler目录必须具有足够容纳安装文件的空间。
  11. [root@linux-node1 ~]# cd /var/www/cobbler/ks_mirror/
  12. [root@linux-node1 ks_mirror]# ls
  13. CentOS-7.1-x86_64 config
  14. [root@linux-node1 ks_mirror]# ls CentOS-7.1-x86_64/
  15. CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
  16. EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
  17. EULA isolinux repodata TRANS.TBL

3.3 指定ks.cfg文件及调整内核参数

  1. # Cobbler的ks.cfg文件存放位置
  2. [root@linux-node1 ks_mirror]# cd /var/lib/cobbler/kickstarts/
  3. [root@linux-node1 kickstarts]# ls # 自带很多
  4. default.ks install_profiles sample_autoyast.xml sample_esxi4.ks sample_old.seed
  5. esxi4-ks.cfg legacy.ks sample_end.ks(默认使用的ks文件) sample_esxi5.ks sample.seed
  6. esxi5-ks.cfg pxerescue.ks sample_esx4.ks sample.ks
  7. [root@linux-node1 kickstarts]# rz # 上传准备好的ks文件
  8. rz waiting to receive.
  9. Starting zmodem transfer. Press Ctrl+C to cancel.
  10. Transferring Cobbler-CentOS-7.1-x86_64.cfg...
  11. 100% 1 KB 1 KB/sec 00:00:01 0 Errors
  12. [root@linux-node1 kickstarts]# mv Cobbler-CentOS-7.1-x86_64.cfg CentOS-7.1-x86_64.cfg
  13. # 在第一次导入系统镜像后,Cobbler会给镜像指定一个默认的kickstart自动安装文件在/var/lib/cobbler/kickstarts下的sample_end.ks。
  14. [root@linux-node1 ~]# cobbler list
  15. distros:
  16. CentOS-7.1-x86_64
  17. profiles:
  18. CentOS-7.1-x86_64
  19. systems:
  20. repos:
  21. images:
  22. mgmtclasses:
  23. packages:
  24. files:
  25. # 查看安装镜像文件信息
  26. [root@linux-node1 ~]# cobbler distro report --name=CentOS-7.1-x86_64
  27. Name : CentOS-7.1-x86_64
  28. Architecture : x86_64
  29. TFTP Boot Files : {}
  30. Breed : redhat
  31. Comment :
  32. Fetchable Files : {}
  33. Initrd : /var/www/cobbler/ks_mirror/CentOS-7.1-x86_64/images/pxeboot/initrd.img
  34. Kernel : /var/www/cobbler/ks_mirror/CentOS-7.1-x86_64/images/pxeboot/vmlinuz
  35. Kernel Options : {}
  36. Kernel Options (Post Install) : {}
  37. Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/CentOS-7.1-x86_64'}
  38. Management Classes : []
  39. OS Version : rhel7
  40. Owners : ['admin']
  41. Red Hat Management Key : <<inherit>>
  42. Red Hat Management Server : <<inherit>>
  43. Template Files : {}
  44. # 查看所有的profile设置
  45. [root@linux-node1 ~]# cobbler profile report
  46. # 查看指定的profile设置
  47. [root@linux-node1 ~]# cobbler profile report --name=CentOS-7.1-x86_64
  48. Name : CentOS-7.1-x86_64
  49. TFTP Boot Files : {}
  50. Comment :
  51. DHCP Tag : default
  52. Distribution : CentOS-7.1-x86_64
  53. Enable gPXE? : 0
  54. Enable PXE Menu? : 1
  55. Fetchable Files : {}
  56. Kernel Options : {}
  57. Kernel Options (Post Install) : {}
  58. Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks -->默认ks文件
  59. Kickstart Metadata : {}
  60. Management Classes : []
  61. Management Parameters : <<inherit>>
  62. Name Servers : []
  63. Name Servers Search Path : []
  64. Owners : ['admin']
  65. Parent Profile :
  66. Internal proxy :
  67. Red Hat Management Key : <<inherit>>
  68. Red Hat Management Server : <<inherit>>
  69. Repos : []
  70. Server Override : <<inherit>>
  71. Template Files : {}
  72. Virt Auto Boot : 1
  73. Virt Bridge : xenbr0
  74. Virt CPUs : 1
  75. Virt Disk Driver Type : raw
  76. Virt File Size(GB) : 5
  77. Virt Path :
  78. Virt RAM (MB) : 512
  79. Virt Type : kvm
  80. # 编辑profile,修改关联的ks文件
  81. [root@linux-node1 ~]# cobbler profile edit --name=CentOS-7.1-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7.1-x86_64.cfg
  82. # 修改安装系统的内核参数,在CentOS7系统有一个地方变了,就是网卡名变成eno16777736这种形式,但是为了运维标准化,我们需要将它变成我们常用的eth0,因此使用下面的参数。但要注意是CentOS7才需要下面的步骤,CentOS6不需要。
  83. [root@linux-node1 ~]# cobbler profile edit --name=CentOS-7.1-x86_64 --kopts='net.ifnames=0 biosdevname=0'
  84. [root@linux-node1 ~]# cobbler profile report CentOS-7.1-x86_64
  85. Name : CentOS-7.1-x86_64
  86. TFTP Boot Files : {}
  87. Comment :
  88. DHCP Tag : default
  89. Distribution : CentOS-7.1-x86_64
  90. Enable gPXE? : 0
  91. Enable PXE Menu? : 1
  92. Fetchable Files : {}
  93. Kernel Options : {'biosdevname': '0', 'net.ifnames': '0'}
  94. Kernel Options (Post Install) : {}
  95. Kickstart : /var/lib/cobbler/kickstarts/CentOS-7.1-x86_64.cfg
  96. Kickstart Metadata : {}
  97. Management Classes : []
  98. Management Parameters : <<inherit>>
  99. Name Servers : []
  100. Name Servers Search Path : []
  101. Owners : ['admin']
  102. Parent Profile :
  103. Internal proxy :
  104. Red Hat Management Key : <<inherit>>
  105. Red Hat Management Server : <<inherit>>
  106. Repos : []
  107. Server Override : <<inherit>>
  108. Template Files : {}
  109. Virt Auto Boot : 1
  110. Virt Bridge : xenbr0
  111. Virt CPUs : 1
  112. Virt Disk Driver Type : raw
  113. Virt File Size(GB) : 5
  114. Virt Path :
  115. Virt RAM (MB) : 512
  116. Virt Type : kvm
  117. # 每次修改完都要同步一次
  118. [root@linux-node1 ~]# cobbler sync

3.4 安装系统

可以很愉快的告诉你到这里就可以安装系统了!

新建一台虚拟机,不解释,开机就可以看到下面的图片了!

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

** 有没有发现不美观的地方?**

网址不是我的!改!

  1. #修改Cobbler提示
  2. [root@linux-node1 ~]# vim /etc/cobbler/pxe/pxedefault.template
  3. MENU TITLE Cobbler | http://www.zyops.com
  4. [root@linux-node1 ~]# cobbler sync # 修改配置都要同步

OK,现在好看多了。选择第二项就可以继续装机了。你可以让系统飞着,然后接着看下文!! 
006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

4. ks.cfg文件简析

文件大部分参数含义见kickstart文章,此处只讲一些不同的地方。同时可以参考模板文件。

  1. [root@linux-node1 kickstarts]# cat CentOS-7.1-x86_64.cfg
  2. # Cobbler for Kickstart Configurator for CentOS 7.1 by yao zhang
  3. install
  4. url --url=$tree # 这些$开头的变量都是调用配置文件里的值。
  5. text
  6. lang en_US.UTF-8
  7. keyboard us
  8. zerombr
  9. bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
  10. # Network information
  11. $SNIPPET('network_config')
  12. timezone --utc Asia/Shanghai
  13. authconfig --enableshadow --passalgo=sha512
  14. rootpw --iscrypted $default_password_crypted
  15. clearpart --all --initlabel
  16. part /boot --fstype xfs --size 1024 # CentOS7系统磁盘默认格式xfs
  17. part swap --size 1024
  18. part / --fstype xfs --size 1 --grow
  19. firstboot --disable
  20. selinux --disabled
  21. firewall --disabled
  22. logging --level=info
  23. reboot
  24. %pre
  25. $SNIPPET('log_ks_pre')
  26. $SNIPPET('kickstart_start')
  27. $SNIPPET('pre_install_network_config')
  28. # Enable installation monitoring
  29. $SNIPPET('pre_anamon')
  30. %end
  31. %packages
  32. @base
  33. @compat-libraries
  34. @debugging
  35. @development
  36. tree
  37. nmap
  38. sysstat
  39. lrzsz
  40. dos2unix
  41. telnet
  42. iptraf
  43. ncurses-devel
  44. openssl-devel
  45. zlib-devel
  46. OpenIPMI-tools
  47. screen
  48. %end
  49. %post
  50. systemctl disable postfix.service
  51. %end

5. 定制化安装

可能从学习kickstart开始就有人想怎样能够指定某台服务器使用指定ks文件,kickstart实现这功能可能比较复杂,但是Cobbler就很简单了。

区分一台服务器的最简单的方法就是物理MAC地址。

物理服务器的MAC地址在服务器上的标签上写了。

虚拟机的MAC查看

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

  1. cobbler system add --name=oldboy --mac=00:0C:29:7F:2F:A1 --profile=CentOS-7.1-x86_64 --ip-address=10.0.0.111 --subnet=255.255.255.0 --gateway=10.0.0.2 --interface=eth0 --static=1 --hostname=oldboy.example.com --name-servers="114.114.114.114 8.8.8.8"
  2. # --name 自定义,但不能重复
  3. # 查看定义的列表
  4. [root@linux-node1 ~]# cobbler system list
  5. oldboy
  6. [root@linux-node1 ~]# cobbler sync

再次开机安装就不再询问选择了,直接安装。

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

6. Cobbler的Web管理界面的安装与配置

已经安装cobbler-web软件。

访问网址:http://10.0.0.7/cobbler_webhttps://10.0.0.7/cobbler_web

默认用户名:cobbler 
默认密码 :cobbler

到此cobbler就安装完成,下面进行web界面的操作。

1.3 cobbler的web及界面操作

浏览器访问https://10.0.0.202/cobbler_web

注意CentOS7中cobbler只支持https访问。

   账号密码默认均为cobbler

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

1.3.1 操作说明--导入镜像

1)在虚拟机上添加上镜像

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

2)挂载上镜像

[root@Cobbler ~]# mount /dev/cdrom  /mnt/
mount: /dev/sr0 is write-protected, mounting read-only [root@Cobbler ~]# df -h |grep mnt
/dev/sr0 4.3G 4.3G 0 100% /mnt

3)进行导入镜像

选择Import DVD  输入Prefix(文件前缀),Arch(版本),Breed(品牌),Path(要从什么地方导入)

在导入镜像的时候要注意路径,防止循环导入。

信息配置好后,点击run,即可进行导入。

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

导入过程使用rsync进行导入,三个进程消失表示导入完毕

[root@Cobbler mnt]# ps -ef |grep rsync
root 12026 1 0 19:04 ? 00:00:00 /usr/bin/rsync --daemon --no-detach
root 13554 11778 12 19:51 ? 00:00:06 rsync -a /mnt/ /var/www/cobbler/ks_mirror/CentOS7.4-x86_64 --progress
root 13555 13554 0 19:51 ? 00:00:00 rsync -a /mnt/ /var/www/cobbler/ks_mirror/CentOS7.4-x86_64 --progress
root 13556 13555 33 19:51 ? 00:00:17 rsync -a /mnt/ /var/www/cobbler/ks_mirror/CentOS7.4-x86_64 --progress
root 13590 10759 0 19:52 pts/1 00:00:00 grep --color=auto rsync

查看日志可以发现右running进程

日志位于 Events

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

导入完成后生成的文件夹

[root@Cobbler ks_mirror]# pwd
/var/www/cobbler/ks_mirror [root@Cobbler ks_mirror]# ls
CentOS7.4-x86_64 config

1.3.2 创建一台空白虚拟机,进行测试网路安装

注意:虚拟机的内存不能小于2G,网卡的配置要保证网络互通

启动虚拟机

   启动虚拟机即可发现会有cobbler的选择界面

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

选择CentOS7.4即可进行安装,安装过程与光盘安装一致,这里就不在复述。

1.4 定制化安装操作系统

1.4.1 添加内核参数

1)查看导入的镜像,点击edit

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

2)在内核参数中添加net.ifnames=0 biosdevname=0

能够让显示的网卡变为eth0 ,而不是CentOS7中的ens33

修改完成后点击保存

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

1.4.2 查看镜像属性

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

1.4.3 编写ks文件

1)创建新的ks文件

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

2)添加ks文件,并配置文件名

创建完成后点击Save进行保存

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

CentOS7  ks配置文件参考

 
 1 # Cobbler for Kickstart Configurator for CentOS 7 by clsn
2 install
3 url --url=$tree
4 text
5 lang en_US.UTF-8
6 keyboard us
7 zerombr
8 bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
9 #Network information
10 $SNIPPET('network_config')
11 #network --bootproto=dhcp --device=eth0 --onboot=yes --noipv6 --hostname=CentOS7
12 timezone --utc Asia/Shanghai
13 authconfig --enableshadow --passalgo=sha512
14 rootpw --iscrypted $default_password_crypted
15 clearpart --all --initlabel
16 part /boot --fstype xfs --size 1024
17 part swap --size 1024
18 part / --fstype xfs --size 1 --grow
19 firstboot --disable
20 selinux --disabled
21 firewall --disabled
22 logging --level=info
23 reboot
24
25 %pre
26 $SNIPPET('log_ks_pre')
27 $SNIPPET('kickstart_start')
28 $SNIPPET('pre_install_network_config')
29 # Enable installation monitoring
30 $SNIPPET('pre_anamon')
31 %end
32
33 %packages
34 @^minimal
35 @compat-libraries
36 @core
37 @debugging
38 @development
39 bash-completion
40 chrony
41 dos2unix
42 kexec-tools
43 lrzsz
44 nmap
45 sysstat
46 telnet
47 tree
48 vim
49 wget
50 %end
51
52 %post
53 systemctl disable postfix.service
54 %end

1.4.4 自定义安装系统

1)选择systems 创建一个新的系统

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

2)定义系统信息

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

3)配置全局网络信息

主机名、网关、DNS

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

4)配置网卡信息,eth0,eth1

需要注意,选择static静态,

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

以上的所有配置完成后,点击Save进行保存

附录:

VMware workstation中查看虚拟机mac地址的方法。在虚拟机设置中。

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

 cobbler web 界面说明

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

1.5 安装虚拟机

1.5.1 开启虚拟机

如果之前的设置就显示安装进度

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

1.5.2 安装完成进行检查

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

1.6 cobbler使用常见错误

1.6.1 cobbler check报错

[root@Cobbler ~]# cobbler sync
Traceback (most recent call last):
File "/usr/bin/cobbler", line 36, in <module>
sys.exit(app.main())
File "/usr/lib/python2.7/site-packages/cobbler/cli.py", line 662, in main
rc = cli.run(sys.argv)
File "/usr/lib/python2.7/site-packages/cobbler/cli.py", line 269, in run
self.token = self.remote.login("", self.shared_secret)
File "/usr/lib64/python2.7/xmlrpclib.py", line 1233, in __call__
return self.__send(self.__name, args)
File "/usr/lib64/python2.7/xmlrpclib.py", line 1587, in __request
verbose=self.__verbose
File "/usr/lib64/python2.7/xmlrpclib.py", line 1273, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib64/python2.7/xmlrpclib.py", line 1306, in single_request
return self.parse_response(response)
File "/usr/lib64/python2.7/xmlrpclib.py", line 1482, in parse_response
return u.close()
File "/usr/lib64/python2.7/xmlrpclib.py", line 794, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: "<class 'cobbler.cexceptions.CX'>:'login failed'">

解决办法

systemctl restart httpd.service
systemctl restart cobblerd.service
cobbler check

1.6.2 No space left on device

006-(成功环境记录)基于Centos7系统部署cobbler批量安装系统

出现这个错误的原因是虚拟机的内存不足2G,

将内存调为2G即可(这个错误只会出现在CentOS7.3之上)

1.7 附录cobbler_CentOS6.x_ks配置文件

# Cobbler for Kickstart Configurator for CentOS 6  by clsn
install
url --url=$tree
text
lang en_US.UTF-8
keyboard us
zerombr
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
$SNIPPET('network_config')
timezone --utc Asia/Shanghai
authconfig --enableshadow --passalgo=sha512
rootpw --iscrypted $default_password_crypted
clearpart --all --initlabel
part /boot --fstype=ext4 --asprimary --size=200
part swap --size=1024
part / --fstype=ext4 --grow --asprimary --size=200
firstboot --disable
selinux --disabled
firewall --disabled
logging --level=info
reboot %pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end %packages
@base
@compat-libraries
@debugging
@development
tree
nmap
sysstat
lrzsz
dos2unix
telnet
%end %post --nochroot
$SNIPPET('log_ks_post_nochroot')
%end %post
$SNIPPET('log_ks_post')
# Start yum configuration
$yum_config_stanza
# End yum configuration
$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$SNIPPET('kickstart_done')
# End final steps
%end

1.8 参考文档

  http://blog.oldboyedu.com/autoinstall-cobbler/

  http://www.zyops.com/autoinstall-cobbler

上一篇:[Bayesian] “我是bayesian我怕谁”系列 - Gaussian Process


下一篇:基于CentOS7系统部署cobbler批量安装系统(week3_day5_part1)-技术流ken