Cobbler图文详解安装及遇到的问题说明

一、介绍

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

Cobbler提供了DHCP管理,YUM管理,电源管理等功能,除此之外还支持命令行管理,WEB界面管理,cobbler相关软件包由EPEL源提供。EPEL(Extra Pavkages for Enterprise Linux,企业版Linux的额外软件包)是Fedora小组维护的一个软件仓库项目。为RHEL/CentOS提供默认不提供的软件包,安装Cobbler除了EPEL源还需要CentOS自带的网络yum源以提供相关的依赖包。

二、实验环境

1、VMware Workstation虚拟机环境

2、CentOS7系统的虚拟PC作为Cobbler服务端,网卡使用NAT连接方式

三、前期准备

1、linux可以上网;

ping www.baidu.com

2、修改网卡配置,改为DHCP自动获取ip;

vim /etc/sysconfig/network-scripts/ifcfg-ens33

重启网络服务

systemctl restart network.service

获得本机IP

ifconfig

四、下载epel源;

方式1,直接安装

1 yum -y install epel-release    #安装epel源
2 cd /etc/yumrepos.d/    #检查该路径下是否有两个yum源:epel.repo epel-testing.repo
3 yum clean all && yum makecach  #更新yum源,更新后就可以安装源

方式2,使用阿里的源

1 wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

五、安装cobbler及所需的服务软件包

yum install cobbler cobbler-web pykickstart debmirror httpd dhcp tftp-server xinetd syslinux rsync -y

六、启动apache服务,cobbler服务,关闭防火墙,关闭增强型功能并设置开机自启

1 systemctl start httpd.service
2 systemctl enable httpd
3 systemctl start cobblerd.service
4 systemctl enable cobblerd
5 systemctl enable dhcpd
6 systemctl stop firewalld.service  #关闭防火墙
7 setenforce 0   #关闭SElinux

七、检查cobbler配置,而后逐一按提示解决

1 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 : comment out ‘dists‘ on /etc/debmirror.conf for proper debian support
6 : comment out ‘arches‘ on /etc/debmirror.conf for proper debian support
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)编辑/etc/cobbler/settings文件,找到server选项,修改为提供服务的ip地址,即本机ip,不能是127.0.0.1

2)编辑/etc/cobbler/settings文件,找到next_server选项,修改为本机的ip地址,也不能是127.0.0.1

方法1:

1 sed -i ‘s#^server: 127.0.0.1#server: 192.168.50.101#‘ /etc/cobbler/settings2 sed -i ‘s#^next_server: 127.0.0.1#next_server: 192.168.50.101#‘ /etc/cobbler/settings

方法2:

1 vim /etc/cobbler/srttings

.

3)编辑/etc/xinetd/tftp文件,将文件中的disable字段的配置由yes改为no,并启动xinetd服务

1 vim /etc/xinetd.d/tftp  #
2 systemctl start xinetd.service  #启动xinetd服务

4)执行“cobbler get-loaders”命令即可,即下载引导操作系统,需要几分钟

1 cobbler get-loaders

5)注释/etc/debmirror.conf文件中的@dists="sid";一行

1 sed -i ‘s/@dists="sid";/#@dists="sid";/‘ /etc/debmirror.conf

6)注释/etc/debmirror.conf文件中的@arches="i386";一行

1 sed -i ‘s/@arches="i386";/#@arches="i386";/‘ /etc/debmirror.conf

7)设置新系统默认的root密码,执行“openssl passwd -1 -salt $(openssl rand -hex 4)”生成密码,并用其替换/etc/cobbler/settings文件中default_password_crypted参数的值;

8)安装相应的程序包

1 yum install fence-agents

八、重启cobbler并同步不检查

1 systemctl restart cobblerd
2 cobbler sync
3 cobbler check

显示No configuration problems found. All systems go.(没有找到配置问题,一切正常)

九、通过cobbler来管理DHCP

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

十、配置DHCP服务

1 vi /etc/cobbler/dhcp.template

重启cobbler服务并同步配置

systemctl restart cobblerd.service
systemctl restart dhcpd.service  #此服务有可能无法重启可忽略
systemctl restart httpd.service
systemctl restart xinetd.service
cobbler sync

十一、挂载导入镜像

将镜像文件挂载到服务器上

方法1:直接将镜像文件拷贝至root目录下

1 mount -r CentOS-7-x86_64-Minimal-1804.iso /mnt/CentOS-7-x86_64/

方法2:将光驱中的内容进行挂载

1)设置CD/DVD设备状态勾选已连接

2)使用df -h命令查看光盘是否挂载,即是否有/dev/sr*的盘符

