CentOS7下利用cobbler部署CentOS推荐

1)安装epel源和cobbler

[root@cobbler~]#yum-yinstallhttp://mirrors.163.com/centos/7/extras/x86_64/Packages/epel-release-7-9.noarch.rpm[root@cobbler~]#yuminstallcobblercobbler-webdhcptftp-serverpykickstarthttpdxinetd-y[root@cobbler~]#systemctlstartxinetd.service[root@cobbler~]#systemctlenablexinetd.service[root@cobbler~]#systemctlstarthttpd[root@cobbler~]#systemctlenablehttpdCreatedsymlinkfrom/etc/systemd/system/multi-user.target.wants/httpd.serviceto/usr/lib/systemd/system/httpd.service.[root@cobbler~]#systemctlstartcobblerd.service[root@cobbler~]#systemctlenablecobblerd.serviceCreatedsymlinkfrom/etc/systemd/system/multi-user.target.wants/cobblerd.serviceto/usr/lib/systemd/system/cobblerd.service.

2)配置cobbler

检查cobbler:[root@cobbler~]#cobblercheckThefollowingarepotentialconfigurationitemsthatyoumaywanttofix:1:The'server'fieldin/etc/cobbler/settingsmustbesettosomethingotherthanlocalhost,orkickstartingfeatureswillnotwork.ThisshouldbearesolvablehostnameorIPforthebootserverasreachablebyallmachinesthatwilluseit.2:ForPXEtobefunctional,the'next_server'fieldin/etc/cobbler/settingsmustbesettosomethingotherthan127.0.0.1,andshouldmatchtheIPofthebootserveronthePXEnetwork.3:change'disable'to'no'in/etc/xinetd.d/tftp4:somenetworkboot-loadersaremissingfrom/var/lib/cobbler/loaders,youmayrun'cobblerget-loaders'todownloadthem,or,ifyouonlywanttohandlex86/x86_64netbooting,youmayensurethatyouhaveinstalleda*recent*versionofthesyslinuxpackageinstalledandcanignorethismessageentirely.Filesinthisdirectory,shouldyouwanttosupportallarchitectures,shouldincludepxelinux.0,menu.c32,elilo.efi,andyaboot.The'cobblerget-loaders'commandistheeasiestwaytoresolvetheserequirements.5:enableandstartrsyncd.servicewithsystemctl6:debmirrorpackageisnotinstalled,itwillberequiredtomanagedebiandeploymentsandrepositories7:Thedefaultpasswordusedbythesampletemplatesfornewlyinstalledmachines(default_password_cryptedin/etc/cobbler/settings)isstillsetto'cobbler'andshouldbechanged,try:"opensslpasswd-1-salt'random-phrase-here''your-password-here'"togeneratenewone8:fencingtoolswerenotfound,andarerequiredtousethe(optional)powermanagementfeatures.installcmanorfence-agentstousethemRestartcobblerdandthenrun'cobblersync'toapplychanges.

修改cobbler的配置文件:

[root@cobbler~]#vim/etc/cobbler/settings#ifyoudonotsetthiscorrectly,thiswillbemanifestedinTFTPopentimeouts.将“next_server:127.0.0.1”修改为“next_server:10.10.10.222”将“server:127.0.0.1”修改为“server:10.10.10.222”#setto1toenableCobbler'sDHCPmanagementfeatures.#thechoiceofDHCPmanagementengineisin/etc/cobbler/modules.conf将“manage_dhcp:0”修改为“manage_dhcp:1”

修改cobbler默认的密码:

将“default_password_crypted:"$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."”修改为“default_password_crypted:"$1$wanwan$K9lP0CajD0pbFaxI0if84/"”随机生成一个密码:[root@cobbler~]#opensslpasswd-1-salt'wanwan''redhat12345'$1$wanwan$K9lP0CajD0pbFaxI0if84/[root@cobbler~]#vim/etc/xinetd.d/tftp将“disable=yes”修改为“disable=no”

重启rsync服务:

[root@cobbler~]#systemctlstartrsyncd.service[root@cobbler~]#systemctlenablersyncd.serviceCreatedsymlinkfrom/etc/systemd/system/multi-user.target.wants/rsyncd.serviceto/usr/lib/systemd/system/rsyncd.service.

下载cobbler相关的包:

[root@cobbler~]#cobblerget-loaderstaskstarted:2017-03-20_110931_get_loaderstaskstarted(id=DownloadBootloaderContent,time=MonMar2011:09:312017)downloadinghttps://cobbler.github.io/loaders/READMEto/var/lib/cobbler/loaders/READMEdownloadinghttps://cobbler.github.io/loaders/COPYING.eliloto/var/lib/cobbler/loaders/COPYING.elilodownloadinghttps://cobbler.github.io/loaders/COPYING.yabootto/var/lib/cobbler/loaders/COPYING.yabootdownloadinghttps://cobbler.github.io/loaders/COPYING.syslinuxto/var/lib/cobbler/loaders/COPYING.syslinuxdownloadinghttps://cobbler.github.io/loaders/elilo-3.8-ia64.efito/var/lib/cobbler/loaders/elilo-ia64.efidownloadinghttps://cobbler.github.io/loaders/yaboot-1.3.17to/var/lib/cobbler/loaders/yabootdownloadinghttps://cobbler.github.io/loaders/pxelinux.0-3.86to/var/lib/cobbler/loaders/pxelinux.0downloadinghttps://cobbler.github.io/loaders/menu.c32-3.86to/var/lib/cobbler/loaders/menu.c32downloadinghttps://cobbler.github.io/loaders/grub-0.97-x86.efito/var/lib/cobbler/loaders/grub-x86.efidownloadinghttps://cobbler.github.io/loaders/grub-0.97-x86_64.efito/var/lib/cobbler/loaders/grub-x86_64.efi***TASKCOMPLETE***[root@cobbler~]#systemctlrestartcobblerd.service[root@cobbler~]#cobblercheckThefollowingarepotentialconfigurationitemsthatyoumaywanttofix:1:debmirrorpackageisnotinstalled,itwillberequiredtomanagedebiandeploymentsandrepositories2:fencingtoolswerenotfound,andarerequiredtousethe(optional)powermanagementfeatures.installcmanorfence-agentstousethem[root@cobbler~]#cd/etc/cobbler/[root@cobblercobbler]#lsauth.confdhcp.templateldappowerrsync.templateusers.confzone_templatescheetah_macrosdnsmasq.templatemodules.confpxesecondary.templateusers.digestcobbler_bashimport_rsync_whitelistmongodb.confreportingsettingsversioncompletionsisonamed.templatersync.excludetftpd.templatezone.template

3)配置服务

[root@cobblercobbler]#vimdhcp.templatesubnet10.10.10.0netmask255.255.255.0{optionrouters10.10.10.2;optiondomain-name-servers10.10.10.2;optionsubnet-mask255.255.255.0;rangedynamic-bootp10.10.10.10010.10.10.200;default-lease-time21600;max-lease-time43200;next-server$next_server;class"pxeclients"{matchifsubstring(optionvendor-class-identifier,0,9)="PXEClient";ifoptionpxe-system-type=00:02{filename"ia64/elilo.efi";}elseifoptionpxe-system-type=00:06{filename"grub/grub-x86.efi";}elseifoptionpxe-system-type=00:07{filename"grub/grub-x86_64.efi";}else{filename"pxelinux.0";}}备注:主要修改网段、DNS、网关等信息[root@cobblercobbler]#cobblersync通过cobbler管理的dhcp的配置文件[root@cobblercobbler]#egrep-v'^#|^$'/etc/dhcp/dhcpd.confddns-update-styleinterim;allowbooting;allowbootp;ignoreclient-updates;setvendorclass=optionvendor-class-identifier;optionpxe-system-typecode93=unsignedinteger16;subnet10.10.10.0netmask255.255.255.0{optionrouters10.10.10.2;optiondomain-name-servers10.10.10.2;optionsubnet-mask255.255.255.0;rangedynamic-bootp10.10.10.10010.10.10.200;default-lease-time21600;max-lease-time43200;next-server10.10.10.222;class"pxeclients"{matchifsubstring(optionvendor-class-identifier,0,9)="PXEClient";ifoptionpxe-system-type=00:02{filename"ia64/elilo.efi";}elseifoptionpxe-system-type=00:06{filename"grub/grub-x86.efi";}elseifoptionpxe-system-type=00:07{filename"grub/grub-x86_64.efi";}else{filename"pxelinux.0";}}group{}

挂载并导入数据:

[root@cobbler~]#mount/dev/cdrom/mntmount:/dev/sr0iswrite-protected,mountingread-only[root@cobbler~]#df-hFilesystemSizeUsedAvailUse%Mountedon/dev/mapper/cl-root50G9.8G41G20%/devtmpfs1.9G01.9G0%/devtmpfs1.9G144K1.9G1%/dev/shmtmpfs1.9G9.0M1.9G1%/runtmpfs1.9G01.9G0%/sys/fs/cgroup/dev/mapper/cl-home46G36M46G1%/home/dev/sda11014M175M840M18%/boottmpfs378M12K378M1%/run/user/0/dev/sr04.1G4.1G0100%/mnt[root@cobbler~]#cobblerimport--path=/mnt--name=CentOS-7.3--arch=x86_64taskstarted:2017-03-20_113200_importtaskstarted(id=Mediaimport,time=MonMar2011:32:002017)Foundacandidatesignature:breed=redhat,version=rhel6Foundacandidatesignature:breed=redhat,version=rhel7Foundamatchingsignature:breed=redhat,version=rhel7Addingdistrosfrompath/var/www/cobbler/ks_mirror/CentOS-7.3-x86_64:creatingnewdistro:CentOS-7.3-x86_64tryingsymlink:/var/www/cobbler/ks_mirror/CentOS-7.3-x86_64- /var/www/cobbler/links/CentOS-7.3-x86_64creatingnewprofile:CentOS-7.3-x86_64associatingreposcheckingforrsyncrepo(s)checkingforrhnrepo(s)checkingforyumrepo(s)startingdescentinto/var/www/cobbler/ks_mirror/CentOS-7.3-x86_64forCentOS-7.3-x86_64processingrepoat:/var/www/cobbler/ks_mirror/CentOS-7.3-x86_64needtoprocessrepo/comps:/var/www/cobbler/ks_mirror/CentOS-7.3-x86_64lookingfor/var/www/cobbler/ks_mirror/CentOS-7.3-x86_64/repodata/*comps*.xmlKeepingrepodataas-is:/var/www/cobbler/ks_mirror/CentOS-7.3-x86_64/repodata***TASKCOMPLETE***

说明:cobbler导入的镜像放在:/var/www/cobbler/ks_mirror

[root@cobblerks_mirror]#pwd/var/www/cobbler/ks_mirror[root@cobblerks_mirror]#lsCentOS-7.3-x86_64config

默认kickstart文件存放位置:/var/lib/cobbler/kickstarts/

[root@cobbler~]#cd/var/lib/cobbler/kickstarts/[root@cobblerkickstarts]#lltotal52-rw-r--r--1rootroot115Nov1703:09default.ks-rw-r--r--1rootroot22Nov1703:09esxi4-ks.cfg-rw-r--r--1rootroot22Nov1703:09esxi5-ks.cfgdrwxr-xr-x2rootroot56Mar2010:39install_profiles-rw-r--r--1rootroot1424Nov1703:09legacy.ks-rw-r--r--1rootroot292Nov1703:09pxerescue.ks-rw-r--r--1rootroot2916Nov1703:09sample_autoyast.xml-rw-r--r--1rootroot1825Nov1703:09sample_end.ks-rw-r--r--1rootroot0Nov1703:09sample_esx4.ks-rw-r--r--1rootroot324Nov1703:09sample_esxi4.ks-rw-r--r--1rootroot386Nov1703:09sample_esxi5.ks-rw-r--r--1rootroot1784Nov1703:09sample.ks-rw-r--r--1rootroot3419Nov1703:09sample_old.seed-rw-r--r--1rootroot5879Nov1703:09sample.seed[root@cobbler~]#cobblerlistdistros:CentOS-7.3-x86_64profiles:CentOS-7.3-x86_64systems:repos:images:mgmtclasses:packages:files:[root@cobbler~]#cobblerprofilereportName:CentOS-7.3-x86_64TFTPBootFiles:{}Comment:DHCPTag:defaultDistribution:CentOS-7.3-x86_64EnablegPXE?:0EnablePXEMenu?:1FetchableFiles:{}KernelOptions:{}KernelOptions(PostInstall):{}Kickstart:/var/lib/cobbler/kickstarts/sample_end.ksKickstartMetadata:{}ManagementClasses:[]ManagementParameters: inherit NameServers:[]NameServersSearchPath:[]Owners:['admin']ParentProfile:Internalproxy:RedHatManagementKey: inherit RedHatManagementServer: inherit Repos:[]ServerOverride: inherit TemplateFiles:{}VirtAutoBoot:1VirtBridge:xenbr0VirtCPUs:1VirtDiskDriverType:rawVirtFileSize(GB):5VirtPath:VirtRAM(MB):512VirtType:kvm

查看cobbler profile的帮助:

