温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Linux系统如何部署Cobbler服务

发布时间:2022-01-25 10:12:59 来源:亿速云 阅读:113 作者:小新 栏目:开发技术

小编给大家分享一下Linux系统如何部署Cobbler服务,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

Cobbler是一个Linux系统安装的服务,可以通过网络启动cobbler(PXE)的方式来快速安装、重装物理服务器和虚拟机。

Linux系统如何部署Cobbler服务

1.cobbler简介

  • Cobbler 是一个系统启动服务(boot server),可以通过网络启动(PXE)的方式用来快速安装、重装物理服务器和虚拟机,支持安装不同的 Linux 发行版和 Windows。

  • 该工具使用python开发,小巧轻便(才15k行代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP,DNS,以及yum包镜像。

  •  Cobbler 使用命令行方式管理,也提供了基于 Web 的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。


2.cobbler集成的服务:

PXE服务支持 DHCP服务管理 DNS服务管理(可选bind,dnsmasq) 电源管理 Kickstart服务支持 YUM仓库管理 TFTP(PXE启动时需要) Apache(提供kickstart的安装源,并提供定制化的kickstart配置)


3.cobbler配置文件详解

cobbler配置文件目录在/etc/cobbler

/etc/cobbler/settingscobbler主配置文件
/etc/cobbler/isoiso模板配置文件
/etc/cobbler/pxepxe模板配置文件
/etc/cobbler/power电源配置文件
/etc/cobbler/user.confweb服务授权配置文件
/etc/cobbler/users.digestweb访问的用户名密码配置文件
/etc/cobbler/dhcp.templatedhcp服务器的配置模板
/etc/cobbler/dnsmasq.templatedns服务器的配置模板
/etc/cobbler/tftpd.templatetftp服务的配置模板
/etc/cobbler/modules.conf模块的配置文件

cobbler数据目录

目录作用
/var/lib/cobbler/config/用于存放distros,system,profiles等信息配置文件
/var/lib/cobbler/triggers/用于存放用户定义的cobbler命令
/var/lib/cobbler/kickstart/默认存放kickstart文件
/var/lib/cobbler/loaders/存放各种引导程序以及镜像目录
/var/lib/cobbler/ks_mirror/导入的发行版系统的所有数据
/var/lib/cobbler/images导入发行版的kernel和initrd镜像用于远程网络启动
/var/www/cobbler/repo_mirror/yum仓库存储目录

cobbler日志文件

日志文件路径说明
/var/log/cobbler/installing客户端安装日志
/var/log/cobbler/cobbler.logcobbler日志

4.cobbler命令详解

cobbler check //核对当前设置是否有问题 cobbler list //列出所有的cobbler元素 cobbler report //列出元素的详细信息 cobbler sync //同步配置到数据目录,更改配置最好都要执行下 cobbler reposync //同步yum仓库 cobbler distro //查看导入的发行版系统信息 cobbler system //查看添加的系统信息 cobbler profile //查看配置信息


5.cobbler服务端部署(演示)

环境ip
服务器端192.168.209.12
  *************************服务器做以下操作**************************8 //关闭防火墙以及selinux [root@lanzhiyong ~]# systemctl disable firewalld [root@lanzhiyong ~]# systemctl stop firewalld [root@lanzhiyong ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/sysconfig/selinux [root@lanzhiyong ~]# setenforce 0 
 //配置yum 源 [root@lanzhiyong ~]# cd /etc/yum.repos.d/ [root@lanzhiyong yum.repos.d]# curl -o 163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo [root@lanzhiyong yum.repos.d]# sed -i 's/\$releasever/7/g' 163.repo [root@lanzhiyong yum.repos.d]#  sed -i 's/^enabled=.*/enabled=1/g' 163.repo [root@lanzhiyong ~]# yum install -y epel-release 
 //安装cobbler以及相关软件 [root@lanzhiyong ~]# yum -y install httpd dhcp tftp python-ctypes cobbler xinetd cobbler-web pykickstart 
 //启动服务并设置开机自启 [root@lanzhiyong ~]# systemctl start httpd [root@lanzhiyong ~]# systemctl enable httpd [root@lanzhiyong ~]# systemctl start cobblerd [root@lanzhiyong ~]# systemctl enable cobblerd 
 //修改server的ip地址为本机的ip [root@lanzhiyong ~]#  sed -i 's/^server: 127.0.0.1/server: 192.168.209.12/' /etc/cobbler/settings 
 //修改tftp的ip地址为本机ip [root@lanzhiyong ~]#  sed -i 's/^next_server: 127.0.0.1/next_server: 192.168.209.12/' /etc/cobbler/settings 
 //开启tftp [root@lanzhiyong ~]#  sed -i '/disable/s/yes/no/g' /etc/xinetd.d/tftp 
 //下载缺失文件 [root@lanzhiyong ~]# cobbler get-loaders 
 //启动rsync并设置开机自启 [root@lanzhiyong ~]# systemctl start rsyncd [root@lanzhiyong ~]# systemctl enable rsyncd 
 //生成加密的密码 [root@lanzhiyong ~]# openssl passwd -1 -salt "$RANDOM" 'lanzhiyong123!' $1$29572$Kgcy/Dq/5BIFjGXm8.Yfm/ //这是密码加密后的形式 
 //将生成的加密密码加入到配置文件 [root@lanzhiyong ~]# vim /etc/cobbler/settings ………………………… default_password_crypted: "$1$29572$Kgcy/Dq/5BIFjGXm8.Yfm/"

………………………………

 //重启cobbler [root@lanzhiyong ~]# systemctl restart cobblerd [root@lanzhiyong ~]# ss -antl State      Recv-Q Send-Q    Local Address:Port      Peer Address:Port               LISTEN     0      128                   *:22                              *:*                   LISTEN     0      100           127.0.0.1:25                         *:*                   LISTEN     0      5             127.0.0.1:25151                     *:*                   LISTEN     0      5                     *:873                               *:*                   LISTEN     0      128                  :::80                               :::*                   LISTEN     0      128                  :::22                               :::*                   LISTEN     0      100                 ::1:25                               :::*                   LISTEN     0      128                  :::443                              :::*                   LISTEN     0      5                    :::873                              :::*                 
 //通过cobbler check 核对当前设置是否有问题 [root@lanzhiyong ~]# cobbler check ………………这处是两个关于debian系统的错误,请忽略 
 //这步重启 [root@lanzhiyong ~]# reboot 关闭防火墙******************* 
  //核对当前设置是否有问题 [root@lanzhiyong ~]# cobbler check 
 //配置cobbler dhcp 修改cobbler配置文件,让cobbler控制dhcp [root@lanzhiyong ~]# sed -i '/^manage_dhcp/s/0/1/g' /etc/cobbler/settings [root@lanzhiyong ~]# sed -n '/^manage_dhcp/p' /etc/cobbler/settings manage_dhcp: 1 
 //配置dhcp [root@lanzhiyong ~]# vim /etc/cobbler/dhcp.template subnet 192.168.209.0 netmask 255.255.255.0 { option routers             192.168.209.12; option domain-name-servers 192.168.209.12; option subnet-mask         255.255.255.0; range dynamic-bootp      192.168.209.100 192.168.209.250; default-lease-time           21600; max-lease-time               43200; next-server                $next_server; 
 //重启服务并同步配置,改完dhcp必须要sync同步配置 [root@lanzhiyong ~]# systemctl restart cobblerd [root@lanzhiyong ~]# cobbler sync 
 //检查dhcp是否正常 [root@lanzhiyong ~]# netstat -anulp | grep dhcp udp        0      0 0.0.0.0:67              0.0.0.0:* 
 //导入Centos7镜像 [root@lanzhiyong ~]# mount /dev/cdrom /mnt/ [root@lanzhiyong ~]# cobbler import --path=/mnt --name=Centos-7 --arch=x86_64 
 //查看cobbler镜像列表 [root@lanzhiyong ~]# cobbler list 
 //创建kickstarts自动安装脚本 [root@lanzhiyong ~]# cat > /var/lib/cobbler/kickstarts/Centos-7-x86_64.ks 
 auth --enableshadow --passalgo=sha512 bootloader --location=mbr clearpart --all --initlabel part /boot --asprimary --fstype="ext4" --size=500 part swap --fstype="swap" --size=4096 part / --fstype="ext4" --grow --size=15000 text firewall --disabled firstboot --disable keyboard us lang en_US url --url=http://192.168.209.12/cobbler/ks_mirror/Centos-7- x86_64 $yum_repo_stanza $SNIPPET('network_config') reboot 
 rootpw --iscrypted $6$DEHzuoHRCJMBjzzK$DKallGno50cVbJ27yEIP5O1M4p3/rwfilgIdpKW9IU25Q4KI8tXmSPwH1JuB2UW/pk3NlayujtEZ9ckfclRM81 
 selinux --disabled skipx timezone Asia/Shanghai --isUtc --nontp install zerombr 
 %packages @^minimal @core kexec-tools 
 %end 
 %addon com_redhat_kdump --enable --reserve-mb='auto' 
 %end %anaconda pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty %end EOF 
 //检查ks文件语法是否错误 [root@lanzhiyong ~]# cobbler validateks 
 //查看当前cobbler有哪些配置文件 [root@lanzhiyong ~]# cobbler profile list Centos-7-x86_64 
 //修改profile将我们新建的ks文件设为默认的kickstarts安装文件 [root@lanzhiyong ~]# cobbler profile edit --name Centos-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos-7-x86_64.ks 
 //配合网卡名称为传统网卡名称eth0 [root@lanzhiyong ~]# cobbler profile edit --name Centos-7-x86_64 --kopts='net.ifnames=0 biosdevname=0' 
 //检查当前系统cobbler配置文件信息 [root@lanzhiyong ~]# cobbler profile report 
 //同步cobbler [root@lanzhiyong ~]# cobbler sync 
 //把服务器端所有重启 [root@lanzhiyong ~]# systemctl restart xinetd//超级守护进程 [root@lanzhiyong ~]# systemctl restart cobblerd [root@lanzhiyong ~]# systemctl restart httpd [root@lanzhiyong ~]# ss -antl State      Recv-Q Send-Q    Local Address:Port                   Peer Address:Port               LISTEN     0      128                   *:22                                *:*                   LISTEN     0      100           127.0.0.1:25                                *:*                   LISTEN     0      5             127.0.0.1:25151                             *:*                   LISTEN     0      5                     *:873                               *:*                   LISTEN     0      128                  :::80                               :::*                   LISTEN     0      128                  :::22                               :::*                   LISTEN     0      100                 ::1:25                               :::*                   LISTEN     0      128                  :::443                              :::*                   LISTEN     0      5                    :::873                              :::* 
  *********************************安装客户端********************      在虚拟机新建一个虚拟机 选择Centos7 安装,其他默认  1.不选择光盘  2.内存建议2000MB  3.安装客户端

以上是“Linux系统如何部署Cobbler服务”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI