标签:arp ks.cfg intern data tla socket deb bar wget
一、环境准备1.系统环境
[root@vm1 ~]# cat /etc/centos-release CentOS Linux release 7.4.1708 (Core) [root@vm1 ~]# getenforce Disabled [root@vm1 ~]# ip add | grep ens32 2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 inet 192.168.10.136/24 brd 192.168.10.255 scope global dynamic ens32 [root@vm1 ~]# systemctl status firewalld firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man:firewalld(1)
2.添加epel源
[root@vm1 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
二、配置cobbler服务端
1.安装相关服务
[root@vm1 ~]# yum install -y httpd tftp dhcp cobbler cobbler-web pykickstart xinetd
2.启动htppd和cobblerd
[root@vm1 ~]# systemctl start httpd [root@vm1 ~]# systemctl start cobblerd
3.检查cobble服务异常
[root@vm1 ~]# 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.
①修改server的ip地址
[root@vm1 ~]# sed -i 's/^server: 127.0.0.1/server: 192.168.10.136/' /etc/cobbler/settings
②修改tftp的地址
[root@vm1 ~]# sed -i 's/^next_server: 127.0.0.1/next_server: 192.168.10.136/' /etc/cobbler/settings
③修改/etc/xinetd.d/tftp文件
[root@vm1 ~]# cat /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 /var/lib/tftpboot disable = no #修改为no per_source = 11 cps = 100 2 flags = IPv4 }
④下载所需的文件
[root@vm1 ~]# cobbler get-loaders
⑤开启rsyn服务
[root@vm1 ~]# systemctl start rsyncd [root@vm1 ~]# systemctl enable rsyncd
⑥安装debmirror #可忽略
[root@vm1 ~]# yum install -y debmirror
⑦修改安装完成后的初始密码
[root@vm1 ~]# openssl passwd -1 -salt '123456' '123456' $1$123456$wOSEtcyiP2N/IfIl15W6Z0 [root@vm1 ~]# vim /etc/cobbler/settings default_password_crypted: "$1$123456$wOSEtcyiP2N/IfIl15W6Z0"
⑧安装fence-agents #可忽略
[root@vm1 ~]# yum install -y fence-agents
4.重启cobbler服务并再次检查
[root@vm1 ~]# systemctl restart cobblerd [root@vm1 ~]# cobbler check The following are potential configuration items that you may want to fix: 1 : comment out 'dists' on /etc/debmirror.conf for proper debian support 2 : comment out 'arches' on /etc/debmirror.conf for proper debian support Restart cobblerd and then run 'cobbler sync' to apply changes.
[root@vm1 ~]# vim /etc/debmirror.conf #注释掉下面两行 #@dists="sid"; #@arches="i386";
[root@vm1 ~]# cobbler check No configuration problems found. All systems go.
5.配置aobbler管理dhcp和dhcp模板
[root@vm1 ~]# sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings
[root@vm1 ~]# vim /etc/cobbler/dhcp.template #修改一下几个位置 subnet 192.168.10.0 netmask 255.255.255.0 { option routers 192.168.10.2; option domain-name-servers 192.168.10.2; option subnet-mask 255.255.255.0; range dynamic-bootp 192.168.10.200 192.168.10.240;
6.修改cobbler配置文件防止重复安装
[root@vm1 ~]# sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
7.重启服务并使用cobbler sync同步
[root@vm1 ~]# systemctl restart httpd.service [root@vm1 ~]# systemctl restart cobblerd.service [root@vm1 ~]# systemctl restart dhcpd.service [root@vm1 ~]# systemctl restart rsyncd.service [root@vm1 ~]# systemctl restart tftp.socket [root@vm1 ~]# cobbler sync task started: 2018-01-23_010211_sync task started (id=Sync, time=Tue Jan 23 01:02:11 2018) running pre-sync triggers cleaning trees removing: /var/lib/tftpboot/pxelinux.cfg/default removing: /var/lib/tftpboot/grub/images removing: /var/lib/tftpboot/grub/grub-x86.efi removing: /var/lib/tftpboot/grub/grub-x86_64.efi removing: /var/lib/tftpboot/grub/efidefault removing: /var/lib/tftpboot/s390x/profile_list copying bootloaders trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi copying distros to tftpboot copying images generating PXE configuration files generating PXE menu structure rendering DHCP files generating /etc/dhcp/dhcpd.conf rendering TFTPD files generating /etc/xinetd.d/tftp cleaning link caches running post-sync triggers running python triggers from /var/lib/cobbler/triggers/sync/post/* running python trigger cobbler.modules.sync_post_restart_services running: dhcpd -t -q received on stdout: received on stderr: running: service dhcpd restart received on stdout: received on stderr: Redirecting to /bin/systemctl restart dhcpd.service running shell triggers from /var/lib/cobbler/triggers/sync/post/* running python triggers from /var/lib/cobbler/triggers/change/* running python trigger cobbler.modules.scm_track running shell triggers from /var/lib/cobbler/triggers/change/* *** TASK COMPLETE ***
8.挂载并导入镜像
[root@vm1 ~]# mount /dev/cdrom anaconda-ks.cfg .bash_logout .bashrc .config/ .last.vim .rnd .tcshrc .vimrc .bash_history .bash_profile .cache/ .cshrc .pki/ ss .viminfo [root@vm1 ~]# mount /dev/cdrom /mnt mount: /dev/sr0 is write-protected, mounting read-only [root@vm1 ~]# cobbler import --path=/mnt/ --name=CentOS-7.4 --arch=x86_64 task started: 2018-01-23_010753_import task started (id=Media import, time=Tue Jan 23 01:07:53 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/CentOS-7.4-x86_64: creating new distro: CentOS-7.4-x86_64 trying symlink: /var/www/cobbler/ks_mirror/CentOS-7.4-x86_64 -> /var/www/cobbler/links/CentOS-7.4-x86_64 creating new profile: CentOS-7.4-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/CentOS-7.4-x86_64 for CentOS-7.4-x86_64 processing repo at : /var/www/cobbler/ks_mirror/CentOS-7.4-x86_64 need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-7.4-x86_64 looking for /var/www/cobbler/ks_mirror/CentOS-7.4-x86_64/repodata/*comps*.xml Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-7.4-x86_64/repodata *** TASK COMPLETE *** [root@vm1 ~]# cobbler distro list CentOS-7.4-x86_64
9.配置cfg文件
[root@vm1 ~]# cat /var/lib/cobbler/kickstarts/Centos-7.4-x86_64.cfg # System language lang en_US # System keyboard keyboard us # System timezone timezone Asia/Shanghai #Root password rootpw --iscrypted $default_password_crypted #Use text mode install text #Install OS instead of upgrade install #Use NFS installation Media url --url=$tree #System bootloader configuration bootloader --location=mbr #Clear the Master Boot Record zerombr #Partition clearing information clearpart --all --initlabel #Disk partitioning information part /boot --fstype xfs --size 1024 --ondisk sda part swap --size 1024 --ondisk sda part / --fstype xfs --size 1 --grow --ondisk sda #System authorization --enablemd5 auth --useshadow --enablemd5 # Network information $SNIPPET('network_config') reboot firewall --disabled selinux --disabled skipx %pre $SNIPPET('log_ks_pre') $SNIPPET('kickstart_start') $SNIPPET('pre_install_network_config') $SNIPPET('pre_anamon') %end %packages @^infrastructure-server-environment @base @core chrony kexec-tools nmap sysstat lrzsz dos2unix telnet tree %end %post systemctl disable postfix.service %end
10.指定ks.cfg文件并同步
[root@vm1 ~]# cobbler profile edit --name=Centos-7.4-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos-7.4-x86_64.cfg [root@vm1 ~]# cobbler profile report Name : Centos-7.4-x86_64 TFTP Boot Files : {} Comment : DHCP Tag : default Distribution : CentOS-7.4-x86_64 Enable gPXE? : 0 Enable PXE Menu? : 1 Fetchable Files : {} Kernel Options : {} Kernel Options (Post Install) : {} Kickstart : /var/lib/cobbler/kickstarts/Centos-7.4-x86_64.cfg Kickstart Metadata : {} Management Classes : [] Management Parameters : <<inherit>> Name Servers : [] Name Servers Search Path : [] Owners : ['admin'] Parent Profile : Internal proxy : Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Repos : [] Server Override : <<inherit>> Template Files : {} Virt Auto Boot : 1 Virt Bridge : xenbr0 Virt CPUs : 1 Virt Disk Driver Type : raw Virt File Size(GB) : 5 Virt Path : Virt RAM (MB) : 512 Virt Type : kvm
三、客户机安装
1.关闭VM自带的DHCP服务
2.新建一台虚拟机
标签:arp ks.cfg intern data tla socket deb bar wget
原文地址:http://blog.51cto.com/lullaby/2064235