1. 程式人生 > >cobbler集群網絡裝機

cobbler集群網絡裝機

potential 進行 集群 全局 exec linu enc free ucc

Centos7.X版本安裝cobbler
vim /etc/selinux/config #關閉selinux
setenforce 0 #半關閉
chkconfig iptables off #開機不自啟
iptables -F #清空防火墻
[root@bogon ~]# systemctl stop firewalld #關閉防火墻
[root@bogon ~]# systemctl disable firewalld #開機不自啟
[root@bogon ~]# cat /etc/redhat-release #查看linux版本
CentOS Linux release 7.4.1708 (Core)
[root@bogon ~]# uname -r #查看內核版本
3.10.0-693.el7.x86_64
[root@localhost ~]# yum clean all #清理緩存
[root@localhost yum.repos.d]# yum makecache #建立緩存
[root@bogon ~]# yum -y install epel-release #
[root@localhost yum.repos.d]# yum -y install cobbler cobbler-web pykickstart debmirror
#pykickstart #自動配置kickstart腳本端
#debmirror #能夠被PXE引導的引導文件的軟件包
[root@bogon ~]# yum -y install httpd
[root@bogon ~]# systemctl restart httpd
[root@bogon ~]# systemctl restart cobblerd
[root@bogon ~]# netstat -an |grep 25151
tcp 0 0 127.0.0.1:25151 0.0.0.0:* LISTEN

[root@bogon ~]# systemctl status httpd #查看apache狀態

● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since 三 2018-09-12 16:11:25 CST; 3h 7min ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 1448 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─1448 /usr/sbin/httpd -DFOREGROUND
├─1449 /usr/sbin/httpd -DFOREGROUND
├─1450 /usr/sbin/httpd -DFOREGROUND
├─1451 /usr/sbin/httpd -DFOREGROUND
├─1452 /usr/sbin/httpd -DFOREGROUND
└─1453 /usr/sbin/httpd -DFOREGROUND

9月 12 16:10:24 bogon systemd[1]: Starting The Apache HTTP Server...
9月 12 16:10:55 bogon httpd[1448]: AH00558: httpd: Could not reliably determine the se...age
9月 12 16:11:25 bogon systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.

[root@bogon ~]# systemctl status cobblerd #查看cobbler狀態
● cobblerd.service - Cobbler Helper Daemon
Loaded: loaded (/usr/lib/systemd/system/cobblerd.service; disabled; vendor preset: disabled)
Active: active (running) since 三 2018-09-12 16:18:02 CST; 3h 3min ago
Process: 1498 ExecStartPost=/usr/bin/touch /usr/share/cobbler/web/cobbler.wsgi (code=exited, status=0/SUCCESS)
Main PID: 1497 (cobblerd)
CGroup: /system.slice/cobblerd.service
└─1497 /usr/bin/python2 -s /usr/bin/cobblerd -F

9月 12 16:18:02 bogon systemd[1]: Starting Cobbler Helper Daemon...
9月 12 16:18:02 bogon systemd[1]: Started Cobbler Helper Daemon.

[root@bogon ~]# vim /etc/cobbler/settings

272 next_server: 192.168.10.10
384 server: 192.168.10.10

[root@bogon ~]# vim /etc/xinetd.d/tftp

default: off

description: The tftp server serves files using the trivial file transfer \

protocol. The tftp protocol is often used to boot diskless \

workstations, download configuration files to network-aware printers, \

and to start the installation process for some operating systems.

service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
~
[root@bogon ~]# cobbler get-loaders #更新補丁
task started: 2018-09-12_195923_get_loaders
task started (id=Download Bootloader Content, time=Wed Sep 12 19:59:23 2018)
downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
TASK COMPLETE

[root@bogon ~]# systemctl enable rsyncd #開啟rsync
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.

[root@bogon ~]# vim /etc/debmirror.conf

Download options

$host="ftp.debian.org";$user="anonymous";
$passwd="anonymous@";
br/>$user="anonymous";
$passwd="anonymous@";
$download_method="ftp";
#@dists="sid"; #註釋掉@sections="main,main/debian-installer,contrib,non-free";
br/>@sections="main,main/debian-installer,contrib,non-free";

[root@bogon ~]# openssl passwd -1 -salt $(openssl rand -hex 4)
Password:
$1$19017682$.wZFJpkl.qP88idfa34IK/
[root@bogon ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$19017682$.wZFJpkl.qP88idfa34IK/"

安裝柵設備隔離 #centos6是有cman的,centos7是沒有cman的,如果報錯,是正常的。
[root@bogon ~]# yum -y install cman fence-agents
用cobbler管理DHCP,修改242行manage_dhcp: 0
vim /etc/cobbler/settings
manage_dhcp: 1

#防止循環裝系統,適用於服務器第一啟動項是PXE啟動,修改292行pxe_just_once: 0 #修改為1
285 # if this setting is set to 1, cobbler systems that pxe boot 如果這個設置被設置為1,pxe啟動的cobbler系統
286 # will request at the end of their installation to toggle the 在安裝結束時,將請求關閉
287 # --netboot-enabled record in the cobbler system record. This eliminates 在cobbler系統記錄中啟用了netboot-enabled記錄。這就消除了
288 # the potential for a PXE boot loop if the system is set to PXE 如果系統被設置為PXE,那麽PXE啟動循環的潛力
289 # first in it‘s BIOS order. Enable this if PXE is first in your BIOS 首先是BIOS的順序。如果PXE在您的BIOS中首先出現,則啟用此功能
290 # boot order, otherwise leave this disabled. See the manpage 啟動訂單,否則將禁用此功能。看到從
291 # for --netboot-enabled. 支持netboot-啟用。

292 pxe_just_once: 1

#修改完後重啟服務再進行一次檢測
[root@bogon system]# systemctl restart cobblerd
[root@bogon system]# yum -y install dhcp
[root@bogon system]# cp -a /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
cp:是否覆蓋"/etc/dhcp/dhcpd.conf"? y

[root@bogon system]# vim /etc/dhcp/dhcpd.conf
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.100 192.168.10.200;
option routers 192.168.10.2;
default-lease-time 600;
max-lease-time 7200;
}
next-server 192.168.10.10;
filename="pxelinux.0";

