1.实验环境
cobbler服务器: CentOS7.0 64位
IP地址: 192.168.126.120?
子网掩码: 255.255.255.0
2.Cobbler安装配置
2.1 安装CentOS7(略)
2.2 关闭SELinux
[[email protected] ~]# vim /etc/selinux/config
SELINUX=disabled
或者
[[email protected] ~]# sed -i ‘s/SELINUX=.*/SELINUX=disabled/g‘ /etc/selinux/config
修改SELinux配置文件后需要重启才能生效
[[email protected] ~]# reboot
2.3关闭防火墙
[[email protected] ~]# systemctl stop firewalld.service
[[email protected] ~]# systemctl disable firewalld.service
rm ‘/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service‘
rm ‘/etc/systemd/system/basic.target.wants/firewalld.service‘
2.4安装EPEL
下载并安装EPEL包
[[email protected] ~]# wget http://mirrors.ustc.edu.cn/fedora/epel//7/x86_64/e/epel-release-7-9.noarch.rpm
[[email protected] ~]# yum -y localinstall epel-release-7-9.noarch.rpm
安装完成后检查EPEL是否已添加到源列表
[[email protected] ~]# yum repolist
2.5安装cobbler/dhcp/xinetd/tcpdump/pykickstart
[[email protected] ~]# yum -y install cobbler-web
[[email protected] ~]# yum -y install dhcp
[[email protected] ~]# yum -y install xinetd
[[email protected] ~]# yum -y install tcpdump
[[email protected] ~]# yum -y install pykickstart
2.6 配置cobbler
启用cobbler及http服务
[[email protected] ~]# systemctl enable cobblerd.service
ln -s ‘/usr/lib/systemd/system/cobblerd.service‘ ‘/etc/systemd/system/multi-user.target.wants/cobblerd.service‘
[[email protected] ~]# systemctl start cobblerd.service
[[email protected] ~]# systemctl enable httpd.service
ln -s ‘/usr/lib/systemd/system/httpd.service‘ ‘/etc/systemd/system/multi-user.target.wants/httpd.service‘
[[email protected] ~]# systemctl start httpd.service
配置cobbler
生成密码:
[[email protected] ~]# openssl passwd -1 -salt "cobbler" "123456"
$1$cobbler$sqDDOBeLKJVmxTCZr52/11
密码是123456,此密码就是Linux安装完成后的root密码
修改cobbler配置:
[[email protected] ~]# vim /etc/cobbler/settings //打开配置文件,修改3处地方
server: 192.168.126.120 //把127.0.0.1改为本机的IP地址
next_server: 192.168.126.120 //把127.0.0.1改为本机的IP地址
default_password_crypted: "$1$cobbler$sqDDOBeLKJVmxTCZr52/11" //把原来的加密密码改为上面生成的密码
配置tftp
[[email protected] ~]# ?vim /etc/xinetd.d/tftp
disable = no //找到disable那行把yes改成no
[[email protected] ~]# systemctl enable xinetd.service
[[email protected] ~]# systemctl start xinetd.service
[[email protected] ~]# systemctl enable tftp.service
[[email protected] ~]# systemctl start tftp.service
get-loaders
[[email protected] ~]# cobbler get-loaders
task started: 2017-05-25_110906_get_loaders
task started (id=Download Bootloader Content, time=Thu May 25 11:09:06 2017)
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
[[email protected] ~]# systemctl enable rsyncd.service
ln -s ‘/usr/lib/systemd/system/rsyncd.service‘ ‘/etc/systemd/system/multi-user.target.wants/rsyncd.service‘
[[email protected] ~]# systemctl start rsyncd.service
Cobbler check
[[email protected] ~]# systemctl restart cobblerd.service
[[email protected] ~]# 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.
以上警告可忽略
Cobbler sync
[[email protected] ~]# cobbler sync
task started: 2017-05-25_112231_sync
task started (id=Sync, time=Thu May 25 11:22:31 2017)
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
copying: /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 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 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 ***
2.7 导入distro
在虚拟机上挂载RHEL7.3的ISO
[[email protected] ~]# mount /dev/sr0 /mnt
mount: /dev/sr0 is write-protected, mounting read-only
然后导入distro
[[email protected] ~]# cobbler import --path=/mnt/ --name=rhel7
task started: 2017-05-25_112707_import
task started (id=Media import, time=Thu May 25 11:27:07 2017)
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/rhel7:
creating new distro: rhel7-x86_64
trying symlink: /var/www/cobbler/ks_mirror/rhel7 -> /var/www/cobbler/links/rhel7-x86_64
creating new profile: rhel7-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/rhel7 for rhel7-x86_64
processing repo at : /var/www/cobbler/ks_mirror/rhel7
need to process repo/comps: /var/www/cobbler/ks_mirror/rhel7
looking for /var/www/cobbler/ks_mirror/rhel7/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/rhel7/repodata
processing repo at : /var/www/cobbler/ks_mirror/rhel7/addons/HighAvailability
need to process repo/comps: /var/www/cobbler/ks_mirror/rhel7/addons/HighAvailability
looking for /var/www/cobbler/ks_mirror/rhel7/addons/HighAvailability/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/rhel7/addons/HighAvailability/repodata
processing repo at : /var/www/cobbler/ks_mirror/rhel7/addons/ResilientStorage
need to process repo/comps: /var/www/cobbler/ks_mirror/rhel7/addons/ResilientStorage
looking for /var/www/cobbler/ks_mirror/rhel7/addons/ResilientStorage/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/rhel7/addons/ResilientStorage/repodata
*** TASK COMPLETE ***
检查
[[email protected] ~]# cobbler distro list
rhel7-x86_64
[[email protected] ~]# cobbler distro report rhel7-x86_64
Name : rhel7-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : redhat
Comment :
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/rhel7/images/pxeboot/initrd.img
Kernel : /var/www/cobbler/ks_mirror/rhel7/images/pxeboot/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {‘tree‘: ‘http://@@[email protected]@/cblr/links/rhel7-x86_64‘}
Management Classes : []
OS Version : rhel7
Owners : [‘admin‘]
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Template Files : {}
2.8配置dhcp
首先修改cobbler配置,让cobbler来管理dhcp服务
[[email protected] ~]# vim /etc/cobbler/settings
manage_dhcp: 1
接下来修改/etc/cobbler/dhcp.template,此文件是cobbler管理dhcp的模板
对于此文件,只需要修改如下部分:
subnet 192.168.126.0 netmask 255.255.255.0 {
option routers 192.168.126.1;
option domain-name-servers 192.168.126.10;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.126.150 192.168.126.250;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
同步cobbler
[[email protected] ~]# cobbler sync
2.9修改profile
在/var/lib/cobbler/kickstarts目录下创建kickstart profie文件
文件示例
[[email protected] kickstarts]# more rhel7.cfg
#version=RHEL7
# System authorization information
auth --enableshadow --passalgo=sha512
?
# Use CDROM installation media
install
url --url=http://192.168.126.120/cblr/links/rhel7-x86_64
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts=‘us‘
# System language
lang en_US
?
# Network information
# Root password
rootpw --iscrypted $6$V80MlXh4At3AojC.$.jm0Iz5MWo.l52ob9iA9Ov.e.AcD8L5guE3Vp6HSkwco.omLjPPEVFlBYC8rVzbR0IhqIXW3FGmz.z/VcW0rD1
# System timezone
timezone Asia/Shanghai
# X Window System configuration information
#xconfig --startxonboot
text
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --none --initlabel
# Disk partitioning information
part pv.11 --fstype="lvmpv" --ondisk=sda --size=1 --grow
part /boot --fstype="xfs" --ondisk=sda --size=200
volgroup rootvg --pesize=4096 pv.11
logvol /tmp --fstype="xfs" --size=5000 --name=tmplv --vgname=rootvg
logvol /var --fstype="xfs" --size=5000 --name=varlv --vgname=rootvg
logvol swap --fstype="swap" --size=4000 --name=swaplv --vgname=rootvg
logvol /usr --fstype="xfs" --size=10000 --name=usrlv --vgname=rootvg
logvol / --fstype="xfs" --size=5000 --name=rootlv --vgname=rootvg
logvol /home --fstype="xfs" --size=10000 --name=homelv --vgname=rootvg
?
%packages
@^Server With GUI
%end
修改profile文件
[[email protected] ~]# cobbler profile list
rhel7-x86_64
[[email protected] ~]# cobbler profile edit --name=rhel7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/rhel7.cfg
[[email protected] ~]# cobbler profile report rhel7-x86_64
Name : rhel7-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : rhel7-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/rhel7.cfg
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
?
[[email protected] ~]# cobbler sync
时间: 2024-11-08 15:46:17