|
Cobbler实现CentOS自动安装
大纲
- 前言
- Cobbler介绍
- 实验拓扑
- 实验步骤
- 测试
- 总结
前言
在生产环境中我们可能需要批量安装操作系统, 我们当然可以一台一台的安装, 但是运维工作应该标准化、流程化、自动化,降低对特定人员的依赖,节省专业人员的宝贵时间和精力,这样才能有更多的时间去学习新的知识和提升。 –转自: 陈明乾 的BLOG
那么我们就应该使用运维工具来帮助我们快速、批量的自动安装。 现在较为流行的解决方案有Cobbler, 这篇我们介绍了Cobbler实现批量自动安装CenOS 6.7的步骤
Cobbler介绍
Cobbler是一款实现自动构建和部署系统的软件, Cobbler通过自动化实现来简化管理员的操作, 并可以通过模板重复部署, Cobbler还能够实现虚拟化部署
Cobbler的工作组件
实验拓扑
实验步骤
安装配置dhcp和tftp
dhcp配置
[root@node6 ~]# yum install dhcp tftp-server -y
[root@node6 ~]# vim /etc/dhcp/dhcpd.conf option domain-name "anyisalin.com";
option domain-name-servers 172.16.1.1;
subnet 172.16.1.0 netmask 255.255.255.0 {
range 172.16.1.10 172.16.1.20;
option routers 172.16.1.1;
}
next-server 172.16.1.7;
filename="pxelinux.0"; tftp和sync配置
[root@node6 ~]# vim /etc/xinetd.d/tftp service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no #设置为no
per_source = 11
cps = 100 2
flags = IPv4
}
[root@node6 ~]# vim /etc/xinetd.d/rsync service rsync
{
disable = no
flags = IPv6
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure = USERID
} 启动tftp、rsync和dhcp
[root@node6 ~]# service dhcpd startStarting dhcpd: [ OK ]
[root@node6 ~]# service xinetd startStarting xinetd: [ OK ] 安装Cobbler
我们需要epel源
[root@node6 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo[root@node6 ~]# yum install cobbler cobbler-web pykickstart debmirror -y 启动并测试Cobbler
[root@node6 ~]# service cobblerd startStarting cobbler daemon: [ OK ]
[root@node6 ~]# pkill cobbler #不知道为什么, 第一次启动要先kill掉进程
[root@node6 ~]# service cobblerd start #重新启动Starting cobbler daemon: [ OK ] 修改cobbler配置文件
[root@node6 ~]# vim /etc/cobbler/settings #修改以下两项
server: 172.16.1.7
next_server: 172.16.1.7
default_password_crypted: "$1$13b50228$tdXYYYr9hhXqkusGMIOVF/" #指定默认的密码, 使用openssl passwd -1 -salt `openssl rand -hex 4`生成 下载PXE引导文件
[root@node6 ~]# cobbler get-loaders #如果不能连接互联网, 则先安装syslinux, 然后复制/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目录中;
[root@node6 ~]# cp /var/lib/cobbler/loaders/* /var/lib/tftpboot/ #将loaders目录下的文件复制到tftproot 提供软件仓库
[root@node6 ~]# mount /dev/sr0 /mnt/ #挂载本地光盘 ; 提供ks文件
[root@node6 ~]# grep -v \\\'^[[:space:]]*#\\\' ks2.cfg #按自己需要自行修改firewall --enabled --service=ssh
install
url --url=$treerootpw --iscrypted $1$PN/zByoq$p3JWVhjzfPwZ6la3k.LED.
auth --useshadow --passalgo=sha512
graphical
firstboot --disable
keyboard us
lang en_US
selinux --enforcing
logging --level=info
timezone America/New_York
network --bootproto=dhcp --device=eth0 --onboot=on
bootloader --append="crashkernel=auto rhgb quiet" --location=mbr --driveorder="sda"zerombr
clearpart --all --initlabel
part /boot --fstype="ext4" --size=200part / --fstype="ext4" --grow --size=1%packages --nobase
@core
%end 添加distro和profile
[root@node6 ~]# cobbler import --name=centos-6.7 --path=/mnt/ #出现TASK COMPLETE代表成功了[root@node6 ~]# cobbler distro list #可以查看到当前的distro
centos-6.7-x86_64
[root@node6 ~]# cp ks2.cfg /var/lib/cobbler/kickstarts/ #将ks文件复制到指定目录
[root@node6 ~]# cobbler profile add --name cenos-6.5-minal --distro=centos-6.7-X86_64 --kickstart=/var/lib/cobbler/kickstarts/ks2.cfg #添加profile
[root@node6 ~]# cobbler profile list #查看profile
cenos-6.5-minal
centos-6.7-x86_64##由于centos7做法差不多, 所以就不演示了测试
总结
使用Cobbler安装系统提高了我们运维工作的效率, 这样才能有更多的时间去学习新的知识和提升。
文章内容浅尝辄止, 大家有更好的见解可以提出
作者: AnyISaIln QQ: 1449472454
感谢: MageEdu
|
|
|