1 umount  /dev/sr1 #先卸载
2 midkr /mnt/cdrom #创建cdrom挂载点
3 mount  /dev/sr1  /mnt/cdrom   #将光盘挂载到刚才创建的cdrom
4 df-h    #查看当前挂载

导入ISO镜像文件

使用cobbler的import命令从ISO安装镜像中导入安装所需要的程序包。数据文件较大,需等待。

命令格式;cobbler import --path=镜像路径 --name=安装引导名 --arch=32位或64位

--path表示镜像所挂载的目录

--name表示为安装源定义的名字

--arch表示指定安装源是32位还是64位,目前支持的选项:x86,x86_64,ia64.

1 cobbler import --path=/mnt/CentOS-7-x86_64/ --name=CentOS-7.5-x86_64 --arch=x86_64

cobbler会将镜像中的所有安装文件拷贝到本地一份,放在/var/www/cobbler/ks_mirrors下。因此/var/www/cobbler目录必须具有足够容纳安装文件的空间,如果空间不够,可以对/var/www/cobbler目录进行移动,建软链接来修改文件存储位置。

导入镜像后可通过cobbler list来查看导入的结果,

其中distro表示一个发行版,

profile表示kickstart配置文件

此时tftp服务器的共享目录也有了启动linux所需的文件,因为从OS安装光盘导入时,同时会把内核vmlinuz和初始化镜像文件initrd.img复制到tftp共享目录下,

可以使用tree命令查看(系统默认没有这个命令,需要单独安装相应软件包)

十二、验证cobbler自动装机

新建一台虚拟机PC进行验证,不使用镜像,网络连接方式选择NAT,注意内存选择2G以上(否则会因内存不够而安装失败)。然后开启新建的虚拟机会出现cobbler画面,选择第二种回车继续等待。

如果是物理机需要保证和服务器网络畅通

等待一会系统就会自动安装好了,案后输入root用户和之前设好的密码进行登录

十三、自定义KickStart文件

在上面的实验中,我们没有进行任何的安装配置,全部都是Cobbler帮助我们完成的。可是在实际生产中,我们对每台主机的硬盘分区,安装的软件都有相应的要求,所以我们需要自己来定制KickStart文件,这样我们就能够定制地批量安装操作系统了。
我们就利用实验环境(CentOS 7.3)中的KickStart文件来定制我们自己的KickStart文件。

1)Cobbler的ks.cfg文件存放位置

cd /var/lib/cobbler/kickstarts/ && ls #自带很多
default.ks    install_profiles  sample_autoyast.xml  sample_esxi4.ks  sample_old.seed
esxi4-ks.cfg  legacy.ks         sample_end.ks(默认使用的ks文件)        sample_esxi5.ks  sample.seed
esxi5-ks.cfg  pxerescue.ks      sample_esx4.ks       sample.ks

提供两种配置ks的方法:

方法1、 每安装好一台Centos机器,Centos安装程序都会创建一个kickstart配置文件,记录你的真实安装配置。如果你希望实现和某系统类似的安装,可以基于该系统的kickstart配置文件来生成你自己的kickstart配置文件。(生成的文件名字叫anaconda-ks.cfg位于/root/anaconda-ks.cfg)

方法2、Centos提供了一个图形化的kickstart配置工具。在任何一个安装好的Linux系统上运行该工具,就可以很容易地创建你自己的kickstart配置文件。kickstart配置工具命令为redhat-config-kickstart(RHEL3)或system-config-kickstart(RHEL5/6/7)

# yum install system-config-kickstart #安装

# yum groupinstall "X Window System" #安装X Window图形界面

# system-config-kickstart #运行kickstart配置

#笔者不喜欢使用Linux运行图形化界面,浪费资源,有兴趣的伙伴可以研究一下

实例一(CentOS7.4 ks)

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
# old format: keyboard us
# new format:
keyboard --vckeymap=us --xlayouts=‘us‘
# Root password
rootpw --iscrypted $1$ljohn$yBMDpKkntQ9jfV1ZAWKpU1
# Use network installation
url --url="http://192.168.137.38/cobbler/ks_mirror/CentOS-7.4-x86_64/"
# System language
lang en_US.UTF-8
# Firewall configuration
firewall --disabled
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System services
services --disabled="chronyd"
ignoredisk --only-use=sda
# Network information
network  --bootproto=dhcp --device=eth0 --onboot=on
#network  --bootproto=static --device=eth0 --gateway=192.168.137.1 --ip=192.168.137.40 --nameserver=8.8.8.8 --netmask=255.255.255.0  --activate
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --asprimary --fstype="xfs" --size=1024
part swap --fstype="swap" --size=2048
part / --fstype="xfs" --grow --size=1
%packages
@^minimal
@core
%end

