1.yum国内源的安装与更新

1.1 备份原repo文件

cd /etc/yum.repo.d/
mkdir repo_bak
mv *.repo repo_bak

1.2 在centos中配置网易和阿里的开源镜像

wget http://mirrors.aliyun.com/repo/Centos-7.repo

wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

1.3 清除系统缓存并生成新的yum缓存

yum clean all

yum makecache

1.4 安装epel源

yum -y install epel-release

1.5 下载安装阿里开源镜像提供的epel

wget http://mirrors.aliyun.com/repo/epel-7.repo

1.6 再次清除系统缓存并生成新的yum缓存

yum clean all

yum makecache

1.7 查看系统可用的yum源和所有yum源

yum repolist enable

yum repolist all

2.搭建前操作

2.1 升级系统到最新

yum update -y

2.2 关闭selinux

vi /etc/selinux/config

将SELINUX=enforcing改为disabled

getenforce #检测selinux是否关闭

2.3 关闭防火墙

firewall-cmd --state #查看防火墙状态

systemctl stop firewalld.service #临时关闭防火墙

systemctl disable firewalld.service #禁止firewall开机启动

2.4 支撑环境安装

yum -y install cobbler httpd rsync tftp-server xinetd dhcp pykickstart fence-agents cobbler-web

3.配置Tftp,Http

vim /etc/xinetd.d/tftp
service tftp
{ disable = no #原为yes
socket_type = dgram
protocol = udp
wait = yes
user = root
server =/usr/sbin/in.tftpd
server_args = -B 1380 -v -s /var/lib/tftpboot
per_source = 11
cps = 100 2
flags = IPv4
}
vim /etc/httpd/conf/httpd.conf
ServerName 192.168.4.88:80

4.配置Cobbler

4.1 生成系统装机默认密码

如在kiskstart文件内设置密码则系统安装后root密码为kickstart文件内设置的密码)

openssl passwd -1 -salt 'testabc' '123456'

$1$random-p$mzxQ/Sx848sXgvfwJCoZM0 #生成root密码

4.2 修改settings文件

vim /etc/cobbler/settings
manage_dhcp: 1 ## 原为 0
manage_tftpd: 1
manage_rsync: 1 ## 原为 0
next_server: 192.168.4.88 ## 本机 IP
server: 192.168.4.88 ## 本机 IP
default_password_crypted: "$1$random-p$mzxQ/Sx848sXgvfwJCoZM0" ## 生成的 root 密码

4.3 cobbler-web用户及密码修改

cobbler-web登陆默认使用cobbler/cobbler登陆,用户及密码存放的位置在/etc/cobbler/users.conf和/etc/cobbler/users.digest 两个文件内

如想修改可以使用如下命令:

htdigest /etc/cobbler/users.digest "Cobbler" cobbler
Changing password for user cobbler in realm Cobbler
New password:
Re-type new password:

4.4 配置DHCP

只修改这个区域的IP地址即可

