Linux九阴真经之九阴白骨爪残卷4(PXE)

cobbler

pex的二次封装,由Python开发,提供CLI和Web管理,cobbler在epel源中,安装时需要配置epel源。

工作原理:

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裸机通过上面告知的TFTP server地址通信,下载引导文件

6、client裸机执行执行该引导文件,确定加载信息,选择要安装的os,期间会再向cobbler server请求kickstart文件和os image

7、cobbler server发送请求的kickstart和os iamge

8、client裸机加载kickstart文件

9、client裸机接收os image,安装该os image

配置文件:

/etc/cobbler/settings : cobbler 主配置文件

/etc/cobbler/iso/: iso模板配置文件

/etc/cobbler/pxe: pxe模板文件

/etc/cobbler/power: 电源配置文件

/etc/cobbler/user.conf: web服务授权配置文件

/etc/cobbler/users.digest: web访问的用户名密码配置文件

/etc/cobbler/dhcp.template : dhcp服务器的的配置末班

/etc/cobbler/dnsmasq.template : dns服务器的配置模板

/etc/cobbler/tftpd.template : tftp服务的配置模板

/etc/cobbler/modules.conf : 模块的配置文件

数据目录:

/var/lib/cobbler/config/: 用于存放distros,system,profiles 等信息配置文件

/var/lib/cobbler/triggers/: 用于存放用户定义的cobbler命令

/var/lib/cobbler/kickstart/: 默认存放kickstart文件

/var/lib/cobbler/loaders/: 存放各种引导程序

镜像目录:

/var/www/cobbler/ks_mirror/: 导入的发行版系统的所有数据

/var/www/cobbler/images/ : 导入发行版的kernel和initrd镜像用于远程网络启动

/var/www/cobbler/repo_mirror/: yum 仓库存储目录

日志目录:

/var/log/cobbler/installing: 客户端安装日志

/var/log/cobbler/cobbler.log : cobbler日志

cobbler常用命令:

cobbler check 核对当前设置是否有问题

cobbler list 列出所有的cobbler元素

cobbler report 列出元素的详细信息

cobbler sync 同步配置到数据目录,更改配置最好都要执行下

cobbler reposync 同步yum仓库

cobbler distro 查看导入的发行版系统信息

cobbler system 查看添加的系统信息

cobbler profile 查看配置信息

cobbler profile report --name=xxxx 查看ks文件的详细信息

例:配置cobbler服务器

环境:主机IP:192.168.2.3  ,epel 源

一、安装前需要的服务

[root@centos7 ~]# yum install cobbler dhcp
[root@centos7 ~]# systemctl enable cobblerd dhcpd httpd tftp
[root@centos7 ~]# systemctl start cobblerd httpd tftp

二、检查环境,按照提示的错误修改对应 文件

[root@centos7 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. #修改配置文件中server参数为自己的主机IP
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. #修改配置文件中next_server指向tftp服务器,这里我也指向自己的IP
3 : 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 #将selinux关闭
4 : change 'disable' to 'no' in /etc/xinetd.d/tftp #将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. #执行cobbler get-loaders下载启动引导的文件
6 : enable and start rsyncd.service with systemctl #启动rsync服务
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories #安装支持deb包的组件,现在安装CentOS不需要此组件
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 #修改配置文件中password的参数为自己指定的安装完系统后的root密码
9 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them #fencing设备的配置

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

具体修改情况如下

将配置文件中的server服务器IP改为本机IP

修改配置文件中的net_server 指向tftp 服务器,这里我指向自己的IP,因为自己是tftp服务器

运行下图中划红色下划线标注的命令,下载引导启动文件

重新用MD5生成一个口令,替换原来的cobbler口令

利用cobbler自动 设置dhcp服务

接下来重启cobbler 服务

[root@centos7 cobbler]#systemctl restart cobblerd

这时我们来观察一下dhcp 的配置文件并没有生成

[root@centos7 tftpboot]#ls /etc/dhcp/dhcpd.conf

三、在/etc/cobbler/下有个 dhcp.templlte模板文件 我们用vim编辑它,就会自动生成一个dhcp配置文件

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

四、cobbler  sync 同步一下设置, 查看dhcp端口有没有开启

五、在mnt目录下 创建cdrom 和 cdrom2 文件夹  将 centos7 和 centos6 挂载上去

六、我们需要将发行版的源和ks文件导入发行版,过程较慢,要确保硬盘有足够的空间

查看一下大小(由于之前做了PXE安装,已经有7的系统,所以文件较大)

[root@centos7 ~]#du -sh /var/www
12G    /var/www

[root@centos7 tftpboot]#cobbler distro list
   Centos-6.9-x86_64

七、

猜你喜欢

转载自www.cnblogs.com/huxiaojun/p/9093506.html