概述
参考文献:
《Cobbler自动装机(装机步骤,优化内容详解,导入系统镜像步骤,cobbler-web管理认证方式)》
《cobbler》
《cobbler》
《cobbler》官方文档
《kickstart配置文件详解和system-config-kickstart》
《自动化部署(kickstart/cobbler)问题总结》
《解决centos7中使用service iptables stop 显示not loaded》
《Cobbler自动化部署》
《CentOS7.4安装cobbler实现自动化安装ubuntu18.04》
<Cobbler+preseed自动化安装Ubuntu18/19系统>
《cobbler环境搭建+IPMI/PXE远程装机》
<Cobbler 部署使用>
cobbler服务端的部署
配置yum 源
[root@localhost ~]# cd /etc/yum.repos.d/
[root@cobbler-server yum.repos.d]# curl -o CentOS7-Base-163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
[root@cobbler-server yum.repos.d]# sed -i 's/$releasever/7/g' /etc/yum.repos.d/CentOS7-Base-163.repo
[root@cobbler-server yum.repos.d]# sed -i 's/^enabled=.*/enabled=1/g' /etc/yum.repos.d/CentOS7-Base-163.repo
[root@cobbler-server yum.repos.d]# yum -y install epel-release
安装cobbler 以及相关的软件
[root@cobbler-server ~]# yum -y install httpd dhcp tftp python-ctypes cobbler xinetd cobbler-web pykickstart
[root@ yum.repocobbler-server ~]# yum search httpd # //查找详细的包名安装
关闭防火墙、关闭selinux
[root@cobbler-server ~]# systemctl stop firewalld
[root@cobbler-server ~]# systemctl disable firewalld
[root@cobbler-server ~]# setenforce 0
[root@cobbler-server ~]# sed -ri 's/(^SELINUX=).*/1disabled/g' /etc/selinux/config
启动服务并设置开机自启动
[root@cobbler-server ~]# systemctl start httpd
[root@cobbler-server ~]# systemctl start cobblerd
[root@cobbler-server ~]# systemctl status cobblerd
[root@cobbler-server ~]# systemctl enable cobblerd
[root@cobbler-server ~]# systemctl enable httpd
[root@cobbler-server ~]# systemctl status httpd
systemctl stop firewalld.service
systemctl disable firewalld.service
修改Server的IP地址为本机的IP
[root@cobbler-server ~]# sed -i 's/^server: 127.0.0.1/server: 192.168.169.10/' /etc/cobbler/settings
设置tftp的ip地址为本机的ip地址
sed -i 's/^next_server: 127.0.0.1/next_server: 192.168.169.10/' /etc/cobbler/settings
开启tftp
[root@cobbler-server ~]# sed -i '/disable/s/yes/no/g' /etc/xinetd.d/tftp
下载缺失文件
[root@cobbler-server ~]# cobbler get-loaders
task started: 2018-09-01_184556_get_loaders
task started (id=Download Bootloader Content, time=Sat Sep 1 18:45:56 2018)
downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***
启动rsync并设置开机自启
[root@cobbler-server ~]# systemctl start rsyncd
[root@cobbler-server ~]# systemctl enable rsyncd
[root@cobbler-server ~]# systemctl status rsyncd
生成加密的密码
[root@cobbler-server ~]# openssl passwd -1 -salt "$RANDOM" 'chen'
$1$17149$vmcHNH3PTq6bxSR8m44di0 //这是密码加密后的形式
将新生成的加密密码加入到配置文件
… 此处省略内容
[root@cobbler-server ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$17149$vmcHNH3PTq6bxSR8m44di0"
…此处省略
重启cobbler
[root@cobbler-server ~]# ss -anlt
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@cobbler-server ~]# cobbler check
The following are potential configuration items that you may want to fix:
1 : debmirror package is not installed, it will be required to manage debian deployments and repositories
2 : 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.
//以上两个是关于debian系统的错误,请忽略
配置cobbler dhcp
[root@cobbler-server ~]# sed -i '/^manage_dhcp/s/0/1/g' /etc/cobbler/settings
[root@cobbler-server ~]# sed -n '/^manage_dhcp/p' /etc/cobbler/settings
manage_dhcp: 1
配置dhcp
[root@cobbler-server ~]# vim /etc/cobbler/dhcp.template
…此处省略内容
subnet 192.168.169.0 netmask 255.255.255.0 { //修改为同网段
option routers 192.168.169.10; //修改为自己的IP
option domain-name-servers 192.168.169.10; //修改为自己的IP
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.169.100 192.168.169.250; //表示能够一次装多少台同网段的主机
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
.....此处省略内容
重启服务并同步配置,改完dhcp必须要sync同步配置
[root@cobbler-server ~]# systemctl restart cobblerd
[root@cobbler-server ~]# cobbler sync
task started: 2018-09-01_191232_sync
task started (id=Sync, time=Sat Sep 1 19:12:32 2018)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/images
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
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: dhcpd -t -q
received on stdout:
received on stderr:
running: service dhcpd restart
received on stdout:
received on stderr: Redirecting to /bin/systemctl restart dhcpd.service
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 ***
检查dhcp是否正常
[root@cobbler-server ~]# netstat -anulp|grep dhcp
udp 0 0 0.0.0.0:67 0.0.0.0:* 1124/dhcpd
导入( CentOS7 | redhat 7 )镜像 ,这里我用的是CentOS7 的镜像
[root@cobbler-server ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[root@cobbler-server ~]# #cobbler import --path=/mnt --name=CentOS-7 --arch=x86_64 task started: 2018-08-21_162444_import
task started: 2018-09-01_192023_import
task started (id=Media import, time=Sat Sep 1 19:20:23 2018)
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/CentOS-7-x86_64:
creating new distro: CentOS-7-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-7-x86_64 -> /var/www/cobbler/links/CentOS-7-x86_64
creating new profile: CentOS-7-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/CentOS-7-x86_64 for CentOS-7-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-7-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-7-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-7-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-7-x86_64/repodata
*** TASK COMPLETE ***
说明:
–path //镜像路径
–name //为安装定义一个名字
–arch //指定安装源平台
安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是CentOS-7-x86_64,如果重复,系统会提示失败
查看cobbler镜像列表
[root@cobbler-server ~]# cobbler list
distros:
CentOS-7-x86_64
profiles:
CentOS-7-x86_64
systems:
repos:
images:
mgmtclasses:
packages:
files:
创建kickstarts自动安装脚本
[root@cobbler-server ~]# 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=1 //这里的grow指的是 / 需要多大的空间就会给多大,并不是只给1M
text
firewall --disabled
firstboot --disable
keyboard us
lang en_US
url --url=http://192.168.169.10/cobbler/ks_mirror/CentOS-7-x86_64
$yum_repo_stanza
$SNIPPET('network_config')
reboot
rootpw --iscrypted $6$CFgNGKVZdqde7.Nw$8U42BYN3sA7pLnfsX/GJtjjGZBC9gwyCWMQBTHsKVQP1aUH4rREUPcl3N9F7HPTwVyWHUflnEQ5N1jL89zRqC.
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
注意:这里的rootpw –iscrypted 我用的是以下的密码,可以在/var/lib/cobbler/kickstarts/CentOS-7-x86_64.ks 这个配置文件里面修改,如果系统不一样这里的url这一行也需要修改,并且IP改为自己服务器的IP
[root@cobbler-server ~]# grep 'rootpw' /root/anaconda-ks.cfg
rootpw --iscrypted $6$CFgNGKVZdqde7.Nw$8U42BYN3sA7pLnfsX/GJtjjGZBC9gwyCWMQBTHsKVQP1aUH4rREUPcl3N9F7HPTwVyWHUflnEQ5N1jL89zRqC.
检查ks文件的语法是否有误
[root@cobbler-server ~]# cobbler validateks
task started: 2018-09-01_195321_validateks
task started (id=Kickstart Validation, time=Sat Sep 1 19:53:21 2018)
----------------------------
osversion: rhel7
checking url: http://192.168.169.10/cblr/svc/op/ks/profile/CentOS-7-x86_64
running: /usr/bin/ksvalidator -v "rhel7" "http://192.168.169.10/cblr/svc/op/ks/profile/CentOS-7-x86_64"
received on stdout:
received on stderr:
*** all kickstarts seem to be ok ***
*** TASK COMPLETE ***
查看当前cobbler 有哪些配置文件
[root@cobbler-server ~]# cobbler profile list
CentOS-7-x86_64
修改profile,将我们新建的ks文件设为默认的kickstarts安装文件
[root@cobbler-server ~]# cobbler profile edit --name CentOS-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7-x86_64.ks
配置网卡名称为传统网卡名称eth0
[root@cobbler-server ~]# cobbler profile edit --name CentOS-7-x86_64 --kopts='net. ifnames=0 biosdevname=0'
检查当前系统cobbler配置文件信息
[root@cobbler-server ~]# cobbler profile report
Name : CentOS-7-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-7-x86_64 //仓库名字
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {'ifnames': '0', 'net.': '~', 'biosdevname': '0'}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/CentOS-7-x86_64.ks //使用的kickstarts配置文件的路径,必须为我们新建的ks文件的路径
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm
同步cobbler
[root@cobbler-server ~]# cobbler sync
task started: 2018-09-01_200435_sync
task started (id=Sync, time=Sat Sep 1 20:04:35 2018)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/CentOS-7-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/CentOS-7-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying files for distro: CentOS-7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-7-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: CentOS-7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-7-x86_64/initrd.img
Writing template files for CentOS-7-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: CentOS-7-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: dhcpd -t -q
received on stdout:
received on stderr:
running: service dhcpd restart
received on stdout:
received on stderr: Redirecting to /bin/systemctl restart dhcpd.service
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 ***
为避免发生未知问题,先把服务器所有服务重启
[root@cobbler-server ~]# systemctl restart xinetd
[root@cobbler-server ~]# systemctl restart cobblerd
[root@cobbler-server ~]# systemctl restart httpd
[root@cobbler-server ~]# ss -anlt
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
最后
以上就是英勇可乐为你收集整理的centos76 安装cobbler的全部内容,希望文章能够帮你解决centos76 安装cobbler所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复