vim /etc/cobbler/dhcp.template
subnet 172.16.31.0 netmask 255.255.255.0 {
option routers 172.16.31.88;
#option domain-name-servers 192.168.1.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 172.16.31.100 172.16.31.120;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;

5.启动相关服务

5.1 启动服务

systemctl start httpd
systemctl start xinetd
systemctl start cobblerd
systemctl start rsyncd

5.2 将服务加入启动项

systemctl enable httpd
systemctl enable xinetd
systemctl enable cobblerd
systemctl enable rsyncd

6.检查配置

cobbler check

依照检查配置的要求完成每一步

执行cobbler get-loaders自动下载引导文件

cobbler get-loaders

注意 debmirror检查这一步可以忽略

7.同步操作

cobbler sync

8.重启cobbler服务

systemctl restart cobblerd
systemctl status cobblerd

9.注意事项

cobbler-web使用的python Django1.8.9实现,如果通过页面https://192.168.4.88/cobbler_web 登陆报“Internal Server Error”错误可以通过以下方式修复

#下载pip.py
    wget https://bootstrap.pypa.io/get-pip.py
#调用本地python运行pip.py脚本
    python get-pip.py
#安装pip
    pip install Django==1.8.9
#查看pip版本号
    python -c "import django; print(django.get_version())"
#重启httpd
    systemctl restart httpd

10.cobbler使用

10.1 下载安装镜像文件

wget http://mirrors.163.com/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-DVD-1810.iso

10.2导入安装源 #以下步骤均可在web页面完成

mkdir /mnt/CentOS-7-x86_64
mount -r CentOS-7-x86_64-DVD-1810.iso /mnt/CentOS-7-x86_64/
cobbler import --path=/mnt/CentOS-7-x86_64 --name=Centos-7-x86_64

输出信息略(Cobbler 将镜像拷贝一份放在 /var/www/cobbler/ks_mirror/Centos-7-x86_64 目录下)

(同时会创建一个名为 Centos-7-x86_64 的发布版本及 profile 文件)

[root@localhost ~]# cobbler list
distros:
CenOS-7-xx86_64-Minimal-x86_64
Centos-7-x86_64
profiles:
CenOS-7-xx86_64-Minimal-x86_64
Centos-7-x86_64
systems:
CHN-JS-1-IRON-07
repos:
images:
mgmtclasses:
packages:
files:

10.3 创建ks文件

vim /var/lib/cobbler/kickstarts/Centos7-base-install.cfg

#platform=x86, AMD64, or Intel EM64T
# System language
lang en_US
# System keyboard
keyboard us
# System timezone
timezone Asia/Shanghai
# Root password
rootpw --plaintext ezsvs@123
#Use text mode install
text
# Install OS instead of upgrade
install
#Use NFS installation Media
url --url=$tree
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr #version=DEVEL #Firewall configuration
firewall --disabled # System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
text # SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# Network information
$SNIPPET('network_config')
# Network information
#network --bootproto=dhcp --device=eth0 --onboot=on # Partition clearing information
#clearpart --all --initlabel
clearpart --drives=sda --all
# Disk partitioning information
#part /boot --asprimary --fstype="ext4" --ondisk=sda --size=200
#part swap --asprimary --fstype="swap" --ondisk=sda --size=4096
#part / --asprimary --fstype="xfs" --grow --ondisk=sda --size=1
part / --fstype="xfs" --ondisk=sda --size=20480
part swap --fstype="swap" --ondisk=sda --size=4096
part /boot --fstype="xfs" --ondisk=sda --size=500
part /data --fstype="xfs" --ondisk=sda --grow --asprimary --size=1 %pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end %post
$SNIPPET('post_install_network_config')
%end %packages
@base
@core
%end

目前已有编写好的文件供安装系统调用,注意ks文件中不能有中文,注释也不能有中文。

注意磁盘分区字段

clearpart --all --initlabel #系统初装删除所有分区

clearpart --drives=sda --all #系统重装只删除系统分区sda保留数据盘

10.4 关联ks文件

[root@localhost kickstarts]# cobbler distro list
CenOS-7-xx86_64-Minimal-x86_64
Centos-7-x86_64

这里有2个镜像,其中Centos-7-x86_64是我刚上传制作的

[root@localhost kickstarts]# cobbler profile report --name Centos-7-x86_64
Name : Centos-7-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : Centos-7-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm

这个镜像默认使用的ks文件为/var/lib/cobbler/kickstarts/sample_end.ks

cobbler profile add --name=Cenos-7-x86_64 --distro=Centos-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos7-base-install.cfg

再次查看关联成功

Kickstart : /var/lib/cobbler/kickstarts/Centos7-base-install.cfg

10.5 修改内核参数

[root@localhost ~]# cobbler profile edit --name=Centos-7-x86_64  --kopts='net.ifnames=0 biosdevname=0'
[root@localhost ~]# cobbler profile report --name=Centos-7-x86_64
Name : Centos-7-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : Centos-7-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {'biosdevname': '0', 'net.ifnames': '0'}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/Centos7-base-install.cfg
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm

10.6 同步配置完成操作

cobbler sync

至此,cobbler的安装和配置已经完成,连接待安装的服务器,将服务器启动引导PXE启动,即可开始安装系统。

11.附录

11.1 cobbler 常用命令列表

[root@localhost kickstarts]# cobbler --help
usage
=====
cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ...
[add|edit|copy|getks*|list|remove|rename|report] [options|--help]
cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help]
[root@localhost kickstarts]# cobbler profile --help
usage
=====
cobbler profile add
cobbler profile copy
cobbler profile dumpvars
cobbler profile edit
cobbler profile find
cobbler profile getks
cobbler profile list
cobbler profile remove
cobbler profile rename
cobbler profile report

