Linux中详细部署Cobbler安装的服务
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux中详细部署Cobbler安装的服务相关的知识,希望对你有一定的参考价值。
1.cobbler简介
Cobbler 是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装,重装物理服务和虚拟机,同时还可以管理 DHCP、DNS等。
Cobbler 可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler_web),还提供了API接口,可以方便二次开发使用。
Cobbler 是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。
Cobbler 内置了一个轻量级配置管理系统,但它也支持和其他配置管理系统集成,如Puppet,暂时不支持SaltStack。
2.cobbler集成的服务:
PXE服务支持
DHCP服务管理
DNS服务管理(可选bind,dnsmasq)
电源管理
Kickstart服务支持
YUM仓库管理
TFTP(PXE启动时需要)
Apache(提供kickstart的安装源,并提供定制化的kickstart配置)
3.cobbler配置文件详解
cobbler配置文件目录在/etc/cobbler
/etc/cobbler/settings | cobbler主配置文件 |
---|---|
/etc/cobbler/iso | iso模板配置文件 |
/etc/cobbler/pxe | pxe模板配置文件 |
/etc/cobbler/power | 电源配置文件 |
/etc/cobbler/user.conf | web服务授权配置文件 |
/etc/cobbler/users.digest | web访问的用户名密码配置文件 |
/etc/cobbler/dhcp.template | dhcp服务器的配置模板 |
/etc/cobbler/dnsmasq.template | dns服务器的配置模板 |
/etc/cobbler/tftpd.template | tftp服务的配置模板 |
/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.log | cobbler日志 |
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
[[email protected] ~]# systemctl disable firewalld
[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# sed -ri ‘s/^(SELINUX=).*/1disabled/g‘ /etc/sysconfig/selinux
[[email protected] ~]# setenforce 0
//配置yum 源
[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# curl -o 163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
[[email protected] yum.repos.d]# sed -i ‘s/$releasever/7/g‘ 163.repo
[[email protected] yum.repos.d]# sed -i ‘s/^enabled=.*/enabled=1/g‘ 163.repo
[[email protected] ~]# yum install -y epel-release
//安装cobbler以及相关软件
[[email protected] ~]# yum -y install httpd dhcp tftp python-ctypes cobbler xinetd cobbler-web pykickstart
//启动服务并设置开机自启
[[email protected] ~]# systemctl start httpd
[[email protected] ~]# systemctl enable httpd
[[email protected] ~]# systemctl start cobblerd
[[email protected] ~]# systemctl enable cobblerd
//修改server的ip地址为本机的ip
[[email protected]g ~]# sed -i ‘s/^server: 127.0.0.1/server: 172.16.12.128/‘ /etc/cobbler/settings
//修改tftp的ip地址为本机ip
[[email protected] ~]# sed -i ‘s/^next_server: 127.0.0.1/next_server: 172.16.1 2.128/‘ /etc/cobbler/settings
//开启tftp
[[email protected] ~]# sed -i ‘/disable/s/yes/no/g‘ /etc/xinetd.d/tftp
//下载缺失文件
[[email protected] ~]# cobbler get-loaders
//启动rsync并设置开机自启
[[email protected] ~]# systemctl start rsyncd
[[email protected] ~]# systemctl enable rsyncd
//生成加密的密码
[[email protected] ~]# openssl passwd -1 -salt "$RANDOM" ‘lanzhiyong123!‘
$1$29572$Kgcy/Dq/5BIFjGXm8.Yfm/ //这是密码加密后的形式
//将生成的加密密码加入到配置文件
[[email protected] ~]# vim /etc/cobbler/settings
………………………… default_password_crypted: "$1$29572$Kgcy/Dq/5BIFjGXm8.Yfm/"
………………………………
//重启cobbler
[[email protected] ~]# systemctl restart cobblerd
[[email protected] ~]# 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 核对当前设置是否有问题
[[email protected] ~]# cobbler check
………………这处是两个关于debian系统的错误,请忽略
//这步重启
[[email protected] ~]# reboot
关闭防火墙*******************
//核对当前设置是否有问题
[[email protected] ~]# cobbler check
//配置cobbler dhcp 修改cobbler配置文件,让cobbler控制dhcp
[[email protected] ~]# sed -i ‘/^manage_dhcp/s/0/1/g‘ /etc/cobbler/settings
[[email protected] ~]# sed -n ‘/^manage_dhcp/p‘ /etc/cobbler/settings
manage_dhcp: 1
//配置dhcp
[[email protected] ~]# 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.1.250;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
//重启服务并同步配置,改完dhcp必须要sync同步配置
[[email protected] ~]# systemctl restart cobblerd
[[email protected] ~]# cobbler sync
//检查dhcp是否正常
[[email protected] ~]# netstat -anulp | grep dhcp
udp 0 0 0.0.0.0:67 0.0.0.0:*
//导入Centos7镜像
[[email protected] ~]# mount /dev/cdrom /mnt/
[[email protected] ~]# cobbler import --path=/mnt --name=Centos-7 --arch=x86_64
//查看cobbler镜像列表
[[email protected] ~]# cobbler list
//创建kickstarts自动安装脚本
[[email protected] ~]# cat > /var/lib/cobbler/kickstarts/Centos-7-x86_64.ks <<‘EOF‘
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文件语法是否错误
[[email protected] ~]# cobbler validateks
//查看当前cobbler有哪些配置文件
[[email protected] ~]# cobbler profile list
Centos-7-x86_64
//修改profile将我们新建的ks文件设为默认的kickstarts安装文件
[[email protected] ~]# cobbler profile edit --name Centos-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos-7-x86_64.ks
//配合网卡名称为传统网卡名称eth0
[[email protected] ~]# cobbler profile edit --name Centos-7-x86_64 --kopts=‘net.ifnames=0 biosdevname=0‘
//检查当前系统cobbler配置文件信息
[[email protected] ~]# cobbler profile report
//同步cobbler
[[email protected] ~]# cobbler sync
//把服务器端所有重启
[[email protected] ~]# systemctl restart xinetd//超级守护进程
[[email protected] ~]# systemctl restart cobblerd
[[email protected] ~]# systemctl restart httpd
[[email protected] ~]# 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安装的服务的主要内容,如果未能解决你的问题,请参考以下文章