博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用Cobbler安装多版本操作系统
阅读量:7125 次
发布时间:2019-06-28

本文共 8677 字,大约阅读时间需要 28 分钟。

Cobbler是PXE的二次开发产品所以功能更强大;

准备一台已经安装好操作系统的虚拟机:CentOS Linux release 7.5.1804 (Core) IP地址172.16.75.1
安装一些必备组件:
cobbler实在epel源当中的,可能直接yum安不上,所以我们先解决epel源的问题:
[root@1 ~]# yum -y install epel-release
然后安装组件:
[root@1 ~]# yum -y install cobbler dhcp bind httpd rsync syslinux tftp-server
安好,就进行下面的工作:
[root@1 ~]# setenforce 0
[root@1 ~]# iptables -F
[root@1 ~]# systemctl start httpd
[root@1 ~]# systemctl start cobblerd
[root@1 ~]# 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 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
4 : change 'disable' to 'no' in /etc/xinetd.d/tftp
5 : 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.
6 : enable and start rsyncd.service with systemctl
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
8 : 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
9 : 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.
解决第一个问题:
使用Cobbler安装多版本操作系统
解决第二个问题:
使用Cobbler安装多版本操作系统
解决第三个问题:
[root@1 ~]# setenforce 0 //执行者各命令就行了
解决第四个问题:
使用Cobbler安装多版本操作系统
解决第五个问题:
使用Cobbler安装多版本操作系统
解决第六个问题:
[root@1 ~]# systemctl enable rsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
[root@1 ~]# systemctl start rsyncd
解决第八个问题:
[root@1 ~]# openssl passwd -1 123456
$1$1PRzBrcv$DUkTlLcxl/PFAtLZWdJ4M.
使用Cobbler安装多版本操作系统
第七个和第九个不用管;

我们可以看到在问题结尾有这么一行:Restart cobblerd and then run 'cobbler sync' to apply changes.

解决完这些完问题后,按照最后一行的提示操作即可:
[root@1 ~]# systemctl restart cobblerd
[root@1 ~]# cobbler sync
完成后再次检查:
使用Cobbler安装多版本操作系统
这些就不用管了,对我们安装系统就没影响了;
接下来我们要用cobbler管理dhcp:
使用Cobbler安装多版本操作系统
[root@1 ~]# vim /etc/cobbler/settings
使用Cobbler安装多版本操作系统
[root@1 ~]# vim /etc/cobbler/dhcp.template
使用Cobbler安装多版本操作系统
修改上面的内容即可,这些都是干啥的我在之前的PXE安装操作系统的时候有解释;
重启服务,同步数据:
[root@1 ~]# systemctl restart cobblerd
[root@1 ~]# cobbler sync
[root@1 ~]# cat /etc/dhcp/dhcpd.conf //再次查看,其内部会自动添加如下内容;

**

Cobbler managed dhcpd.conf file

generated from cobbler dhcp.conf template (Sun Jan 6 04:01:36 2019)

Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes

in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be

overwritten.

**

ddns-update-style interim;

allow booting;

allow bootp;

ignore client-updates;

set vendorclass = option vendor-class-identifier;

option pxe-system-type code 93 = unsigned integer 16;

subnet 172.16.0.0 netmask 255.255.0.0 {

option routers 172.16.75.1;
option domain-name-servers 172.16.75.1;
option subnet-mask 255.255.0.0;
range dynamic-bootp 172.16.100.100 172.16.100.254;
default-lease-time 21600;
max-lease-time 43200;
next-server 172.16.75.1;
class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
if option pxe-system-type = 00:02 {
filename "ia64/elilo.efi";
} else if option pxe-system-type = 00:06 {
filename "grub/grub-x86.efi";
} else if option pxe-system-type = 00:07 {
filename "grub/grub-x86_64.efi";
} else if option pxe-system-type = 00:09 {
filename "grub/grub-x86_64.efi";
} else {
filename "pxelinux.0";
}
}

}

group for Cobbler DHCP tag: default

group {

}

与PXE不同,Cobbler可以自动帮助我们生成系统安装的yum 源,而不需要我们自己去制作,我们只要指定光盘路径就好了,并指定kickstart文件路径(这个文件的制作之前的博客中有说呦):

