linux进阶-利用cobbler快速网络安装linux系统全get

实现cobbler服务

什么是cobbler?

1.Cobbler翻译为中文是补鞋匠,在linux方面则一个免费的用于系统安装部署的开源软件,官方地址 http://cobbler.github.io/,
2.cobbler是对技术的二次基于python的开发,提供了CLI(命令行)和Web的管理方式,另外还提供了API(应用程序编程接口)接口,方便二次开发使用,
3.相比PXE,cobbler支持多系统同时引导,而PXE只能一次引导一个系统的安装,
4.cobbler通常与开源软件puppet、saltstack配合使用,进行操作系统的批量安装与部署优化,从而实现大批量linux系统的无人值守安装与服务部署,大大提升运维的工作效率,
4.cobbler工作于服务端,结合DHCP/TFTP/saltstack等服务提供批量系统安装部署,
5.cobbler需要结合PXE技术对客户端进行操作系统的安装

在这里插入图片描述

1.client裸机配置了从网络启动后,开机后会广播包请求DHCP服务器(cobbler server)发送其分配好的一个IP
2.DHCP服务器(cobbler server)收到请求后发送responese,包括其ip地址
3.client裸机拿到ip后再向cobbler server发送请求OS引导文件的请求
4.cobbler server告诉裸机OS引导文件的名字和TFTP server的ip和port
5.client裸机通过上面告知的TFTPserver地址通信,下载引导文件
6.client裸机执行执行该引导文件,确定加载信息,选择要安装的os,期间会再向cobbler server请求kickstart文件和os image
7.cobbler server发送请求的kickstart和os iamge.
8.client裸机加载kickstart文件 .client裸机接收os image,安装该os image
cobbler常用命令

在这里插入图片描述

cobbler配置文件目录

在这里插入图片描述

在这里插入图片描述

大家好我们又见面了!我们今天是利用cobbler服务快速安装linux系统!
准备好,我们就开始咯

软件准备

在这里插入图片描述

安装前准备

关闭SElinux
vim /etc/sysconfig/selinux

编辑文件
······
SELINUX=disabled ✅
······
-------------------------------
关闭防火墙
systenctl stop firewalld   #临时关闭 ✅
systemctl disable firewalld   #禁止开机启动 ✅
-------------------------------------------
使用/misc/cd 本机是cnetos7对应的是/misc/cd
yum install autofs -y ✅
systenctl start autos ✅
systemctl enable autofs ✅
----------------------------------------------
安装epel源
yum -y install epel-release ✅
--------------------------------
自己创建yum源
mkdir /etc/yum.repos.d/yum/
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/yum/

vim /etc/yum.repos.d/base.repo

编辑文件
······
[base]
name=base
baseurl=file:///misc/cd
gpgcheck=0

[epel]
name=epel
baseurl=http://mirrors.sohu.com/fedora-epel/7/x86_64/
gpgcheck=0
enabled=1
······
https://mirrors.aliyun.com/epel/7/x86_64/   
#上为阿里云镜像文件,后面的实现cobbler web管理,无法使用
------------------------------------------------------
yum repolist   #确认epel源可用
---------------------------------
挂载光盘
[root@centos7 ~]# mkdir -pv /mnt/{centos6,centos7} ✅
[root@centos7 ~]# mount /dev/sr0 /mnt/centos7 ✅
[root@centos7 ~]# mount /dev/sr1 /mnt/centos6 ✅
[root@centos7 ~]# lsblk 
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  200G  0 disk 
├─sda1   8:1    0    1G  0 part /boot
├─sda2   8:2    0  100G  0 part /
├─sda3   8:3    0   50G  0 part /data
├─sda4   8:4    0    1K  0 part 
└─sda5   8:5    0    3G  0 part [SWAP]
sr0     11:0    1 10.3G  0 rom  /mnt/centos7
sr1     11:1    1  3.7G  0 rom  /mnt/centos6
-------------------------------------

确认桥接网卡,须能上网。第一块桥接,第二块NAT

能够访问外网的地址

在这里插入图片描述

在这里插入图片描述

cobbler 安装

cobbler常见8项问题

[root@centos7 ~]# yum -y install cobbler dhcp tftp-server pykickstart httpd    #安装cobbler ✅
---------------------------------------------------------------------
[root@centos7 ~]# systemctl start tftp.socket httpd cobblerd   #启动服务 ✅
[root@centos7 ~]# systemctl enable  tftp httpd dhcpd cobblerd   #开机自启 ✅
ss -ntul #tcp80端口   udp69端口打开
---------------------------------------------------------------------
cobbler chaeck   #测试cobbler
[root@centos7 ~]# 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.

8项问题解决方法

