第十二周
作者:互联网
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.confserver 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 localLABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1LABEL 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 2MENU 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 localLABEL local
MENU LABEL (local)
MENU DEFAULT
LOCALBOOT -1LABEL 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 2LABEL 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用户对仓库有完全控制权限。
标签:第十二,x86,lib,loaders,64,var,cobbler 来源: https://blog.51cto.com/5440126/2477951