您当前所在位置:首页安装教程通过cobbler实现自动化开机批量装CentOS系统部署安装

通过cobbler实现自动化开机批量装CentOS系统部署安装

更新:2023-11-06 20:02:23编辑:tooool归类:安装教程人气:131

Cobbler是一款Linux生态的自动化运维工具,基于Python2开发,用于自动化批量部署安装操作系统;其提供基于CLI的管理方式和WEB配置界面,其中WEB配置界面是基于Python2和Django框架开发。另外,cobbler还提供了API,方便二次开发。Cobbler属于C/S模型(客户端/服务器模型)

通过cobbler实现自动化开机批量装CentOS系统部署安装

1、查看系统版本

cat /etc/redhat-release

CentOS Linux release 7.1.1503 (Core) (备注本次部署是在Centos7中进行)

uname -rm

3.10.0-229.el7.x86_64 x86_64

2、安装epel源,安装epel库

yum install -y epel-releasewget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

3、安装cobbler环境所需的包

下载最新版的pip,然后安装

wget https://bootstrap.pypa.io/get-pip.pypython get-pip.pyln -s /usr/local/python27/bin/pip2.7 /usr/bin/pip2pip2 install Django==1.8.9

4、开始安装cobbler

yum install -y httpd dhcp tftp tftp-server rsync pykickstart xinetdyum install -y cobbler

5、centos7安装cobbler-webcobbler-web2.8版本必须用django1.8.9版本

yum install httpd-develyum install -y cobbler-web

6、配置HTTPD的配置文件,更改项目存放的权限

vim /etc/httpd/conf/httpd.conf
SSLRequireSSLNSSRequireSSLSetEnvVIRTUALENVOptionsIndexes MultiViewsOrderallow,deny     apache2.4必须改为AllowOverrideAllAllowfromallapache2.4必须改为Requireallgranted

7、开启服务和加开机启动

systemctlenablexinetdsystemctl start xinetdsystemctl start httpdsystemctl start cobblerdsystemctlenablehttpdsystemctlenablecobblerdsystemctlenablersyncdsystemctl start rsyncd

8、检查cobbler

cobbler check

按照上面的提示,逐步修改配置如下:

修改cobbler的settings文件,备份

cp /etc/cobbler/settings{,.ori}

修改server,Cobbler服务器的IP。

sed -is/server: 127.0.0.1/server: 192.168.0.131//etc/cobbler/settings

如果用Cobbler管理DHCP,修改本项

sed -is/next_server: 127.0.0.1/next_server: 192.168.0.131//etc/cobbler/settingssed -is/manage_dhcp: 0/manage_dhcp: 1//etc/cobbler/settings

防止循环装系统,适用于服务器第一启动项是PXE启动。

sed -is/pxe_just_once: 0/pxe_just_once: 1//etc/cobbler/settings

设置新装系统的默认root密码123456。random-phrase-here为干扰码,可以自行设定。

openssl passwd -1 -saltcobbler123456

$1$cobbler$sqDDOBeLKJVmxTCZr52/11

vim /etc/cobbler/settings

default_password_crypted: "$1$cobbler$sqDDOBeLKJVmxTCZr52/11"

修改tftp配置,启用tftp

vim /etc/xinetd.d/tftp

将disable = yes改为:disable = no

配置DHCP

vim /etc/cobbler/dhcp.template

配置修改如下:

subnet192.168.1.0netmask255.255.255.0{optionrouters192.168.1.1;optiondomain-name-servers114.114.114.114;optionsubnet-mask255.255.255.0;rangedynamic-bootp10.0.0.10010.0.0.200;

下载boot-loaders

cobbler get-loaders

同步配置

systemctl restart cobblerdcobbler sync

9、导入镜像到cobbler中

mount /dev/cdrom /mntcobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64

10、编辑kickstart文件

cd/var/lib/cobbler/kickstarts/vim CentOS-7-x86_64.cfg

配置文件如下:

Kickstart Configurator for cobbler by Jason Zhaoplatform=x86, AMD64, or Intel EM64TSystem  languagelang en_USSystem keyboardkeyboard usSytem timezonetimezone Asia/ShanghaiRoot passwordrootpw--iscrypted $default_password_cryptedUse text mode installtextInstall OS instead of upgradeinstallUse NFS installation Mediaurl--url=$treeSystem bootloader configurationbootloader--location=mbrClear the Master Boot RecordzerombrPartition clearing informationclearpart--all --initlabelDisk partitioning informationpart /boot--fstype xfs --size 1024 --ondisk sdapart swap--size 1024 --ondisk sdapart /--fstype xfs --size 1 --grow --ondisk sdaSystem authorization infomationauth--useshadow  --enablemd5Network information$SNIPPET(network_config)network --bootproto=dhcp --device=em1 --onboot=onReboot after installationrebootFirewall configurationfirewall--disabledSELinux configurationselinux--disabledDo not configure XWindowsskipxPackage install information%pre
$SNIPPET(log_ks_pre)
$SNIPPET(kickstart_start)
$SNIPPET(pre_install_network_config)Enable installation monitoring$SNIPPET(pre_anamon)
%end%packages
@ base
@ core
sysstat
iptraf
ntp
lrzsz
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
mysql
nmap
screen
%end%post
systemctldisablepostfix.service
%end

11、更改centos6和centos7的ks文件位置

cobbler profile edit --name=CentOS-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7-x86_64.cfg

12、Cobbler 常用命令

cobbler check 检查cobbler配置

cobbler sync 同步配置到dhcp/pxe和数据目录

cobbler list 列出所有的cobbler元素

cobbler import 导入安装的系统镜像

cobbler report 列出各元素的详细信息

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

cobbler profile 查看配置信息

cobbler system 查看添加的系统信息

cobbler reposync 同步yum仓库到本地

13、查看详细配置信息,这里把centos7配置信息都显示了

cobbler profile reportcobbler sync

14、配置绑定mac地址和IP地址 ,开机自动选择

cobbler system add --name=centos711 --mac=00:0C:29:70:E8:A3 --profile=Centos-7-x86_64  \--ip-address=192.168.0.40--subnet=255.255.255.0--gateway=192.168.0.1--interface=eth0 \--static=1--hostname=centos711 --name-servers="223.5.5.5"cobbler sync

到此cento7系统的也可以装机了

我告诉你msdn版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

win7旗舰版系统下载,Win7旗舰版系统下载 | 全面了解Win7旗舰版下载及安装步骤 win10选择框颜色怎么修改?win10修改选择框颜色的方法