cobbler 安装

在此感谢赵班长与张耀~~


环境

环境

LINUX

系统

CentOS release 6.8 (Final)

内核版本

2.6.32-642.el6.x86_64

epel

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

rpm -ivh  http://mirrors.aliyun.com/epel/epel-release-latest-6.noarch.rpm

selinux

Disabled

ip  tables

Firewall is not running.

需要的软件

httpd dhcp tftp cobbler cobbler-web  pykickstart


主机ip

172.16.1.77

1、下载需要的软件

[root@cobbler scripts]# yum install -y httpd dhcp tftp cobbler cobbler-web pykickstart[root@cobbler scripts]# rpm -qa httpd dhcp tftp cobbler cobbler-web pykickstartcobbler-2.6.11-1.el6.x86_64pykickstart-1.74.20-1.el6.noarchhttpd-2.2.15-54.el6.centos.x86_64cobbler-web-2.6.11-1.el6.noarchtftp-0.49-8.el6.x86_64dhcp-4.1.1-51.P1.el6.centos.x86_64

如果cobbler没有下载下载,换一个epel源再去下载

rpm -ivh  http://mirrors.aliyun.com/epel/epel-release-latest-6.noarch.rpm

2、开启httpd cobbler

[root@cobbler scripts]# service httpd startStarting httpd: [root@cobbler scripts]# service cobblerd startStarting cobbler daemon:                                   [  OK  ][root@cobbler scripts]#

3、检查cobbler配置存在的问题,逐一解决

[root@cobbler scripts]# cobbler checkThe 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/tftp4 : 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/rsync6 : file /etc/xinetd.d/rsync does not exist7 : debmirror package is not installed, it will be required to manage debian deployments and repositories8 : 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 one9 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use themRestart 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

备份原文件

[root@cobbler cobbler]# cp /etc/cobbler/settings{,.ori}

serverCobbler服务器的IP

修改272next_server: 127.0.0.1 172.16.1.77

修改384server: 127.0.0.1 = 172.16.1.77

[root@cobbler cobbler]# sed -i 's/next_server: 127.0.0.1/next_server: 172.16.1.77/' /etc/cobbler/settings[root@cobbler cobbler]# sed -i 's/server: 127.0.0.1/server: 172.16.1.77/' /etc/cobbler/settings

检查一下修改的部分:

[root@cobbler scripts]# grep "172.16.1.77" /etc/cobbler/settingsnext_server: 172.16.1.77server: 172.16.1.77[root@cobbler scripts]#

5、修改/etc/xinetd.d/tftp

修改/etc/xinetd.d/tftp文件中的disable参数修改为 disable = no

备份原文件

[root@cobbler cobbler]# cp /etc/xinetd.d/tftp{,.ori}

修改替换

[root@cobbler cobbler]# sed -i 's/disable.*=yes/disable                 = no/g'/etc/xinetd.d/tftp

6、修改/etc/xinetd.d/rsync

