1. 程式人生 > >CentOS 7搭建Cobbler批量自動安裝系統

CentOS 7搭建Cobbler批量自動安裝系統

楓雨

1.簡介

1.1Cobbler

linux系統安裝服務,可以通過網絡啟動(PXE)方式快速安裝、重裝物理服務器和虛擬機,同時管理DNS、DHCP等。既可以使命令行方式管理,也可以給予web界面管理工具。同時提供API接口,可以方便二次開發使用,是較早的kickstart的升級版,比較容易配置,自帶web界面比較易於管理。


2.環境準備

[root@CentOS 7 ~]# cat /etc/redhat-release

CentOS Linux release 7.2.1511 (Core)

[root@CentOS 7 ~]# uname -r

3.10.0-327.el7.x86_64

[root@CentOS 7 ~]# getenforce

Disabled

[root@CentOS 7 ~]# systemctl status firewalld.service

● firewalld.service - firewalld - dynamic firewall daemon

Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)

Active: inactive (dead)

[root@CentOS 7 ~]# ifconfig

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500

inet 10.0.0.201 netmask 255.255.255.0 broadcast 10.0.0.255

inet6 fe80::20c:29ff:fe40:1a4e prefixlen 64 scopeid 0x20<link>

ether 00:0c:29:40:1a:4e txqueuelen 1000 (Ethernet)

RX packets 684 bytes 133847 (130.7 KiB)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 198 bytes 24620 (24.0 KiB)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500

inet 172.16.1.201 netmask 255.255.255.0 broadcast 172.16.1.255

inet6 fe80::20c:29ff:fe40:1a58 prefixlen 64 scopeid 0x20<link>

ether 00:0c:29:40:1a:58 txqueuelen 1000 (Ethernet)

RX packets 0 bytes 0 (0.0 B)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 10 bytes 744 (744.0 B)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536

inet 127.0.0.1 netmask 255.0.0.0

inet6 ::1 prefixlen 128 scopeid 0x10<host>

loop txqueuelen 0 (Local Loopback)

RX packets 0 bytes 0 (0.0 B)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 0 bytes 0 (0.0 B)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


3.部署Cobbler服務


3.1添加yum源

curl -o /etc/yum.repos.d/CentOS-Base.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo


3.2安裝相關服務

[root@CentOS 7 ~]# yum install -y cobbler cobbler-web dhcp tftp-server pykickstart httpd python-django


3.3修改/etc/cobbler/settings中的server項

[root@CentOS 7 ~]# sed -i 's#server: 127.0.0.1#server: 172.16.1.201#' /etc/cobbler/settings


3.4修改/etc/cobbler/settings中的next_server項

[root@CentOS 7 ~]# sed -i 's/next_server: 127.0.0.1/next_server: 172.16.1.202/' /etc/cobbler/settings


3.5下載所有需要的網絡啟動文件(需要先啟動cobbler服務,國外網站,下載速度巨慢,或者下載失敗)

cobbler get-loaders


3.6修改密碼

[root@CentOS 7 ~]# sed -ri "/default_password_crypted/s#(.*: ).*#\1\"`openssl passwd -1 -salt 'fengyu' '123456'`\"#" /etc/cobbler/settings


3.7配置Cobbler統一管理DHCP

root@CentOS 7 ~]# sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings


3.8防止誤重裝

[root@CentOS 7 ~]# sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings


3.9配置DHCP Cobbler模板

[root@CentOS 7 ~]# sed -i.ori 's#192.168.1#172.16.1#g;22d;23d' /etc/cobbler/dhcp.template


3.10啟動相關服務

[root@CentOS 7 ~]# systemctl start rsyncd

[root@CentOS 7 ~]# systemctl start tftp.socket

[root@CentOS 7 ~]# systemctl start cobblerd.service

[root@CentOS 7 ~]# cobbler sync


4.web界面操作


4.1瀏覽器訪問https://10.0.0.201/cobbler_web

技術分享圖片


CentOS 7搭建Cobbler批量自動安裝系統