第十二週

1、配置chrony服務,實現服務器時間自動同步

chrony服務: 192.168.43.127
其他主機: 192.168.43.106

1、配置chrony服務:

(1)yum安裝chrony程序包:yum -y install chrony

(2)編輯chrony配置文件,添加以下配置;
vim /etc/chrony.conf

server 210.72.145.44 iburst
allow all
local stratum 10
第十二週

啓動chronyd服務:systemctl start chronyd
設置開機啓動服務: systemctl enable chronyd

2、其他主機向 192.168.43.127同步時間配置:

安裝chrony:Yum -y install chrony
編輯配置文件,添加以下配置:
vim /etc/chrony.conf
server 192.168.43.127 iburst
第十二週

啓動chronyd服務:systemctl start chronyd
將chronyd服置開機啓動:systemctl enable chronyd

3、效果驗證:

192.168.43.127上:

第十二週
192.168.43.106上:

第十二週

2、實現cobbler+pxe自動化裝機

1、安裝cobbler和dhcp,安裝cobbler同時會將http和tftp安裝,啓動cobblerd、 httpd 、tftp服務

[root@ka2 ~]#yum -y install cobbler dhcp
[root@ka2 ~]#systemctl start cobblerd httpd tftp

第十二週

2、覈對cobbler當前設置
[root@ka2 ~]#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 : enable and start rsyncd.service with systemctl
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
7 : 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
8 : 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.

1、哪個機器提供cobbler 配置cobbler 地址;
2、 配置tftp服務器地址;
3、centos7裏第3項不設置;
4、從互聯網下載BootLoader等啓動相關文件;
5、不啓動 ,rsyncd 啓動的目的時同步速度快 rsyncd ;
6、不需要,debian系列需要;
7、設置密碼,最小化應答文件中root的默認口令,(默認生成的應答文件);
8、集羣使用(淘汰) fencing;

**3、修改配置文件:

vim /etc/cobbler/settings

   next_server: 192.168.43.147 
   server: 192.168.43.147
   default_password_crypted: "$1$Ku5rhKCL$65q7pGIClD.PnJ8MTjsG11" 

---->
加密口令生成方法:
[root@ka2 ~]#openssl passwd -1
Password:
Verifying - Password:
$1$Ku5rhKCL$65q7pGIClD.PnJ8MTjsG11
<----

4、連互聯網下載相關文件:

[root@ka2 ~]#cobbler get-loaders

        task started: 2020-03-11_131051_get_loaders
        task started (id=Download Bootloader Content, time=Wed Mar 11 13:10:51 2020)
        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 ***

5、配置dhcp:

編輯cobbler自己的dhcp模板:

[root@ka2 ~]#vim /etc/cobbler/dhcp.template
subnet 192.168.43.0 netmask 255.255.255.0 {
option routers 192.168.43.2;
option domain-name-servers 192.168.43.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.43.100 192.168.43.254;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
if option pxe-system-type = 00:02 {
filename "ia64/elilo.efi";
} else if option pxe-system-type = 00:06 {
filename "grub/grub-x86.efi";
} else if option pxe-system-type = 00:07 {
filename "grub/grub-x86_64.efi";
} else if option pxe-system-type = 00:09 {
filename "grub/grub-x86_64.efi";
} else {
filename "pxelinux.0";
}
}

}

第十二週

6、同步文件:

[root@ka2 ~]#cobbler sync
此步驟將從互聯網下載的文件,同步到 /var/lib/tftpboot/下,文件同步成功:

[root@ka2 ~]#tree /var/lib/tftpboot/
/var/lib/tftpboot/
├── boot
│   └── grub
│   └── menu.lst
├── etc
├── grub
│   ├── efidefault
│   ├── grub-x8664.efi
│   ├── grub-x86.efi
│   └── images -> ../images
├── images
├── images2
├── memdisk
├── menu.c32
├── ppc
├── pxelinux.0
├── pxelinux.cfg
│   └── default
├── s390x
│   └── profilelist
└── yaboot

