阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Cobbler自动化集群Linux系统安装

215次阅读
没有评论

共计 13939 个字符,预计需要花费 35 分钟才能阅读完成。

Cobbler: 是一个快速网络安装 Linux 的工具,使用简单的命令即可完成 PXE 网络安装环境的配置,同时还可以管理 DHCP,DNS,以及 yum 包镜像。Cobbler 支持命令行管理,web 界面管理

主要由 Repository,Distribution,Profile: 各部分组成分别是

Repository:mirror url

Distribution:kernek ,initrd

Profile:distribution,kickstart file ,repositories

实验内容

1.1 安装实验所需要的程序

    [root@node1 ~]# yum install cobbler  pykickstart debmirror

在安装 cobbler 时会自动安装 httpd 程序

1.2 安装完成后启动

    [root@node1 ~]# service httpd start   
    Starting httpd:   
    [root@node1 ~]# service cobblerd start   
    Starting cobbler daemon:         

1.3 检测 cobbler 存在哪些错误

[root@node1 ~]# cobbler check

    1 : The ‘server’ field in /etc/cobbler/settings must be set to something other than loc    alhost, or kickstarting features will not work.  This should be a resolvable hostname o    r 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 th    e PXE network.
    3 : some network boot-    loaders are missing from /var/lib/cobbler/loaders, you may ru    n ‘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.
    4 : change ‘disable’ to ‘no’ in /etc/xinetd.d/rsync
    5 : comment ‘dists’ on /etc/debmirror.conf for proper debian support
    6 : comment ‘arches’ on /etc/debmirror.conf for proper debian support
    7 : The default password used by the sample templates for newly installed machines (def    ault_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
    8 : fencing tools were not found, and are required to use the (optional) power manageme    nt features. install cman or fence-agents to use them
    Restart cobblerd and then run ‘cobbler sync’ to apply changes.

下来一个个排错

1,修改 /etc/cobbler/settings 文件中的 server 参数值为提供 cobbler 服务的主机相应的 IP 地址或主机名和 next_server 参数的值为 PXE 服务的主机相应的 IP 地址   

    server=172.16.18.1
    next_server=172.16.18.1

2,生成密码,替换默认密码

    [root@node1 ~]# openssl passwd -1 -salt $(openssl rand -hex 4)”
    Password:      $1$d69ce09e$UNrtVcVkT.Rd5E6bSVxx8/
    default_password_crypted: ” $1$d69ce09e$UNrtVcVkT.Rd5E6bSVxx8/”

3,复制 /usr/share/syslinux/* 所有文件去 /var/lib/cobbler/loaders/ 目录中

    [root@node1 ~]# cp -r  /usr/share/syslinux/* /var/lib/cobbler/loaders/

4,注释 /etc/debmirror.conf 中的两个参数

    #@dists=”sid”;
    #@arches=”i386″;

5,安装相应的程序包

    yum install cman fence-agents

6,chkconfig rsync on

7,启动,检测

    [root@node1 ~]# service cobblerd start

8,cobbler check 检测是否还有错误

    The following are potential configuration items that you may want to fix:
    1 : some network boot-    loaders are missing from /var/lib/cobbler/loaders, you may ru    n ‘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.
    Restart cobblerd and then run ‘cobbler sync’ to apply changes.

此错误可以忽略了,我们已经将所需要的文件都复制过去了。

此时环境就算配置好了

2.1 下来需要配置 pxe 所需要的服务。DHCP TFTP RSYNC DNS, 其中 dhcp tftp rsync 为必须
    [root@node1 ~]# yum install dhcp
    [root@node1 ~]# service dhcpd start  Starting dhcpd:                        [OK]

复制 /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample 到 /etc/dhcp/dhcpd.conf 覆盖原有文件,编辑

  [root@node1 ~]# vim /etc/dhcp/dhcpd.conf
    option domain-name “aolens.com”;
    option domain-name-servers 172.16.18.1 ;
    default-lease-time 10000;
    max-lease-time 20000;
    log-facility local7;
    subnet 172.16.0.0 netmask 255.255.0.0 {
      range 172.16.18.100 172.16.18.110;
      option routers 172.16.18.1;
    }
    next-server 172.16.18.1;
    filename=”pxelinux.0″;

其他的全注释掉

    [root@node1 ~]# service dhcpd restart 
    Shutting down dhcpd:                                      [OK] 
    Starting dhcpd:                                          [OK]

2.2 启动 tftp 服务器
    [root@node1 ~]#  chkconfig tftp on
    [root@node1 ~]#  service xinetd restart
3.1 首先添加 distro    , 这一步是定义 ramdisk 和内核文件。我们直接导入完整的光盘镜像。

我们先将光盘镜像装载上,挂载于 /mnt 下

    [root@node1 ~]# mount /dev/cdrom /mnt/
对光盘镜像进行导入
    cobbler import –name=CentOS-6.5-x86_64 –path=/mnt
导入成功后查看
    [root@node1 ~]# cobbler distro list  centos-6.5-x86_64
发现一个 distro

3.2 提供一个 kickstart 文件

启动 kickstart 工具需要安装

    yum  install system-config-kickstart

然后运行 system-config-kickstart

Cobbler 自动化集群 Linux 系统安装

运维自动化之 Cobbler 安装配置 http://www.linuxidc.com/Linux/2013-03/81575.htm

RHEL5.5 下 Cobbler 的配置 http://www.linuxidc.com/Linux/2013-06/86115.htm

运维自动化部署 Cobbler 之服务安装篇 http://www.linuxidc.com/Linux/2013-02/80133.htm

利用 Cobbler 批量快速网络安装 CentOS http://www.linuxidc.com/Linux/2012-12/75838.htm

CentOS 6.3 上安装部署 Cobbler http://www.linuxidc.com/Linux/2012-10/72094.htm

Cobbler 批量部署 Linux 系统 http://www.linuxidc.com/Linux/2014-02/97259.htm

具体的操作过程去不做演示,将生成的 kickstart 文件放在 /var/lib/cobbler/kickstarts/ 下

要确保 url –url=”http://172.16.0.1/cobbler/ks_mirror/centos-6.5-x86_64/” 指向正确的 yum 源,也就是导入的光盘文件

也可以直接复制系统中的 /root/anaconda-ks.cfg 做修改使用。

下边提供一个 kickstart 文件供大家参考

    #platform=x86, AMD64, or Intel EM64T
    firewall –disabled
    # Install OS instead of upgrade
    install
    # Use network installation
    url –url=”http://172.16.0.1/cobbler/ks_mirror/centos-6.5-x86_64/”
    # Root password
    rootpw –iscrypted $1$iRHppr42$VMesh73wBqhUTjKp6OYOD.
    # System authorization information
    auth –useshadow –passalgo=sha512
    # Use text mode install
    text
    firstboot –disable
    # System keyboard
    keyboard us
    # SELinux configuration
    selinux –disabled
    # Reboot after installation
    reboot
    # System timezone
    timezone Asia/Shanghai
    # System bootloader configuration
    part /boot –fstype=”ext4″ –size=200
    part pv.008 –size=61440
    logvol swap –name=swap –vgname=vg0 –size=2048
    logvol /usr –fstype=ext4 –name=usr –vgname=vg0 –size=10240
    logvol /var –fstype=ext4 –name=var –vgname=vg0 –size=20480
    %post
    sed -i ‘1,$s@id:[0-9]:initdefault:@id:3:initdefault:@g’ /etc/inittab
    [! -d /root/.ssh] && mkdir /root/.ssh && chmod og=— /root/.ssh
    cat >> /root/.ssh/authorized_keys > /etc/hosts
    %end
    %packages
    @base
    @basic-desktop
    @chinese-support
    @client-mgmt-tools
    @core
    @desktop-platform
    @fonts
    @general-desktop
    @graphical-admin-tools
    @legacy-x
    @network-file-system-client
    @perl-runtime
    @remote-desktop-clients
    @x11
    func
    lftp
    ibus-table-cangjie
    ibus-table-erbi
    ibus-table-wubi
    puppet
    %end

3.2 创建 profile

profile 来为 cobbler 提供所需要安装配置,即在 distro 的基础上通过提供 kickstart 文件来生成一个特定的系统安装配置。distro 的 profile 可以出现在 PXE 的引导菜单中作为安装的选择之一。
    [root@node1 ~]# cobbler profile add –name=centos-6.5-x86_64-basic –distro=centos-6.5-x86_64 –kickstart=/var/lib/cobbler/kickstarts/centos6.x86_64.cfg
查看 profile 文件是否创建成功,每一个 kickstart 都可以创建一个 profile 来安装不同配置的程序
    [root@node1 ~]# cobbler profile list  centos-6.5-x86-basic  centos-6.5-x86_64
    [root@node1 ~]# cobbler sync    同步一下

更多详情见请继续阅读下一页的精彩内容:http://www.linuxidc.com/Linux/2014-10/107956p2.htm

4.1 创建一个新的虚拟机

将接口都调为相同的定制端口

打开新建的虚拟机,就可以发现有两个选项,其中 basic 就是我们提供 kickstart 文件的,选定,就可以安装下去了。

Cobbler 自动化集群 Linux 系统安装

5.1 配置 cobbler_web 界面配置方式

首先需要安装 cobbler_web

配置认证方式;
    [root@node1 ~]# vim /etc/cobbler/modules.conf
    [authentication]
    module = authn_pam                        #修改此一项即可
    [root@node1 ~]# useradd cblradmin        #创建用户
    [root@node1 ~]# passwd cblradmin        #创建密码
编辑用户配置文件,配置下边的项
    [root@node1 ~]# vim /etc/cobbler/users.conf
    [admins]
    admin = “cblradmin”
重启 cobbler 和 httpd 服务
    [root@node1 ~]# service cobblerd restart 
    Stopping cobbler daemon:          [OK] 
    Starting cobbler daemon:          [OK] 
    [root@node1 ~]# service httpd restart 
    Stopping httpd:                  [OK] 
    httpd:                            [OK]
访问 cobbler_web 页面,并登陆

Cobbler 自动化集群 Linux 系统安装

Cobbler 自动化集群 Linux 系统安装

Cobbler: 是一个快速网络安装 Linux 的工具,使用简单的命令即可完成 PXE 网络安装环境的配置,同时还可以管理 DHCP,DNS,以及 yum 包镜像。Cobbler 支持命令行管理,web 界面管理

主要由 Repository,Distribution,Profile: 各部分组成分别是

Repository:mirror url

Distribution:kernek ,initrd

Profile:distribution,kickstart file ,repositories

实验内容

1.1 安装实验所需要的程序

    [root@node1 ~]# yum install cobbler  pykickstart debmirror

在安装 cobbler 时会自动安装 httpd 程序

1.2 安装完成后启动

    [root@node1 ~]# service httpd start   
    Starting httpd:   
    [root@node1 ~]# service cobblerd start   
    Starting cobbler daemon:         

1.3 检测 cobbler 存在哪些错误

[root@node1 ~]# cobbler check

    1 : The ‘server’ field in /etc/cobbler/settings must be set to something other than loc    alhost, or kickstarting features will not work.  This should be a resolvable hostname o    r 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 th    e PXE network.
    3 : some network boot-    loaders are missing from /var/lib/cobbler/loaders, you may ru    n ‘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.
    4 : change ‘disable’ to ‘no’ in /etc/xinetd.d/rsync
    5 : comment ‘dists’ on /etc/debmirror.conf for proper debian support
    6 : comment ‘arches’ on /etc/debmirror.conf for proper debian support
    7 : The default password used by the sample templates for newly installed machines (def    ault_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
    8 : fencing tools were not found, and are required to use the (optional) power manageme    nt features. install cman or fence-agents to use them
    Restart cobblerd and then run ‘cobbler sync’ to apply changes.

下来一个个排错

1,修改 /etc/cobbler/settings 文件中的 server 参数值为提供 cobbler 服务的主机相应的 IP 地址或主机名和 next_server 参数的值为 PXE 服务的主机相应的 IP 地址   

    server=172.16.18.1
    next_server=172.16.18.1

2,生成密码,替换默认密码

    [root@node1 ~]# openssl passwd -1 -salt $(openssl rand -hex 4)”
    Password:      $1$d69ce09e$UNrtVcVkT.Rd5E6bSVxx8/
    default_password_crypted: ” $1$d69ce09e$UNrtVcVkT.Rd5E6bSVxx8/”

3,复制 /usr/share/syslinux/* 所有文件去 /var/lib/cobbler/loaders/ 目录中

    [root@node1 ~]# cp -r  /usr/share/syslinux/* /var/lib/cobbler/loaders/

4,注释 /etc/debmirror.conf 中的两个参数

    #@dists=”sid”;
    #@arches=”i386″;

5,安装相应的程序包

    yum install cman fence-agents

6,chkconfig rsync on

7,启动,检测

    [root@node1 ~]# service cobblerd start

8,cobbler check 检测是否还有错误

    The following are potential configuration items that you may want to fix:
    1 : some network boot-    loaders are missing from /var/lib/cobbler/loaders, you may ru    n ‘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.
    Restart cobblerd and then run ‘cobbler sync’ to apply changes.

此错误可以忽略了,我们已经将所需要的文件都复制过去了。

此时环境就算配置好了

2.1 下来需要配置 pxe 所需要的服务。DHCP TFTP RSYNC DNS, 其中 dhcp tftp rsync 为必须
    [root@node1 ~]# yum install dhcp
    [root@node1 ~]# service dhcpd start  Starting dhcpd:                        [OK]

复制 /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample 到 /etc/dhcp/dhcpd.conf 覆盖原有文件,编辑

  [root@node1 ~]# vim /etc/dhcp/dhcpd.conf
    option domain-name “aolens.com”;
    option domain-name-servers 172.16.18.1 ;
    default-lease-time 10000;
    max-lease-time 20000;
    log-facility local7;
    subnet 172.16.0.0 netmask 255.255.0.0 {
      range 172.16.18.100 172.16.18.110;
      option routers 172.16.18.1;
    }
    next-server 172.16.18.1;
    filename=”pxelinux.0″;

其他的全注释掉

    [root@node1 ~]# service dhcpd restart 
    Shutting down dhcpd:                                      [OK] 
    Starting dhcpd:                                          [OK]

2.2 启动 tftp 服务器
    [root@node1 ~]#  chkconfig tftp on
    [root@node1 ~]#  service xinetd restart
3.1 首先添加 distro    , 这一步是定义 ramdisk 和内核文件。我们直接导入完整的光盘镜像。

我们先将光盘镜像装载上,挂载于 /mnt 下

    [root@node1 ~]# mount /dev/cdrom /mnt/
对光盘镜像进行导入
    cobbler import –name=CentOS-6.5-x86_64 –path=/mnt
导入成功后查看
    [root@node1 ~]# cobbler distro list  centos-6.5-x86_64
发现一个 distro

3.2 提供一个 kickstart 文件

启动 kickstart 工具需要安装

    yum  install system-config-kickstart

然后运行 system-config-kickstart

Cobbler 自动化集群 Linux 系统安装

运维自动化之 Cobbler 安装配置 http://www.linuxidc.com/Linux/2013-03/81575.htm

RHEL5.5 下 Cobbler 的配置 http://www.linuxidc.com/Linux/2013-06/86115.htm

运维自动化部署 Cobbler 之服务安装篇 http://www.linuxidc.com/Linux/2013-02/80133.htm

利用 Cobbler 批量快速网络安装 CentOS http://www.linuxidc.com/Linux/2012-12/75838.htm

CentOS 6.3 上安装部署 Cobbler http://www.linuxidc.com/Linux/2012-10/72094.htm

Cobbler 批量部署 Linux 系统 http://www.linuxidc.com/Linux/2014-02/97259.htm

具体的操作过程去不做演示,将生成的 kickstart 文件放在 /var/lib/cobbler/kickstarts/ 下

要确保 url –url=”http://172.16.0.1/cobbler/ks_mirror/centos-6.5-x86_64/” 指向正确的 yum 源,也就是导入的光盘文件

也可以直接复制系统中的 /root/anaconda-ks.cfg 做修改使用。

下边提供一个 kickstart 文件供大家参考

    #platform=x86, AMD64, or Intel EM64T
    firewall –disabled
    # Install OS instead of upgrade
    install
    # Use network installation
    url –url=”http://172.16.0.1/cobbler/ks_mirror/centos-6.5-x86_64/”
    # Root password
    rootpw –iscrypted $1$iRHppr42$VMesh73wBqhUTjKp6OYOD.
    # System authorization information
    auth –useshadow –passalgo=sha512
    # Use text mode install
    text
    firstboot –disable
    # System keyboard
    keyboard us
    # SELinux configuration
    selinux –disabled
    # Reboot after installation
    reboot
    # System timezone
    timezone Asia/Shanghai
    # System bootloader configuration
    part /boot –fstype=”ext4″ –size=200
    part pv.008 –size=61440
    logvol swap –name=swap –vgname=vg0 –size=2048
    logvol /usr –fstype=ext4 –name=usr –vgname=vg0 –size=10240
    logvol /var –fstype=ext4 –name=var –vgname=vg0 –size=20480
    %post
    sed -i ‘1,$s@id:[0-9]:initdefault:@id:3:initdefault:@g’ /etc/inittab
    [! -d /root/.ssh] && mkdir /root/.ssh && chmod og=— /root/.ssh
    cat >> /root/.ssh/authorized_keys > /etc/hosts
    %end
    %packages
    @base
    @basic-desktop
    @chinese-support
    @client-mgmt-tools
    @core
    @desktop-platform
    @fonts
    @general-desktop
    @graphical-admin-tools
    @legacy-x
    @network-file-system-client
    @perl-runtime
    @remote-desktop-clients
    @x11
    func
    lftp
    ibus-table-cangjie
    ibus-table-erbi
    ibus-table-wubi
    puppet
    %end

3.2 创建 profile

profile 来为 cobbler 提供所需要安装配置,即在 distro 的基础上通过提供 kickstart 文件来生成一个特定的系统安装配置。distro 的 profile 可以出现在 PXE 的引导菜单中作为安装的选择之一。
    [root@node1 ~]# cobbler profile add –name=centos-6.5-x86_64-basic –distro=centos-6.5-x86_64 –kickstart=/var/lib/cobbler/kickstarts/centos6.x86_64.cfg
查看 profile 文件是否创建成功,每一个 kickstart 都可以创建一个 profile 来安装不同配置的程序
    [root@node1 ~]# cobbler profile list  centos-6.5-x86-basic  centos-6.5-x86_64
    [root@node1 ~]# cobbler sync    同步一下

更多详情见请继续阅读下一页的精彩内容:http://www.linuxidc.com/Linux/2014-10/107956p2.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计13939字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中