cobbler 一键自动化安装系统

本文介绍---collber ,路径和配置文件都是完全默认的配置



安装步骤

1 准备测试环境

虚拟机vmware nat模式

VMware的NAT模式的dhcp服务也关闭,避免干扰。 

2 准备系统环境  关闭selinux 关闭iptables,按epel源,可以使用阿里云的epel

cat /etc/redhat-release

getenforce

/etc/init.d/iptables status

ifconfig eth0 | grep "inet addr" | awk -F ‘[: ]+‘ ‘{print $4}‘

yum repolist

3 安装软件

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

dhcp 提供dhcp功能

tftp-server 提供简单文件传输的功能

httpd 提供web功能

cobbler-web  可以不安装如果不需要collber的管理界面

  1. 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日志

4 配置cobbler

/etc/init.d/httpd start

/etc/init.d/cobblerd start

/etc/init.d/cobblerd restart

cobbler check

报错如下:

[[email protected]_server ~]# 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 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/rsync

6 : file /etc/xinetd.d/rsync does not exist

7 : debmirror package is not installed, it will be required to manage debian deployments and repositories

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

9 : 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 指定server ip 结果第一和第二个报错

# server,Cobbler服务器的IP。

  • sed -i ‘s#server: 127.0.0.1#server: 192.168.100.20#g‘ /etc/cobbler/settings

# next_server,如果用Cobbler管理DHCP,修改本项,作用不解释,看kickstart。

  • sed -i ‘s/next_server: 127.0.0.1/next_server: 10.0.0.7/‘ /etc/cobbler/settings

# 用Cobbler管理DHCP

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

2 开启守护进程xinetd支持开启tftp rsync

sed -i ‘s#\(disable.*= \)no#\1no#g‘ /etc/xinetd.d/tftp

sed -i ‘s#\(disable.*= \)yes#\rno#g‘ /etc/xinetd.d/rsync

3 解决下载安装系统是需要的loader文件

cobbler get-loaders

下载的文件内容是

[[email protected]_server ~]# ls  /var/lib/cobbler/loaders/

COPYING.elilo  COPYING.syslinux  COPYING.yaboot  elilo-ia64.efi  grub-x86_64.efi  grub-x86.efi  menu.c32  pxelinux.0  README  yaboot

4 填充密码 解决第8个报错