[root@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/目录中;

[root@cobbler scripts]# cobbler get-loaderstask started: 2016-10-20_172927_get_loaderstask 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/READMEdownloading http://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilodownloading http://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yabootdownloading http://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinuxdownloading http://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efidownloading http://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yabootdownloading http://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0downloading http://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32downloading http://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efidownloading 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

[root@cobbler scripts]# openssl passwd -1 -salt 'cobbler' 'cobbler'$1$cobbler$M6SE55xZodWc9.vAKLJs6.[root@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

[root@cobbler scripts]# sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings

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

修改dhcp里面的参数。ip范围等等 只修改下面的就可以

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的配置,可以看到同步干了哪些事

[root@cobbler scripts]# cobbler synctask started: 2016-10-20_172635_synctask started (id=Sync, time=Thu Oct 20 17:26:35 2016)running pre-sync triggerscleaning treesremoving: /var/lib/tftpboot/grub/imagescopying bootloaderstrying hardlink /usr/share/syslinux/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0trying hardlink /usr/share/syslinux/menu.c32 -> /var/lib/tftpboot/menu.c32trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdiskcopying distros to tftpbootcopying imagesgenerating PXE configuration filesgenerating PXE menu structurerendering TFTPD filesgenerating /etc/xinetd.d/tftpcleaning link cachesrunning post-sync triggersrunning python triggers from /var/lib/cobbler/triggers/sync/post/*running python trigger cobbler.modules.sync_post_restart_servicesrunning shell triggers from /var/lib/cobbler/triggers/sync/post/*running python triggers from /var/lib/cobbler/triggers/change/*running python trigger cobbler.modules.scm_trackrunning shell triggers from /var/lib/cobbler/triggers/change/**** TASK COMPLETE ***

12、设置开机自启动

[root@cobbler scripts]# echo "/etc/init.d/httpd restart" >>/etc/rc.local [root@cobbler scripts]# echo "/etc/init.d/xinetd restart" >>/etc/rc.local      [root@cobbler scripts]# echo "/etc/init.d/cobblerd restart" >>/etc/rc.local       [root@cobbler scripts]# echo "/etc/init.d/dhcpd restart" >>/etc/rc.local

13、导入镜像

挂载centos光盘镜像

[root@cobbler scripts]# mount /dev/cdrom /mntmount: block device /dev/sr0 is write-protected, mounting read-only[root@cobbler scripts]# df -hFilesystem      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[root@cobbler scripts]#

导入镜像

[root@cobbler scripts]# cobbler import --path=/mnt/ --name=CentOS-6-x86_64 --arch=x86_64task started: 2016-10-20_173717_importtask started (id=Media import, time=Thu Oct 20 17:37:17 2016)Found a candidate signature: breed=redhat, version=rhel6Found a matching signature: breed=redhat, version=rhel6Adding distros from path /var/www/cobbler/ks_mirror/CentOS-6-x86_64:creating new distro: CentOS-6-x86_64trying symlink: /var/www/cobbler/ks_mirror/CentOS-6-x86_64 -> /var/www/cobbler/links/CentOS-6-x86_64creating new profile: CentOS-6-x86_64associating reposchecking 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_64processing repo at : /var/www/cobbler/ks_mirror/CentOS-6-x86_64need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-6-x86_64looking for /var/www/cobbler/ks_mirror/CentOS-6-x86_64/repodata/*comps*.xmlKeeping 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,如果重复,系统会提示导入失败。

查看导入镜像

[root@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目录必须具有足够容纳安装文件的空间

[root@cobbler scripts]# cd /var/www/cobbler/ks_mirror/[root@cobbler ks_mirror]# lsCentOS-6-x86_64  CentOS-7-x86_64  config[root@cobbler ks_mirror]# ls CentOS-6-x86_64/CentOS_BuildTag  GPL       Packages                  RPM-GPG-KEY-CentOS-6           RPM-GPG-KEY-CentOS-Testing-6EFI              images    RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-Debug-6     TRANS.TBLEULA             isolinux  repodata                  RPM-GPG-KEY-CentOS-Security-6

上传ks.cfg文件(此处感谢赵班长赵老师,帮忙给我们提供文件。谢谢!~~)

[root@cobbler ks_mirror]# cd /var/lib/cobbler/kickstarts/[root@cobbler kickstarts]# lsdefault.ks    esxi5-ks.cfg      legacy.ks     sample_autoyast.xml  sample_esx4.ks   sample_esxi5.ks  sample_old.seedesxi4-ks.cfg  install_profiles  pxerescue.ks  sample_end.ks        sample_esxi4.ks  sample.ks        sample.seed[root@cobbler kickstarts]# rz[root@cobbler kickstarts]# lsCentOS-6-x86_64.cfg  esxi4-ks.cfg      legacy.ks            sample_end.ks    sample_esxi5.ks  sample.seedCentOS-7-x86_64.cfg  esxi5-ks.cfg      pxerescue.ks         sample_esx4.ks   sample.ksdefault.ks           install_profiles  sample_autoyast.xml  sample_esxi4.ks  sample_old.seed[root@cobbler kickstarts]#

自定义ks.cfg文件

[root@cobbler kickstarts]# cobbler profile edit --name=CentOS-6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6-x86_64.cfg

修改内核参数

[root@cobbler kickstarts]# cobbler profile edit --name=CentOS-6-x86_64 --kopts='net.ifnames=0 biosdevname=0'

查看所有的profile设置 

[root@cobbler kickstarts]# cobbler profile report --name CentOS-6-x86_64Name                          : CentOS-6-x86_64TFTP Boot Files               : {}Comment                       :DHCP Tag                      : defaultDistribution                  : CentOS-6-x86_64Enable gPXE?                  : 0Enable PXE Menu?              : 1Fetchable Files               : {}Kernel Options                : {'biosdevname': '0', 'net.ifnames': '0'}Kernel Options (Post Install) : {}Kickstart                     : /var/lib/cobbler/kickstarts/CentOS-6-x86_64.cfgKickstart Metadata            : {}Management Classes            : []Management Parameters         : <>Name Servers                  : []Name Servers Search Path      : []Owners                        : ['admin']Parent Profile                :Internal proxy                :Red Hat Management Key        : <>Red Hat Management Server     : <>Repos                         : []Server Override               : <>Template Files                : {}Virt Auto Boot                : 1Virt Bridge                   : xenbr0Virt CPUs                     : 1Virt Disk Driver Type         : rawVirt File Size(GB)            : 5Virt Path                     :Virt RAM (MB)                 : 512Virt Type                     : kvm

14、同步下cobbler数据,每次修改完都要镜像同步

[root@cobbler kickstarts]# cobbler synctask started: 2016-10-20_175603_synctask started (id=Sync, time=Thu Oct 20 17:56:03 2016)running pre-sync triggerscleaning treesremoving: /var/www/cobbler/images/CentOS-7-x86_64removing: /var/www/cobbler/images/CentOS-6-x86_64removing: /var/lib/tftpboot/pxelinux.cfg/defaultremoving: /var/lib/tftpboot/grub/efidefaultremoving: /var/lib/tftpboot/grub/imagesremoving: /var/lib/tftpboot/images/CentOS-7-x86_64removing: /var/lib/tftpboot/images/CentOS-6-x86_64removing: /var/lib/tftpboot/s390x/profile_listcopying bootloaderstrying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboottrying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efitrying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.eficopying distros to tftpbootcopying files for distro: CentOS-7-x86_64trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-7-x86_64/vmlinuztrying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-7-x86_64/initrd.imgcopying files for distro: CentOS-6-x86_64trying hardlink /var/www/cobbler/ks_mirror/CentOS-6-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-6-x86_64/vmlinuztrying hardlink /var/www/cobbler/ks_mirror/CentOS-6-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-6-x86_64/initrd.imgcopying imagesgenerating PXE configuration filesgenerating PXE menu structurecopying files for distro: CentOS-7-x86_64trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-7-x86_64/vmlinuztrying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-7-x86_64/initrd.imgWriting template files for CentOS-7-x86_64copying files for distro: CentOS-6-x86_64trying hardlink /var/www/cobbler/ks_mirror/CentOS-6-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-6-x86_64/vmlinuztrying hardlink /var/www/cobbler/ks_mirror/CentOS-6-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-6-x86_64/initrd.imgWriting template files for CentOS-6-x86_64rendering TFTPD filesgenerating /etc/xinetd.d/tftpprocessing boot_files for distro: CentOS-7-x86_64processing boot_files for distro: CentOS-6-x86_64cleaning link cachesrunning post-sync triggersrunning python triggers from /var/lib/cobbler/triggers/sync/post/*running python trigger cobbler.modules.sync_post_restart_servicesrunning shell triggers from /var/lib/cobbler/triggers/sync/post/*running python triggers from /var/lib/cobbler/triggers/change/*running python trigger cobbler.modules.scm_trackrunning shell triggers from /var/lib/cobbler/triggers/change/**** TASK COMPLETE ***

15、修改这里,开机画面显示

[root@cobbler kickstarts]# vim /etc/cobbler/pxe/pxedefault.templateDEFAULT menuPROMPT 0MENU TITLE Cobbler | im syaving!TIMEOUT 200TOTALTIMEOUT 6000ONTIMEOUT $pxe_timeout_profile

650) this.width=650;" src="http://s2.51cto.com/wyfs02/M02/89/20/wKioL1gIreSDZe9cAAANLtaAuZE572.png-wh_500x0-wm_3-wmp_4-s_857307217.png" title="QQ截图20161020193719.png" alt="wKioL1gIreSDZe9cAAANLtaAuZE572.png-wh_50" />

修改完毕后记着同步

[root@cobbler kickstarts]# cobbler sync

16、不管修改什么,都要记着同步!!!

[root@cobbler kickstarts]# cobbler sync


17、最后,查看服务是否启动。

[root@cobbler kickstarts]# netstat -lntupActive 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




本文出自 “宋某人c” 博客,请务必保留此出处http://syaving.blog.51cto.com/5614476/1864014

你可能感兴趣的:(服务器搭建与应用)