cobbler distro add --name=string --kernel=path --initrd=path [--kopts=string] [--kopts-post=string] [--ksmeta=string] [--arch=x86|x86_64|ia64] [--breed=redhat|debian|suse] [--template-files=string]

cobbler profile add --name=string --distro=string [--kickstart=path] [--kopts=string] [--ksmeta=string] [--virt-file-size=gigabytes] [--virt-ram=megabytes] [--virt-type=string] [--virt-cpus=integer] [--virt-path=string] [--virt-bridge=string] [--server] [--parent=profile]

cobbler system add --name=string --profile=string [--mac=macaddress] [--ip-address=ipaddress] [--hostname=hostname] [--kopts=string] [--ksmeta=string] [--kickstart=path] [--netboot-enabled=Y/N] [--server=string] [--gateway=string] [--dns-name=string] [--static-routes=string] [--power-address=string] [--power-type=string] [--power-user=string] [--power-pass=string] [--power-id=string]

11.2 基本命令说明

命令名称 命令用途
cobbler check 核对当前设置是否有问题
cobbler list 列出所有的cobbler元素
cobbler distro/profile/system/repo/image/mgmtclass/package/file list 列出每种元素的列表
cobbler report 详细的列出每个元素
cobbler distro/profile/system/repo/image/mgmtclass/package/file report --name=[object-name] 列出每个元素的报告
cobbler sync 同步配置
cobbler reposync 同步yum仓库

11.3 配置文件说明

cobbler配置文件存放在/etc/cobbler/下

配置文件名称 用途
/etc/cobbler/settings cobbler主配置文件
/etc/cobbler/dhcp.template dhcp的模板配置文件
/etc/cobbler/tftpd.template tftp的模板配置文件
/etc/cobbler/named.template dns的模板配置文件
/etc/cobbler/users.digest 用于web访问的用户名密码配置文件
/etc/cobbler/modules.conf 模块配置文件
/etc/cobbler/users.conf cobbler webUI/web service授权配置文件

repo数据目录/var/www/cobbler

导入的发行版,repos镜像和kickstarts文件都放置在/var/www/cobbler目录下。确保/var目录有足够的空间来存储这些文件

目录名称 用途
images/ 存储所有导入发行版的kernel和initrd镜像用于远程网路启动
ks_mirrors 存储导入的发行版
repo_mirror yum repos存储目录
/var/log/cobbler 存放日志文件/var/log/cobbler/cobbler.log

cobbler数据目录/var/lib/cobbler,此目录存储和cobbler profiles,systems,distros相关的配置。

目录名称 用途
configs/ 存储distros,repos,systems和profiles相关信息
backup/ 备份目录
snippets 放置一些可以在kickstarts导入的脚本小片段
triggers/ 放置一些可执行脚本
kickstarts/ 放置kickstarts模板文件

