环境:

平台:VMware workstation 14

系统:CentOS Linux release 7.4.1708 (Core)

NAT模式 

systemctl stop firewalld.service      //关闭防火墙
setenforce 0                          //关闭增强安全功能

光盘挂载

---


cobbler大平台,管理一切装机操作服务


Cobbler服务    自动部署装机
dhcp        自动分配ip地址使新机器和服务器在同一个段落互联互通
tftp        压缩内核     引导程序  (速度快)
ftp            iso镜像文件



操作:

-----------------Cobbler--------------------

rpm -ivh http://mirrors.yun-idc.com/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm

yum list

yum clean all

yum makecache


-------------------正式部署----------------------------------

yum install cobbler cobbler-web dhcp tftp-server pykickstart httpd rsync xinetd -y

注:cobbler  服务
    cobbler-web   通过网页形式进行管理
    pykickstart   用python开发的kickstart
    httpd         检测文件是否安装
    rsync         同步管理
    xinetd        管理平台,管理tftp和xinetd



   vi /etc/cobbler/settings       //修改cobbler配置文件

   272   next_server: 192.168.80.181          //指定PXE位置

   384   server: 192.168.80.181   //tftp服务器

   242   manage_dhcp: 1                 //管理dhcp启动

   101 default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."    这个就是给客户端装机后的root密码,盐值加密 (先不做修改下面在修改)

systemctl start httpd

systemctl start cobblerd


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 detailson 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, ou may run 'cobbler get-loaders' to download them, or, if you only want t handle x86/x86_64 netbooting, you may ensure that you have installed a *ecent* version of the syslinux package installed and can ignore this messge entirely.  Files in this directory, should you want to support all arcitectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. Th 'cobbler get-loaders' command is the easiest way to resolve these requirments.
4 : enable and start rsyncd.service with systemctl
5 : debmirror package is not installed, it will be required to manage deban deployments and repositories
6 : The default password used by the sample templates for newly installedmachines (default_password_crypted in /etc/cobbler/settings) is still setto 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'randomphrase-here' 'your-password-here'" to generate new one
7 : fencing tools were not found, and are required to use the (optional) ower management features. install cman or fence-agents to use them

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

先设置密码

 openssl passwd -1 -salt 'abner' 'abner'    //盐值加密
 【使用上一条命令后,会弹出一条加密的结果】       //加密结果

 注:如果tab键补不全,就用yum安装

 继续回settings文件中

 default_password_crypted: "加密结果"      //粘贴

 保存退出settings文件


systemctl start rsyncd     //启动服务

vi /etc/xinetd.d/tftp

disable   = no     //启用

systemctl restart xinetd   //重启服务


vi /etc/cobbler/dhcp.template       //cobbler控制的dhcp服务模板


     option routers       //修改网关
     option domain-name-servers     //修改DNS
     option subnet-mask         255.255.255.0;
     range dynamic-bootp       //修改地址池

cobbler sync       //帮助同步生成DHCP配置文件   同步到dhcp服务里去

cobbler get-loaders                //下载引导操作系统文件

systemctl restart dhcpd
systemctl restart xinetd
systemctl restart rsyncd


------------------使用cobbler check再次检查----------

下面三条可以忽略不去处理

-----------------------------------------------------------------

/var/log/cobbler/cobbler.log   //日志文件所在位置

cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64  //导入iso镜像,命名为   ,指定系统多少位

注:iso镜像一定要先挂载到/mnt下面
可以导入多个镜像。  

/var/www/cobbler/ks_mirror/CentOS-7-x86_64        //默认导入存放位置


cobbler list     //查看导入结果

cobbler distro list   //查看发行版本

yum install tree -y
tree /var/lib/tftpboot/
tree /var/lib/tftpboot/images   //查看内核和初始化文件在tftp server 共享目录



cobbler profile report       

                 
/var/lib/cobbler/kickstarts/sample_end.ks    //ks默认文件存放位置


systemctl restart dhcpd  
systemctl restart xinetd
systemctl restart rsyncd
systemctl restart cobblerd



测试装机:

重新新建一台虚拟机


开启之后效果如下:

(不需要点击任何东西,等待装机就ok)

完成。