---------------------------------------------------------
1.#解决办法 cobbler get-loaders #下载缺失的文件 ✅
----------------------------------------------------------
2.#解决办法 systemctl enable rsyncd #添加rsync到自启动并启动rsync 
[root@Centos7 ~]#systemctl start rsyncd ✅
[root@Centos7 ~]#systemctl enable rsyncd.service ✅
----------------------------------------------------------
3.#解决办法 service tftp
  {
           socket_type             = dgram
           protocol                = udp
           wait                    = yes
           user                    = root
           server                  = /usr/sbin/in.tftpd
           server_args             = -s /var/lib/tftpboot
           disable                 = no  # 修改为no ✅
           per_source              = 11
           cps                     = 100 2
           flags                   = IPv4
  }
-----------------------------------------------------------
4.#解决办法 cobbler get-loaders #下载缺失的文件 ✅
-----------------------------------------------------------
5.#解决办法 systemctl enable rsyncd #添加rsync到自启动并启动rsync
[root@Centos7 ~]#systemctl start rsyncd ✅
[root@Centos7 ~]#systemctl enable rsyncd.service ✅
-----------------------------------------------------------
6.#跟debian 相关,可以忽略 ❌
-----------------------------------------------------------
7.#解决方法 # 修改密码为123456 ,salt后面是常用的加盐方式加密
[root@Centos7 ~]#openssl passwd -1 -salt '123456' '123456'
Password: 
Verifying - Password: 
$1$123456$wOSEtcyiP2N/IfIl15W6Z0
vim /etc/cobbler/settings

编辑文件
······
default_password_crypted: "$1$123456$wOSEtcyiP2N/IfIl15W6Z0" ✅
······
------------------------------------------------------------
8.#fence设备相关,不需要 ❌
------------------------------------------------------------
vim /etc/cobbler/settings(注意:配置文件中改这四项:后面必需有一个空格)❗❗❗

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

下面两项和本章无关可忽略
[root@centos7 ~]# 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   #dabian相关 ❌
2 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them   #fence设备相关,不需要 ❌

Restart cobblerd and then run 'cobbler sync' to apply changes.

配置cobbler生成dhcp服务

[root@centos7 ~]# vim /etc/cobbler/dhcp.template

编辑文件
······
subnet 192.168.26.0 netmask 255.255.255.0 {                    ✅
     option routers             192.168.26.254;                ✅
     option domain-name-servers 1.1.1.1;                       ✅
     option subnet-mask         255.255.255.0;                 ✅
     range dynamic-bootp        192.168.26.100 192.168.26.254; ✅
······
--------------------------------------------------------------
[root@centos7 ~]# cobbler sync   #自动启动dhcp服务 ✅
--------------------------------------------------------------
[root@centos7 ~]# systemctl restart tftp httpd cobblerd   #重启服务 ✅
--------------------------------------------------------------

导入安装源文件

[root@centos7 data]# cp /data/ks6_mini.cfg /var/lib/cobbler/kickstarts/ ✅
[root@centos7 data]# cp /data/ks7_mini.cfg /var/lib/cobbler/kickstarts/ ✅
-----------------------------------------------------------------------
vim /var/lib/cobbler/kickstarts/ks6_mini.cfg

编辑文件
······
url --url==$tree ✅
······
-----------------------------------------------------------------------
vim /var/lib/cobbler/kickstarts/ks7_mini.cfg

编辑文件
······
url --url==$tree ✅
······

将ks文件和系统关联,生成启动菜单

-------------------------------------------------------------------
[root@centos7 ~]# cobbler profile add --name=centos-6-x86_64_mini --distro=centos-6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/ks6_mini.cfg ✅
[root@centos7 ~]# cobbler profile add --name=centos-7-x86_64_mini --distro=centos-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/ks7_mini.cfg ✅
--------------------------------------------------------------------
[root@centos7 ~]# cobbler profile list   #应答文件
   centos-6-x86_64_mini
   centos-7-x86_64_mini
-----------------------------------------   
[root@centos7 ~]# cobbler distro list   #源文件
   centos-6-x86_64
   centos-7-x86_64
-----------------------------------------
[root@centos7 ~]# cobbler profile remove --name=centos-6-x86_64  #删除默认的文件 ✅
[root@centos7 ~]# cobbler profile remove --name=centos-7-x86_64  #删除默认的文件 ✅
----------------------------------------------------------------

实现cobbler web管理

yum -y install cobbler-web ✅
--------------------------------------------------------------------
systemctl restart httpd ✅
--------------------------------------------------------------------
systemctl restart cobblerd ✅
--------------------------------------------------------------------
[root@centos7 ~]# htdigest /etc/cobbler/users.digest Cobbler cobbler2 ✅
Adding user cobbler2 in realm Cobbler
New password: 
Re-type new password: 
---------------------------------------------------------------------
https://192.168.26.7/cobbler_web
---------------------------------------------------------------------

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

看到这条信息,首先谢谢您😘其次表示本次实验到这就完全结束了,欢迎下次光临!(~ ̄▽ ̄)~
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章