设为首页 收藏本站
查看: 666|回复: 0

[经验分享] cobbler无人值守安装CentOS7

[复制链接]

尚未签到

发表于 2018-4-20 06:46:28 | 显示全部楼层 |阅读模式
cobbler介绍
  cobbler是一个linux系统安装的服务,可以通过网络启动(PXE)的方式来快速安装,重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。
  cobbler可以使用命令行方式管理,也提供了基于web的界面管理工具(cobbler-web),还提供了Apl接口,可以方便二次开发使用。
  cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理
  cobbler下载及启动
[root@Cobbler ~]# yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd  python-django

[root@Cobbler ~]# systemctl start cobblerd.service
[root@Cobbler ~]# systemctl start httpd.service

  根据检查配置文件来修改cobbler配置文件
[root@Cobbler ~]# cobbler check
The following are potential configuration items that you may want to fix:

  1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work.  This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be s   to something other than 127.0.0.1, and should match the IP of the boot server on the ▽XE network.
3 : change 'disable' to 'no' in /etc/xinetd.d/tftp
4 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a recent version of the syslinux package installed and can ignore this message entirely.  Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
5 : enable and start rsyncd.service with systemctl
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
7 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
8 : 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.
  备份
[root@Cobbler ~]# cp /etc/cobbler/settings{,.ori}
  快速修改配置文件
  sed -i 's/server: 127.0.0.1/server: 172.16.1.202/' /etc/cobbler/settings
sed -i 's/next_server: 127.0.0.1/next_server: 172.16.1.202/' /etc/cobbler/settings
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
sed -ri "/default_password_crypted/s#(.: ).#\1\"openssl passwd -1 -salt 'oldboy' '123456'\"#" /etc/cobbler/settings
链接:https://pan.baidu.com/s/1mjFeaes 密码:nk4l
[root@Cobbler ~]# tar xfP cobbler_load_for_CentOS7.tar.gz
[root@Cobbler ~]# ls /var/lib/cobbler/loaders
COPYING.elilo     COPYING.yaboot  grub-x86_64.efi  menu.c32    README
COPYING.syslinux  elilo-ia64.efi  grub-x86.efi     pxelinux.0

[root@Cobbler ~]# systemctl enable rsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
[root@Cobbler ~]# systemctl start rsyncd

  与备份文件对比
[root@Cobbler ~]# diff /etc/cobbler/settings{,.ori}
101c101
< default_password_crypted: &quot;$1$oldboy$Npg9Pt9k98Mlg0ZeqHAuN1&quot;


  default_password_crypted: &quot;$1$mF86/UHC$WvcIcX2t6crBz2onWxyac.&quot;
242c242
< manage_dhcp: 1
  manage_dhcp: 0
272c272
< next_server: 172.16.1.202
  next_server: 127.0.0.1
292c292
< pxe_just_once: 1
  pxe_just_once: 0
384c384
< server: 172.16.1.202
  server: 127.0.0.1

  修改dhcp配置文件
[root@Cobbler ~]# cp /etc/cobbler/dhcp.template{,.ori}
[root@Cobbler ~]# vim /etc/cobbler/dhcp.template
批量修改ip
:%s/192.168/172.16/g
21 subnet 172.16.1.0 netmask 255.255.255.0 {
22      option subnet-mask         255.255.255.0;
23      range dynamic-bootp        172.16.1.100 172.16.1.254;
24      default-lease-time         21600;
25      max-lease-time             43200;
26      next-server                $next_server;

  与备份文件对比
[root@Cobbler ~]# diff /etc/cobbler/dhcp.template{,.ori}
21c21,23
< subnet 172.16.1.0 netmask 255.255.255.0 {


  subnet 192.168.1.0 netmask 255.255.255.0 {
option routers             192.168.1.5;
option domain-name-servers 192.168.1.1;
23c25
<      range dynamic-bootp        172.16.1.100 172.16.1.254;

range dynamic-bootp        192.168.1.100 192.168.1.254;
  重启服务
[root@Cobbler ~]# systemctl enable tftp.socket
Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket.
[root@Cobbler ~]# systemctl start tftp.socket
[root@Cobbler ~]# systemctl restart cobblerd.service
  cobbler同步
[root@Cobbler ~]# cobbler sync
task started: 2018-01-09_094453_sync
task started (id=Sync, time=Tue Jan  9 09:44:53 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
  登录cobbler的web界面
  https://10.0.0.202/cobbler_web
DSC0000.jpg

  虚拟机磁盘挂载
[root@Cobbler ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[root@Cobbler ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        98G  1.6G   97G   2% /
devtmpfs        903M     0  903M   0% /dev
tmpfs           912M     0  912M   0% /dev/shm
tmpfs           912M  8.6M  904M   1% /run
tmpfs           912M     0  912M   0% /sys/fs/cgroup
/dev/sda1      1014M  135M  880M  14% /boot
tmpfs           183M     0  183M   0% /run/user/0
/dev/sr0        4.3G  4.3G     0 100% /mnt

DSC0001.jpg

  查看是否导入
[root@Cobbler ~]# ps -ef|grep rsync  
root      11796      1  0 09:20 ?        00:00:00 /usr/bin/rsync --daemon --no-detach
root      12205  11869 27 09:58 ?        00:00:03 rsync -a /mnt/ /var/www/cobbler/ks_mirror/CentOS7.4-x86_64 --progress
root      12206  12205  0 09:58 ?        00:00:00 rsync -a /mnt/ /var/www/cobbler/ks_mirror/CentOS7.4-x86_64 --progress
root      12207  12206 32 09:58 ?        00:00:04 rsync -a /mnt/ /var/www/cobbler/ks_mirror/CentOS7.4-x86_64 --progress
root      12217  10658  0 09:58 pts/0    00:00:00 grep --color=auto rsync
DSC0002.jpg
镜像文件
[root@Cobbler ~]# ls  /var/www/cobbler/ks_mirror/
CentOS7.4-x86_64  config

DSC0003.jpg

DSC0004.jpg

  http://***@@httpserver@@***/cblr/links/CentOS7.4-x86_64 ==http://**10.0.0.202**/cblr/links/CentOS7.4-x86_64/
DSC0005.jpg

  界面配置文件  可以修图
[root@Cobbler ~]# cat /etc/cobbler/pxe/pxedefault.template
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://cobbler.github.io/
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT $pxe_timeout_profile
  LABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1
  $pxe_menu_items
  MENU end
  不想要local可以修改
DSC0006.jpg
  自定义安装系统
DSC0007.jpg
  Cobbler-CentOS-7-x86_64.cfg
  #Cobbler for Kickstart Configurator for CentOS 7 by yao zhang
  install
url --url=$tree
text
lang en_US.UTF-8
keyboard us
zerombr
bootloader --location=mbr --driveorder=sda --append=&quot;crashkernel=auto rhgb quiet&quot;
#Network information
$SNIPPET('network_config')
#network --bootproto=dhcp --device=eth0 --onboot=yes --noipv6 --hostname=CentOS7
timezone --utc Asia/Shanghai
authconfig --enableshadow --passalgo=sha512
rootpw  --iscrypted $default_password_crypted
clearpart --all --initlabel
part /boot --fstype xfs --size 1024
part swap --size 1024
part / --fstype xfs --size 1 --grow
firstboot --disable
selinux --disabled
firewall --disabled
logging --level=info
reboot
  %pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
#Enable installation monitoring
$SNIPPET('pre_anamon')
%end

  %packages@^minimalbr/>@core

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-449309-1-1.html 上篇帖子: docker centos安装部署 下篇帖子: centos7安装confluence遇到的问题
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表