博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
基于centos7系统部署cobbler批量安装系统
阅读量:4338 次
发布时间:2019-06-07

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

1.cobbler

  cobbler是一个可以实现批量安装系统的linux应用程序。它有别于pxe+kickstart,cobbler可以实现同个服务器批量安装不同操作系统版本。

cobbler部署安装:

  1. 下载相关软件

  2. 配置dhcp

  3. 配置tftp

  4. 启动httpd

  5. 启动cobbler

  6. cobbler自检

  7. 根据提示进行修改

  8. cobbler重启及同步

  9. 挂载光盘

  10. 生成distro

  11. 创建kickstart文件

  12. 创建profile

  13. 删除不包含自定义kickstart文件

 

1.1 系统环境及cobbler的安装

给服务机192.168.16.4添加网卡,桥接模式

[root@localhost ~]# ip a3: ens37: 
mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:d0:98:19 brd ff:ff:ff:ff:ff:ff inet 192.168.5.35/24 brd 192.168.5.255 scope global ens37 #桥接ip valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fed0:9819/64 scope link valid_lft forever preferred_lft forever

1.2  关闭防火墙
 

[root@localhost ~]# setenforce 0[root@localhost ~]#systemctl stop firewalld

 

1.3 下载cobbler及所需服务程序

[root@localhost ~]#yum install cobbler dhcp tftp-server xinetd syslinux httpd -y#xinetd:超级守护进程  tftp-server:简单传输协议 syslinux: 提供pxelinux.0这个文件 ,pxelinux.0引导文件引导vmlinux和initrd两个启动文件#注意: 要在yum源里添加163的镜像[root@localhost ~]# cd /etc/yum.repos.d[root@localhost yum.repos.d]# vim bendi.repo       #添加网易源[wangyi]name=wangyienabled=1gpgcheck=0baseurl=http://mirrors.163.com/centos/7/os/x86_64/

 

1.4 配置dhcp

[root@localhost ~]# vim /etc/dhcp/dhcpd.conf# DHCP Server Configuration file.#   see /usr/share/doc/dhcp*/dhcpd.conf.example#   see dhcpd.conf(5) man page:r/usr/share/doc/dhcp*/dhcpd.conf.example             #拉取文件subnet 192.168.5.0  netmask 255.255.255.0 {           #和桥接地址一个网段  range 192.168.5.10 192.168.5.100;  default-lease-time 600;  max-lease-time 7200; filename "pxelinux.0";                               #寻找pxelinux.0        }:wq

 

1.5 配置tftp(xinetd) 

[root@localhost ~]# vim /etc/xinetd.d/tftpservice 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}  [root@localhost yum.repos.d]# systemctl restart httpd   #重启,注意重启顺序[root@localhost yum.repos.d]# systemctl restart cobblerd[root@localhost yum.repos.d]# systemctl restart dhcpd[root@localhost yum.repos.d]# systemctl restart xinetd

 

1.6  检查cobbler配置 

[root@localhost ~]# cobbler checkThe 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:    https://github.com/cobbler/cobbler/wiki/Selinux4 : 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 systemctl6 : debmirror package is not installed, it will be required to manage debian deployments and repositories7 : ksvalidator was not found, install pykickstart8 : 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 one9 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use themRestart cobblerd and then run 'cobbler sync' to apply changes.

一共有9条错误,根据反馈修改文件:

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

问题1:cobbler文件默认是127.0.0.1本地回环地址,需要更改为提供cobbler服务的ip地址 192.168.182.128,在384行

384 server: 192.168.5.35

问题2:netx_server也是默认本地127.0.0.1回环地址,需要修改为提供cobbler服务的ip地址 192.163.182,128,在272行

272 next_server: 192.168.5.35

 

问题3:防火已关,不用理会

问题4:可以忽略

问题5:启动rsync(同步程序)

[root@localhost ~]# systemctl restart rsyncd[root@localhost ~]# systemctl enable  rsyncd

问题6:可以忽略

 问题7:可以忽略

 问题8:根据提示更改密码

[root@localhost ~]# openssl passwd -1 -salt "123" "123456"$1$123$7mft0jKnzzvadU4t0unTG1           #加密密码#123为随机数,123456为密码将新生成的加密数据写入/etc/cobbler/settings101 default_password_crypted: "$1$123$7mft0jKnzzvadU4t0unTG1."

问题9:可以忽略 

更改结束后重启并同步

[root@localhost ~]# systemctl restart cobblerd[root@localhost ~]# cobbler synctask started: 2019-04-23_052424_synctask started (id=Sync, time=Tue apr 23 05:24:24 2019)running pre-sync triggerscleaning treesremoving: /var/lib/tftpboot/grub/imagescopying bootloaderscopying: /usr/share/syslinux/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0copying: /usr/share/syslinux/menu.c32 -> /var/lib/tftpboot/menu.c32copying: /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdiskcopying distros to tftpbootcopying imagesgenerating PXE configuration filesgenerating PXE menu structurerendering TFTPD filesgenerating /etc/xinetd.d/tftpcleaning link cachesrunning post-sync triggersrunning python triggers from /var/lib/cobbler/triggers/sync/post/*running python trigger cobbler.modules.sync_post_restart_servicesrunning shell triggers from /var/lib/cobbler/triggers/sync/post/*running python triggers from /var/lib/cobbler/triggers/change/*running python trigger cobbler.modules.manage_gendersrunning python trigger cobbler.modules.scm_trackrunning shell triggers from /var/lib/cobbler/triggers/change/**** TaSK COMPlETE ***

再次检查cobbler

[root@localhost ~]# cobbler checkThe 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/Selinux2 : 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.3 : debmirror package is not installed, it will be required to manage debian deployments and repositories4 : ksvalidator was not found, install pykickstart5 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

 

1.7  挂载光盘
 

[root@localhost ~]# mount /dev/cdrom /mnt

1.8 导入数据

[root@localhost ~]# cobbler import --path=/mnt --name="centos7.5"#导入路径在挂载点,并指定name#导入较慢,耐心等待Found a candidate signature: breed=redhat, version=rhel6...........Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos7.5/repodata*** TaSK COMPlETE ***    #导入完成

  distro : 发行版, 就是我们安装什么版本的linux操作系统的名称

  profile : 类似于一个 配置文件,类似于bash_profile, 里面包含可以添加 kernel 参数,对应的kickstart 文件 以及 此profile 对应的 distro 等等.

 查看distro

[root@localhost ~]# cobbler distro list   centos7.5-x86_64

查看profile

[root@localhost ~]# cobbler profile list   centos7.5-x86_64

 

1.9 准备kickstart文件

[root@localhost ~]# cp anaconda-ks.cfg /var/lib/cobbler/kickstarts/ks.cfg           #复制ananconda文件到/var/lib/cobbler/kickstarts/到目录下并改名为ks.cfg[root@localhost ~]# vim /var/lib/cobbler/kickstarts/ks.cfg# Use CDROM installation mediaurl --url=http://192.168.5.35/cobbler//ks_mirror//centos7.5/# Use graphical install                                    #将cdrom改为url,即将光盘启动改为apache启动,                                           后面接服务机的桥接ip和repodata的路径[root@localhost ~]# ls /var/www/cobbler//ks_mirror//centos7.5/  repodata:wq

 

1.10 创建profile

[root@localhost ~]# cobbler profile add --kickstart="/var/lib/cobbler/kickstarts/ks.cfg" --distro="centos7.5-x86_64" --name="centos7.5_zxj"                                    #添加profile 指定配置文件路径和镜像路径,并命名[root@localhost ~]# cobbler profile list           #查看profile   centos7.5-x86_64   centos7.5_zxj

 

1.11 删除不包含自定义的kickstart文件

[root@localhost ~]# cobbler profile remove --name="centos7.5-x86_64"[root@localhost ~]# cobbler profile list   centos7.5_zxj

cobbler部署完成 

 

1.12 创建新的虚拟机自动部署安装

cobbler部署完成后,新建虚拟机就可以自动部署安装了。在创建虚拟机时需要注意将内存改到3G,否则无法安装系统

转载于:https://www.cnblogs.com/ajunyu/p/10883521.html

你可能感兴趣的文章
java学习笔记④MySql数据库--01/02 database table 数据的增删改
查看>>
两台电脑如何实现共享文件
查看>>
组合模式Composite
查看>>
程序员最想得到的十大证件,你最想得到哪个?
查看>>
我的第一篇CBBLOGS博客
查看>>
【MyBean调试笔记】接口的使用和清理
查看>>
07 js自定义函数
查看>>
jQueru中数据交换格式XML和JSON对比
查看>>
form表单序列化后的数据转json对象
查看>>
[PYTHON]一个简单的单元測试框架
查看>>
iOS开发网络篇—XML数据的解析
查看>>
[BZOJ4303]数列
查看>>
一般处理程序在VS2012中打开问题
查看>>
C语言中的++和--
查看>>
thinkphp3.2.3入口文件详解
查看>>
POJ 1141 Brackets Sequence
查看>>
Ubuntu 18.04 root 使用ssh密钥远程登陆
查看>>
Servlet和JSP的异同。
查看>>
虚拟机centOs Linux与Windows之间的文件传输
查看>>
ethereum(以太坊)(二)--合约中属性和行为的访问权限
查看>>