千家信息网

使用cobbler 安装CentOS8

发表于:2024-11-23 作者:千家信息网编辑
千家信息网最后更新 2024年11月23日,修改cobbler distro 让支持CentOS8cp /var/lib/cobbler/distro_signatures.json /var/lib/cobbler/distro_signat
千家信息网最后更新 2024年11月23日使用cobbler 安装CentOS8

修改cobbler distro 让支持CentOS8

cp /var/lib/cobbler/distro_signatures.json /var/lib/cobbler/distro_signatures.json.bak vi /var/lib/cobbler/distro_signatures.json # 找到rhel7 段在下面添加内容    "rhel8": {    "signatures":["BaseOS"],    "version_file":"(redhat|sl|slf|centos|oraclelinux|vzlinux)-release-(?!notes)([\\w]*-)*8[\\.-]+(.*)\\.rpm",    "version_file_regex":null,    "kernel_arch":"kernel-(.*).rpm",    "kernel_arch_regex":null,    "supported_arches":["i386","x86_64","ppc","ppc64","ppc64le"],    "supported_repo_breeds":["rsync", "rhn", "yum"],    "kernel_file":"vmlinuz(.*)",    "initrd_file":"initrd(.*)\\.img",    "isolinux_ok":false,    "default_kickstart":"/var/lib/cobbler/kickstarts/sample_end.ks",    "kernel_options":"",    "kernel_options_post":"",    "boot_files":[]   },# 保存 # 重启cobblerd service cobblerd restart

下载CentOS8

wget http://centos.ustc.edu.cn/centos/8.0.1905/isos/x86_64/CentOS-8-x86_64-1905-dvd1.iso

挂载下载完成iso

mkdir -p /mnt/centosmount -t iso9660 -r -o ro,loop /tmp/CentOS-8-x86_64-1905-dvd1.iso /mnt/centos

创建ks 文件及初始化shell文件

# cobbler 服务器IP 192.168.2.56 请修改成自己的cobbler服务器地址vim /var/lib/cobbler/kickstarts/CentOS8-x86_64.ks#Kickstart Configurator by Qist#platform=x86, AMD64, or Intel EM64T#System  languagelang en_US#System keyboardkeyboard us#Sytem timezonetimezone Asia/Shanghai#Root passwordrootpw --iscrypted $default_password_crypted#rootpw --iscrypted $1$ops-node$7hqdpgEmIE7Z0RbtQkxW20#Use text mode installtext#Install OS instead of upgradeinstall#Use NFS installation Mediaurl --url=$tree#System bootloader configuration#inst.dd modprobe.blacklist=iscibootloader --location=mbr#Clear the Master Boot Recordzerombr#Partition clearing informationclearpart --all --initlabel#Disk partitioning information#autopartpart /boot --fstype ext4 --size 5120#part swap --size 16384part / --fstype ext4 --size 51200#part /home --fstype ext4 --size 10240part /apps --fstype xfs --size 1 --grow#System authorization infomation#System authorization infomationauth  --useshadow  --enablemd5#Network information$SNIPPET('network_config')#network --bootproto=dhcp --device=eth0 --onboot=on# Reboot after installationreboot#Firewall configurationfirewall --disabled#SELinux configurationselinux --disabled#Do not configure XWindowsskipx%pre$SNIPPET('log_ks_pre')$SNIPPET('kickstart_start')$SNIPPET('pre_install_network_config')# Enable installation monitoring$SNIPPET('pre_anamon')%end#Package install information#autopart%packages@ base@ coresysstatiptrafncurses-develzlib-develnet-toolstreemailxwgettelnetbash-completion%end%postsystemctl disable postfix.servicemkdir -p /root/.sshwget -P /root/.ssh http://192.168.2.56/cobbler/ks_mirror/bash/authorized_keys # 公钥cd /rootwget http://192.168.2.56/cobbler/ks_mirror/bash/CentOS8-x86_64.sh # 安装完成执行shell 文件sh /root/CentOS8-x86_64.shsh rm -rf /root/*%end# 创建CentOS8-x86_64.sh# 创建shell 存放目录 mkdir -p  /var/www/cobbler/ks_mirror/bash/ vim  /var/www/cobbler/ks_mirror/bash/CentOS8-x86_64.sh #!/bin/bash###############################################set conf##################################################set ulimitecho "ulimit -SHn 1024000" >> /etc/rc.localcat >> /etc/security/limits.conf << EOF *           soft   nofile       1024000 *           hard   nofile       1024000 *           soft   nproc        1024000 *           hard   nproc        1024000EOF# set max service processescat >> /etc/systemd/system.conf << EOFDefaultLimitNOFILE=1024000DefaultLimitNPROC=1024000EOF#set max user processes#sed -i 's/4096/1024000/' /etc/security/limits.d/20-nproc.conf#set sshsed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_configsed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config#sed -i 's/#PermitRootLogin yes/#PermitRootLogin no/' /etc/ssh/sshd_configservice sshd restart#set sysctltrue > /etc/sysctl.confcat >> /etc/sysctl.conf << EOF net.ipv4.ip_forward = 1 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 kernel.sysrq = 0 kernel.core_uses_pid = 1 net.ipv4.tcp_syncookies = 1 fs.file-max = 1024000 fs.nr_open = 1024000 vm.swappiness = 0 vm.max_map_count = 2048000 vm.overcommit_memory = 1 kernel.sem =5010 641280 5010 128 kernel.pid_max = 4194303 kernel.msgmnb = 65536 kernel.msgmax = 65536 kernel.shmmax = 68719476736 kernel.shmall = 4294967296 net.ipv4.tcp_max_tw_buckets = 6000 net.ipv4.tcp_sack = 1 net.ipv4.tcp_window_scaling = 1 net.ipv4.tcp_mem = 786432 1697152 1945728 net.ipv4.tcp_rmem = 4096 87380 16777216 net.ipv4.tcp_wmem = 4096 65536 16777216 net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.core.netdev_max_backlog = 2048000 net.core.somaxconn = 65535 net.ipv4.tcp_max_orphans = 3276800 net.ipv4.tcp_max_syn_backlog = 2048000 net.ipv4.tcp_syn_retries = 1 net.ipv4.tcp_synack_retries = 1 net.ipv4.tcp_tw_reuse = 1  net.ipv4.tcp_synack_retries = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_mem = 94500000 915000000 927000000 net.ipv4.tcp_fin_timeout = 1 net.ipv4.tcp_keepalive_time = 600 net.ipv4.tcp_keepalive_probes = 10 net.ipv4.tcp_keepalive_intvl = 30 net.ipv4.ip_local_port_range = 1024 65535# net.ipv4.ip_local_reserved_ports = 8000-20000 net.ipv4.neigh.default.gc_stale_time=120 net.ipv4.conf.default.rp_filter=0 net.ipv4.conf.all.rp_filter=0 net.ipv4.conf.all.arp_announce=2 net.ipv4.conf.lo.arp_announce=2 sunrpc.tcp_slot_table_entries=256EOF/sbin/sysctl -pecho "sysctl set OK!!"sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/configsetenforce 0#set profilecat >> /etc/profile << EOFulimit -d unlimitedulimit -m unlimitedulimit -s unlimitedulimit -v unlimitedulimit -t unlimitedulimit -c unlimitedEOFchmod +x /etc/rc.localsystemctl stop firewalld.servicerm -rf /root/*.cfgrm -rf /root/*.logrm -rf /root/CentOS8-x86_64.sh

导入镜像到cobbler

cobbler import --path=/mnt/centos --name=CentOS-8-x86_64-1905 --kickstart=/var/lib/cobbler/kickstarts/CentOS8-x86_64.ks --arch=x86_64# 设置网卡名字为ethxcobbler profile edit --name=CentOS-8-1905-x86_64 --kopts='net.ifnames=0 biosdevname=0'# 同步cobblercobbler sync

测试

# 等等安装完成#进入系统[root@localhost ~]# ip a1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00    inet 127.0.0.1/8 scope host lo       valid_lft forever preferred_lft forever    inet6 ::1/128 scope host       valid_lft forever preferred_lft forever2: eth0:  mtu 1500 qdisc fq_codel state UP group default qlen 1000    link/ether 52:54:00:33:e0:0f brd ff:ff:ff:ff:ff:ff    inet 192.168.2.196/23 brd 192.168.3.255 scope global noprefixroute eth0       valid_lft forever preferred_lft forever    inet6 fc00:bd4:efa8:1001:5054:ff:fe33:e00f/64 scope global dynamic noprefixroute       valid_lft 86127sec preferred_lft 14127sec    inet6 fe80::5054:ff:fe33:e00f/64 scope link noprefixroute       valid_lft forever preferred_lft forever[root@localhost ~]# uname -aLinux localhost.localdomain 4.18.0-80.7.1.el8_0.x86_64 #1 SMP Sat Aug 3 15:14:00 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux[root@localhost ~]# cat /etc/redhat-releaseCentOS Linux release 8.0.1905 (Core)[root@localhost ~]# ulimit -acore file size          (blocks, -c) unlimiteddata seg size           (kbytes, -d) unlimitedscheduling priority             (-e) 0file size               (blocks, -f) unlimitedpending signals                 (-i) 31148max locked memory       (kbytes, -l) 16384max memory size         (kbytes, -m) unlimitedopen files                      (-n) 1024000pipe size            (512 bytes, -p) 8POSIX message queues     (bytes, -q) 819200real-time priority              (-r) 0stack size              (kbytes, -s) unlimitedcpu time               (seconds, -t) unlimitedmax user processes              (-u) 1024000virtual memory          (kbytes, -v) unlimitedfile locks                      (-x) unlimited# 系统已经安装完成
0