博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
cobbler部署
阅读量:6454 次
发布时间:2019-06-23

本文共 15943 字,大约阅读时间需要 53 分钟。

cobbler部署

配置yum源

[root@linfan ~]# cd /etc/yum.repos.d/[root@linfan yum.repos.d]# lsCentOS-Base.repo.gz  CentOS-Debuginfo.repo.gz  CentOS-Media.repo.gz    CentOS-Vault.repo.gzCentOS-CR.repo.gz    CentOS-fasttrack.repo.gz  CentOS-Sources.repo.gz  lin.repo[root@linfan yum.repos.d]# curl -o 163.repo   http://mirrors.163.com/.help/CentOS7-Base-163.repo  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                 Dload  Upload   Total   Spent    Left  Speed100  1572  100  1572    0     0   3917      0 --:--:-- --:--:-- --:--:--  3930[root@linfan yum.repos.d]# ls163.repo             CentOS-CR.repo.gz         CentOS-fasttrack.repo.gz  CentOS-Sources.repo.gz  lin.repoCentOS-Base.repo.gz  CentOS-Debuginfo.repo.gz  CentOS-Media.repo.gz      CentOS-Vault.repo.gz[root@linfan yum.repos.d]# sed -i 's/\$releasever/7/g' 163.repo[root@linfan yum.repos.d]# sed -i 's/^enabled=.*/enabled=1/g' 163.repo[root@linfan yum.repos.d]# yum clean allLoaded plugins: fastestmirrorCleaning repos: base centosplus extras lin updatesCleaning up everythingMaybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed reposCleaning up list of fastest mirrors[root@linfan yum.repos.d]# yum -y install epel-release

安装cobbler以及相关软件

[root@linfan ~]#  yum -y install httpd dhcp tftp python-ctypes cobbler xinetd cobbler-web pykickstart

启动服务并设置开机自启动

[root@linfan ~]#  systemctl start httpd[root@linfan ~]# systemctl start cobblerd[root@linfan ~]# systemctl enable httpdCreated symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.[root@linfan ~]# systemctl enable cobblerdCreated symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.

修改server的ip为本机ip

[root@linfan ~]# sed -i 's/^server: 127.0.0.1/server: 192.168.24.168/' /etc/cobbler/settings

设置tftp的ip地址为本机ip

sed -i 's/^next_server: 127.0.0.1/next_server: 192.168.24.168/' /etc/cobbler/settings

开启tfp

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

下载缺失文件

[root@linfan ~]# cobbler get-loaderstask started: 2018-08-29_105820_get_loaderstask started (id=Download Bootloader Content, time=Wed Aug 29 10:58:20 2018)downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/READMEdownloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilodownloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yabootdownloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinuxdownloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efidownloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yabootdownloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efidownloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi*** TASK COMPLETE ***

启动rysnc并设置开启自启动

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

生成加密的密码

[root@linfan ~]# openssl passwd -1 -salt "$RANDOM" 'linfan123'$1$22895$x1tfkN/VsYusTzt449H.L.

将新生成的加密密码加入配置文件

[root@linfan ~]# sed -i 's/default_password_crypted/#default_password_crypted/g' /etc/cobbler/settings[root@linfan ~]# echo "default_password_crypted:  "$1$22895$x1tfkN/VsYusTzt449H.L."" >> /etc/cobbler/settings

重启cobbler

[root@linfan ~]# systemctl restart cobblerd[root@linfan ~]#  ss -antlState      Recv-Q Send-Q                Local Address:Port                               Peer Address:PortLISTEN     0      128                               *:22                                            *:*LISTEN     0      100                       127.0.0.1:25                                            *:*LISTEN     0      5                         127.0.0.1:25151                                         *:*LISTEN     0      5                                 *:873                                           *:*LISTEN     0      128                              :::80                                           :::*LISTEN     0      128                              :::22                                           :::*LISTEN     0      100                             ::1:25                                           :::*LISTEN     0      128                              :::443                                          :::*LISTEN     0      5                                :::873                                          :::*

通过cobbler check 核对当前设置

[root@linfan ~]# cobbler checkThe following are potential configuration items that you may want to fix:1 : debmirror package is not installed, it will be required to manage debian deployments and repositories2 : 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.

以上两个是关于debian系统的错误,请忽略

配置cobbler dhcp

修改cobbler配置文件,让cobbler控制dhcp

[root@linfan ~]#  sed -i '/^manage_dhcp/s/0/1/g' /etc/cobbler/settings[root@linfan ~]# sed -n '/^manage_dhcp/p' /etc/cobbler/settingsmanage_dhcp: 1

配置dhcp