[root@cobbler~]#cobblerprofileedit--helpUsage:cobbler[options]Options:-h,--helpshowthishelpmessageandexit--name=NAMEName(Ex:F10-i386-webserver)--uid=UID--owners=OWNERSOwners(Ownerslistforauthz_ownership(spacedelimited))--distro=DISTRODistribution(Parentdistribution)--parent=PARENTParentProfile--enable-gpxe=ENABLE_GPXEEnablegPXE?(UsegPXEinsteadofPXELINUXforadvancedbootingoptions)--enable-menu=ENABLE_MENUEnablePXEMenu?(ShowthisprofileinthePXEmenu?)--kickstart=KICKSTARTKickstart(Pathtokickstarttemplate)--kopts=KERNEL_OPTIONSKernelOptions(Ex:selinux=permissive)--kopts-post=KERNEL_OPTIONS_POSTKernelOptions(PostInstall)(Ex:clocksource=pitnoapic)--ksmeta=KS_METAKickstartMetadata(Ex:dog=fangagent=86)--proxy=PROXYInternalproxy(InternalproxyURL)--repos=REPOSRepos(Repostoauto-assigntothisprofile)--comment=COMMENTComment(Freeformtextdescription)--virt-auto-boot=VIRT_AUTO_BOOTVirtAutoBoot(AutobootthisVM?)--virt-cpus=VIRT_CPUSVirtCPUs(integer)--virt-file-size=VIRT_FILE_SIZEVirtFileSize(GB)--virt-disk-driver=VIRT_DISK_DRIVERVirtDiskDriverType(Theon-diskformatforthevirtualizationdisk)--virt-ram=VIRT_RAMVirtRAM(MB)--depth=DEPTH--virt-type=VIRT_TYPEVirtType(Virtualizationtechnologytouse)(validoptions:xenpv,xenfv,qemu,kvm,vmware,openvz,SETTINGS:default_virt_type)--virt-path=VIRT_PATHVirtPath(Ex:/directoryORVolGroup00)--virt-bridge=VIRT_BRIDGEVirtBridge--dhcp-tag=DHCP_TAGDHCPTag(Seemanpageorleaveblank)--server=SERVERServerOverride(Seemanpageorleaveblank)--ctime=CTIME--mtime=MTIME--name-servers=NAME_SERVERSNameServers(spacedelimited)--name-servers-search=NAME_SERVERS_SEARCHNameServersSearchPath(spacedelimited)--mgmt-classes=MGMT_CLASSESManagementClasses(Forexternalconfigurationmanagement)--mgmt-parameters=MGMT_PARAMETERSManagementParameters(Parameterswhichwillbehandedtoyourmanagementapplication(MustbevalidYAMLdictionary))--boot-files=BOOT_FILESTFTPBootFiles(Filescopiedintotftpbootbeyondthekernel/initrd)--fetchable-files=FETCHABLE_FILESFetchableFiles(Templatesfortftporwget/curl)--template-files=TEMPLATE_FILESTemplateFiles(Filemappingsforbuilt-inconfigmanagement)--redhat-management-key=REDHAT_MANAGEMENT_KEYRedHatManagementKey(RegistrationkeyforRHN,Spacewalk,orSatellite)--redhat-management-server=REDHAT_MANAGEMENT_SERVERRedHatManagementServer(AddressofSpacewalkorSatelliteServer)--template-remote-kickstarts=TEMPLATE_REMOTE_KICKSTARTS--clobberallowaddtooverwriteexistingobjects--in-placeedititemsinkoptsorksmetawithoutclearingtheotheritems

修改kickstart文件:

[root@cobbler~]#cobblerprofileedit--name=CentOS-7.3-x86_64--kickstart=/var/lib/cobbler/kickstarts/CentOS-7.3-x86_64.cfg

修改内核参数:

[root@cobbler~]#cobblerprofileedit--name=CentOS-7.3-x86_64--kopts='net.ifnames=0biosdevname=0'[root@cobbler~]#cobblerprofilereportName:CentOS-7.3-x86_64TFTPBootFiles:{}Comment:DHCPTag:defaultDistribution:CentOS-7.3-x86_64EnablegPXE?:0EnablePXEMenu?:1FetchableFiles:{}KernelOptions:{'biosdevname':'0','net.ifnames':'0'}KernelOptions(PostInstall):{}Kickstart:/var/lib/cobbler/kickstarts/CentOS-7.3-x86_64.cfgKickstartMetadata:{}ManagementClasses:[]ManagementParameters: inherit NameServers:[]NameServersSearchPath:[]Owners:['admin']ParentProfile:Internalproxy:RedHatManagementKey: inherit RedHatManagementServer: inherit Repos:[]ServerOverride: inherit TemplateFiles:{}VirtAutoBoot:1VirtBridge:xenbr0VirtCPUs:1VirtDiskDriverType:rawVirtFileSize(GB):5VirtPath:VirtRAM(MB):512VirtType:kvm[root@cobbler~]#cobblersynctaskstarted:2017-03-20_135014_synctaskstarted(id=Sync,time=MonMar2013:50:142017)runningpre-synctriggerscleaningtreesremoving:/var/www/cobbler/images/CentOS-7.3-x86_64removing:/var/lib/tftpboot/pxelinux.cfg/defaultremoving:/var/lib/tftpboot/grub/imagesremoving:/var/lib/tftpboot/grub/grub-x86.efiremoving:/var/lib/tftpboot/grub/grub-x86_64.efiremoving:/var/lib/tftpboot/grub/efidefaultremoving:/var/lib/tftpboot/images/CentOS-7.3-x86_64removing:/var/lib/tftpboot/s390x/profile_listcopyingbootloaderstryinghardlink/var/lib/cobbler/loaders/pxelinux.0- /var/lib/tftpboot/pxelinux.0copying:/var/lib/cobbler/loaders/pxelinux.0- /var/lib/tftpboot/pxelinux.0tryinghardlink/var/lib/cobbler/loaders/menu.c32- /var/lib/tftpboot/menu.c32copying:/var/lib/cobbler/loaders/menu.c32- /var/lib/tftpboot/menu.c32tryinghardlink/var/lib/cobbler/loaders/grub-x86.efi- /var/lib/tftpboot/grub/grub-x86.efitryinghardlink/var/lib/cobbler/loaders/grub-x86_64.efi- /var/lib/tftpboot/grub/grub-x86_64.eficopyingdistrostotftpbootcopyingfilesfordistro:CentOS-7.3-x86_64tryinghardlink/var/www/cobbler/ks_mirror/CentOS-7.3-x86_64/images/pxeboot/vmlinuz- /var/lib/tftpboot/images/CentOS-7.3-x86_64/vmlinuztryinghardlink/var/www/cobbler/ks_mirror/CentOS-7.3-x86_64/images/pxeboot/initrd.img- /var/lib/tftpboot/images/CentOS-7.3-x86_64/initrd.imgcopyingimagesgeneratingPXEconfigurationfilesgeneratingPXEmenustructurecopyingfilesfordistro:CentOS-7.3-x86_64tryinghardlink/var/www/cobbler/ks_mirror/CentOS-7.3-x86_64/images/pxeboot/vmlinuz- /var/www/cobbler/images/CentOS-7.3-x86_64/vmlinuztryinghardlink/var/www/cobbler/ks_mirror/CentOS-7.3-x86_64/images/pxeboot/initrd.img- /var/www/cobbler/images/CentOS-7.3-x86_64/initrd.imgWritingtemplatefilesforCentOS-7.3-x86_64renderingDHCPfilesgenerating/etc/dhcp/dhcpd.confrenderingTFTPDfilesgenerating/etc/xinetd.d/tftpprocessingboot_filesfordistro:CentOS-7.3-x86_64cleaninglinkcachesrunningpost-synctriggersrunningpythontriggersfrom/var/lib/cobbler/triggers/sync/post/*runningpythontriggercobbler.modules.sync_post_restart_servicesrunning:dhcpd-t-qreceivedonstdout:receivedonstderr:running:servicedhcpdrestartreceivedonstdout:receivedonstderr:Redirectingto/bin/systemctlrestartdhcpd.servicerunningshelltriggersfrom/var/lib/cobbler/triggers/sync/post/*runningpythontriggersfrom/var/lib/cobbler/triggers/change/*runningpythontriggercobbler.modules.scm_trackrunningshelltriggersfrom/var/lib/cobbler/triggers/change/****TASKCOMPLETE***

客户端设置从网卡启动:

安装完的CentOS6:

cobbler的图形化管理界面(默认用户名cobbler,默认密码cobbler):

补充下,如果重启cobbler后发现dhcpd服务不能正常使用,很有可能是因为没设置自动启动

[root@cobbler~]#systemctlstartdhcpd.service[root@cobbler~]#systemctlenabledhcpd.serviceCreatedsymlinkfrom/etc/systemd/system/multi-user.target.wants/dhcpd.serviceto/usr/lib/systemd/system/dhcpd.service.

附件:http://down.51cto.com/data/2366521

我们首先去了象鼻山,那里景色秀丽神奇,

CentOS7下利用cobbler部署CentOS推荐

相关文章:

你感兴趣的文章:

标签云: