cobbler部署

cobbler

cobbler 简介

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

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

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

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

puppet是一种Linux、Unix、windows平台的集中配置管理系统,使用自有的puppet描述语言,可管理配置文件、用户、cron任务、软件包、系统服务等。puppet把这些系统实体称之为资源,puppet的设计目标是简化对这些资源的管理以及妥善处理资源间的依赖关系。

puppet采用C/S星状的结构,所有的客户端和一个或几个服务器交互。每个客户端周期的(默认半个小时)向服务器发送请求,获得其最新的配置信息,保证和该配置信息同步。每个puppet客户端每半小时(可以设置)连接一次服务器端, 下载最新的配置文件,并且严格按照配置文件来配置客户端. 配置完成以后,puppet客户端可以反馈给服务器端一个消息. 如果出错,也会给服务器端反馈一个消息

cobbler集成的服务:

PXE服务支持

DHCP服务管理

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

电源管理

Kickstart服务支持

YUM仓库管理

TFTP(PXE启动时需要)

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

cobbler配置文件详解

cobbler配置文件目录在/etc/cobbler
配置文件	                     作用
/etc/cobbler/settings.yaml	cobbler 主配置文件
/etc/cobbler/iso/	iso模板配置文件
/etc/cobbler/pxe	pxe模板配置文件
/etc/cobbler/power	电源配置文件
/etc/cobbler/user.conf	web服务授权配置文件
/etc/cobbler/users.digest	web访问的用户名密码配置文件
/etc/cobbler/dhcp.template	dhcp服务器的的配置模板
/etc/cobbler/dnsmasq.template	dns服务器的配置模板
/etc/cobbler/tftpd.template	tftp服务的配置模板
/etc/cobbler/modules.conf	模块的配置文件

cobbler数据目录

目录	                                                          作用
/var/lib/cobbler/config/	用于存放distros,system,profiles等信息配置文件
/var/lib/cobbler/triggers/	用于存放用户定义的cobbler命令
/var/lib/cobbler/kickstart/	默认存放kickstart文件
/var/lib/cobbler/loaders/	存放各种引导程序以及镜像目录
/var/www/cobbler/ks_mirror/	导入的发行版系统的所有数据
/var/www/cobbler/images/	导入发行版的kernel和initrd镜像用于远程网络启动
/var/www/cobbler/repo_mirror/	yum仓库存储目录

cobbler日志文件

日志文件路径	                      说明
/var/log/cobbler/installing	客户端安装日志
/var/log/cobbler/cobbler.log	cobbler日志

cobbler命令详解

cobbler check       //核对当前设置是否有问题
cobbler list        //列出所有的cobbler元素
cobbler report      //列出元素的详细信息
cobbler sync        //同步配置到数据目录,更改配置最好都要执行下
cobbler reposync    //同步yum仓库
cobbler distro      //查看导入的发行版系统信息
cobbler system      //查看添加的系统信息
cobbler profile     //查看配置信息

cobbler服务部署