[root@linfan ~]#sed -i 's/subnet 192.168.1.0/subnet 192.168.24.0/g'  /etc/cobbler/dhcp.template[root@linfan ~]# sed -i 's/option routers             192.168.1.5;/option routers             192.168.24.168;/g' /etc/cobbler/dhcp.template[root@linfan ~]# sed -i 's/option domain-name-servers 192.168.1.1;/option domain-name-servers 192.168.24.168;/g' /etc/cobbler/dhcp.template[root@linfan ~]#  sed -i 's/range dynamic-bootp        192.168.1.100 192.168.1.254;/range dynamic-bootp        192.168.24.100 192.168.24.150;/g' /etc/cobbler/dhcp.template

重启服务并同步配置,改完dhcp必须要先sync同步配置

[root@linfan ~]# systemctl restart cobblerd[root@linfan ~]# cobbler synctask started: 2018-08-29_120850_synctask started (id=Sync, time=Wed Aug 29 12:08:50 2018)running pre-sync triggerscleaning treesremoving: /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/s390x/profile_listcopying bootloaderstrying 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 imagesgenerating PXE configuration filesgenerating PXE menu structurerendering DHCP filesgenerating /etc/dhcp/dhcpd.confrendering 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: dhcpd -t -qreceived on stdout:received on stderr:running: service dhcpd restartreceived on stdout:received on stderr: Redirecting to /bin/systemctl restart dhcpd.servicerunning 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 ***

检查dhcp是否正常

[root@linfan ~]#  netstat -anulp|grep dhcpudp        0      0 0.0.0.0:67              0.0.0.0:*                           1709/dhcpd

导入centos7镜像

[root@linfan ~]# mount /dev/cdrom /mnt[root@linfan ~]# cobbler import --path=/mnt --name=centos7 --arch=x86_64task started: 2018-08-29_123313_importtask started (id=Media import, time=Wed Aug 29 12:33:13 2018)Found a candidate signature: breed=redhat, version=rhel6Found a candidate signature: breed=redhat, version=rhel7Found a matching signature: breed=redhat, version=rhel7Adding distros from path /var/www/cobbler/ks_mirror/centos7-x86_64:creating new distro: centos7-x86_64trying symlink: /var/www/cobbler/ks_mirror/centos7-x86_64 -> /var/www/cobbler/links/centos7-x86_64creating new profile: centos7-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/centos7-x86_64 for centos7-x86_64processing repo at : /var/www/cobbler/ks_mirror/centos7-x86_64need to process repo/comps: /var/www/cobbler/ks_mirror/centos7-x86_64looking for /var/www/cobbler/ks_mirror/centos7-x86_64/repodata/*comps*.xmlKeeping repodata as-is :/var/www/cobbler/ks_mirror/centos7-x86_64/repodata*** TASK COMPLETE ***

//说明

--path //镜像路径

--name //为安装源定义一个名字
--arch //指定安装源平台

//安装源的唯一标识就是根据name参数来定义

查看cobbler镜像列表

[root@linfan ~]# cobbler listdistros:   centos7-x86_64profiles:   centos7-x86_64systems:repos:images:mgmtclasses:packages:files:

创建kickstarts自动安装脚本

[root@linfan ~]# cat > /var/lib/cobbler/kickstarts/centos7-x86_64.ks <<'EOF'> auth --enableshadow --passalgo=sha512> bootloader --location=mbr> clearpart --all --initlabel> part /boot --asprimary --fstype="ext4" --size=500> part swap --fstype="swap" --size=4096> part / --fstype="ext4" --grow --size=14000> text> firewall --disabled> firstboot --disable> keyboard us> lang en_US> url --url=http://192.168.24.168/cobbler/ks_mirror/centos7-x86_64> $yum_repo_stanza> $SNIPPET('network_config')> reboot>  rootpw --iscrypted $6$noLJ6S9MCXH6zxix$vUora.pqzXplCt/bKqiqSDtxH0E1.hfJ4BxRkLmkfgtb7HlPb3kYehTtS6/GutiCWNC4P2uU2Wm/Ra7W3uxjK.> selinux --disabled> skipx> timezone Asia/Shanghai --isUtc --nontp> install> zerombr> %packages> @^minimal> @core> kexec-tools> %end> %addon com_redhat_kdump --enable --reserve-mb='auto'> %end> %anaconda> pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty> pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok> pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty> %end> EOF

检查ks文件语法是否有误

