PXE+DHCP+TFTP+Cobbler 无人值守安装centos 7
Cobbler(补鞋匠)是通过将DHCP、TFTP、DNS、HTTP等服务进行集成,创建一个中央管理节点,其可以实现的功能有配置服务,创建存储库,解压缩操作系统媒介,代理或集成一个配置管理系统,控制电源管理等。 Cobbler的最终目的是实现无需进行人工干预即可安装机器。
pxe概述
预启动执行环境(Preboot eXecution Environment,PXE,也被称为预执行环境)是让计算机通过网卡独立地使用数据设备(如硬盘)或者安装操作系统
PXE Client发送广播包请求DHCP分配IP地址DHCP
Server回复请求,给出IP地址以及Boot
Server的地址PXE下载引导文件执行引导程序
总结来说,
pxe客户端会调用网际协议(ip)、用户数据报协议(udp)、动态主机设定协议(DHCP)、小型文件传输协议(TFTP)
pxe客户端(client)指机器在pxe启动过程中的角色。一个pxe客户端可以是一台服务器、笔记本电脑或者其他装有pxe启动代码的机器
PXE主要是通过广播的方式发送一个包,并请注获取一个地址,而后交给TFTP程序下载一个引导文件。
cobbler和Kickstart批量装机软件
Cobbler由python语言开发,是对PXE和Kickstart以及DHCP的封装。融合很多特性,提供了CLI和Web的管理形式。更加方便的实行网络安装。同时,Cobbler也提供了API接口,使用其它语言也很容易做扩展。它不紧可以安装物理机,同时也支持kvm、xen虚拟化、Guest OS的安装。更多的是它还能结合Puppet等集中化管理软件,实现自动化的管理。
Kickstart 是一种无人值守的安装方式,它的工作原理是在安装过程中记录人工干预填写的各种参数,并生成一个名为ks.cfg的文件。我们可以简单理解为一个自动安装应答配置管理程序。通过读取这个配置文件,系统知道怎么去分区,要安装什么包,配什么IP,优化什么内核参数等等
一句话总结:Cobbler补鞋匠是对Kickstart的封装,简化安装步骤、使用流程,官方号称补鞋匠都能学会的批量装机。
Cobbler 工作流程
server端:
第一步,启动Cobbler服务
第二步,进行Cobbler错误检查,执行cobbler check命令
第三步,进行配置同步,执行cobbler sync命令
第四步,复制相关启动文件文件到TFTP目录中
第五步,启动DHCP服务,提供地址分配
第六步,DHCP服务分配IP地址
第七步,TFTP传输启动文件
第八步,Server端接收安装信息
第九步,Server端发送ISO镜像与Kickstart文件
Client端:
第一步,客户端以PXE模式启动
第二步,客户端获取IP地址
第三步,通过TFTP服务器获取启动文件
第四步,进入Cobbler安装选择界面
第五步,客户端确定加载信息
第六步,根据配置信息准备安装系统
第七步,加载Kickstart文件
第八步,传输系统安装的其它文件
第九步,进行安装系统
正式环境准备:
1.网络环境:host-only、nat网络,因为Cobbler需要用到自己的dhcp服务器,所以为了防止都在同一个网络造成dhcp获取混乱,需要切换网络!~
2.类似安装服务必要的环境准备:1,关闭iptables,selinux 2,配置静态IP、设置主机名 并且在hosts文件下绑定 3.时间同步 4.配置本地iso镜像里的yum仓库,163源epel源 (安装软件)
cobbler server ------- client
192.168.100.221/24 ------------------------------------ 装机时候由DHCP自动配置
一. 在cobbler server上安装cobbler
yum install cobbler cobbler-web tftp* rsync xinetd http* syslinux dhcp* pykickstart
[root@bokeyuan ~]# yum install cobbler cobbler-web tftp* rsync xinetd http* syslinux dhcp* pykickstart
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package rsync-3.0.9-17.el7.x86_64 already installed and latest version
Package 12:dhcp-common-4.2.5-47.el7.centos.x86_64 already installed and latest version
Package 12:dhcp-libs-4.2.5-47.el7.centos.x86_64 already installed and latest version
Package pykickstart-1.99.66.10-1.el7.noarch already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package cobbler.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: python-cheetah for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: mod_wsgi for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: PyYAML for package: cobbler-2.6.3-1.el6.noarch
---> Package cobbler-web.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: mod_ssl for package: cobbler-web-2.6.3-1.el6.noarch
--> Processing Dependency: Django for package: cobbler-web-2.6.3-1.el6.noarch
---> Package dhcp.x86_64 12:4.2.5-47.el7.centos will be installed
---> Package httpcomponents-client.noarch 0:4.2.5-5.el7_0 will be installed
--> Processing Dependency: mvn(commons-logging:commons-logging) for package: httpcomponents-client-4.2.5-5.el7_0.noarch
--> Processing Dependency: mvn(commons-codec:commons-codec) for package: httpcomponents-client-4.2.5-5.el7_0.noarch
---> Package httpcomponents-core.noarch 0:4.2.4-6.el7 will be installed
---> Package httpd.x86_64 0:2.4.6-45.el7.centos will be installed
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-45.el7.centos.x86_64
---> Package httpd-devel.x86_64 0:2.4.6-45.el7.centos will be installed
--> Processing Dependency: apr-util-devel for package: httpd-devel-2.4.6-45.el7.centos.x86_64
--> Processing Dependency: apr-devel for package: httpd-devel-2.4.6-45.el7.centos.x86_64
---> Package httpd-manual.noarch 0:2.4.6-45.el7.centos will be installed
---> Package httpd-tools.x86_64 0:2.4.6-45.el7.centos will be installed
---> Package syslinux.x86_64 0:4.05-13.el7 will be installed
---> Package tftp.x86_64 0:5.2-13.el7 will be installed
---> Package tftp-server.x86_64 0:5.2-13.el7 will be installed
---> Package xinetd.x86_64 2:2.3.15-13.el7 will be installed
--> Running transaction check
---> Package Django14.noarch 0:1.4.20-1.el6 will be installed
--> Processing Dependency: python(abi) = 2.6 for package: Django14-1.4.20-1.el6.noarch
--> Processing Dependency: python-simplejson for package: Django14-1.4.20-1.el6.noarch
---> Package PyYAML.x86_64 0:3.10-11.el7 will be installed
--> Processing Dependency: libyaml-0.so.2()(64bit) for package: PyYAML-3.10-11.el7.x86_64
---> Package apache-commons-codec.noarch 0:1.8-7.el7 will be installed
---> Package apache-commons-logging.noarch 0:1.1.2-7.el7 will be installed
--> Processing Dependency: mvn(logkit:logkit) for package: apache-commons-logging-1.1.2-7.el7.noarch
--> Processing Dependency: mvn(log4j:log4j) for package: apache-commons-logging-1.1.2-7.el7.noarch
--> Processing Dependency: mvn(avalon-framework:avalon-framework-api) for package: apache-commons-logging-1.1.2-7.el7.noarch
---> Package apr-devel.x86_64 0:1.4.8-3.el7 will be installed
---> Package apr-util-devel.x86_64 0:1.5.2-6.el7 will be installed
--> Processing Dependency: openldap-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64
--> Processing Dependency: libdb-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64
--> Processing Dependency: expat-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64
---> Package cobbler.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: python-cheetah for package: cobbler-2.6.3-1.el6.noarch
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
---> Package mod_ssl.x86_64 1:2.4.6-45.el7.centos will be installed
---> Package mod_wsgi.x86_64 0:3.4-12.el7_0 will be installed
--> Running transaction check
---> Package Django14.noarch 0:1.4.20-1.el6 will be installed
--> Processing Dependency: python(abi) = 2.6 for package: Django14-1.4.20-1.el6.noarch
--> Processing Dependency: python-simplejson for package: Django14-1.4.20-1.el6.noarch
---> Package avalon-framework.noarch 0:4.3-10.el7 will be installed
--> Processing Dependency: xalan-j2 for package: avalon-framework-4.3-10.el7.noarch
---> Package avalon-logkit.noarch 0:2.1-14.el7 will be installed
--> Processing Dependency: tomcat-servlet-3.0-api for package: avalon-logkit-2.1-14.el7.noarch
--> Processing Dependency: jms for package: avalon-logkit-2.1-14.el7.noarch
---> Package cobbler.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: python-cheetah for package: cobbler-2.6.3-1.el6.noarch
---> Package expat-devel.x86_64 0:2.1.0-8.el7 will be installed
---> Package libdb-devel.x86_64 0:5.3.21-19.el7 will be installed
---> Package libyaml.x86_64 0:0.1.4-11.el7_0 will be installed
---> Package log4j.noarch 0:1.2.17-15.el7 will be installed
--> Processing Dependency: mvn(javax.mail:mail) for package: log4j-1.2.17-15.el7.noarch
---> Package openldap-devel.x86_64 0:2.4.40-13.el7 will be installed
--> Processing Dependency: cyrus-sasl-devel(x86-64) for package: openldap-devel-2.4.40-13.el7.x86_64
--> Running transaction check
---> Package Django14.noarch 0:1.4.20-1.el6 will be installed
--> Processing Dependency: python(abi) = 2.6 for package: Django14-1.4.20-1.el6.noarch
--> Processing Dependency: python-simplejson for package: Django14-1.4.20-1.el6.noarch
---> Package cobbler.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: python-cheetah for package: cobbler-2.6.3-1.el6.noarch
---> Package cyrus-sasl-devel.x86_64 0:2.1.26-20.el7_2 will be installed
---> Package geronimo-jms.noarch 0:1.1.1-19.el7 will be installed
---> Package javamail.noarch 0:1.4.6-8.el7 will be installed
---> Package tomcat-servlet-3.0-api.noarch 0:7.0.69-10.el7 will be installed
---> Package xalan-j2.noarch 0:2.7.1-23.el7 will be installed
--> Processing Dependency: xerces-j2 for package: xalan-j2-2.7.1-23.el7.noarch
--> Processing Dependency: osgi(org.apache.xerces) for package: xalan-j2-2.7.1-23.el7.noarch
--> Running transaction check
---> Package Django14.noarch 0:1.4.20-1.el6 will be installed
--> Processing Dependency: python(abi) = 2.6 for package: Django14-1.4.20-1.el6.noarch
--> Processing Dependency: python-simplejson for package: Django14-1.4.20-1.el6.noarch
---> Package cobbler.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: python-cheetah for package: cobbler-2.6.3-1.el6.noarch
---> Package xerces-j2.noarch 0:2.11.0-17.el7_0 will be installed
--> Processing Dependency: xml-commons-resolver >= 1.2 for package: xerces-j2-2.11.0-17.el7_0.noarch
--> Processing Dependency: xml-commons-apis >= 1.4.01 for package: xerces-j2-2.11.0-17.el7_0.noarch
--> Processing Dependency: osgi(org.apache.xml.resolver) for package: xerces-j2-2.11.0-17.el7_0.noarch
--> Processing Dependency: osgi(javax.xml) for package: xerces-j2-2.11.0-17.el7_0.noarch
--> Running transaction check
---> Package Django14.noarch 0:1.4.20-1.el6 will be installed
--> Processing Dependency: python(abi) = 2.6 for package: Django14-1.4.20-1.el6.noarch
--> Processing Dependency: python-simplejson for package: Django14-1.4.20-1.el6.noarch
---> Package cobbler.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: python-cheetah for package: cobbler-2.6.3-1.el6.noarch
---> Package xml-commons-apis.noarch 0:1.4.01-16.el7 will be installed
---> Package xml-commons-resolver.noarch 0:1.2-15.el7 will be installed
--> Finished Dependency Resolution
Error: Package: Django14-1.4.20-1.el6.noarch (cobbler)
Requires: python-simplejson
Error: Package: cobbler-2.6.3-1.el6.noarch (cobbler)
Requires: python-simplejson
Error: Package: Django14-1.4.20-1.el6.noarch (cobbler)
Requires: python(abi) = 2.6
Installed: python-2.7.5-48.el7.x86_64 (@anaconda)
python(abi) = 2.7
python(abi) = 2.7
Error: Package: cobbler-2.6.3-1.el6.noarch (cobbler)
Requires: python-cheetah
You could try using --skip-broken to work around the problem
** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:
ipa-client-4.4.0-12.el7.centos.x86_64 has installed conflicts freeipa-client: ipa-client-4.4.0-12.el7.centos.x86_64
ipa-client-common-4.4.0-12.el7.centos.noarch has installed conflicts freeipa-client-common: ipa-client-common-4.4.0-12.el7.centos.noarch
ipa-common-4.4.0-12.el7.centos.noarch has installed conflicts freeipa-common: ipa-common-4.4.0-12.el7.centos.noarch
报错解决:提示--skip-broken ,检查发现自己yum源不全yum无法安装上面三个依赖包。补全yum源解决
安装完成,启动软件
[root@bokeyuan ~]# systemctl restart cobblerd.service
[root@bokeyuan ~]# systemctl restart httpd.service
[root@bokeyuan ~]# systemctl enable cobblerd.service //开机自启动
Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.
[root@bokeyuan ~]# systemctl enable httpd.service //开机自启动
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
为什么启动apache?血的教训,排了很久。不先启动apache 后续cobbler check 报python file 的错误!!!
二.基本配置
[root@bokeyuan ~]# 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.
一步步解决上述需求,部分需求可忽略。个体差异不同 每个人需求数量也不同,基本上大同小异
解决需求1、2、7
# openssl passwd -1 -salt 'werwqerwqr' '123456' --123456为密码(这是自动安装客户端系统成功后的root登录密码),werwqerwqr为随机字节干扰码(随便写)
$1$werwqerw$.prcfrYFbwuvkD8XspayN.
# vim /etc/cobbler/settings
384 server: 192.168.100.221 --换成cobbler服务器端的IP
272 next_server: 192.168.100.221 --同上
101 default_password_crypted: "$1$werwqerw$.prcfrYFbwuvkD8XspayN." --把密码字符串换成你上面产生的字符串(此密码为客户机安装后的root登录密码)
解决需求3
# vim /etc/xinetd.d/tftp
disable = no --yes改为no
解决需求5
#systemctl restart rsyncd.service
#systemctl enable rsyncd.service
解决需求8
# yum install fence-agents
OK,剩下的需求像
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.
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
(问题4可以使用cobbler get-loaders解决,但需要有外网和外网的yum源 跳过,现在是NAT模式;问题6 是关于debian系统的,我们这里可以忽略)
最后# systemctl restart cobblerd.service 重起下cobbler补鞋匠服务!
三.导入centos7.3的iso镜像
我的环境iso镜像挂载在/yum目录,此拷贝步骤时间较长
# cobbler import --path=/yum/ --name=centos7.3
# cobbler distro list --导入成功后,确认导入的镜像名
centos7.3-x86_64
# cobbler profile list --导入成功后,确认默认的profile名
centos7.3-x86_64
[root@bokeyuan ~]# cobbler import --path=/yum/ --name=centos7.
task started: --03_175701_import
task started (id=Media import, time=Sun Sep :: )
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/centos7.:
creating new distro: centos7.-x86_64
trying symlink: /var/www/cobbler/ks_mirror/centos7. -> /var/www/cobbler/links/centos7.-x86_64
creating new profile: centos7.-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/centos7. for centos7.-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos7.
need to process repo/comps: /var/www/cobbler/ks_mirror/centos7.
looking for /var/www/cobbler/ks_mirror/centos7./repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos7.3/repodata
*** TASK COMPLETE ***
四.修改dhcp配置
# vim /etc/cobbler/dhcp.template --在此文件的第21行到第25行修改成你对应的网段和ip
subnet 192.168.100.0 netmask 255.255.255.0 {
option routers 192.168.100.221;
option domain-name-servers 192.168.100.221;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.100.100 192.168.100.254;
--图形的操作过程这里省略后续还有这一步 重要
# vim /etc/cobbler/settings --再去修改这个配置文件,改成dhcp服务由cobbler来管理
242 manage_dhcp: 1 --把0改为1
# systemctl restart cobblerd.service --保存后,再重启此服务
五.使用cobbler sync同步,并启动xinetd服务
下面的cobbler sync 很重要,如果这步报错一定要排出来,就经验来说这步出错一般是IP配置出错,记得细心一点,个体差异不用就不详细表述~
# cobbler sync
[root@bokeyuan ~]# cobbler sync
task started: 2017-09-03_180107_sync
task started (id=Sync, time=Sun Sep 3 18:01:07 2017)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/centos7.3-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/centos7.3-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /usr/share/syslinux/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /usr/share/syslinux/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
copying distros to tftpboot
copying files for distro: centos7.3-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos7.3/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/centos7.3-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos7.3/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/centos7.3-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: centos7.3-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos7.3/images/pxeboot/vmlinuz -> /var/www/cobbler/images/centos7.3-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos7.3/images/pxeboot/initrd.img -> /var/www/cobbler/images/centos7.3-x86_64/initrd.img
Writing template files for centos7.3-x86_64
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: centos7.3-x86_64
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
# systemctl restart xinetd.service
# systemctl enable xinetd.service
六.新建另一个虚拟机 选择网络安装PXE (保证相同私有网络,并且最好2G内存,内存小的话会在安装时报空间不够的错误),进行安装测试
安装完成后,更改boot引导
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
自动安装我们已经实现了,但如何自定义我们想安装的profile
重点就是你需要自定义一个ks文件
自定义ks文件的方法
1,如果你很熟悉此文件,直接拷别人的模版修改或者直接使用/root/anaconda-ks.cfg来修改
2,使用一个图形工具system-config-kickstart来帮助你配置(下面我就是使用这种方法)
# yum install system-config-kickstart
# system-config-kickstart
--图形的操作过程这里省略
给大家两个做好的ks.cfg文件参考:
第一个文件就是用来安装centos7.3宿主机的ks文件,内容如下:
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$6RbFC2nC$GBugZL7ACuGhck8DbUZgM/
# Use network installation
url --url="http://172.16.13.250/cobbler/ks_mirror/centos7.3/"
# System language
lang en_US
# Firewall configuration
firewall --disabled
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
firstboot --disable
# SELinux configuration
selinux --disabled
# Network information
network --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --append="rhgb quiet" --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=300
part swap --fstype="swap" --size=4000
part / --fstype="xfs" --size=150000
part /data --fstype="xfs" --size=80000
%packages
@additional-devel
@desktop-debugging
@development
@fonts
@gnome-desktop
@input-methods
@kde-desktop
@legacy-x
@platform-devel
@remote-desktop-clients
@x11
initial-setup
initial-setup-gui
vinagre
%end
第二个文件是用来宿主机安装双系统的ks文件
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$6RbFC2nC$GBugZL7ACuGhck8DbUZgM/
# Use network installation
url --url="http://172.16.13.250/cobbler/ks_mirror/centos7.3/"
# System language
lang en_US
# Firewall configuration
firewall --disabled
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
firstboot --disable
# SELinux configuration
selinux --disabled
# Network information
network --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --append="rhgb quiet" --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --none
# Disk partitioning information
part swap --fstype="swap" --size=4000
part / --fstype="xfs" --grow --size=1
%packages
@additional-devel
@desktop-debugging
@development
@fonts
@gnome-desktop
@input-methods
@kde-desktop
@legacy-x
@platform-devel
@remote-desktop-clients
@x11
initial-setup
initial-setup-gui
vinagre
%end
=========================================================================
# cobbler profile help --查看帮助
# cobbler profile list --查看有哪些profile
centos7.3-x86_64
# cobbler profile report --name=centos7.3-x86_64 |grep Kickstart
Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks --这就是这个安装方案的kickstart文件
Kickstart Metadata : {}
我现在自定义一个ks文件,也想做成一个profile,步骤如下:
步骤一:
自定义ks文件(使用system-config-kickstart或直接找一个模版文件修改),得到如下的文件
# vim /var/lib/cobbler/kickstarts/centos7.3.ks --复制下面一大段信息,粘到此文件里
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$6RbFC2nC$GBugZL7ACuGhck8DbUZgM/
# Use network installation
url --url="http://192.168.100.2/cobbler/ks_mirror/centos7.3/"
# System language
lang en_US
# Firewall configuration
firewall --disabled
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
firstboot --disable
# SELinux configuration
selinux --disabled
# Network information
network --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --append="rhgb quiet" --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=300
part swap --fstype="swap" --size=2000
part / --fstype="xfs" --grow --size=1
%post
rm /etc/yum.repos.d/* -rf
cat > /etc/yum.repos.d/local.repo << EOF
[base]
name=base
baseurl=file:///yum
enabled=1
gpgcheck=0
EOF
%end
%packages
@additional-devel
@desktop-debugging
@development
@fonts
@gnome-desktop
@input-methods
@kde-desktop
@legacy-x
@platform-devel
@remote-desktop-clients
@x11
initial-setup
initial-setup-gui
vinagre
%end
步骤二:把准备好的ks文件做成一个新的profile
# cobbler profile add --name=new_centos7.3 --distro=centos7.3-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.3.ks
# cobbler profile list --在原来基础上就多了自定义的安装方案
centos7.3-x86_64
new_centos7.3
步骤三:
测试
然后就可以新建一个客户端虚拟机,使用上面的new_centos7.3安装名字来测试了
==================================================================
对上面操作的扩展(仅供参考)
# cobbler profile edit --name=new_centos7.3 --kickstart=/var/lib/cobbler/kickstarts/xxx.ks
# cobbler profile remove --name=new_centos7.3
======================================================================
客户端使用koan与服务器的cobbler联系,实现自动重装系统
客户端需要安装koan软件包(epel源里就有)
# yum install koan
# koan --server=192.168.100.2 --list=profiles --192.168.100.2为cobbler服务器IP,得到的结果和在cobbler服务器上cobbler profile list命令得到的结果一样
centos7.3-x86_64
new_centos7.3
# koan --replace-self --server=192.168.100.2 --profile=new_centos7.3 --指定本客户端按照名为new_centos7.3的profile重装系统
# reboot --敲完上面的命令,使用reboot,就会重装了(没敲上面的命令那reboot就是重启)
写文不易 且行且珍惜
这是一个二维码
给个机会,客官扫我
PXE+DHCP+TFTP+Cobbler 无人值守安装centos 7的更多相关文章
- PXE+Kickstart+DHCP+TFTP实现无人值守安装操作系统
PXE+Kickstart+DHCP+TFTP实现无人值守安装操作系统 PXE + Kickstart PXE的工作流程及配置文件 Kickstart的配置文件 Linux安装大致可以分为2个阶段 第 ...
- 其他综合-Cobbler无人值守安装系统 CentOS 7
Cobbler 无人值守安装系统 CentOS 7 1.实验描述 1.1 概述 作为运维,在公司经常遇到一些机械性重复工作要做,例如:为新机器装系统,一台两台机器装系统,可以用光盘.U盘等介质安装,1 ...
- CentOS7.x安装cobbler无人值守安装系统
CentOS7.x cobbler无人值守安装 cobbler介绍 自打若干年前 Red Hat,推出了 Kickstart,不再需要刻了光盘一台一台地安装 Linux,只要搞定 PXE.DHCP.T ...
- (转)COBBLER无人值守安装
COBBLER无人值守安装 说在最前面的话 在看Cobbler之前请大家先看一下Kickstart无人值守安装,了解一下Cobbler的实现原理.但是Cobbler是独立的,不需要先安装Kicksta ...
- kvm无人值守安装centos 7虚拟机
centos 7安装好KVM之后还要安装虚拟机,通过VNC连接手动安装centos 7虚拟机太麻烦了,所以无人值守安装是做好的.简单记录下. 无人值守安装centos 7前提是要安装KVM,并且能手动 ...
- PXE+kickstart无人值守安装CentOS 7
kickstart+cobbler系列文章:http://www.cnblogs.com/f-ck-need-u/p/7048359.html 本文是PXE+kickstart无人值守安装CentOS ...
- (转)PXE+kickstart无人值守安装CentOS 7
kickstart+cobbler系列文章:http://www.cnblogs.com/f-ck-need-u/p/7048359.html 本文是PXE+kickstart无人值守安装CentOS ...
- 关于linux - Centos 7 系统下使用PXE网络的方式(pxe+dhcpd+tftp+httpd)安装操作系统
PXE(Pre-boot Execution Environment)是由Intel设计的协议,它可以使计算机通过网络而不是从本地硬盘.光驱等设备启动. 现代的网卡,一般都内嵌支持PXE的ROM芯片. ...
- win2003系统网络安装——基于linux+pxe+dhcp+tftp+samba+ris
原文发表于:2010-09-16 转载至cu于:2012-07-21 一.原理简介 PXE(preboot execute environment)工作于Client/Server的网络模式,支持工作 ...
随机推荐
- python 3.6 链接mssql 进行数据操作
#!/usr/bin/env python # -*- coding: UTF-8 -*- import pymssql class MSSQL(object): ''' 对pymssql的简单封装 ...
- 如何修改eclipse的web项目默认浏览器
- spring注入bean的五种方式
1.属性注入 2.构造方法注入 3.静态工厂注入 package com.voole.factorybeans; import com.voole.beans.TestBean; public cla ...
- 构建跨平台APP开发的两本书,这里重点推荐下
第一本是<构建跨平台:jquery Mobile移动应用实战> 是目前jqm开发写的比较入门的一本书,上手很快,但是高手我觉得就没有必要学习了,因为写的比较浅显. 第二本是<构建跨平 ...
- 【^.^】hello world~~
一直以来都没有在公共博客上写作的习惯,加之Evernote的强大和方便好用,让我仅仅依赖它就足以满足日常学习笔记的记录和整理. 不过看着Evernote里面记录的大大小小的笔记已经有400+了,觉得应 ...
- 带来全新的网络格局---html5
自从HTML5诞生之后,就是开始建立了一个标准的原则,那就是所有的技术它必须是面向开放,并不能有专利的一个存在,在整个期间Opera捐献了css技术,而google的话则是给开发者提供了视频的webM ...
- HTML入门2—HTML常用标签
HTML常用标签练习 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> &l ...
- 关于tcp的keepalive
先记录几个要点 只能用在面向连接的tcp中,对应对端的非正常关闭有效(对端服务器重启这种,也是正常关闭,FIN RST包都算) 只要是写入到缓冲区就认为OK,所以UDP不适合,所以如果有正常的网络交互 ...
- POJ-2376 Cleaning Shifts---区间覆盖&贪心
题目链接: https://vjudge.net/problem/POJ-2376 题目大意: farmer John要安排他的牛清理牛棚,一共有T个牛棚要清理,每头牛可以清理相邻的牛棚.比如,一头牛 ...
- 数据库连接-ADO.NET
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/huo065000/article/details/25830291 非常早就知道了ADO ...