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

[经验分享] RHEL6.5上安装配置Cobbler

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-11-5 09:05:34 | 显示全部楼层 |阅读模式
RHEL6.5上安装配置CobblerCobbler运行流程图 QQ截图20151105090453.png
(注:图来自煮酒品茶)
加载epel源# rpm -Uvh http://mirrors.ustc.edu.cn/epel/ ... ease-6-8.noarch.rpm
或者
# rpm -ivh http://dl.fedoraproject.org/pub/ ... ease-6-8.noarch.rpm
安装cobbler包及其组件# yum install -y cobbler rsync tftp dhcphttpd cman pykickstart debmirror tftp-server xinetd python-ctypes
# yum install -y ed patch perlperl-Compress-Zlib perl-Digest-SHA1 perl-LockFile-Simple perl-libwww-perl
设置服务开机启动# chkconfig httpd on
# chkconfig dhcpd on
# chkconfig xinetd on
# chkconfig cobblerd on
系统环境设置selinux/iptables# sed -i '/SELINUX/s/enforcing/disabled/'/etc/selinux/config
# setenforce 0
# chkconfig iptables off
# service iptables stop
修改httpd配置并启动# vim /etc/httpd/conf/httpd.conf
ServerName 127.0.0.1:80
# service httpd start
修改cobbler配置并启动设置目标系统root密码# PASSWORD=”`echo "jiayuan.com" |openssl passwd -1 -salt 'randomstr' –stdin`”
# sed -is@"^default_password_crypted.*$"@"default_password_crypted:\"$PASSWORD\""@g /etc/cobbler/settings
设置cobbler server的IP# sed -i 's/server: 127.0.0.1/server:10.240.216.1/g' /etc/cobbler/settings
设置DHCP server的IP# sed -i 's/next_server:127.0.0.1/next_server: 10.240.216.1/g' /etc/cobbler/settings
设置允许cobbler管理DHCP# sed -i 's/manage_dhcp: 0/manage_dhcp:1/g' /etc/cobbler/settings
设置允许cobbler管理rsync# sed -i 's/manage_rsync: 0/manage_rsync:1/g' /etc/cobbler/settings
设置一次安装开关(可选)# sed -i 's/pxe_just_once: 0/pxe_just_once:1/g' /etc/cobbler/settings
修改cobbler管理DHCP的模板# cat /etc/cobbler/dhcp.template
ddns-update-style interim;

allow booting;
allow bootp;

ignore client-updates;
set vendorclass = optionvendor-class-identifier;

option pxe-system-type code 93 = unsignedinteger 16;

subnet 10.240.216.0 netmask 255.255.255.0 {
    option routers            10.240.216.254;     #路由地址
    #option domain-name-servers 8.8.8.8;                            #DNSserver地址
    option subnet-mask        255.255.255.0;             #子网掩码
     #rangedynamic-bootp        10.240.216.210.240.216.200;  #分配IP地址段
    default-lease-time         21600;
    max-lease-time             43200;
    next-server               $next_server;
    filename                  "pxelinux.0";
}
subnet 10.240.217.0 netmask 255.255.255.0 {
    option routers            10.240.217.254;
    option subnet-mask        255.255.255.0;
    filename                  "/pxelinux.0";
    default-lease-time         21600;
    max-lease-time             43200;
    next-server               $next_server;
}
启动cobbler# service cobblerd start
校验cobbler安装条件# cobbler check
更新loader信息# cobbler get-loaders
修改xinetd关于tftp和rsync的配置并启动# sed -i '/disable/c\\tdisable\t\t\t= no'/etc/xinetd.d/tftp
# sed -i -e 's/\=\ yes/\=\ no/g'/etc/xinetd.d/rsync
# service xinetd start
配置dhcp server并启动# cat /etc/dhcp/dhcpd.conf
ddns-update-style interim;

allow booting;
allow bootp;

ignore client-updates;
set vendorclass = optionvendor-class-identifier;