同時會根據cobbler的dhcp配置模板,自動生成dhcp配置文件:

第十二週

啓動dhcp服務
systemctl start dhcpd

7、導入光盤,根據導入光盤內容自動生成應答文件,以及菜單項:

[root@ka2 mnt]#mount /dev/sr0 /mnt/
[root@ka2 mnt]#cobbler import --path=/mnt --name=cnetos6.10-x86_64 --arch=x86_64

導入到了/var/www/cobbler/目錄下
[root@ka2 cobbler]#tree /var/www/cobbler/ -d
/var/www/cobbler/
├── images
├── ks_mirror
│   ├── cnetos6.10-x86_64
│   │   ├── EFI
│   │   │   └── BOOT
│   │   ├── images
│   │   │   └── pxeboot
│   │   ├── isolinux
│   │   ├── Packages
│   │   └── repodata
│   └── config
├── links
├── localmirror
├── misc
├── pub
├── rendered
├── repo_mirror
└── svc

此時啓動菜單已經自動生成:
[root@ka2 cobbler]#cat /var/lib/tftpboot/pxelinux.cfg/default
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://cobbler.github.io/
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT local

LABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1

LABEL cnetos6.10-x86_64
kernel /images/cnetos6.10-x86_64/vmlinuz
MENU LABEL cnetos6.10-x86_64
append initrd=/images/cnetos6.10-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=http://192.168.43.147/cblr/svc/op/ks/profile/cnetos6.10-x86_64
ipappend 2

MENU end

現在就可依照默認的應答文件安裝centos6 了
第十二週

8、關聯自己的應答文件:

將準備好的應答文件放到/var/lib/cobbler/kickstarts/:
[root@ka2 kickstarts]#ls /var/lib/cobbler/kickstarts/ksmini*
/var/lib/cobbler/kickstarts/ks_mini_6.cfg

關聯應答文件
distro 表示yum源,profile 表示應答文件,兩者一一對應
[root@ka2 kickstarts]#cobbler profile list
cnetos6.10-x86_64
[root@ka2 kickstarts]#cobbler distro list
cnetos6.10-x86_64

將自己的應答文件與distro關聯,執行命令:
[root@ka2 ~]#cobbler profile add --name centos6.10-86_64_mini --distro=cnetos6.10-x86_64 --kickstart=/var/lib/cobbler/kickstarts/ks_mini_6.cfg

刪除cobbler生成的應答文件方法:
[root@ka2 ~]#cobbler profile remove --name=cnetos6.10-x86_64

關聯應答文件時會自動添加菜單,此時的菜單:(可以根據需要同樣步驟導入centos7的profile和distro)

[root@ka2 ~]#cat /var/lib/tftpboot/pxelinux.cfg/default
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | http://cobbler.github.io/
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT local

LABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1

LABEL NeoKylin-x89_64-x86_64
kernel /images/NeoKylin-x89_64-x86_64/vmlinuz
MENU LABEL NeoKylin-x89_64-x86_64
append initrd=/images/NeoKylin-x89_64-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=http://192.168.43.147/cblr/svc/op/ks/profile/NeoKylin-x89_64-x86_64
ipappend 2

> LABEL centos6.10-86_64_mini
kernel /images/cnetos6.10-x86_64/vmlinuz
MENU LABEL centos6.10-86_64_mini
append initrd=/images/cnetos6.10-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=http://192.168.43.147/cblr/svc/op/ks/profile/centos6.10-86_64_mini
ipappend 2

LABEL centos7.6-x86_64
kernel /images/centos7.6-x86_64/vmlinuz
MENU LABEL centos7.6-x86_64
append initrd=/images/centos7.6-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=http://192.168.43.147/cblr/svc/op/ks/profile/centos7.6-x86_64
ipappend 2

7、啓動測試機器,開始自動安裝:

第十二週

架構班小夥伴作業看這裏:

1、安裝配置jenkins

2、安裝配置gitlab,並創建magedu倉庫代碼,分配mage用戶對倉庫有完全控制權限。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章