1. <th id="orwrz"></th>
        <tbody id="orwrz"><pre id="orwrz"></pre></tbody>
      2. <rp id="orwrz"><object id="orwrz"></object></rp>
        首頁 系統自動部署PXE和Cobbler教程實戰案例:CentOS 7 實現基于cobbler實現自動化安裝

        故障排查Trouble Shooting

        運維派隸屬馬哥教育旗下專業運維社區,是國內成立最早的IT運維技術社區,歡迎關注公眾號:yunweipai
        領取學習更多免費Linux云計算、Python、Docker、K8s教程關注公眾號:馬哥linux運維

        實戰案例:CentOS 7 實現基于cobbler實現自動化安裝

        環境準備

        兩臺主機

        一臺主機:CentOS 7.7 充當Cobbler,http,dhcp,tftp服務器,并關閉防火墻和SELinux

        一臺主機:充當測試機,用于實現自動化安裝Linux系統

        網絡要求:關閉Vmware軟件中的NAT模式中的DHCP服務,兩個主機網卡基于NAT模式

        安裝相關包并啟動服務
        [root@centos7 ~]#yum install cobbler dhcp
        [root@centos7 ~]#systemctl enable --now cobblerd httpd tftp dhcpd 
        修改cobbler相關的配置
        [root@centos7 ~]#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 : enable and start rsyncd.service with systemctl
        6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
        7 : ksvalidator was not found, install pykickstart
        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
        
        #根據以上提示,只需要做1,2,8這三項即可,修改下面四行
        [root@centos7 ~]#vim  /etc/cobbler/settings 
        default_password_crypted: "1gEc7ilpP$pg5iSOj/mlxTxEslhRvyp/"
        next_server:< tftp服務器的 IP 地址>
        server:<cobbler服務器的 IP 地址>
        manage_dhcp:1  #設置為1,表示通過cobbler生成dhcpd.conf配置文件
        
        [root@centos7 ~]#systemctl restart cobblerd 
        [root@centos7 ~]#cobbler sync 
        下載啟動的相關文件
        [root@centos7 ~]#cobbler get-loaders
        task started: 2020-02-10_163111_get_loaders
        task started (id=Download Bootloader Content, time=Mon Feb 10 16:31:11 2020)
        downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
        downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
        downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
        downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
        downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
        downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
        downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
        downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
        downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
        downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
        *** TASK COMPLETE ***
        [root@centos7 ~]#ls /var/lib/cobbler/loaders
        COPYING.elilo     COPYING.yaboot  grub-x86_64.efi  menu.c32    README
        COPYING.syslinux  elilo-ia64.efi  grub-x86.efi     pxelinux.0  yaboot
        [root@centos7 ~]#tree /var/lib/tftpboot/
        /var/lib/tftpboot/
        ├── boot
        ├── etc
        ├── grub
        ├── images
        ├── images2
        ├── ppc
        ├── pxelinux.cfg
        └── s390x
        
        8 directories, 0 files
        [root@centos7 ~]#cobbler sync
        task started: 2020-02-10_163219_sync
        task started (id=Sync, time=Mon Feb 10 16:32:19 2020)
        running pre-sync triggers
        cleaning trees
        removing: /var/lib/tftpboot/grub/images
        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 /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
        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 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.manage_genders
        running python trigger cobbler.modules.scm_track
        running shell triggers from /var/lib/cobbler/triggers/change/*
        *** TASK COMPLETE ***
        [root@centos7 ~]#tree /var/lib/tftpboot/
        /var/lib/tftpboot/
        ├── boot
        │?? └── grub
        │??     └── menu.lst
        ├── etc
        ├── grub
        │?? ├── efidefault
        │?? ├── grub-x86_64.efi
        │?? ├── grub-x86.efi
        │?? └── images -> ../images
        ├── images
        ├── images2
        ├── memdisk
        ├── menu.c32
        ├── ppc
        ├── pxelinux.0
        ├── pxelinux.cfg
        │?? └── default
        ├── s390x
        │?? └── profile_list
        └── yaboot
        
        10 directories, 10 files
        
        實現dhcp服務
        #修改dhcp的模版文件下面的行,用來生成dhcp的配置文件
        [root@centos7 ~]#vim /etc/cobbler/dhcp.template
        subnet 192.168.100.0 netmask 255.255.255.0 {
             option routers             192.168.100.1;
             option domain-name-servers 180.76.76.76,223.6.6.6;
             option subnet-mask         255.255.255.0;
             range  dynamic-bootp       192.168.100.1 192.168.100.200;
        
        [root@centos7 ~]#cobbler sync 
        [root@centos7 ~]#systemctl start dhcpd 
        修改菜單的標題信息
        [root@centos7 ~]#vim /etc/cobbler/pxe/pxedefault.template
        MENU TITLE Cobbler | http://www.magedu.com/ 
        
        [root@centos7 ~]#cobbler sync
        [root@centos7 ~]#cat /var/lib/tftpboot/pxelinux.cfg/default
        DEFAULT menu
        PROMPT 0
        MENU TITLE Cobbler | http://www.magedu.com/
        TIMEOUT 200
        TOTALTIMEOUT 6000
        ONTIMEOUT local
        
        LABEL local
                MENU LABEL (local)
                MENU DEFAULT
                LOCALBOOT -1
        
        MENU end
        導入CentOS系統的安裝文件,生成相應的YUM源
        [root@centos7 ~]#cobbler import --name=centos-8.1-x86_64 --path=/misc/cd --arch=x86_64
        [root@centos7 ~]#mount /dev/sr1 /mnt
        mount: /dev/sr1 is write-protected, mounting read-only
        [root@centos7 ~]#cobbler import --name=centos-7.7-x86_64 --path=/mnt --arch=x86_64
        [root@centos7 ~]#du -sh /var/www/cobbler/ks_mirror/*
        11G /var/www/cobbler/ks_mirror/centos-7.7-x86_64
        7.2G    /var/www/cobbler/ks_mirror/centos-8.1-x86_64
        12K /var/www/cobbler/ks_mirror/config
        [root@centos7 ~]#cobbler distro list
           centos-7.7-x86_64
           centos-8.1-x86_64
        
        [root@centos7 ~]#cobbler profile list
           centos-7.7-x86_64
           centos-8.1-x86_64
        
        #默認生成的是最小化安裝

        實戰案例:CentOS 7 實現基于cobbler實現自動化安裝插圖

        準備 kickstart文件,并關聯至指定的YUM源
        [root@centos7 ~]#vim /var/lib/cobbler/kickstarts/centos8.cfg
        [root@centos7 ~]#cat /var/lib/cobbler/kickstarts/centos8.cfg
        ignoredisk --only-use=sda
        zerombr
        text
        reboot
        clearpart --all --initlabel
        selinux --disabled
        firewall --disabled
        url --url=tree   #注意此行必須指定
        keyboard --vckeymap=us --xlayouts='us'
        lang en_US.UTF-8
        network  --bootproto=dhcp --device=ens160 --ipv6=auto --activate
        network  --hostname=centos8.magedu.com
        rootpw --iscrypted6nOPs5JTMlP4mhQeWR/o62B6SXAh3RR.zrZ3U0X4xYX9/u5nSLrR/vqCB6kdO2XFfMk2a4yAgrHJQpXK/e4jzRb0jiLBv2nFMXaBjB/
        firstboot --enable
        skipx
        services --disabled="chronyd"
        timezone Asia/Shanghai --isUtc --nontp
        user --name=wang --password=6oUfb/02CWfLb5l8f$sgEZeR7c7DpqfpmFDH6huSmDbW1XQNR4qKl2EPns.gOXqlnAIgv9pTogtFVaDtEpMOC.SWXKYqxfVtd9MCwxb1 --iscrypted --gecos="wang"
        part / --fstype="xfs" --ondisk=sda --size=102400
        part /data --fstype="xfs" --ondisk=sda --size=51200
        part swap --fstype="swap" --ondisk=sda --size=2048
        part /boot --fstype="ext4" --ondisk=sda --size=1024
        %packages
        @^minimal-environment
        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
        
        #將kickstart文件,關聯指定的YUM源和生成菜單列表
        [root@centos7 ~]#cobbler profile add --name=CentOS-8.1_test --distro=CentOS-8.1-x86_64 --kickstart= /var/lib/cobbler/kickstarts/centos8.cfg
        [root@centos7 ~]#cobbler profile add --name=CentOS-7.7_test --distro=CentOS-7.7-x86_64 --kickstart= /var/lib/cobbler/kickstarts/centos7.cfg
        
        #刪除默認生成的菜單
        [root@centos7 ~]#cobbler profile remove --name=centos-8.1-x86_64
        [root@centos7 ~]#cobbler profile remove --name=centos-7.7-x86_64
        
        [root@centos7 ~]#cobbler profile list
           CentOS-7.7_test
           CentOS-8.1_test
        
        #刪除默認的菜單列表
        [root@centos7 ~]#cobbler profile remove --name=CentOS8.0-x86_64
        測試客戶端基于Cobbler實現自動安裝

        實戰案例:CentOS 7 實現基于cobbler實現自動化安裝插圖1

        實現cobbler 的web管理
        [root@centos7 ~]#yum -y install  cobbler-web
        [root@centos7 ~]#systemctl restart httpd 

        通過瀏覽器訪問下面地址:https://cobblerserver/cobbler_web

        實戰案例:CentOS 7 實現基于cobbler實現自動化安裝插圖2

        用戶名:cobbler,默認密碼:cobbler

        實戰案例:CentOS 7 實現基于cobbler實現自動化安裝插圖3

        實戰案例:CentOS 7 實現基于cobbler實現自動化安裝插圖4

        創建cobbler的自定義的web用戶
        [root@centos7 ~]#cat /etc/cobbler/users.digest
        cobbler:Cobbler:a2d6bae81669d707b72c0bd9806e01f3
        [root@centos7 ~]#htdigest -c /etc/cobbler/users.digest Cobbler admin 
        Adding password for admin in realm Cobbler.
        New password: 
        Re-type new password: 
        [root@centos7 ~]#cat /etc/cobbler/users.digest
        admin:Cobbler:461941848a17e1b412f94c100a79bf75
        3
        [root@centos7 ~]#htdigest  /etc/cobbler/users.digest Cobbler admin2
        Adding user admin2 in realm Cobbler
        New password: 
        Re-type new password: 
        [root@centos7 ~]#cat /etc/cobbler/users.digest
        admin:Cobbler:461941848a17e1b412f94c100a79bf75
        3
        admin2:Cobbler:8e3ab6cc196fac11dcf0512c200a672f

        使用上面命令創建的用戶登錄web界面

        實戰案例:CentOS 7 實現基于cobbler實現自動化安裝插圖5

        登錄成功后,可以看到下面界面

        實戰案例:CentOS 7 實現基于cobbler實現自動化安裝插圖6

        本文鏈接:http://www.abandonstatusquo.com/36158.html

        故障排查Trouble Shooting

        網友評論comments

        發表評論

        您的電子郵箱地址不會被公開。

        暫無評論

        Copyright ? 2012-2022 YUNWEIPAI.COM - 運維派 京ICP備16064699號-6
        掃二維碼
        掃二維碼
        返回頂部
        十分钟免费观看视频高清下载