Cobbler安装和配置的更多相关文章

  1. Centos7 下cobbler安装及配置

    1.背景介绍 作为运维,在公司经常遇到一些机械性重复工作要做,例如:为新机器装系统,一台两台机器装系统,可以用光盘.U盘等介质安装,1小时也完成了,但是如果有成百台的服务器还要用光盘.U盘去安装,就显 ...

  2. Centos7.4 下cobbler安装及配置

    1.背景介绍 作为运维,在公司经常遇到一些机械性重复工作要做,例如:为新机器装系统,一台两台机器装系统,可以用光盘.U盘等介质安装,1小时也完成了,但是如果有成百台的服务器还要用光盘.U盘去安装,就显 ...

  3. Linux装机利器Cobbler安装配置

     Linux装机利器Cobbler安装配置 2011-05-27 15:31:05 分类: LINUX 一.安装环境 centos 5.4 关掉iptables 关掉 selinux selinux ...

  4. cobbler之详细配置

    目录 作用 组件 命令 安装过程     安装包     配置文件     启动cobbler服务     配置cobbler服务     使用cobbler_web 作用:系统自动化安装,支持lin ...

  5. 自动化运维之cobbler安装centos7.3

    自动化运维之cobbler安装centos7.3 一.cobbler简介和服务 Cobbler是一款自动化操作系统安装的实现,与PXE安装系统的区别就是可以同时部署多个版本的系统,而PXE只能选择一种 ...

  6. centos 7 下 cobbler 安装

    一.cobbler 介绍: Cobbler 是一个系统启动服务(boot server),可以通过网络启动(PXE)的方式用来快速安装.重装物理服务器和虚拟机,支持安装不同的 Linux 发行版和 W ...

  7. centos7+cobbler安装

    cobbler工作流程 1.安装软件包: yum -y install httpd dhcp tftp python-ctypes cobbler xinetd cobbler-web pykicks ...

  8. JDK安装与配置

    JDK安装与配置 一.下载 JDK是ORACLE提供免费下载使用的,官网地址:https://www.oracle.com/index.html 一般选择Java SE版本即可,企业版的选择Java ...

  9. Node.js 教程 01 - 简介、安装及配置

    系列目录: Node.js 教程 01 - 简介.安装及配置 Node.js 教程 02 - 经典的Hello World Node.js 教程 03 - 创建HTTP服务器 Node.js 教程 0 ...

随机推荐

  1. C#实现隐藏手机号、邮箱、姓名等敏感信息扩展方法

    还是老惯例,直接上代码. 最终效果图: public static class HideSensitiveInfoExtension { /// <summary> /// 隐藏敏感信息 ...

  2. 子组件props接受父组件传递的值,能不能修改的问题

    参考链接:https://www.cnblogs.com/pangchunlei/p/11139356.html

  3. vue-cli 打包后提交到线上出现 "Uncaught SyntaxError:Unexpected token <" 报错

    参考链接:https://segmentfault.com/a/1190000016919340

  4. Zookeeper概述、特点、数据模型

    Zookeeper 1.Zookeeper概述 Zookeeper是一个工具,可以实现集群中的分布式协调服务. 所谓的分布式协调服务,就是在集群的节点中进行可靠的消息传递,来协调集群的工作.   Zo ...

  5. css消除已有的背景颜色

    比如我们在第三方库的时候,样式会有你不喜欢的,就比如背景颜色.那么就要去除已有的背景颜色 background-color:transparent;

  6. JavaSE基础(七)--Java流程控制语句之switch case 语句

    Java switch case 语句 switch case 语句判断一个变量与一系列值中某个值是否相等,每个值称为一个分支. 语法 switch case 语句语法格式如下: switch(exp ...

  7. RESTful规范与常用状态码

    GET 安全且幂等 获取表示 变更时获取表示(缓存) 200(OK)-表示已在响应中发出 204(无内容) - 资源有空表示 301(Moved Permanently) - 资源的URI已被更新 3 ...

  8. poj2486 Apple Tree (树形dp+分组背包)

    题目链接:https://vjudge.net/problem/POJ-2486 题意:一棵点权树,起点在1,求最多经过m条边的最大点权和. 思路: 树形dp经典题.用3维状态,dp[u][j][0/ ...

  9. [转帖]强大的strace命令用法详解

    强大的strace命令用法详解 文章转自: https://www.linuxidc.com/Linux/2018-01/150654.htm strace是什么? 按照strace官网的描述, st ...

  10. [转帖]Oracle 起诉 Google 事件

    Oracle 起诉 Google 事件 https://www.cnblogs.com/panchanggui/p/9449842.html Oracle 是世界第二大软件公司 世界第一大DBMS公司 ...