zoukankan      html  css  js  c++  java
  • cobbler一键多台安装服务


    环境准备

    • 使用NAT链接模式,勾选dhcp自动分配,在网卡配置文件中修改为dhcp自动获取IP,开机自启动,重启网络服务可以ping通百度

    关闭防火墙,selinux,配置网络源

    [root@bad ~]# systemctl stop firewalld  //关闭防火墙
    [root@bad yum.repos.d]# cd /etc/yum.repos.d/
    //获取163网络源
    [root@bad 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  Speed
    100  1572  100  1572    0     0    457      0  0:00:03  0:00:03 --:--:--   457
    [root@bad yum.repos.d]# ls
    163.repo  yum.repo
    [root@bad yum.repos.d]# sed -i 's/$releasever/7/g' 163.repo   //替换版本号为当前系统的主版本号
    [root@bad yum.repos.d]# sed -i 's/^enabled=.*/enabled=1/g' 163.repo   //启用163.repo源
    [root@bad yum.repos.d]# yum install -y epel-release   //下载网络源
    //安装cobbler及相关软件包
    [root@bad yum.repos.d]# yum -y install httpd dhcp tftp python-ctypes cobbler
    

    使用阿里源

    [root@bad ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
    --2019-11-28 05:07:03--  http://mirrors.aliyun.com/repo/epel-7.repo
    。。。
    100%[=====================================>] 664         --.-K/s   in 0s      
    
    2019-11-28 05:07:03 (152 MB/s) - ‘/etc/yum.repos.d/epel.repo’ saved [664/664]
    

    安装相关软件包,并启动服务

    [root@bad ~]# yum -y install cobbler cobbler-web pykickstart debmirror httpd dhcp tftp-server xinetd syslinux rsync
    [root@bad ~]# systemctl start httpd   //启动http服务
    [root@bad ~]# systemctl enable httpd   //设置开机自启动
    ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
    [root@bad ~]# systemctl start cobblerd  //启动cobbler
    [root@bad ~]# systemctl enable cobblerd   //设置开机自启动
    ln -s '/usr/lib/systemd/system/cobblerd.service' '/etc/systemd/system/multi-user.target.wants/cobblerd.service'
    

    修改配置文件

    //修改server的ip地址为本机的ip
    [root@bad ~]# sed -i 's/^server: 127.0.0.1/server: 192.168.10.24/' /etc/cobbler/settings   //修改server的ip地址为本机的ip
    //修改tftp的ip地址为本机ip
    [root@bad ~]# sed -i 's/^next_server: 127.0.0.1/next_server: 192.168.10.24/' /etc/cobbler/settings   //修改tftp的ip地址为本机ip
    //开启tftp
    [root@bad ~]# sed -i '/disable/s/yes/no/g' /etc/xinetd.d/tftp
    

    下载缺失文件

    [root@bad ~]# systemctl restart cobblerd   //重新启动cobbler
    [root@bad ~]# systemctl restart httpd   //重新启动httpd
    [root@bad ~]# cobbler get-loaders   //下载缺失的文件
    task started: 2019-11-28_054701_get_loaders
    task started (id=Download Bootloader Content, time=Thu Nov 28 05:47:01 2019)
    path /var/lib/cobbler/loaders/README already exists, not overwriting existing content, use --force if you wish to update
    。。。
    path /var/lib/cobbler/loaders/grub-x86_64.efi already exists, not overwriting existing content, use --force if you wish to update
    *** TASK COMPLETE ***
    
    如果下载缺失文件失败,尝试以下步骤,并重新启动cobbler和http
    yum -y install syslinux   //安装引导加载程序
    cp /usr/share/syslinux/menu.c32 /var/lib/cobbler/loaders/
    cp /usr/share/syslinux/pxelinux.0 /var/lib/cobbler/loaders/
    

    启动rsync,设置开机自启动,修改配置文件,添加密码

    [root@bad ~]# systemctl start rsyncd   //启动rsync
    [root@bad ~]# systemctl enable rsyncd   //设置开机自动启动
    ln -s '/usr/lib/systemd/system/rsyncd.service' '/etc/systemd/system/multi-user.target.wants/rsyncd.service'
    [root@bad ~]# openssl passwd -1 -salt "$RANDOM" '123'   //生成加密密码
    $1$25895$eKsGdiCzUnpI95DNkOgkN.   //加密的密码
    [root@bad ~]# vim /etc/cobbler/settings   //将随机密码写入配置文件中
    

    在这里插入图片描述

    重新启动cobler,检查配置

    [root@bad ~]# systemctl restart cobblerd   //重新启动cobbler
    [root@bad ~]# ss -antl   //查看已开启的端口
    State       Recv-Q Send-Q       Local Address:Port         Peer Address:Port 
    LISTEN      0      100              127.0.0.1:25                      *:*     
    LISTEN      0      128                      *:59998                   *:*     
    LISTEN      0      5                127.0.0.1:25151                   *:*     
    LISTEN      0      64                       *:2049                    *:*     
    。。。
    [root@bad ~]# cobbler check   //核对当前设置是否有误
    The 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 repositories  
    2 : fencing tools were not found, and are required to use the (optional) power management features. 
    以上两个问题可以忽略
    Restart cobblerd and then run 'cobbler sync' to apply changes.
    [root@bad ~]# reboot   //重启
    

    再次查看防火墙,修改相关配置文件

    [root@bad ~]# systemctl status firewalld   //查看防火墙是否关闭
    firewalld.service - firewalld - dynamic firewall daemon
       Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled)
       Active: inactive (dead)
    
    //配置cobbler dhcp 修改cobbler配置文件,让cobbler控制dhcp
    [root@bad ~]# sed -i '/^manage_dhcp/s/0/1/g' /etc/cobbler/settings 
    [root@bad ~]# sed -n '/^manage_dhcp/p' /etc/cobbler/settings
    manage_dhcp: 1
    [root@bad ~]# vim /etc/cobbler/dhcp.template   //配置dhcp
    subnet 192.168.10.0 netmask 255.255.255.0 {
         option routers             192.168.10.24;
         option domain-name-servers 192.168.10.2;
         option subnet-mask         255.255.255.0;
         range dynamic-bootp        192.168.10.100 192.168.10.254;
         default-lease-time         21600;
         max-lease-time             43200;
         next-server                $next_server;
    [root@bad ~]# systemctl restart cobblerd   //重启服务
    [root@bad ~]# cobbler sync   //完成sync同步配置
    task started: 2019-12-14_103711_sync
    task started (id=Sync, time=Sat Dec 14 10:37:11 2019)
    running pre-sync triggers
    。。。
    running python trigger cobbler.modules.scm_track
    running shell triggers from /var/lib/cobbler/triggers/change/*
    *** TASK COMPLETE ***
    [root@bad ~]# 
    

    在这里插入图片描述

    导入镜像

    [root@bad ~]# netstat -anulp | grep dhcp   //检查dhcp是否正常
    udp        0      0 0.0.0.0:67              0.0.0.0:*                           2329/dhcpd          
    [root@bad ~]# mount /dev/cdrom /mnt/   //挂载光驱
    mount: /dev/sr0 is write-protected, mounting read-only
    [root@bad ~]# cobbler list   //查看cobbler镜像列表
    distros:
       Centos-7-x86_64
    profiles:
       Centos-7-x86_64
    systems:
    。。。
    

    创建ks部署脚本

    //创建kickstarts自动安装脚本
    [root@bad ~]# cobbler import --path=/mnt --name=Centos-7 --arch=x86_64
    task started: 2019-12-14_104002_import
    task started (id=Media import, time=Sat Dec 14 10:40:02 2019)
    Found a candidate signature: breed=redhat, version=rhel6
    。。。
    creating new profile: Centos-7-x86_64
    associating repos
    checking for rsync repo(s)
    checking for rhn repo(s)
    checking for yum repo(s)
    。。。
    looking for /var/www/cobbler/ks_mirror/Centos-7-x86_64/addons/ResilientStorage/repodata/*comps*.xml
    Keeping repodata as-is :/var/www/cobbler/ks_mirror/Centos-7-x86_64/addons/ResilientStorage/repodata
    *** TASK COMPLETE ***
    

    编辑ks脚本

    //编辑此文件,把以下内容写入到文件中
    [root@bad ~]# vim /var/lib/cobbler/kickstarts/Centos-7-x86_64.ks
    install  
    keyboard 'us'  
    rootpw --iscrypted $1$m1pE0DG6$vALBphGGynqvUzfJaWZ6U1  
    
    url --url="$tree"  
    lang en_US  
    firewall --disabled  
    auth  --useshadow  --passalgo=sha512  
    graphical  
    firstboot --disable  
    
    selinux --disabled  
    
    network  --bootproto=dhcp --device=eth0  
    network  --bootproto=dhcp --device=eth1  
    
    reboot  
    
    timezone Asia/Shanghai  
    bootloader --location=mbr  
    zerombr  
    
    clearpart --all --initlabel  
    
    part /boot --asprimary --fstype="ext4" --size=200  
    part swap --fstype="swap" --size=1024  
    part / --fstype="ext4" --grow --size=1  
    %packages  
    @base  
    @core  
    @compat-libraries  
    @debugging  
    @development  
    @gnome-desktop  
    @X Window System  
    %end  
    

    检查语法是否错误

    [root@bad ~]# cobbler validateks   //检查语法是否错误
    task started: 2019-12-14_105811_validateks
    task started (id=Kickstart Validation, time=Sat Dec 14 10:58:11 2019)
    ----------------------------
    osversion: rhel7
    checking url: http://192.168.10.24/cblr/svc/op/ks/profile/Centos-7-x86_64
    running: /usr/bin/ksvalidator -v "rhel7" "http://192.168.10.24/cblr/svc/op/ks/profile/Centos-7-x86_64"
    received on stdout: 
    received on stderr: 
    *** all kickstarts seem to be ok ***
    *** TASK COMPLETE ***
    [root@bad ~]# cobbler profile list   //查看当前cobbler有哪些配置文件
       Centos-7-x86_64
    
    //修改profile将我们新建的ks文件设为默认的kickstarts安装文件 
    [root@bad ~]# cobbler profile edit --name Centos-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos-7-x86_64.ks
    
    //配合网卡名称为传统网卡名称eth0
    [root@bad ~]# cobbler profile edit --name Centos-7-x86_64 --kopts='net.ifnames=0 biosdevname=0'
    [root@bad ~]# cobbler profile report   //配合网卡名称为传统网卡名称eth0
    Name                           : Centos-7-x86_64
    TFTP Boot Files                : {}
    Comment                        : 
    DHCP Tag                       : default
    Distribution                   : Centos-7-x86_64
    Enable gPXE?                   : 0
    Enable PXE Menu?               : 1
    。。。
    

    同步cobbler,重新启动服务

    [root@bad ~]# cobbler sync   //同步cobbler
    task started: 2019-12-14_110250_sync
    task started (id=Sync, time=Sat Dec 14 11:02:50 2019)
    running pre-sync triggers
    。。。
    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@bad ~]# systemctl restart xinetd   //重新启动超级守护进程
    [root@bad ~]# systemctl restart cobblerd   //重新启动cobbler
    [root@bad ~]# systemctl restart httpd   //重新启动http
    [root@bad ~]# ss -antl   //查看已经开启的端口
    State       Recv-Q Send-Q   Local Address:Port     Peer Address:Port 
    LISTEN      0      100          127.0.0.1:25                  *:*     
    LISTEN      0      128                  *:48189               *:*     
    LISTEN      0      5            127.0.0.1:25151               *:*     
    。。。
    [root@bad ~]# 
    

    新建一台虚拟机

    • 与服务器端保持一致,选择NAT模式(新建过程略)

    在这里插入图片描述

    • 正在安装

    在这里插入图片描述

    • 安装完成

    在这里插入图片描述

     

    以上内容均属原创,如有不详或错误,敬请指出。
    
    本文作者: 坏坏
  • 相关阅读:
    微信小程序跳转传参参数丢失?
    微信小程序订阅消息,我踩过的坑都在这里了!
    CSS 了解一下
    简单地认识一下 HTML
    我和前端的猿粪,了解一下我眼中的前端。
    微信小程序如何发送订阅消息,正确姿势来了,建议收藏!
    微信小程序新服务消息推送 —— 订阅消息
    微信小程序 wxml 文件中如何让多余文本省略号显示?
    如何制作国旗头像,微信小程序利用 canvas 绘制挂件头像
    Vue组件中的Data为什么是函数。
  • 原文地址:https://www.cnblogs.com/bad5/p/13022654.html
Copyright © 2011-2022 走看看