• 欢迎访问显哥博客,本网站纯属学习技术,绝无商业用途,欢迎小伙伴们共同学习!研究技术!QQ:52249909 加我QQ
  • 世界75亿人,这么小的概率,能认识你,是我一生的幸运,不妨加个QQ接触一下:52249909 加我QQ

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

技术栈 lixian 1年前 (2020-05-28) 684次浏览 1个评论 扫描二维码
文章目录[隐藏]

一、cobbler介绍

1.cobbler概念

Cobbler是一个Linux服务器快速网络安装的服务,由python开发,小巧轻便(15k行python代码),可以通过PXE的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS,TFTP、RSYNC以及yum仓库、构造系统ISO镜像。

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

2.配置目录及文件介绍

3.cobbler命令介绍

二、cobbler安装系统实践

#安装相关服务
[root@cobbler ~]# yum install -y cobbler cobbler-web  dhcp  tftp-server  httpd  python-django pykickstart
[root@cobbler ~]# systemctl  start httpd  cobblerd.service

#配置部署 
[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.

根据以上提示执行以下命令:

#大概 390行 和 278行 更改ip为本机的ip
[root@cobbler ~]# vim +390 /etc/cobbler/settings
server: 172.16.1.100

[root@cobbler ~]# vim +278 /etc/cobbler/settings
next_server: 172.16.1.100

#将service层disable值改为no
[root@cobbler ~]# vim /etc/xinetd.d/tftp
disable                 = no

#需要相关文件 
[root@cobbler ~]# cobbler get-loaders

#启动rsynd并且加入开机自启动
[root@cobbler ~]# systemctl  restart rsyncd
[root@cobbler ~]# systemctl  enable rsyncd

#不能使用默认的密码用户(生成加密秘钥 并找到文件中default_password_crypted参数改为生成的秘钥)
[root@cobbler ~]# openssl passwd -1 -salt  'lx' '123456'
$1$lx$sDWZmB0pQ7ewwXUyiEw/41
[root@cobbler ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$lx$sDWZmB0pQ7ewwXUyiEw/41"

#重启cobblerd并执行cobbler check
[root@cobbler ~]# systemctl  restart cobblerd.service
[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.

#在文件中执行下面的vim命令
:%s#192.168#172.16#g
[root@cobbler ~]# vim /etc/cobbler/dhcp.template
subnet 172.16.1.0 netmask 255.255.255.0 {
     #option routers             172.16.1.5;
     #option domain-name-servers 172.16.1.1;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        172.16.1.100 172.16.1.200;

#使用cobbler服务管理dhcp服务    
[root@cobbler ~]# sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings

#启动cobbler相关服务程序
[root@cobbler ~]# systemctl restart httpd.service rsyncd.service tftp.socket cobblerd.service

#同步数据 
[root@cobbler ~]# cobbler sync

三、cobbler-web页面配置

1.登录cobbler

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

2.挂载镜像及导入镜像

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

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

3.rsync同步

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

#查看同步的进度
[root@cobbler ~]# du -sh /var/www/cobbler/ks_mirror/centos-7.6-x86_64/
1.8G	/var/www/cobbler/ks_mirror/centos-7.6-x86_64/
[root@cobbler ~]# du -sh /var/www/cobbler/ks_mirror/centos-7.6-x86_64/
4.3G	/var/www/cobbler/ks_mirror/centos-7.6-x86_64/

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

4.系统安装过程配置

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】

四、批量化安装系统

[root@cobbler ~]# vim /etc/cobbler/dhcp.template
subnet 10.0.0.0 netmask 255.255.255.0 {
        option routers             10.0.0.254;
        option domain-name-servers 223.5.5.5;
        option subnet-mask         255.255.255.0;
        range dynamic-bootp        10.0.0.100 10.0.0.200;
        default-lease-time         21600;
        max-lease-time             43200;
        next-server                10.0.0.200;
}

[root@cobbler ~]# systemctl  restart cobblerd.service  httpd.service tftp.socket 
[root@cobbler ~]# cobbler sync

00:50:56:35:8B:A2

00:50:56:32:9B:DF


[root@cobbler ~]# cobbler system add --name=cobbler02 --mac=00:50:56:35:8B:A2 --profile=centos-7.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos-7.6.cfg --interface=eth0 --hostname=qls



[root@cobbler ~]# cobbler system edit --name=cobbler02 --mac=00:50:56:32:9B:DF --profile=centos-7.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos-7.6.cfg --interface=eth1 


[root@cobbler ~]# cobbler sync

本站博主 , 版权所有丨如未注明 , 均为原创
转载请注明原文链接:自动化Cobbler无人值守安装企业级部署【显哥出品,必为精品】
喜欢 (1)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到
(1)个小伙伴在吐槽
  1. 小显哥哥 好大,好棒 好牛皮
    匿名2020-05-29 11:30 回复