# 设置新安装装系统(不是本机系统)的默认root密码123456。下面的命令来源于提示6。random-phrase-here为干扰码,可以自行设定。
[[email protected] ~]# openssl passwd -1 -salt ‘oldboy‘ ‘123456‘
$1$oldboy$Npg9Pt9k98Mlg0ZeqHAuN1
[[email protected] ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$oldboy$Npg9Pt9k98Mlg0ZeqHAuN1"

一条命令搞定(变量替换)

sed -i ‘s#default_password_crypted:.*#default_password_crypted: \"‘`openssl passwd -1 -salt ‘oldboy‘ ‘123456‘`‘\"#g‘ /etc/cobbler/settings

5  忽略的报错

  1. 1 : debmirror package is not installed, it will be required to manage debian deployments and repositories # 和debian系统相关,不需要
  2. 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设备相关,不需要

5 配置dhcp

vi /etc/cobbler/dhcp.template

# 修改cobbler的dhcp模版,不要直接修改dhcp本身的配置文件,因为cobbler cobbler sync同步会覆盖。

[[email protected] ~]# vim /etc/cobbler/dhcp.template
# 仅列出修改过的字段
……
subnet 10.0.0.0 netmask 255.255.255.0 {
option routers 10.0.0.2;
option domain-name-servers 10.0.0.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 10.0.0.100 10.0.0.200;
……

6 同步cobbler配置

做的操作

同步的内容大致为:

dhcp配置文件到 /etc/dhcp/dhcpd.conf

做硬连接 /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0等系统loaders文件

pxe的menu文件生成

7 开启启动设置

chkconfig httpd on
chkconfig xinetd on
chkconfig cobblerd on
chkconfig dhcpd on
/etc/init.d/httpd restart
/etc/init.d/xinetd restart
/etc/init.d/cobblerd restart
/etc/init.d/dhcpd restart

8 管理cobbler

3. Cobbler的命令行管理

3.1 查看命令帮助

[[email protected] ~]# cobbler
usage
=====
cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ... 
        [add|edit|copy|getks*|list|remove|rename|report] [options|--help]
cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help]
[[email protected] ~]# cobbler import --help  # 导入镜像
Usage: cobbler [options]
Options:
  -h, --help            show this help message and exit
  --arch=ARCH           OS architecture being imported
  --breed=BREED         the breed being imported
  --os-version=OS_VERSION
                        the version being imported
  --path=PATH           local path or rsync location
  --name=NAME           name, ex ‘RHEL-5‘
  --available-as=AVAILABLE_AS
                        tree is here, don‘t mirror
  --kickstart=KICKSTART_FILE
                        assign this kickstart file
  --rsync-flags=RSYNC_FLAGS
                        pass additional flags to rsync
cobbler check    核对当前设置是否有问题
cobbler list     列出所有的cobbler元素
cobbler report   列出元素的详细信息
cobbler sync     同步配置到数据目录,更改配置最好都要执行下
cobbler reposync 同步yum仓库
cobbler distro   查看导入的发行版系统信息
cobbler system   查看添加的系统信息
cobbler profile  查看配置信息

常用

cobbler distro report

cobbler profile report

9 导入镜像

cobbler import --path=/mnt/ --name=CentOS-6.4-x86_64 --arch=x86_64

注意命名的规范和源iso镜像命名一致

# --path 镜像路径
# --name 为安装源定义一个名字
# --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64
# 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:CentOS-6.4-x86_64,如果重复,系统会提示导入失败。

[[email protected]_server mnt]# cobbler distro list # 查看镜像列表

CentOS-6.4-x86_64

# 镜像存放目录,cobbler会将镜像中的所有安装文件拷贝到本地一份,放在/var/www/cobbler/ks_mirror下的CentOS-6.4-x86_64目录下。因此/var/www/cobbler目录必须具有足够容纳安装文件的空间。

[[email protected]_server mnt]# cobbler distro list

CentOS-6.4-x86_64

[[email protected]_server mnt]# ls /var/www/cobbler/ks_mirror

CentOS-6.4-x86_64  config

10 kickstart文件

  1. # 在第一次导入系统镜像后,Cobbler会给镜像指定一个默认的kickstart自动安装文件在/var/lib/cobbler/kickstarts下的sample_end.ks。

如:

cobbler profile report

11 不做任何修改kickstart文件进行新建安装系统

界面不美观---需要优化

修改:

vim /etc/cobbler/pxe/pxedefault.template

修改完成后 记得 cobbler sync

二修改: 我们不能让local作默认的启动选项

实际菜单文件起作用的是:/var/lib/tftpboot/pxelinux.cfg/default

可以参考一下修改:

或者讲local那一个label删除

[[email protected]_server ~]# cat /var/lib/tftpboot/pxelinux.cfg/default

DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://cobbler.github.io
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT CentOS-6.4-x86_64
LABEL CentOS-6.4-x86_64
        MENU DEFAULT
        kernel /images/CentOS-6.4-x86_64/vmlinuz
        MENU LABEL CentOS-6.4-x86_64
        append initrd=/images/CentOS-6.4-x86_64/initrd.img ksdevice=bootif lang=  kssendmac text  ks=http://192.168.100.20/cblr/svc/op/ks/profile/CentOS-6.4-x86_64
        ipappend 2
LABEL local
        MENU LABEL (local)
        LOCALBOOT 2 
MENU end

选择  Centos-6.4-x86_64 进行安装

安装过程的一部分

安装过程的一部分

总结: 我的经历

1 一般小公司会使用原生collber进行管理,原因 可以不懂其中的具体操作,且镜像比较少

2 缺点: collber重复文件 导入较多,且路径很复杂 很依赖collber这个工具

3 大公司都是 自己根据原理 安装每个组件(http tftp dhcp 等自己规划路径和镜像和load等文件 ) 而不需要collber

如 以下是一家公司的多个镜像图:

我此刻再次阐述原理:

Cobbler 的设计方式

Cobbler 的配置结构基于一组注册的对象。每个对象表示一个与另一个实体相关联的实体(该对象指向另一个对象,或者另一个对象指向该对象)。当一个对象指向另一个对象时,它就继承了被指向对象的数据,并可覆盖或添加更多特定信息。以下对象类型的定义为:

  • 发行版:表示一个操作系统。它承载了内核和 initrd 的信息,以及内核参数等其他数据。
  • 配置文件:包含一个发行版、一个 kickstart 文件以及可能的存储库,还包含更多特定的内核参数等其他数据。
  • 系统:表示要配给的机器。它包含一个配置文件或一个镜像,还包含 IP 和 MAC 地址、电源管理(地址、凭据、类型)以及更为专业的数据等信息。
  • 存储库:保存一个 yum 或 rsync 存储库的镜像信息。
  • 镜像:可替换一个包含不属于此类别的文件的发行版对象(例如,无法分为内核和 initrd 的对象)。

基于注册的对象以及各个对象之间的关联,Cobbler 知道如何更改文件系统以反映具体配置。因为系统配置的内部是抽象的,所以您可以仅关注想要执行的操作。

常见报错:

1 cobbler sync过程

关键错误

dhcpd -t failed

解决思路

查看cat /etc/cobbler/dhcp.template  和 vim /var/log/messages 查看日志

1 可能dhcp配置错误

时间: 2024-08-26 02:48:15

cobbler 一键自动化安装系统的相关文章

基于cobbler实现自动化安装系统

基于cobbler实现自动化安装系统 环境介绍 centos6.8 为centos6.8提供两块网卡 (非必要) 一块为桥接,方便xshell连接和测试 一块为vmnet3:用来搭建dhcp,tftp,和为客户端提供cobbler服务 前提,(确保安装TFTP,dhcp,rsync) # yum install httpd cobbler cobbler-web pykickstart debmirror 1.启动对应的服务 # service httpd start # service cob

Cobbler+preseed自动化安装Ubuntu18/19系统

说明: #Cobbler 部署不在详细说明 # Ubuntu版本: 18.04.3 及19.10 # 测试机器: kvm 虚拟机 # 测试ip:192.168.3.63 #使用vnc 进行连接操作 cobbler distro 添加Ubuntu 最新系统支持 cp /var/lib/cobbler/distro_signatures.json /var/lib/cobbler/distro_signatures.json.bak vi /var/lib/cobbler/distro_signat

简单搭建PXE无人值守自动化安装系统

PXE环境概述 在公司进行批量部署服务器安装方法: Kickstart (PXE+DHCP+TFTP+HTTP) 或 Cobbler 批量装机软件介绍 Kickstart和Cobbler. ??Kickstart是一种无人值守的安装方式.它的工作原理是在安装过程中记录人工干预填写的各种参数,并生成一个名为ks.cfg的文件.如果在自动安装过程中出现要填写参数的情况,安装程序首先会去查找ks.cfg文件,如果找到合适的参数,就采用所找到的参数:如果没有找到合适的参数,便会弹出对话框让安装者手工填写

cobbler通过koan安装系统,VM安装失败

cobbler通过koan安装系统,VM虚拟机有如下提示,不知道什么原因!

初步使用pxe自动化安装系统

1.安装dhcp服务 #yum install dhcpd 修改配置文件 /etc/dhcp/dhcpd.conf # This is a very basic subnet declaration. subnet 172.16.249.0 netmask 255.255.255.0 {  range 172.16.249.111 172.16.249.115;  option routers 172.16.0.1;  next-server 172.16.249.161;  filename

一键自动化安装zabbix服务

目的 一键自动化安装zabbix服务. 环境 OS:CentOS 6.2 zabbix版本:2.2.4 配置 #!/bin/bash # 脚本名称:一键自动化安装zabbix服务 # 注意事项: # 1.该脚本仅在CentOS最小化安装环境中测试成功,不一定适用于其他环境. # 2.如需修改mysql数据库的root和zabbix用户的密码,请注意修改下面这两个变量! mysql_user_root_password="redhat" mysql_user_zabbix_passwor

PXE自动化安装系统

如何配置PXE: 一.dhcp安装 1.安装程序 2.修改配置脚本 配置dhcp服务 subnet ... netmask ... { ... next-server TFTP-SERVER-IP; filename "pxelinux.0"; } 提示脚本示例文档  cat /etc/dhcp/dhcpd.conf 二.tftp安装 1.程序安装 2.默认文件目录 3.基本演示操作 4.服务启动 三.提供PXE的工作环境 1.程序安装  yum install syslinux 2.

kickstart安装配置自动化安装系统

环境:VMware Workstation 10.0.1 build-1379776网络:桥接虚拟机A:kickstart+Dhcp+Nfs+Tftp(系统版本centos6.2)        ip  192.168.1.51 虚拟机B:客户机(需要自动化安装系统的机器)                  ip  192.168.1.52 以下操作均在A机上:挂载iso系统文件到光驱,记得在vm里光驱那里[已连接]打勾mount /dev/cdrom /mnt/关闭防火墙和selinuxser

一键自动化安装nagios客户端

声明 作者:昨夜星辰 博客:http://yestreenstars.blog.51cto.com/ 本文由本人创作,如需转载,请注明出处,谢谢合作! 目的 一键自动化安装nagios客户端. 环境 OS: CentOS 6.2 32 nagios-plugins: 2.0.3 nrpe: 2.15 配置 #!/bin/bash # Script Name: One-key Automatic Install Nagios Client # Author: yestreenstars # Cre