实例二(CentOS6.8 ks):

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url="http://192.168.137.38/cobbler/ks_mirror/CentOS-6.8-x86_64/"
#repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100
# Root password
rootpw --iscrypted $1$ljohn$yBMDpKkntQ9jfV1ZAWKpU1
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
graphical
# System keyboard
keyboard us
# System language
lang en_US.UTF-8
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Installation logging level
#logging --level=info
# Reboot after installation
reboot
# System timezone
timezone  Asia/Shanghai
# Network information
network  --bootproto=dhcp --device=eth0 --onboot=on
#network  --bootproto=dhcp --device=eth1 --onboot=on
# System bootloader configuration
bootloader --append="crashkernel=auto rhgb quiet" --location=mbr --driveorder="sda"
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --asprimary --fstype="ext4" --size=500
part swap --fstype="swap" --size=2048
part / --fstype="ext4" --grow --size=1
%packages --nobase
@core
%end

这两个实例安装包都使用了core的最小化版本安装,可以大大缩短系统部署时间,毕竟时间就是金钱。如果有需要的,可以在packages后面添加一些常用的工具,这里不再赘述。

2)关联镜像与kickstart 文件,修改kickstart文件为自定义的CentOS-7.5-x86_64.cfg

 # --name 我们需要添加的启动菜单的名字
 # --distro  我们自定制的ks文件关联的yum库
 # --kickstart 我们自定制的ks文件的路径
cobbler profile edit --name=CentOS-7.5-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7.5-x86_64.cfg
# 查看Cobbler中现在还有多少个启动项
[root@localhost kickstarts]cobbler profile list
   centos6.9-x86_64
    centos7.3-x86_64
    centos7.3-x86_64-desktop

cobbler profile report --name CentOS-7.4-x86_64#查看镜像是否存在,
cobbler profile report --name CentOS-6.8-x86_64
cobbler profile edit --name=CentOS-7.4-x86_64 --kopts=‘net.ifnames=0 biosdevname=0‘#这里还原centos7网卡名为“eth0”
cobbler profile edit --name=CentOS-7.4-x86_64 --distro=CentOS-7.4-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7.4-x86_64.cfg #关联ks文件与对应的CentOS7.4镜像
cobbler profile edit --name=CentOS-6.8-x86_64 --distro=CentOS-6.8-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6.8-x86_64.cfg
service cobbler sync #与cobbler sync作用相同,同步配置,每次对cobbler更改都要执行同步

十四、Cobbler的Web管理

cobbler web支持多种认证方式,下面介绍两种用户认证登录cobbler web的方式

1)使用cobbler默认的authn_configfile模块认证方式

cobbler web界面的身份认证和授权配置位于文件/etc/cobbler/modules.conf中,cobbler默认这种方式的认证

可以直接使用htdigest命令添加cobbler用户和密码

然后重启cobbler服务,apache服务即可

2)使用authn_pam模块认证方式

首先需要在配置文件/etc/cobbler/modules.conf里修改认证方式

然后添加系统用户

之后在文件/etc/cobbler/users.conf中,将新添加的webuser用户添加到admins组中,该组具有完整访问权限

配置完成后重启cobbler,apache服务,就可以用webuser的身份登录到cobbler web页面了。

使用https://192.168.195.128/cobbler_web地址访问cobbler web页面,使用设定的用户和密码就可以进行登录,在web页面进行相关配置。

附录1:错误汇总

1)Cobbler 登录web界面提示报错“Internal Server Error”

有可能是pythone-django版本问题

#下载pip.py
wget https://bootstrap.pypa.io/get-pip.py

#调用本地python运行pip.py脚本
python get-pip.py

#安装pip
pip install Django==1.8.9

#查看pip版本号
python -c "import django; print(django.get_version())"

#重启httpd
systemctl restart httpd

完美解决

附录2:cobbler命令

# 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]
Cobbler 命令介绍:
cobbler get-loaders  #加载部分缺失的网络boot-loaders
cobbler check          #检查cobbler配置
cobbler sync            #同步配置到dhcp pxe和数据目录
cobbler list              #列出所有的cobbler元素
cobbler import          #导入安装的系统光盘镜像
cobbler report          #列出各元素的详细信息
cobbler distro          #查看导入的发行版系统信息
cobbler profile         #查看配置信息
cobbler system         #查看添加的系统信息
cobbler reposync       #同步yum仓库到本地
cobbler signature update
cobbler --help           #获得cobbler的帮助
cobbler distro --help  #获得cobbler子命令的帮助
获取帮助:
#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

原文地址:https://www.cnblogs.com/guantouping/p/10597044.html

时间: 2024-08-01 00:08:30

Cobbler图文详解安装及遇到的问题说明的相关文章

图文详解安装PHP运行环境

