您当前的位置: 首页 > 

少林码僧

暂无认证

  • 3浏览

    0关注

    317博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

cobbler无人值守安装

少林码僧 发布时间:2017-05-15 20:36:39 ,浏览量:3

说在最前面的话  在看Cobbler之前请大家先看一下Kickstart无人值守安装,了解一下Cobbler的实现原理。但是Cobbler是独立的,不需要先安装Kickstart然后再安装Cobbler,这是写给不了解Kickstart的人看的。

1. Cobbler介绍

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

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

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

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

Cobbler官网

1.1 Cobbler集成的服务
  • PXE服务支持
  • DHCP服务管理
  • DNS服务管理(可选bind,dnsmasq)
  • 电源管理
  • Kickstart服务支持
  • YUM仓库管理
  • TFTP(PXE启动时需要)
  • Apache(提供kickstart的安装源,并提供定制化的kickstart配置)
1.2 系统环境准备
 
 
  1. [root@linux-node1 ~]# cat /etc/redhat-release
  2. CentOS release 6.7 (Final)
  3. [root@linux-node1 ~]# uname -r
  4. 2.6.32-573.el6.x86_64
  5. [root@linux-node1 ~]# getenforce
  6. Disabled
  7. [root@linux-node1 ~]# /etc/init.d/iptables status
  8. iptables: Firewall is not running.
  9. [root@linux-node1 ~]# ifconfig eth0|awk -F "[ :]+" 'NR==2 {print $4}'
  10. 10.0.0.7
  11. [root@linux-node1 ~]# hostname
  12. linux-node1.example.com
  13. # 配置阿里云的epel源
  14. [root@linux-node1 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

注意:

  • 虚拟机网卡采用NAT模式,不要使用桥接模式,因为稍后我们会搭建DHCP服务器,在同一局域网多个DHCP服务会有冲突。
  • VMware的NAT模式的dhcp服务也关闭,避免干扰。 
2. Cobbler安装配置 2.1 安装Cobbler
 
 
  1. [root@linux-node1 ~]# yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd
  2. [root@linux-node1 ~]# rpm -ql cobbler # 查看安装的文件,下面列出部分。
  3. /etc/cobbler # 配置文件目录
  4. /etc/cobbler/settings # cobbler主配置文件,这个文件是YAML格式,Cobbler是python写的程序。
  5. /etc/cobbler/dhcp.template # DHCP服务的配置模板
  6. /etc/cobbler/tftpd.template # tftp服务的配置模板
  7. /etc/cobbler/rsync.template # rsync服务的配置模板
  8. /etc/cobbler/iso # iso模板配置文件目录
  9. /etc/cobbler/pxe # pxe模板文件目录
  10. /etc/cobbler/power # 电源的配置文件目录
  11. /etc/cobbler/users.conf # Web服务授权配置文件
  12. /etc/cobbler/users.digest # 用于web访问的用户名密码配置文件
  13. /etc/cobbler/dnsmasq.template # DNS服务的配置模板
  14. /etc/cobbler/modules.conf # Cobbler模块配置文件
  15. /var/lib/cobbler # Cobbler数据目录
  16. /var/lib/cobbler/config # 配置文件
  17. /var/lib/cobbler/kickstarts # 默认存放kickstart文件
  18. /var/lib/cobbler/loaders # 存放的各种引导程序
  19. /var/www/cobbler # 系统安装镜像目录
  20. /var/www/cobbler/ks_mirror # 导入的系统镜像列表
  21. /var/www/cobbler/images # 导入的系统镜像启动文件
  22. /var/www/cobbler/repo_mirror # yum源存储目录
  23. /var/log/cobbler # 日志目录
  24. /var/log/cobbler/install.log # 客户端系统安装日志
  25. /var/log/cobbler/cobbler.log # cobbler日志
2.2 配置Cobbler
 
 
  1. [root@linux-node1 ~]# /etc/init.d/httpd restart
  2. 停止 httpd: [失败]
  3. 正在启动 httpd: [确定]
  4. [root@linux-node1 ~]# /etc/init.d/cobblerd start
  5. Starting cobbler daemon: [确定]
  6. [root@linux-node1 ~]# cobbler check # 检查Cobbler的配置,如果看不到下面的结果,再次执行/etc/init.d/cobblerd restart
  7. The following are potential configuration items that you may want to fix:
  8. 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.
  9. 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.
  10. 3 : 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.
  11. 4 : change 'disable' to 'no' in /etc/xinetd.d/rsync
  12. 5 : debmirror package is not installed, it will be required to manage debian deployments and repositories
  13. 6 : 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
  14. 7 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
  15. Restart cobblerd and then run 'cobbler sync' to apply changes.
  16. # 看着上面的结果,一个一个解决。
  17. # 第1、2、6个问题,顺便修改其他功能
  18. [root@linux-node1 ~]# cp /etc/cobbler/settings{,.ori} # 备份
  19. # server,Cobbler服务器的IP。
  20. sed -i 's/server: 127.0.0.1/server: 10.0.0.7/' /etc/cobbler/settings
  21. # next_server,如果用Cobbler管理DHCP,修改本项,作用不解释,看kickstart。
  22. sed -i 's/next_server: 127.0.0.1/next_server: 10.0.0.7/' /etc/cobbler/settings
  23. # 用Cobbler管理DHCP
  24. sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings
  25. # 防止循环装系统,适用于服务器第一启动项是PXE启动。
  26. sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
  27. # 设置新装系统的默认root密码123456。下面的命令来源于提示6。random-phrase-here为干扰码,可以自行设定。
  28. [root@linux-node1 ~]# openssl passwd -1 -salt 'oldboy' '123456'
  29. $1$oldboy$Npg9Pt9k98Mlg0ZeqHAuN1
  30. [root@linux-node1 ~]# vim /etc/cobbler/settings
  31. default_password_crypted: "$1$oldboy$Npg9Pt9k98Mlg0ZeqHAuN1"
  32. # 第3个问题
  33. [root@linux-node1 ~]# cobbler get-loaders # 会自动从官网下载
  34. [root@linux-node1 ~]# cd /var/lib/cobbler/loaders/ # 下载的内容
  35. [root@linux-node1 loaders]# ls
  36. COPYING.elilo COPYING.yaboot grub-x86_64.efi menu.c32 README
  37. COPYING.syslinux elilo-ia64.efi grub-x86.efi pxelinux.0 yaboot
  38. # 第4个问题
  39. [root@linux-node1 ~]# vim /etc/xinetd.d/rsync
  40. disable = no
  41. [root@linux-node1 ~]# /etc/init.d/xinetd restart
  42. 停止 xinetd: [确定]
  43. 正在启动 xinetd: [确定]
  44. [root@linux-node1 ~]# /etc/init.d/cobblerd restart
  45. Stopping cobbler daemon: [确定]
  46. Starting cobbler daemon: [确定]
  47. [root@linux-node1 ~]# cobbler check
  48. The following are potential configuration items that you may want to fix:
  49. 1 : debmirror package is not installed, it will be required to manage debian deployments and repositories # 和debian系统相关,不需要
  50. 2 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them # fence设备相关,不需要
  51. Restart cobblerd and then run 'cobbler sync' to apply changes.
2.3 配置DHCP
 
 
  1. # 修改cobbler的dhcp模版,不要直接修改dhcp本身的配置文件,因为cobbler会覆盖。
  2. [root@linux-node1 ~]# vim /etc/cobbler/dhcp.template
  3. # 仅列出修改过的字段
  4. ……
  5. subnet 10.0.0.0 netmask 255.255.255.0 {
  6. option routers 10.0.0.2;
  7. option domain-name-servers 10.0.0.2;
  8. option subnet-mask 255.255.255.0;
  9. range dynamic-bootp 10.0.0.100 10.0.0.200;
  10. ……
2.4 同步cobbler配置
 
 
  1. # 同步最新cobbler配置,它会根据配置自动修改dhcp等服务。
  2. [root@linux-node1 ~]# cobbler sync # 同步所有配置,可以仔细看一下sync做了什么。
  3. task started: 2015-12-03_204822_sync
  4. task started (id=Sync, time=Thu Dec 3 20:48:22 2015)
  5. running pre-sync triggers
  6. cleaning trees
  7. removing: /var/lib/tftpboot/pxelinux.cfg/default
  8. removing: /var/lib/tftpboot/grub/images
  9. copying bootloaders
  10. trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
  11. copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
  12. trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
  13. trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
  14. trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
  15. trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
  16. trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
  17. copying distros to tftpboot
  18. copying images
  19. generating PXE configuration files
  20. generating PXE menu structure
  21. rendering DHCP files
  22. generating /etc/dhcp/dhcpd.conf
  23. rendering TFTPD files
  24. generating /etc/xinetd.d/tftp
  25. cleaning link caches
  26. running post-sync triggers
  27. running python triggers from /var/lib/cobbler/triggers/sync/post/*
  28. running python trigger cobbler.modules.sync_post_restart_services
  29. running: dhcpd -t -q
  30. received on stdout:
  31. received on stderr:
  32. running: service dhcpd restart
  33. received on stdout: 关闭 dhcpd:[确定]
  34. 正在启动 dhcpd:[确定]
  35. received on stderr:
  36. running shell triggers from /var/lib/cobbler/triggers/sync/post/*
  37. running python triggers from /var/lib/cobbler/triggers/change/*
  38. running python trigger cobbler.modules.scm_track
  39. running shell triggers from /var/lib/cobbler/triggers/change/*
  40. *** TASK COMPLETE ***
  41. # 再看一下dhcp的配置文件。
  42. [root@linux-node1 ~]# less /etc/dhcp/dhcpd.conf
  43. # ******************************************************************
  44. # Cobbler managed dhcpd.conf file
  45. # generated from cobbler dhcp.conf template (Thu Dec 3 12:48:23 2015)
  46. # Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
  47. # in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
  48. # overwritten.
  49. # ******************************************************************
  50. ddns-update-style interim;
  51. …………
2.5 开机启动
 
 
  1. # 启动相关服务并设置开机启动(可选) 与第二种方法二选一
  2. chkconfig httpd on
  3. chkconfig xinetd on
  4. chkconfig cobblerd on
  5. chkconfig dhcpd on
  6. /etc/init.d/httpd restart
  7. /etc/init.d/xinetd restart
  8. /etc/init.d/cobblerd restart
  9. /etc/init.d/dhcpd restart
  10. # 编写Cobbler相关服务启动脚本(可选)
  11. cat >>/etc/init.d/cobbler
关注
打赏
1661398670
查看更多评论
0.1149s