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

[经验分享] cobbler 安装

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-10-21 08:24:18 | 显示全部楼层 |阅读模式
环境
环境
LINUX
系统
CentOS release 6.8 (Final)
内核版本
2.6.32-642.el6.x86_64
epel源
selinux
Disabled
ip  tables
Firewall is not running.
需要的软件
httpd dhcp tftp cobbler cobbler-web  pykickstart

主机ip
172.16.1.77
1、下载需要的软件
1
2
3
4
5
6
7
8
[iyunv@cobbler scripts]# yum install -y httpd dhcp tftp cobbler cobbler-web pykickstart
[iyunv@cobbler scripts]# rpm -qa httpd dhcp tftp cobbler cobbler-web pykickstart
cobbler-2.6.11-1.el6.x86_64
pykickstart-1.74.20-1.el6.noarch
httpd-2.2.15-54.el6.centos.x86_64
cobbler-web-2.6.11-1.el6.noarch
tftp-0.49-8.el6.x86_64
dhcp-4.1.1-51.P1.el6.centos.x86_64



如果cobbler没有下载下载,换一个epel源再去下载
1
rpm -ivh  http://mirrors.aliyun.com/epel/epel-release-latest-6.noarch.rpm



2、开启httpd cobbler
1
2
3
4
5
[iyunv@cobbler scripts]# service httpd start
Starting httpd:
[iyunv@cobbler scripts]# service cobblerd start
Starting cobbler daemon:                                   [  OK  ]
[iyunv@cobbler scripts]#



3、检查cobbler配置存在的问题,逐一解决
1
2
3
4
5
6
7
8
9
10
11
12
[iyunv@cobbler scripts]# 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 set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE 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 : change 'disable' to 'no' in /etc/xinetd.d/rsync
6 : file /etc/xinetd.d/rsync does not exist
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
8 : 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
9 : 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
4、修改/etc/cobbler/settings修改/etc/cobbler/settings文件中的server参数的值为提供cobbler服务的主机相应的IP地址或主机名,如server: 172.16.1.61;
备份原文件
1
[iyunv@cobbler cobbler]# cp /etc/cobbler/settings{,.ori}



server,Cobbler服务器的IP,
修改272行next_server: 127.0.0.1 = 172.16.1.77
修改384行server: 127.0.0.1 = 172.16.1.77
1
2
[iyunv@cobbler cobbler]# sed -i 's/next_server:127.0.0.1/next_server: 172.16.1.77/' /etc/cobbler/settings
[iyunv@cobbler cobbler]# sed -i 's/server:127.0.0.1/server: 172.16.1.77/' /etc/cobbler/settings



检查一下修改的部分:

1
2
3
4
[iyunv@cobbler scripts]# grep "172.16.1.77" /etc/cobbler/settings
next_server: 172.16.1.77
server: 172.16.1.77
[iyunv@cobbler scripts]#



5、修改/etc/xinetd.d/tftp修改/etc/xinetd.d/tftp文件中的disable参数修改为 disable = no
备份原文件
1
[iyunv@cobbler cobbler]# cp/etc/xinetd.d/tftp{,.ori}



修改替换
1
[iyunv@cobbler cobbler]# sed -i 's/disable.*=yes/disable                 = no/g'/etc/xinetd.d/tftp



6、修改/etc/xinetd.d/rsync
1
[iyunv@cobbler cobbler]# sed -i s/"disable.*=yes"/"disable         =no"/g /etc/xinetd.d/rsync



7、执行cobbler et-loaders命令即可;否则,需要安装syslinux程序包,而后复制/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目录中;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[iyunv@cobbler scripts]# cobbler get-loaders
task started: 2016-10-20_172927_get_loaders
task started (id=Download Bootloader Content, time=Thu Oct 20 17:29:27 2016)
downloading http://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading http://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading http://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading http://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading http://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading http://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading http://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading http://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading http://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading http://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***




8、生成密码来取代默认的密码并把密码到/etc/cobbler/settings
1
2
3
[iyunv@cobbler scripts]# openssl passwd -1 -salt 'cobbler' 'cobbler'
$1$cobbler$M6SE55xZodWc9.vAKLJs6.
[iyunv@cobbler scripts]# sed -i s/'default_password_crypted:.*'/'default_password_crypted: "$1$cobbler$M6SE55xZodWc9.vAKLJs6.\/"'/g /etc/cobbler/settings