一.什么是PHP运行环境 能够理解人与计算机交流时语言软件,通常指解释PHP编程语言的软件. 例如: PHP(代码) 需要PHP超文本预编译器(软件). Java需要JVM虚拟机 二.安装PHP运行环境(PHP软件) 以下是两个PHP软件32位. 直接解压就表示安装. 我们在上课期间使用32位.因为32位软件既可以运行在32位电脑上也可以运行在64位的电脑上. 注意:安装目录不要出现特殊字符或者是中文 三.如何让PHP环境运行(理解)PHP代码 有两种方式: 1.直接使用php软件直接运行(理解

LNMP编译安装之msyql安装--图文详解

LNMP编译安装之msyql安装--图文详解 1.前言 本次安装采用源码安装,主要资源包从官网下载,次要依赖则使用yum进行安装,本篇只涉及mysql的安装,msyql远程登录,不涉及mysql具体配置.该教程纯属安装,不涉及任何重要知识点,老少皆宜. 2.安装步骤 2.1.下载boost(只下载不安装) wget http://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz 2.2.解压bosot t

LNMP编译安装之nginx安装--图文详解

LNMP编译安装之nginx安装--图文详解 1.前言 本次安装采用源码安装,主要资源包从官网下载,次要依赖则使用yum进行安装,本篇只涉及nginx的安装,不涉及nginx的配置,对应nginx如何访问php,本篇也不涉及.该教程纯属安装,不涉及任何重要知识点,老少皆宜. 2.安装步骤 nginx官网:http://nginx.org/en/download.html 2.1.下载nginx wget http://nginx.org/download/nginx-1.12.0.tar.gz

CentOS 7上安装Zabbix Server 3.0 图文详解

转载自 http://www.linuxidc.com/Linux/2016-09/135204.htm CentOS 7上安装Zabbix Server 3.0 图文详解 1.查看系统信息. cat /etc/RedHat-releaseCentOS Linux release 7.0.1406 (Core) uname -a Linux VM_96_155_centos3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014 x86_

图文详解PDF与word、excel、ppt互转工具Solid PDF Tools v9的下载、安装与注册激活

很多同学经常询问小编有没有关于PDF转word.excel.ppt或者它们之间互转的软件,之前亦是美网络小编曾经给大家介绍过一款工具AnyBizSoft_PDF_Convert的下载.安装与注册激活使用教程,但是有部分小伙伴反映说安装时出现了问题,可能是系统不兼容导致的无法使用,为了解决小伙伴的难题,今天再给大家分享一款PDF与word.excel.ppt互转工具,那就是Solid PDF Tools v9中文版,下面亦是美网络给大家介绍一下它的下载.安装与注册激活教程吧. Solid PDF

LNMP编译安装之php安装--图文详解

LNMP编译安装之php安装--图文详解 1.前言 本次安装采用源码安装,主要资源包从官网下载,次要依赖则使用yum进行安装,本篇只涉及php的安装,不涉及php的配置,对应nginx如何访问php,本篇也不涉及.该教程纯属安装,不涉及任何重要知识点,老少皆宜. 2.安装步骤 php官网:http://www.php.net/ 2.1.下载php wget  http://php.net/get/php-7.1.7.tar.gz/from/a/mirror 2.2.解压php安装包 tar -z

【图文详解】scrapy安装与真的快速上手——爬取豆瓣9分榜单

写在开头 现在scrapy的安装教程都明显过时了,随便一搜都是要你安装一大堆的依赖,什么装python(如果别人连python都没装,为什么要学scrapy-.)wisted, zope interface,pywin32---现在scrapy的安装真的很简单的好不好! 代码我放github上了,可以参考: https://github.com/hk029/doubanbook 为什么要用scrapy 我之前讲过了requests,也用它做了点东西,([图文详解]python爬虫实战--5分钟做

Python安装、配置图文详解

原文地址:http://weixiaolu.iteye.com/blog/1617440 目录: 一. Python简介 二. 安装python 1. 在windows下安装 2. 在Linux下安装 三. 在windows下配置python集成开发环境(IDE) 1. 在Eclipse中安装PyDev插件 2. 配置Python Interpreters 四. 创建Python Project 五. 编写HelloWorld 六. 小结 一. Python简介: Python在Linux.wi

Python安装、配置图文详解(转载)

Python安装.配置图文详解 目录: 一. Python简介 二. 安装python 1. 在windows下安装 2. 在Linux下安装 三. 在windows下配置python集成开发环境(IDE) 1. 在Eclipse中安装PyDev插件 2. 配置Python Interpreters 四. 创建Python Project 五. 编写HelloWorld 六. 小结 一. Python简介: Python在Linux.windows.Mac os等操作系统下都有相应的版本,不管在