option pxe-system-type code 93 = unsignedinteger 16;
#可以添加多子网(保持和dhcp.template一致)
subnet 10.240.216.0 netmask 255.255.255.0 {
    option routers            10.240.216.254;
    option subnet-mask        255.255.255.0;
    filename                  "/pxelinux.0";
     #rangedynamic-bootp        10.240.216.210.240.216.200;
    default-lease-time         21600;
    max-lease-time             43200;
    next-server               10.240.216.1;
}
subnet 10.240.217.0 netmask 255.255.255.0 {
    option routers            10.240.217.254;
    option subnet-mask         255.255.255.0;
    filename                  "/pxelinux.0";
    default-lease-time         21600;
    max-lease-time             43200;
    next-server               10.240.216.1;
}
# group for Cobbler DHCP tag: default
group {
}
# service dhcpd start
修改debmirror.conf去掉仅对debian系统的支持参数# sed -i "s/^@dists/#@dists/g"/etc/debmirror.conf
# sed -i "s/^@arches/#@arches/g"/etc/debmirror.conf
Cobbler配置同步# service cobblerd restart
# cobbler sync
挂载安装镜像并导入distro# mkdir /mnt/rhel6.5
# mkdir /mnt/rhel7.0
# mount -t iso9660 -o loop,ro/opt/rhel-server-6.5-x86_64-dvd.iso /mnt/rhel6.5
# cobbler import --name=redhat6.5--arch=x86_64 --path=/mnt/rhel6.5
查看生成的项目# cobbler distro list
# cobbler profile list
查看项目明细# cobbler report
自定义KS文件# vim rhel6.5.ks
install
text
key --skip
keyboard us
lang en_US.UTF-8
skipx
network --device eth0 --bootproto dhcp
rootpw root
firewall --disabled
authconfig --enableshadow --enablemd5
selinux --disabled
timezone --utc Asia/Shanghai
url --url=$tree            
$SNIPPET('network_config')
bootloader --location=mbr --driveorder=sda
zerombr yes
clearpart --all

part /boot --fstype ext4 --size=200
#part /    --fstype ext4 --size=20000
part swap --fstype swap --size=4096
#part /u01 --fstype ext4 --grow --size=200
reboot

%packages
@base
@core
@server-policy
ipmitool
OpenIPMI
openssh-clients
net-snmp
%post