[root@linfan ~]# cobbler validatekstask started: 2018-08-29_124757_validatekstask started (id=Kickstart Validation, time=Wed Aug 29 12:47:57 2018)----------------------------osversion: rhel7checking url: http://192.168.24.168/cblr/svc/op/ks/profile/centos7-x86_64running: /usr/bin/ksvalidator -v "rhel7" "http://192.168.24.168/cblr/svc/op/ks/profile/centos7-x86_64"received on stdout:received on stderr:*** all kickstarts seem to be ok ****** TASK COMPLETE ***

查看当前cobbler有哪些配置文件

[root@linfan ~]# cobbler profile list   centos7-x86_64

修改profile,将我们新建的ks文件设置为默认的kickstarts安装文件

[root@linfan ~]# cobbler profile edit --name centos7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7-x86_64.ks

配置网卡名称为传统网卡名称eth0

[root@linfan ~]# cobbler profile edit --name centos7-x86_64 --kopts='net.ifnames=0 biosdevname=0'

检查当前系统cobbler配置文件信息

[root@linfan ~]# cobbler profile reportName                           : centos7-x86_64TFTP Boot Files                : {}Comment                        :DHCP Tag                       : defaultDistribution                   : centos7-x86_64Enable gPXE?                   : 0Enable PXE Menu?               : 1Fetchable Files                : {}Kernel Options                 : {'biosdevname': '0', 'net.ifnames': '0'}Kernel Options (Post Install)  : {}Kickstart                      : /var/lib/cobbler/kickstarts/centos7-x86_64.ksKickstart 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

同步cobbler

[root@linfan ~]#  cobbler synctask started: 2018-08-29_125708_synctask started (id=Sync, time=Wed Aug 29 12:57:08 2018)running pre-sync triggerscleaning treesremoving: /var/www/cobbler/images/centos7-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/centos7-x86_64removing: /var/lib/tftpboot/s390x/profile_listcopying bootloaderstrying 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: centos7-x86_64trying hardlink /var/www/cobbler/ks_mirror/centos7-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/centos7-x86_64/vmlinuztrying hardlink /var/www/cobbler/ks_mirror/centos7-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/centos7-x86_64/initrd.imgcopying imagesgenerating PXE configuration filesgenerating PXE menu structurecopying files for distro: centos7-x86_64trying hardlink /var/www/cobbler/ks_mirror/centos7-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/centos7-x86_64/vmlinuztrying hardlink /var/www/cobbler/ks_mirror/centos7-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/centos7-x86_64/initrd.imgWriting template files for centos7-x86_64rendering DHCP filesgenerating /etc/dhcp/dhcpd.confrendering TFTPD filesgenerating /etc/xinetd.d/tftpprocessing boot_files for distro: centos7-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: dhcpd -t -qreceived on stdout:received on stderr:running: service dhcpd restartreceived on stdout:received on stderr: Redirecting to /bin/systemctl restart dhcpd.servicerunning 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 ***

为避免发生未知问题,先把服务端所有服务重启

[root@linfan ~]# systemctl restart xinetd[root@linfan ~]# systemctl restart cobblerd[root@linfan ~]# systemctl restart httpd[root@linfan ~]# ss -antlState      Recv-Q Send-Q                Local Address:Port                               Peer Address:PortLISTEN     0      128                               *:22                                            *:*LISTEN     0      100                       127.0.0.1:25                                            *:*LISTEN     0      5                         127.0.0.1:25151                                         *:*LISTEN     0      5                                 *:873                                           *:*LISTEN     0      128                              :::80                                           :::*LISTEN     0      128                              :::22                                           :::*LISTEN     0      100                             ::1:25                                           :::*LISTEN     0      128                              :::443                                          :::*LISTEN     0      5                                :::873                                          :::*

转载于:https://blog.51cto.com/13858192/2166195

你可能感兴趣的文章
CentOS 4.4双网卡绑定,实现负载均衡
查看>>
GitHub页面使用方法
查看>>
Python爬虫综述(笔记)
查看>>
Scala之柯里化和隐式转换
查看>>
Merge and BottomUpSort
查看>>
reids 安装记录
查看>>
获取androdmanifest里面的meta-data
查看>>
mysql拷贝表的几种方式
查看>>
NetApp FAS2240-4存储删除文件数据恢复
查看>>
用设计模式去掉没必要的状态变量 —— 状态模式
查看>>
linux安装elasticsearch及遇到的各种问题
查看>>
健忘的正则
查看>>
[转]CMake快速入门教程:实战
查看>>
IntelliJ IDEA创建JavaWeb工程及配置Tomcat部署
查看>>
Markdown用法
查看>>
求最大值及其下标
查看>>
Request header is too large
查看>>
轮播插件swiper.js?
查看>>
网路流24题总结
查看>>
BZOJ-3732 Network 图论 最小生成树 倍增
查看>>