cobbler部署安装CentOS6.8

Linux运维:cobbler

: Ago linux运维群:93324526


学习cobbler的话,必须先搞懂kickstart,原理不是,不懂如何排错。

kickstart部署请点击这里

1. Cobbler介绍

Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。

Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。

Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。

Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。

cobbler官网

1.1 Cobbler集成的服务

  • PXE服务支持
  • DHCP服务管理
  • DNS服务管理(可选bind,dnsmasq)
  • 电源管理
  • Kickstart服务支持
  • YUM仓库管理
  • TFTP(PXE启动时需要)
  • Apache(提供kickstart的安装源,并提供定制化的kickstart配置)

1.2 系统环境准备

[root@CentOS6 ~]# cat /etc/redhat-release
CentOS release 6.8 (Final)
[root@CentOS6 ~]# uname -r
2.6.32-642.el6.x86_64
[root@CentOS6 ~]# getenforce
Disabled
[root@CentOS6 ~]# /etc/init.d/iptables status
iptables: Firewall is not running.
[root@CentOS6 ~]# ifconfig eth0|awk -F "[ :]+" 'NR==2 {print $4}'
10.0.0.101
[root@CentOS6 ~]# hostname
CentOS6
[root@CentOS6 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

注意:

  • 虚拟机网卡采用NAT模式,不要使用桥接模式,因为稍后我们会搭建DHCP服务器,在同一局域网多个DHCP服务会有冲突。
  • VMware的NAT模式的dhcp服务也关闭,避免干扰。

2.1 安装Cobbler

需要epel源

[root@CentOS6 ~]# yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd
[root@CentOS6 ~]# rpm -ql cobbler  # 查看安装的文件,下面列出部分。
/etc/cobbler # 配置文件目录
/etc/cobbler/settings # cobbler主配置文件,这个文件是YAML格式,Cobbler是python写的程序。
/etc/cobbler/dhcp.template # DHCP服务的配置模板
/etc/cobbler/tftpd.template # tftp服务的配置模板
/etc/cobbler/rsync.template # rsync服务的配置模板
/etc/cobbler/iso # iso模板配置文件目录
/etc/cobbler/pxe # pxe模板文件目录
/etc/cobbler/power # 电源的配置文件目录
/etc/cobbler/users.conf # Web服务授权配置文件
/etc/cobbler/users.digest # 用于web访问的用户名密码配置文件
/etc/cobbler/dnsmasq.template # DNS服务的配置模板
/etc/cobbler/modules.conf # Cobbler模块配置文件
/var/lib/cobbler # Cobbler数据目录
/var/lib/cobbler/config # 配置文件
/var/lib/cobbler/kickstarts # 默认存放kickstart文件
/var/lib/cobbler/loaders # 存放的各种引导程序
/var/www/cobbler # 系统安装镜像目录
/var/www/cobbler/ks_mirror # 导入的系统镜像列表
/var/www/cobbler/images # 导入的系统镜像启动文件
/var/www/cobbler/repo_mirror # yum源存储目录
/var/log/cobbler # 日志目录
/var/log/cobbler/install.log # 客户端系统安装日志
/var/log/cobbler/cobbler.log # cobbler日志

2.2 配置Cobbler

cobbler check

[root@CentOS6 ~]# 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 : change 'disable' to 'no' in /etc/xinetd.d/rsync
6 : file /etc/xinetd.d/rsync does not exist
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
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 Restart cobblerd and then run 'cobbler sync' to apply changes.

解释一下9条内容

1.改变server的主机名
2.第二是DHCP的next_server改成172.16.1.101
3.改xined的tftp disable等于no
4.
5./etc/xinetd.d/rsync 也改成no
6.bug,已经存在
7.debin系统的源
8.生成密码并设置openssl passwd -1 -salt
9.fencing tools 高可用的硬件设备。

修改配置文件

命令直接复制粘贴即可

cp /etc/cobbler/settings{,.ori}                                                                                       #备份
sed -i 's/server: 127.0.0.1/server: 172.16.1.101/' /etc/cobbler/settings #服务端IP
sed -i 's/next_server: 127.0.0.1/next_server: 172.16.1.101/' /etc/cobbler/settings #服务端IP
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings #dhcp只获取一次
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings #cobbler只执行一遍
sed -ri "/default_password_crypted/s#(.*: ).*#\1\"`openssl passwd -1 -salt 'oldboy' '123456'`\"#" /etc/cobbler/settings #设置密码为123456
sed -i 's#yes#no#' /etc/xinetd.d/rsync #xinet 管理rsync
sed -i 's#yes#no#' /etc/xinetd.d/tftp #xinet 管理tftp
cobbler get-loaders #下载
sed -i 's#192.168.1#172.16.1#g;22d;23d' /etc/cobbler/dhcp.template # 修改dhcp配置文件
cobbler sync #写入磁盘
/etc/init.d/xinetd restart #启动三个必须启动的服务。详情请看kickstart
/etc/init.d/cobblerd restart
/etc/init.d/httpd restart
cobbler sync # 修改配置文件等,没事就来一次。保证没事
CentOS-6.8-x86_64.cfg
# Cobbler for Kickstart Configurator for CentOS 6.8 by yao zhang
install
url --url=$tree
text
lang en_US.UTF-8
keyboard us
zerombr
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
$SNIPPET('network_config')
timezone --utc Asia/Shanghai
authconfig --enableshadow --passalgo=sha512
rootpw --iscrypted $default_password_crypted
clearpart --all --initlabel
part /boot --fstype=ext4 --asprimary --size=200
part swap --size=1024
part / --fstype=ext4 --grow --asprimary --size=200
firstboot --disable
selinux --disabled
firewall --disabled
logging --level=info
reboot %pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end %packages
@base
@compat-libraries
@debugging
@development
tree
nmap
sysstat
lrzsz
dos2unix
telnet
%end %post --nochroot
$SNIPPET('log_ks_post_nochroot')
%end %post
$SNIPPET('log_ks_post')
# Start yum configuration
$yum_config_stanza
# End yum configuration
$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$SNIPPET('kickstart_done')
# End final steps
%end

图片详解,ks配置文件请看上方

1.登录界面

cobbler部署安装CentOS6.8

2.导入镜像,记得挂载光盘或者镜像文件

镜像位置/var/www/cobbler/ks_mirror/

cobbler部署安装CentOS6.8

3.自定义KS配置文件。请看上方

cobbler部署安装CentOS6.8

4.创建一个全局变量

cobbler部署安装CentOS6.8

5.制作yum仓库

cobbler部署安装CentOS6.8

6.导入yum仓库并创建全局变量

cobbler部署安装CentOS6.8

7.创建system

cobbler部署安装CentOS6.8

cobbler部署安装CentOS6.8

7.1.global

cobbler部署安装CentOS6.8

7.2.创建网卡

cobbler部署安装CentOS6.8

7.3.制作第二张网卡

cobbler部署安装CentOS6.8

7.4.拷贝和查看ks配置文件

cobbler部署安装CentOS6.8

8.注意事项

cobbler部署安装CentOS6.8

上一篇:vs2017 创建虚拟目录失败 http//locXXXXXX,vs2015 无法访问IIS源数据


下一篇:table指定位置添加行