将自定义的kickstart文件与镜像相关联# cobbler profile edit--name=redhat6.5-x86_64 --distro=redhat6.5-x86_64--kickstart=/var/lib/cobbler/kickstarts/rhel6.5.ks
再次同步cobbler配置# cobbler sync                         ###下面贴出完整信息,注意红色部分
task started: 2015-05-25_154818_sync
task started (id=Sync, time=Mon May 2515:48:18 2015)
running pre-sync triggers
cleaning trees
removing:/var/www/cobbler/images/redhat6.5-x86_64
removing:/var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/grub/images
removing:/var/lib/tftpboot/images/redhat6.5-x86_64
removing:/var/lib/tftpboot/s390x/profile_list
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/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: redhat6.5-x86_64
trying hardlink/var/www/cobbler/ks_mirror/redhat6.5-x86_64/images/pxeboot/vmlinuz ->/var/lib/tftpboot/images/redhat6.5-x86_64/vmlinuz
trying hardlink/var/www/cobbler/ks_mirror/redhat6.5-x86_64/images/pxeboot/initrd.img ->/var/lib/tftpboot/images/redhat6.5-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: redhat6.5-x86_64
trying hardlink/var/www/cobbler/ks_mirror/redhat6.5-x86_64/images/pxeboot/vmlinuz ->/var/www/cobbler/images/redhat6.5-x86_64/vmlinuz
trying hardlink/var/www/cobbler/ks_mirror/redhat6.5-x86_64/images/pxeboot/initrd.img ->/var/www/cobbler/images/redhat6.5-x86_64/initrd.img
Writing template files for redhat6.5-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro:redhat6.5-x86_64
cleaning link caches
rendering Rsync files
running post-sync triggers
running python triggers from/var/lib/cobbler/triggers/sync/post/*
running python triggercobbler.modules.sync_post_restart_services
running: dhcpd -t -q
received on stdout:
received on stderr:
running: service dhcpd restart
received on stdout: Shutting down dhcpd: [  OK  ]
Starting dhcpd: [ OK  ]          <-- 必须要看到dhcpd服务启动才行

received on stderr:
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 ***
<--到此就可以从一台新机器通过pxe启动系统了 -->
配置Cobbler的web管理界面# yum -y install cobbler-web
# sed -i's/authn_denyall/authn_configfile/g' /etc/cobbler/modules.conf
# /etc/init.d/cobblerd restart
# /etc/init.d/httpd restart
访问地址:https://10.240.216.1/cobbler_web
QQ截图20151105090508.png
利用MAC地址自动化安装系统的命令

cobbler system add --name bgw-os-node151--hostname bgw-os-node151   --profileceph

cobbler system edit --namebgw-os-node151   --interface eth0 --macB4:99:BA:BF:1F:EA --ip-address 10.240.216.151 --netmask 255.255.255.0 --gateway 10.240.216.254 --static 1

cobbler system edit --namebgw-os-node151   --interface eth1 --macB4:99:BA:BF:1F:EC --ip-address 10.240.217.151 --netmask 255.255.255.0  --static1

因为设置了只初始化一次,如果还想让系统能够通过pxe来启动重装,那么你需要做下面的操作

cobbler system remove --name bgw-os-node151

问题问题1:[iyunv@bgw-os-node1 ~]# cobbler check
httpd does not appear to be running andproxying cobbler, or SELinux is in the way. Original traceback:
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/cobbler/cli.py", line252, in check_setup
   s.ping()
  File"/usr/lib64/python2.6/xmlrpclib.py", line 1199, in __call__
   return self.__send(self.__name, args)
File "/usr/lib64/python2.6/xmlrpclib.py", line 1489, in__request
   verbose=self.__verbose
File "/usr/lib64/python2.6/xmlrpclib.py", line 1243, inrequest
   headers
ProtocolError: <ProtocolError for127.0.0.1:80/cobbler_api: 502 Proxy Error>
[iyunv@bgw-os-node1 ~]# vim /etc/hosts
127.0.0.1 localhost
[iyunv@bgw-os-node1 ~]# cobbler check
The following are potential configurationitems that you may want to fix:

1 : The 'server' field in/etc/cobbler/settings must be set to something other than localhost, orkickstarting features will not work. This should be a resolvable hostname or IP for the boot server asreachable by all machines that will use it.
2 : For PXE to be functional, the'next_server' field in /etc/cobbler/settings must be set to something otherthan 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : some network boot-loaders are missingfrom /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to downloadthem, or, if you only want to handle x86/x86_64 netbooting, you may ensure thatyou have installed a *recent* version of the syslinux package installed and canignore this message entirely.  Files inthis directory, should you want to support all architectures, should includepxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' commandis the easiest way to resolve these requirements.
4 : change 'disable' to 'no' in/etc/xinetd.d/rsync
5 : since iptables may be running, ensure69, 80/443, and 25151 are unblocked
6 : comment out 'dists' on/etc/debmirror.conf for proper debian support
7 : comment out 'arches' on/etc/debmirror.conf for proper debian support
8 : The default password used by the sampletemplates 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

Restart cobblerd and then run 'cobblersync' to apply changes.

问题2:
[iyunv@bgw-os-node1 ~]# cobbler check
The following are potential configurationitems that you may want to fix:

1 : service dhcpd is not running
2 : since iptables may be running, ensure69, 80/443, and 25151 are unblocked

Restart cobblerd and then run 'cobblersync' to apply changes.

[iyunv@bgw-os-node1 ~]# service iptablesstop
[iyunv@bgw-os-node1 cobbler]# vim/etc/cobbler/dhcp.template
ddns-update-style interim;

allow booting;
allow bootp;

ignore client-updates;
set vendorclass = optionvendor-class-identifier;

option pxe-system-type code 93 = unsignedinteger 16;

subnet 10.240.216.0 netmask 255.255.255.0 {
    option routers             10.240.216.254;
    #option domain-name-servers 8.8.8.8;
    option subnet-mask        255.255.255.0;
    range dynamic-bootp       10.240.216.2 10.240.216.200;
    default-lease-time         21600;
    max-lease-time             43200;
    next-server               $next_server;
    filename                  "pxelinux.0";
    #class "pxeclients" {
    #     match if substring (optionvendor-class-identifier, 0, 9) = "PXEClient";
    #     if option pxe-system-type =00:02 {
    #             filename "ia64/elilo.efi";
    #     } else if optionpxe-system-type = 00:06 {
    #             filename"grub/grub-x86.efi";
    #     } else if optionpxe-system-type = 00:07 {
    #             filename"grub/grub-x86_64.efi";
    #     } else {
    #             filename"pxelinux.0";
    #     }
    #}

}
[iyunv@bgw-os-node1 cobbler]# vim/etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
#  see /usr/share/doc/dhcp*/dhcpd.conf.sample
#  see 'man 5 dhcpd.conf'
#
ddns-update-style interim;

allow booting;
allow bootp;

ignore client-updates;
set vendorclass = optionvendor-class-identifier;

option pxe-system-type code 93 = unsignedinteger 16;

subnet 10.240.216.0 netmask 255.255.255.0 {
    option routers             10.240.216.254;
    option subnet-mask        255.255.255.0;
    filename                  "/pxelinux.0";
    range dynamic-bootp       10.240.216.2 10.240.216.200;
    default-lease-time         21600;
    max-lease-time             43200;
    next-server               10.240.216.1;
}

[iyunv@bgw-os-node1 cobbler]# servicecobblerd restart
Stopping cobbler daemon:                                   [  OK  ]
Starting cobbler daemon:                                   [  OK  ]
[iyunv@bgw-os-node1 cobbler]# service dhcpdstart
Starting dhcpd:                                           [  OK  ]
[iyunv@bgw-os-node1 cobbler]# cobbler check
No configuration problems found.  All systems go.


运维网声明 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-135216-1-1.html 上篇帖子: atlassian 实现企业级知识管理与协同平台 下篇帖子: Linux-pam_cracklib.so选项详解
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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