[root@bogon system]# systemctl restart dhcpd
[root@bogon system]# systemctl enable dhcpd
Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/systemd/system/dhcpd.service.

[root@bogon system]# yum -y install xinetd #在centos7裏沒有xinetd
[root@bogon system]# systemctl enable xinetd
[root@bogon system]# systemctl restart xinetd
[root@bogon system]# systemctl restart tftp
[root@bogon system]# systemctl enable tftp
Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket.
[root@bogon system]# cobbler sync
[root@bogon system]# cobbler check #檢測配置文件
No configuration problems found. All systems go.

#掛載鏡像

[root@bogon system]# mkdir -p /mnt/cdrom
[root@bogon system]# vim /etc/fstab
/dev/sr0 /mnt/cdrom iso9660 defaults 0 0
[root@bogon system]# mount -a

#導入鏡像
[root@bogon system]# cobbler import --name="centos7-x86_64" --path=/mnt/cdrom/
task started: 2018-09-16_113922_import
task started (id=Media import, time=Sun Sep 16 11:39:22 2018)
Found a candidate signature: breed=redhat, version=rhel6
Found a candidate signature: breed=redhat, version=rhel7
Found a matching signature: breed=redhat, version=rhel7
Adding distros from path /var/www/cobbler/ks_mirror/centos7-x86_64:
creating new distro: centos7-x86_64
trying symlink: /var/www/cobbler/ks_mirror/centos7-x86_64 -> /var/www/cobbler/links/centos7-x86_64
creating new profile: centos7-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/centos7-x86_64 for centos7-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos7-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/centos7-x86_64
looking for /var/www/cobbler/ks_mirror/centos7-x86_64/repodata/comps.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos7-x86_64/repodata
TASK COMPLETE
[root@bogon mnt]# cobbler distro list #查看鏡像列表
centos7-x86_64

/var/www/cobbler/ks_mirror/ 鏡像存放目錄

[root@bogon ks_mirror]# cobbler profile list #查看生成的劇本
centos7-x86_64
[root@bogon ks_mirror]# cobbler profile remove --name=centos7-x86_64 #刪除劇本文件

[root@bogon kickstarts]# cobbler list
distros:
centos7-x86_64

profiles:

systems:

repos:

images:

mgmtclasses:

packages:

files:
[root@bogon kickstarts]# cobbler distro report --name=centos7-x86_64 #查看安裝鏡像文件信息
Name : centos7-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : redhat
Comment :
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/centos7-x86_64/images/pxeboot/initrd.img
Kernel : /var/www/cobbler/ks_mirror/centos7-x86_64/images/pxeboot/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {‘tree‘: ‘http://@@http_server@@/cblr/links/centos7-x86_64‘}
Management Classes : []
OS Version : rhel7
Owners : [‘admin‘]
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Template Files : {}

[root@bogon kickstarts]# ls
default.ks install_profiles sample_autoyast.xml sample_esxi4.ks sample.ks
esxi4-ks.cfg legacy.ks sample_end.ks(默認使用的kickstarts文件) sample_esxi5.ks sample_old.seed
esxi5-ks.cfg pxerescue.ks sample_esx4.ks sample_esxi6.ks sample.seed

#找一個centos7-x86_64.cfg文件 拷貝到/var/lib/cobbler/kickstarts目錄下
[root@bogon kickstarts]# cobbler profile add --name=centos7-basic --distro=centos7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7-x86_64.cfg # #指定ks文件名稱,導入鏡像文件名稱,導入劇本文件,把ks文件和鏡像文件聯立起來

如果想做多個系統,首先上傳鏡像文件,生成ks劇本文件,然後把劇本文件和鏡像文件聯立起來

cobbler profile edit --name=centos7-basic --kopts=‘net.ifnames=0 biosdevname=0‘ #修改網卡名稱,使用eth0名稱
#指定
cobbler system add --name=a1 --mac=00:0c:29:6f:b7:4c --profile=centos7-basic --ip-address=192.168.10.20 --subnet=255.255.255.0 --interface=eth0 --static=1 --gateway=192.168.10.2 --hostname=www.wk.com --name-servers="114.114.114.114"
cobbler system list #查看指定主機

自定義安裝系統: #cobble默認使用的是https連接
每次安裝系統都要選擇,比較麻煩,那麽我們指定MAC地址進行安裝,就可以達到自動安裝無需再選擇操作系統,即使有多個操作系統,只要指定操作系統和MAC地址就可以自動安裝
#cobbler WEB端配置:賬戶密碼都是cobbler

選擇--系統--創建新系統

#定義系統信息

#配置全局網絡信息,網關,DNS

#配置網卡信息 eth0 eth1
註意選擇 static

技術分享圖片

cobbler集群網絡裝機