//看是否需求有yum源的话就不用执行这一步
[root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
//下载epel源根据当时服务器的环境,我这里是centos8
[root@localhost ~]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
//这里找一下cobbler的包因为用yum下不了,只能通过使用模块的方式使用。
[root@localhost ~]# yum module list | grep cobbler
//然后直接使用就可以了。
[root@localhost ~]# yum module enable cobbler:3 -y
//下载一些cobbler所需要的服务,和依赖
[root@localhost ~]# yum -y install httpd dhcp* tftp tftp-server cobbler cobbler-web pykickstart rsync rsync-daemon syslinux* yum-utils
//把刚刚下载的服务启动一下并设置开机自启
[root@localhost ~]# systemctl restart httpd;systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# systemctl enable --now rsyncd
Created symlink /etc/systemd/system/multi-user.target.wants/rsyncd.service → /usr/lib/systemd/system/rsyncd.service.
[root@localhost ~]# systemctl enable --now tftp
Created symlink /etc/systemd/system/sockets.target.wants/tftp.socket → /usr/lib/systemd/system/tftp.socket.
[root@localhost ~]# systemctl enable --now cobblerd
Created symlink /etc/systemd/system/multi-user.target.wants/cobblerd.service → /usr/lib/systemd/system/cobblerd.service.
[root@localhost ~]# 
//关闭防火墙和selinux
[root@localhost ~]# systemctl disable --now firewalld
[root@localhost ~]# vim /etc/sysconfig/selinux
SELINUX=disabled   //这里需要重启机器生效配置
//把这个配置文件的server的ip地址为本机ip,和next server的ip改为自己的ip
[root@localhost ~]# vim /etc/cobbler/settings.yaml
server:192.168.171.13
next server:192.168.171.13
//这里生成一下加密的密码
[root@localhost ~]# openssl passwd -1 -salt "$RANDOM" 'cobbler123'
$1$17620$akV7yJVZ.AjmEh4PTpfKW1
//修改成刚生成的随机密码
[root@localhost ~]# vim /etc/cobbler/settings.yaml
default_password_crypted: "$1$17620$akV7yJVZ.AjmEh4PTpfKW1"
//将cobbler的dhcp功能打开
[root@localhost ~]# vim /etc/cobbler/settings.yaml
manage_dhcp: true

//我们等会需要的文件就在这目录下
[root@localhost ~]# ls /usr/share/syslinux/
需要这个 pxelinux.0 ,menu.c32
//把需要的文件cp到/var/lib/cobbler/loaders/这个目录下
[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/cobbler/loaders/
[root@localhost ~]# cp /usr/share/syslinux/menu.c32 /var/lib/cobbler/loaders/
//这个目录下有文件就行了,然后重启服务,同步一下
[root@localhost ~]# ls /var/lib/cobbler/loaders/
menu.c32  pxelinux.0
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# systemctl restart httpd
//然后同步一下
[root@localhost ~]# cobbler check
[root@localhost ~]# cobbler check
The following are potential configuration items that you may want to fix:

1: some network boot-loaders are missing from /var/lib/cobbler/loaders. 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, and yaboot.
2: debmirror package is not installed, it will be required to manage debian deployments and repositories
3: fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
//这里1我们前面cp的文件就是为了解决问题,所以现在不用管,而2,3是debian系统的问题,也不需要管
Restart cobblerd and then run 'cobbler sync' to apply changes.
[root@localhost ~]# 


//配置DHCP模板文件
[root@localhost ~]# vim /etc/cobbler/dhcp.template 
subnet 192.168.171.0 netmask 255.255.255.0 {       //自己的网段
     option routers             192.168.171.2;   //自己的网关
     option domain-name-servers 114.114.114.114; //自己的dns
     option subnet-mask         255.255.255.0;   //自己的子网
     range dynamic-bootp        192.168.171.150 192.168.171.160;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;
[root@localhost ~]# systemctl restart cobblerd.service
//同步cobbler配置
[root@localhost ~]# cobbler sync
...
*** TASK COMPLETE *** //出现这一行就没什么问题了
管理distro
//挂载镜像
[root@localhost ~]# mount /dev/cdrom /mnt/
mount: /mnt: WARNING: device write-protected, mounted read-only.
[root@localhost ~]# 
//导入镜像(切记勿tab)
[root@localhost ~]# cobbler import --path=/mnt/ --name=wtk arch=x86_64      //名字自己定
...
*** TASK COMPLETE ***
//查看镜像信息
[root@localhost ~]# cobbler list
distros:
   wtk-x86_64

profiles:
   wtk-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:
//查看指定的镜像信息,指定镜像的name即可
[root@localhost ~]# cobbler distro report --name wtk-x86_64
Name                           : wtk-x86_64
Architecture                   : x86_64
Automatic Installation Template Metadata : {'tree': 'http://@@http_server@@/cblr/links/wtk-x86_64'}
TFTP Boot Files                : {}
Boot loader                    : grub
Breed                          : redhat
Comment                        : 
Fetchable Files                : {}
Initrd                         : /var/www/cobbler/distro_mirror/wtk/images/pxeboot/initrd.img
Kernel                         : /var/www/cobbler/distro_mirror/wtk/images/pxeboot/vmlinuz
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Management Classes             : []
OS Version                     : rhel8
Owners                         : ['admin']
Redhat Management Key          : 
Remote Boot Initrd             : ~
Remote Boot Kernel             : ~
Template Files                 : {}
//创建kickstarts自动安装脚本(文件以.ks结尾,勿tab)
[root@localhost ~]# cobbler profile get-autoinstall --name wtk-x86_64 > /var/lib/cobbler/templates/wtk.ks
//对脚本进行修改
[root@localhost ~]# vim /var/lib/cobbler/templates/wtk.ks
...
firewall --disable   //防火墙关闭
...
%packages
@^minimal-environment   //设置安装最小化
...

//如果是生产环境,那么部署就已经完成,如果是虚拟机就还需执行以下步骤
[root@localhost ~]# cd /usr/share/cobbler/bin/
[root@localhost bin]# ls
migrate-data-v2-to-v3.py  mkgrub.sh
migrate-settings.sh       settings-migration-v1-to-v2.sh
[root@localhost bin]# 
//执行脚本,如果是生产环境脚本会自动执行.
[root@localhost bin]# bash mkgrub.sh 
//进入这个目录下可以看到grub这个启动引导文件没有这个自动装的虚拟机时启动不了的。
[root@localhost bin]# cd /var/lib/cobbler/loaders/
[root@localhost loaders]# ls
grub  ldlinux.c32  menu.c32  pxelinux.0
//再次同步
[root@localhost loaders]# cobbler sync
*** TASK COMPLETE ***
//重启服务
[root@localhost loaders]# systemctl restart httpd cobblerd rsyncd 

然后创建一个虚拟机默认设置就行,不能添加映像文件,进来选择刚刚创建的镜像
在这里插入图片描述

选择后会安装一个centos8的系统
在这里插入图片描述

这里需要等待一会,安装好后查看ip就是之前dhcp那个地址池的范围里面
在这里插入图片描述

web网站自动创建虚拟机

输入https://192.168.171.13/cobbler_web 这个网址访问然后登录用户密码都是cobbler

在这里插入图片描述

进来后的界面

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值