首页 > 系统服务 > 详细

【亲测可用】Cobbler自动批量部署Linux系统

时间:2018-05-16 23:53:07      阅读:406      评论:0      收藏:0      [点我收藏+]
Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows。该工具使用python开发,小巧轻便,使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP、DNS、TFTP、RSYNC以及yum仓库、构造系统ISO镜像。

Cobbler支持命令行管理,web界面管理,还提供了API接口,可以方便二次开发使用。

Cobbler客户端Koan支持虚拟机安装和操作系统重新安装,使重装系统更便捷。

环境准备

  1. VMware 12 虚拟机
  2. Centos 7 操作系统(网卡模式:NAT模式;IP地址为:192.168.96.129)
  3. 软件包: epel-release-latest-7.noarch.rpm 密 码:fqw7

服务部署

  1. 安装 epel-release-latest-7.noarch.rpm 软件包(cobbler相关软件包是由EPEL源提供的)

    rpm -ivh /mnt/epel-release-latest-7.noarch.rpm
  2. 安装cobbler cobbler-web dhcp tftp-server pykickstart httpd rsync xinetd软件包
yum install cobbler cobbler-web dhcp tftp-server pykickstart httpd rsync xinetd -y
  1. 修改cobbler主配置文件:
    vim /etc/cobbler/settings

next-server:192.168.96.129 #tftp服务器的ip地址
server:192.168.96.129 #服务器的ip地址
manage_dhcp:1 #开启dhcp功能

  1. 使用cobbler check对cobbler做检查设置
    cobbler check 

---------------------提示内容:需要优化-----------------------------------
The following are potential configuration items that you may want to fix:

1 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
https:#github.com/cobbler/cobbler/wiki/Selinux

2 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/tftp

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 haveinstalled 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.

4 : enable and start rsyncd.service with systemctl

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

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

7 : 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. 修改cobbler用户的初始密码,可以使用以下命令生成密码
    openssl passwd -1 -salt ‘abc123‘ ‘abc123‘    #盐值加密

$1$abc123$9v8z2./E/PZihXrVcy3II0 #加密后的密码

将此密码替换到settings文件中

default_password_crypted: "$1$abner$kDle2KnwbPHdm1UZEE79V." #替换密码,此为root用户密码
:wq! #保存退出

  1. 下载引导操作系统文件

    cobbler get-loaders 
  2. 启动rsyncd服务

    systemctl start rsyncd.service
  3. 开启tftp服务
    vim /etc/xinetd.d/tftp

    disable = no #将yes修改为no,启用tftp

重启xinetd服务

systemctl restart xinetd.service

  1. 编辑dhcp模板文件
    vim /etc/cobbler/dhcp.template       

    #cobbler控制的dhcp服务模板

subnet 192.168.96.0 netmask 255.255.255.0 {
option routers 192.168.96.1; #修改网关
option domain-name-servers 192.168.96.2; #修改DNS
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.96.100 192.168.96.200; #修改地址池
:wq! #保存退出

  1. 同步生成DHCP配置文件
    cobbler sync      
  2. 启动dhcpd服务

    systemctl restart dhcpd.service    
  3. 加载系统光盘镜像
    mount /dev/sr0 /mnt

    #导入iso镜像

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

    #默认导入存放位置

    /var/www/cobbler/ks_mirror/CentOS-7-x86_64        

    技术分享图片

#查看导入结果

cobbler list    

distros:
Centos-7-x86_64
profiles:
Centos-7-x86_64
systems:
repos:
images:
mgmtclasses:
packages:
files:

#查看发行版本

cobbler distro list   

技术分享图片

#安装tree软件包

yum install tree -y

tree /var/lib/tftpboot/images #查看内核和初始化文件在tftp server 共享目录
└── Centos-7-x86_64
├── initrd.img
└── vmlinuz

cobbler profile report

Name : Centos-7-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : Centos-7-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : [‘admin‘]
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm

#ks默认文件存放位置

/var/lib/cobbler/kickstarts/sample_end.ks 

#cobbler日志文件所在位置

/var/log/cobbler/cobbler.log

关闭防火墙及安全功能

setenforce 0
systemctl stop firewalld.service

客户端安装完成后只具备字符界面
登录账户名:root 密码:abc123

Cobbler Web用户设置

vim /etc/cobbler/modules.conf     

authn_configfile #默认就是模块认证

htdigest -c /etc/cobbler/users.digest Cobbler maaiqiang
输入两次确认密码(123123)

#重新启动cobblerd、httpd服务

systemctl restart cobblerd.service
systemctl restart httpd.service


自动装机

技术分享图片
技术分享图片
技术分享图片
技术分享图片
技术分享图片
技术分享图片
技术分享图片

以下为Cobbler web管理平台

技术分享图片
技术分享图片
技术分享图片
技术分享图片

【亲测可用】Cobbler自动批量部署Linux系统

原文:http://blog.51cto.com/10316297/2117219

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!