实验注解——Cobbler 自动部署装机及图形化界面安装(超详细注解)

Cobbler 概述与环境配置

  • Cobbler是一个使用Python开发的开源项目,通过将部署系统所涉及的所有服务集中在一起,来提供一个全自动批量快速建立linux系统的网络安装环境。
  • 使用VMware虚拟机软件演示,需连接上互联网,且虚拟机都使用NAT模式。一台CentOS7虚拟机作为服务端,另一台CentOS7虚拟机当做客户端,留作最终测试,安装系统等正常配置。客户端测试机内存需≥2G

Cobbler自动装机服务搭建步骤

  • 1. 导入epel源
[root@localhost 1]# rz -E                               (直接把文件拖进来)
rz waiting to receive.
[root@localhost 1]# ls            
epel-release-latest-7.noarch.rpm                        
[root@localhost ~]# rpm -ivh epel-release-latest-7.noarch.rpm
  • 2.安装Cobbler以及其相关服务软件包
[root@localhost ~]# yum install -y cobbler dhcp tftp-server pykickstart httpd rsync xinetd

各软件包作用如下

软件名说明
cobbler用来快速建立Linux网络安装环境
dhcp用来为空白主机自动分配IP地址
tftp-server提供引导镜像文件的下载
pykickstart实现无人值守安装
httpd作为控制台程序运行
rsync实现数据同步
xinetd提供访问控制、加强的日志和资源管理功能
  • 3.修改cobbler主配置文件
[root@localhost 1]# vim /etc/cobbler/settings
next_server: 192.168.131.13       	(指向tftp服务器的IP,即本机IP)
server: 192.168.131.13				(指向cobbler服务器的IP,即本机IP)
manage_dhcp: 1                 		(让cobbler管理dhcp服务)
manage_rsync: 1					    (让cobbler管理rsync服务)
manage_tftpd: 1					    (让cobbler管理tftp服务)



  • 4.启动相关服务并关闭防火墙和selinux
[root@localhost ~]# systemctl start httpd.service 
[root@localhost ~]# systemctl start cobblerd.service
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
  • 5.修改tftp的配置文件,并开启服务
[root@localhost ~]# vim /etc/xinetd.d/tftp 
service tftp
{
        disable                 = no                  (开启tftp服务,此处将yse改为no)
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -B 1380 -v -s /var/lib/tftpboot
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

[root@localhost ~]# systemctl restart xinetd.service
[root@localhost ~]# systemctl start rsyncd.service 

  • 6.下载引导操作系统文件
[root@localhost ~]# cobbler get-loaders
task started: 2021-02-24_111551_get_loaders
task started (id=Download Bootloader Content, time=Wed Feb 24 11:15:51 2021)
downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***


  • 7.使用盐值加密方式设置 Cobbler用户初始密码
[root@localhost ~]# openssl passwd -1 -salt '11312' '11312'   (使用盐值加密方式生成密钥。前面‘ ’里面的可以任意填写字符,后面
                                                                的‘ ’里面为安装完系统后root用户的密码)
$1$5514$rQPa3RgJ5WEG3TaZT6toR1
[root@localhost ~]# vim /etc/cobbler/settings                 (将生成的密钥加入Cobbler配置文件中)
:/default_password
default_password_crypted: "$1$5514$rWPa3RgJ5XQG3IaZT6toM1"

  • 8.配置 DHCP 服务
[root@localhost 1]# vim /etc/cobbler/dhcp.template

subnet 192.168.131.0 netmask 255.255.255.0 {         (这里修改的是网段)
     option routers             192.168.131.13;      (修改网关)
     option domain-name-servers 192.168.131.2;       (修改DNS,如果网卡使用的是dhcp模式,可通过nslookup 127.0.0.1 | grep
                                                       server 查询DNS地址)
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.131.10 192.168.131.100;(修改地址池)
     default-lease-time         21600;
     max-lease-time             43200;

  • 9.将配置好的模板文件同步到DHCP服务的配置文件中并重启DHCP服务
[root@localhost 1]# cobbler sync
...省略...
*** TASK COMPLETE ***
[root@localhost ~]# systemctl restart dhcpd.service
  • 10.导入ISO镜像文件
[root@localhost ~]# mount /dev/cdrom /mnt/
[root@localhost ~]# cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64
(--path:表示镜像所挂载的目录;--name:表示为安装源定义的名字;--atch:表示指定安装源的系统位数; 默认导入存放路径
为/var/www/cobbler/ks_mirror/CentOS-7-x86_64)
  • 11.查看内核和初始化文件是否在在tftp-server 共享目录中
[root@localhost ~]#  yum -y install tree            (系统默认没有安装,需手动安装tree)
[root@localhost ~]# tree /var/lib/tftpboot/images   (查看文件是否存在)
/var/lib/tftpboot/images
└── CentOS-7-x86_64
    ├── initrd.img
    └── vmlinuz


  • 12.重启所有服务并用cobbler check 对Cobbler做检查设置
[root@localhost ~]# systemctl restart cobblerd.service 
[root@localhost ~]# systemctl restart dhcpd.service 
[root@localhost ~]# systemctl restart xinetd.service 
[root@localhost ~]# systemctl restart httpd.service 
[root@localhost ~]# 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 : enable and start rsyncd.service with systemctl
3 : debmirror package is not installed, it will be required to manage debian deployments and repositories
4 : 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.

  • 13.所有配置完成后开启空白主机即可自动安装系统
    在这里插入图片描述
    在这里插入图片描述

  • 此安装方式为最小化安装,安装的系统只有字符界面

  • 登录账户:root 密码:11312

  • 登录上后查询ip并使用Xshell进行连接操作

如需图形化界面可自行手动安装

[root@localhost ~]# yum update grub2-common
[root@localhost ~]# yum install -y fwupdate-efi
[root@localhost ~]# yum install -y net-tools
[root@localhost ~]# yum groupinstall "GNOME Desktop" "Graphical Administration Tools"
[root@localhost ~]# reboot
  • 将语言修改成中文
[root@localhost ~]# vim /root/anaconda-ks.cfg  

  1 #version=DEVEL
    ......
 14 lang zh_CN.UTF-8

[root@localhost ~]# locale
LANG=zh_CN.UTF-8
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

TaKe___Easy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值