[root@1 ~]# mkdir /mnt/cdrom
[root@1 ~]# mount -r /dev/sr0 /mnt/cdrom/
[root@1 ~]# cobbler import --name="CentOS-7.5-x86_64" --path=/mnt/cdrom --kickstart=/var/lib/cobbler/kickstarts/centos7-common-ks.cfg --arch=x86_64
task started: 2019-01-06_121449_import
task started (id=Media import, time=Sun Jan 6 12:14:49 2019)
Found a candidate signature: breed=redhat, version=rhel6
Found a candidate signature: breed=redhat, version=rhel7
Found a matching signature: breed=redhat, version=rhel7
Adding distros from path /var/www/cobbler/ks_mirror/CentOS-7.5-x86_64:
creating new distro: CentOS-7.5-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-7.5-x86_64 -> /var/www/cobbler/links/CentOS-7.5-x86_64
creating new profile: CentOS-7.5-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/CentOS-7.5-x86_64 for CentOS-7.5-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-7.5-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-7.5-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-7.5-x86_64/repodata/comps.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-7.5-x86_64/repodata
TASK COMPLETE
这个过程很慢,等等就好;
好这个Centos7.5的就准备好了,我们在准备一个Centos6.7的:
在我们的虚拟机中把Centos6.7的光盘镜像挂载上然后再进行操作:
[root@1 ~]# mount -r /dev/sr0 /mnt/cdrom/
[root@1 ~]# cobbler import --name="CentOS-6.7-x86_64" --path=/mnt/cdrom --kickstart=/var/lib/cobbler/kickstarts/centos6-common-ks.cfg --arch=x86_64
task started: 2019-01-06_124948_import
task started (id=Media import, time=Sun Jan 6 12:49:48 2019)
Found a candidate signature: breed=redhat, version=rhel6
Found a matching signature: breed=redhat, version=rhel6
Adding distros from path /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64:

  • Warning : Multiple archs found : ['x86_64', 'i386']
    creating new distro: CentOS-6.7-x86_64
    trying symlink: /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64 -> /var/www/cobbler/links/CentOS-6.7-x86_64
    creating new profile: CentOS-6.7-x86_64
    creating new distro: CentOS-6.7-i386
    trying symlink: /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64 -> /var/www/cobbler/links/CentOS-6.7-i386
    creating new profile: CentOS-6.7-i386
    associating repos
    checking for rsync repo(s)
    checking for rhn repo(s)
    checking for yum repo(s)
    starting descent into /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64 for CentOS-6.7-x86_64
    processing repo at : /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64
    need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64
    looking for /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64/repodata/comps.xml
    Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-6.7-x86_64/repodata
    starting descent into /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64 for CentOS-6.7-i386
    processing repo at : /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64
    need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64
    looking for /var/www/cobbler/ks_mirror/CentOS-6.7-x86_64/repodata/comps.xml
    Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-6.7-x86_64/repodata
    TASK COMPLETE
    在这呢,你多换几个光盘分别挂载,并设置就可以完成多个系统选择了,当我们完成这些操作后可以看到
    [root@1 ~]# cat /var/lib/tftpboot/pxelinux.cfg/default
    DEFAULT menu
    PROMPT 0
    MENU TITLE Cobbler |
    TIMEOUT 200
    TOTALTIMEOUT 6000
    ONTIMEOUT local

LABEL local

MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1

LABEL CentOS-6.7-i386

kernel /images/CentOS-6.7-i386/vmlinuz
MENU LABEL CentOS-6.7-i386
append initrd=/images/CentOS-6.7-i386/initrd.img ksdevice=bootif lang= kssendmac text ks=
ipappend 2

LABEL CentOS-6.7-x86_64

kernel /images/CentOS-6.7-x86_64/vmlinuz
MENU LABEL CentOS-6.7-x86_64
append initrd=/images/CentOS-6.7-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=
ipappend 2

LABEL CentOS-7.5-x86_64

kernel /images/CentOS-7.5-x86_64/vmlinuz
MENU LABEL CentOS-7.5-x86_64
append initrd=/images/CentOS-7.5-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=
ipappend 2

MENU end

这些自动添加的内容,这时候我们就可以打开一台没有安装操作系统的白鼠机进行测试了:

使用Cobbler安装多版本操作系统
随便选一个我们想要安装的系统进行安装就好了;
这里我么选择CentOS-6.7-i386的进行安装就好了,因为CentOS7.5的我装过了,没问题哟!
使用Cobbler安装多版本操作系统
正在安装,需要等一会,干点别的啥的就行,因为到这里基本上就证明你已经成功了;
当然cobbler还可以在cobbler_web界面中进行管理,有兴趣的小伙伴可以了解下。
开始读条了:
使用Cobbler安装多版本操作系统
读条完毕,系统安装好了,登录进去试试吧
使用Cobbler安装多版本操作系统
这个username和password在kickstart文件中有写,我写的是用户:root 密码:123456
登录:
使用Cobbler安装多版本操作系统
成功。

转载于:https://blog.51cto.com/huliheeyu/2339365

你可能感兴趣的文章
python 数据加密以及生成token和token验证
查看>>
优达学城数据分析师纳米学位——P4项目知识点整理及代码分析
查看>>
压缩 KVM 的 qcow2 镜像文件
查看>>
python 读写文件中 w与wt ; r与rt 的区别
查看>>
深究“通过样式表实现固定表头和列”
查看>>
《Office 365开发入门指南》上市说明和读者服务
查看>>
Docker生态会重蹈Hadoop的覆辙吗?
查看>>
WPF换肤之八:创建3D浏览效果
查看>>
JEECG环境搭建(Maven版本)-总结Eclipse
查看>>
HTTP第一篇【简单了解HTTP、与HTTP相关的协议】
查看>>
Python生成随机验证码
查看>>
Python学习笔记(3)——数据类型和变量
查看>>
03、微信小程序之 永不过时的HelloWorld
查看>>
NFS配置不当那些事
查看>>
[译] 如何写出更好的 React 代码?
查看>>
一起撸个朋友圈吧(step3) - ListAdapter篇
查看>>
LeetCode 642 号问题:设计搜索自动补全系统
查看>>
探究Android View 绘制流程,Canvas 的由来
查看>>
JS原生交互
查看>>
[译] JavaScript 工作原理:Web Worker 的内部构造以及 5 种你应当使用它的场景
查看>>