9、用cobbler管理DHCP,修改242行manage_dhcp: 0
1
[iyunv@cobbler scripts]# sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings



10、修改/etc/cobbler/dhcp.template

修改dhcp里面的参数。ip范围等等 只修改下面的就可以
1
2
3
4
5
6
7
8
subnet 172.16.1.0 netmask 255.255.255.0 {
     option routers             172.16.1.5;
     option domain-name-servers 172.16.1.1;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        172.16.1.100 172.16.1.254;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;



11、同步cobbler的配置,可以看到同步干了哪些事
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[iyunv@cobbler scripts]# cobbler sync
task started: 2016-10-20_172635_sync
task started (id=Sync, time=Thu Oct 20 17:26:35 2016)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/images
copying bootloaders
trying hardlink /usr/share/syslinux/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /usr/share/syslinux/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
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 ***



12、设置开机自启动
1
2
3
4
[iyunv@cobbler scripts]# echo "/etc/init.d/httpd restart" >>/etc/rc.local
[iyunv@cobbler scripts]# echo "/etc/init.d/xinetd restart" >>/etc/rc.local      
[iyunv@cobbler scripts]# echo "/etc/init.d/cobblerd restart" >>/etc/rc.local      
[iyunv@cobbler scripts]# echo "/etc/init.d/dhcpd restart" >>/etc/rc.local



13、导入镜像
挂载centos光盘镜像
1
2
3
4
5
6
7
8
9
[iyunv@cobbler scripts]# mount /dev/cdrom /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only
[iyunv@cobbler scripts]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        19G  1.6G   17G   9% /
tmpfs           491M     0  491M   0% /dev/shm
/dev/sda1       190M   33M  147M  19% /boot
/dev/sr0        3.7G  3.7G     0 100% /mnt
[iyunv@cobbler scripts]#



导入镜像
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[iyunv@cobbler scripts]# cobbler import --path=/mnt/ --name=CentOS-6-x86_64 --arch=x86_64
task started: 2016-10-20_173717_import
task started (id=Media import, time=Thu Oct 20 17:37:17 2016)
Found a candidate signature: breed=redhat, version=rhel6
Found a matching signature: breed=redhat, version=rhel6
Adding distros from path /var/www/cobbler/ks_mirror/CentOS-6-x86_64:
creating new distro: CentOS-6-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-6-x86_64 -> /var/www/cobbler/links/CentOS-6-x86_64
creating new profile: CentOS-6-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-6-x86_64 for CentOS-6-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-6-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-6-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-6-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-6-x86_64/repodata
*** TASK COMPLETE ***



# --path 镜像路径
# --name 为安装源定义一个名字
# --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64
# 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:CentOS-6.6-x86_64,如果重复,系统会提示导入失败。
查看导入镜像

1
2
[iyunv@cobbler scripts]# cobbler distro list
   CentOS-6-x86_64



同上例,我把CentOS-7-x86_64也导入

镜像存放目录,cobbler会将镜像中的所有安装文件拷贝到本地一份,放在/var/www/cobbler/ks_mirror下的CentOS-6.6-x86_64目录下。因此/var/www/cobbler目录必须具有足够容纳安装文件的空间
1
2
3
4
5
6
7
[iyunv@cobbler scripts]# cd /var/www/cobbler/ks_mirror/
[iyunv@cobbler ks_mirror]# ls
CentOS-6-x86_64  CentOS-7-x86_64  config
[iyunv@cobbler ks_mirror]# ls CentOS-6-x86_64/
CentOS_BuildTag  GPL       Packages                  RPM-GPG-KEY-CentOS-6           RPM-GPG-KEY-CentOS-Testing-6
EFI              images    RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-Debug-6     TRANS.TBL
EULA             isolinux  repodata                  RPM-GPG-KEY-CentOS-Security-6



上传ks.cfg文件(此处感谢赵班长赵老师,帮忙给我们提供文件。谢谢!~~)
1
2
3
4
5
6
7
8
9
10
[iyunv@cobbler ks_mirror]# cd /var/lib/cobbler/kickstarts/
[iyunv@cobbler kickstarts]# ls
default.ks    esxi5-ks.cfg      legacy.ks     sample_autoyast.xml  sample_esx4.ks   sample_esxi5.ks  sample_old.seed
esxi4-ks.cfg  install_profiles  pxerescue.ks  sample_end.ks        sample_esxi4.ks  sample.ks        sample.seed
[iyunv@cobbler kickstarts]# rz
[iyunv@cobbler kickstarts]# ls
CentOS-6-x86_64.cfg  esxi4-ks.cfg      legacy.ks            sample_end.ks    sample_esxi5.ks  sample.seed
CentOS-7-x86_64.cfg  esxi5-ks.cfg      pxerescue.ks         sample_esx4.ks   sample.ks
default.ks           install_profiles  sample_autoyast.xml  sample_esxi4.ks  sample_old.seed
[iyunv@cobbler kickstarts]#



自定义ks.cfg文件
1
[iyunv@cobbler kickstarts]# cobbler profile edit --name=CentOS-6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6-x86_64.cfg



修改内核参数
1
[iyunv@cobbler kickstarts]# cobbler profile edit --name=CentOS-6-x86_64 --kopts='net.ifnames=0 biosdevname=0'



查看所有的profile设置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
[iyunv@cobbler kickstarts]# cobbler profile report --nameCentOS-6-x86_64
Name                          : CentOS-6-x86_64
TFTP Boot Files               : {}
Comment                       :
DHCP Tag                      : default
Distribution                  : CentOS-6-x86_64
Enable gPXE?                  : 0
Enable PXE Menu?              : 1
Fetchable Files               : {}
Kernel Options                : {'biosdevname': '0', 'net.ifnames': '0'}
Kernel Options (Post Install) : {}
Kickstart                     : /var/lib/cobbler/kickstarts/CentOS-6-x86_64.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



14、同步下cobbler数据,每次修改完都要镜像同步
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
[iyunv@cobbler kickstarts]# cobbler sync
task started: 2016-10-20_175603_sync
task started (id=Sync, time=Thu Oct 20 17:56:03 2016)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/CentOS-7-x86_64
removing: /var/www/cobbler/images/CentOS-6-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/CentOS-7-x86_64
removing: /var/lib/tftpboot/images/CentOS-6-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
copying: /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: 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 files for distro: CentOS-6-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CentOS-6-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-6-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CentOS-6-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-6-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
copying files for distro: CentOS-6-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CentOS-6-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-6-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CentOS-6-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-6-x86_64/initrd.img
Writing template files for CentOS-6-x86_64
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: CentOS-7-x86_64
processing boot_files for distro: CentOS-6-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 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 ***



15、修改这里,开机画面显示
1
2
3
4
5
6
7
[iyunv@cobbler kickstarts]# vim /etc/cobbler/pxe/pxedefault.template
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | im syaving!
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT $pxe_timeout_profile



QQ截图20161021081959.png 修改完毕后记着同步
1
[iyunv@cobbler kickstarts]# cobbler sync



16、不管修改什么,都要记着同步!!!
1
[iyunv@cobbler kickstarts]# cobbler sync




17、最后,查看服务是否启动。
1
2
3
4
5
6
7
8
9
10
11
[iyunv@cobbler kickstarts]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 127.0.0.1:25151             0.0.0.0:*                   LISTEN      25225/python2      
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1195/sshd           
tcp        0      0 :::873                      :::*                        LISTEN      25335/xinetd        
tcp        0      0 :::80                       :::*                        LISTEN      1354/httpd         
tcp        0      0 :::22                       :::*                        LISTEN      1195/sshd           
tcp        0      0 :::443                      :::*                        LISTEN      1354/httpd         
udp        0      0 0.0.0.0:67                  0.0.0.0:*                               25316/dhcpd         
udp        0      0 0.0.0.0:69                  0.0.0.0:*                               25335/xinetd







运维网声明 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-289101-1-1.html 上篇帖子: CentOS下搭建DHCP服务器(联网安装) 下篇帖子: centos7的网卡配置
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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