Cobbler là gì?
Cobbler là một phần mềm mã nguồn mở giúp các bạn cài đặt hệ điều hành Linux một cách tự động (FAI) thông qua network.
Cobbler server sử dụng các dịch vụ như DHCP, TFTP và DNS. Trong quá trình cài đặt cobbler sử dụng kickstart file để bắt đầu cài đặt OS một cách tự động, Client chỉ việc boot hệ thống thông qua network hoặc PXE sau đó mọi thứ đều được tự động bởi cobbler.
Trong bài viết này, mình sẽ hướng dẫn bạn cách cài đặt và cấu hình cobbler một cách cơ bản theo mô hình sau:
Hướng dẫn từng bước cách cài đặt Cobbler
Bước 1: Cài đặt epel repository
Bạn thao tác như hình nhé!
[root@linux ~]# yum install epel-release
Bước 2: Cài đặt cobbler
Sau đó, bạn tiến hành cài đặt cobbler và các gói dịch vụ cần thiết như ví dụ minh họa bên dưới.
[root@linux ~]# yum install cobbler cobbler-web dnsmasq syslinux pykickstart xinetd -y
Bước 3: Khởi động dịch vụ Cobbler và Web Server (httpd) Service
Bạn có thể sử dụng câu lênh systemctl để bật các dịch vụ sau:
[root@linux ~]# systemctl enable —-now cobblerd [root@linux ~]# systemctl enable—-now httpd
Tắt Selinux.
[root@linux ~]# setenforce 0
Cấu hình lại Selinux tại file ‘/etc/sysconfig/selinux‘
SELINUX=disabled
Trong trường hợp, dịch vụ firewalld đang hoạt động thì bạn phải mở các port dưới đây:
[root@linux ~]# firewall-cmd --add-port=80/tcp --permanent success [root@linux ~]# firewall-cmd --add-port=443/tcp --permanent success [root@linux ~]# firewall-cmd --add-service=dhcp --permanent success [root@linux ~]# firewall-cmd --add-port=69/tcp --permanent success [root@linux ~]# firewall-cmd --add-port=69/udp --permanent success [root@linux ~]# firewall-cmd --add-port=4011/udp --permanent success [root@linux ~]# firewall-cmd --reload success
Bước 4: Truy cập Cobbler Web Interface
https://192.168.31.129/cobbler_web/
Trong trường hợp của mình, IP là 192.168.31.129. Bạn truy cập như link trên và đăng nhập với user và password là : cobbler
Bước 5: cấu hình /etc/cobbler/settings
Đến bước này, bạn có thể tiến hành tạo chuỗi cho mật khẩu root:
[root@linux ~]# openssl passwd -1 Password: Verifying - Password: $1$j9/aR8Et$uovwBsGM.cLGcwR.Nf7Qq0
Bạn cập nhật mật khẩu tại file ‘/etc/cobbler/settings’ dưới parameter ‘default_password_crypted’ và bật các dịch vụ của Cobbler DHCP,DNS,PXE của TFTP bằng cách thay đổi giá trị parameter từ 0 thành 1.
Cấu hình địa chỉ IP TFTP server in ‘next_server’ parameter và địa chỉ Cobbler’s Server tại parameter là ‘server’.
[root@linux~]# vi /etc/cobbler/settings default_password_crypted: "$1$j9/aR8Et$uovwBsGM.cLGcwR.Nf7Qq0" manage_dhcp: 1 manage_dns: 1 pxe_just_once: 1 next_server: 192.168.178.2 server: 192.168.178.2
Bạn nên bật các module cần thiết khi cài đặt cobbler cùng các gói rpm:
[root@linux~]# vi /etc/cobbler/modules.conf [dns] #module = manage_bind module = manage_dnsmasq [dhcp] #module = manage_isc module = manage_dnsmasq
Bước 6: cập nhật file ‘/etc/cobbler/dhcp.template’ và ‘/etc/cobbler/dnsmasq.template’
Tiến hành cập nhật file ‘/etc/cobbler/dhcp.template’ :
[root@linux ~]# vi /etc/cobbler/dhcp.template subnet 192.168.172.0 netmask 255.255.255.0 { option routers 192.168.172.2; option domain-name-servers 192.168.172.2; option subnet-mask 255.255.255.0; range dynamic-bootp 192.168.172.3 192.168.172.10; default-lease-time 21700; max-lease-time 43100; 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 { filename "pxelinux.0"; } } }
Bạn tiếp tục cập nhật range ip cho dhcp client ‘/etc/cobbler/dnsmasq.template’
[root@linux ~]# vi /etc/cobbler/dnsmasq.template dhcp-range=192.168.172.3 192.168.172.10
Sau đó, bạn khởi động lại các dịch vụ cần thiết:
[root@linux ~]# systemctl restart cobblerd [root@linux ~]# systemctl enable --now xinetd [root@linux ~]# cobbler check ; cobbler sync [root@linux ~]#systemctl enable --now dnsmasq
Tiến hành import các iso
[root@linux ~]# mkdir /mnt/iso [root@linux ~]# mount -o loop CentOS-7-x86_64-DVD-1511.iso /mnt/iso/ [root@linux ~]# cobbler import --arch=x86_64 --path=/mnt/iso --name=CentOS7
Cập nhật signature của iso:
[root@linux ~]# cobbler signature update
Bước 7: xác nhận lại các distro list
[root@linux ~]# cobbler distro list CentOS7-x86_64
Bạn cũng có thể xem qua giao diện web bằng cách Configuration Tab –> Distros
Xem chi tiết distro bằng lệnh:
[root@linux ~]# 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 : {}
Bước 8: Tạo kickstart file.
Tạo kickstart file cho centos 7 với tên ‘CentOS7.ks‘, Vị trí lưu file ‘/var/lib/cobbler/kickstarts‘
[root@linux ~]# vi /var/lib/cobbler/kickstarts/CentOS7.ks #platform=x86, AMD64, or Intel EM64T #version=DEVEL # Firewall configuration firewall --disabled # Install OS instead of upgrade install # Use HTTP installation media url --url="http://192.168.172.2/cblr/links/CentOS7-x86_64/" # Root password rootpw --iscrypted $1$j9/aR8Et$uovwBsGM.cLGcwR.Nf7Qq0 # Network information network --bootproto=dhcp --device=eth0 --onboot=on # Reboot after installation reboot # System authorization information auth useshadow passalgo=sha512 # Use graphical install graphical firstboot disable # System keyboard keyboard us # System language lang en_US # SELinux configuration selinux disabled # Installation logging level logging level=info # System timezone timezone Europe/Amsterdam # System bootloader configuration bootloader location=mbr clearpart --all --initlabel part swap --asprimary --fstype="swap" --size=1024 part /boot --fstype xfs --size=500 part pv.01 --size=1 --grow volgroup root_vg01 pv.01 logvol / --fstype xfs --name=lv_01 --vgname=root_vg01 --size=1 --grow %packages @^minimal @core %end %addon com_redhat_kdump --disable --reserve-mb='auto' %end
Tiến hành thêm kickstart file và sync lai cobbler
[root@linux ~]# cobbler profile edit --name=CentOS7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS7.ks [root@linux ~]# cobbler sync
Bước 9: Tiến hành boot client với chế độ PXEboot
Để bật chế độ pxeboot bạn có thể vào bios để bật chế độ boot qua network.
Trên đây là 9 bước cơ bản để cài đặt và cấu hình Cobbler trên Centos 7. Chúc bạn thao tác thành công nhé!
Trong quá trình thao tác, nếu có bất cứ thắc mắc gì, bạn có thể để lại bình luận bên dưới bài viết để chúng ta cùng nhau trao đổi và chia sẻ kiến thức nhé.
Comments