温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

使用cobbler 安装CentOS8

发布时间:2020-07-31 07:01:01 来源:网络 阅读:1780 作者:juestnow 栏目:系统运维

修改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/centos
mount -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  language
lang en_US
#System keyboard
keyboard us
#Sytem timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $default_password_crypted
#rootpw --iscrypted $1$ops-node$7hqdpgEmIE7Z0RbtQkxW20
#Use text mode install
text
#Install OS instead of upgrade
install
#Use NFS installation Media
url --url=$tree
#System bootloader configuration
#inst.dd modprobe.blacklist=isci
bootloader --location=mbr
#Clear the Master Boot Record
zerombr
#Partition clearing information
clearpart --all --initlabel

#Disk partitioning information
#autopart
part /boot --fstype ext4 --size 5120
#part swap --size 16384
part / --fstype ext4 --size 51200
#part /home --fstype ext4 --size 10240
part /apps --fstype xfs --size 1 --grow
#System authorization infomation
#System authorization infomation
auth  --useshadow  --enablemd5
#Network information
$SNIPPET('network_config')
#network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Firewall configuration
firewall --disabled
#SELinux configuration
selinux --disabled
#Do not configure XWindows
skipx
%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
@ core
sysstat
iptraf
ncurses-devel
zlib-devel
net-tools
tree
mailx
wget
telnet
bash-completion
%end

%post
systemctl disable postfix.service
mkdir -p /root/.ssh
wget -P /root/.ssh http://192.168.2.56/cobbler/ks_mirror/bash/authorized_keys # 公钥
cd /root
wget http://192.168.2.56/cobbler/ks_mirror/bash/CentOS8-x86_64.sh # 安装完成执行shell 文件
sh /root/CentOS8-x86_64.sh
sh 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 ulimit
echo "ulimit -SHn 1024000" >> /etc/rc.local
cat >> /etc/security/limits.conf << EOF
 *           soft   nofile       1024000
 *           hard   nofile       1024000
 *           soft   nproc        1024000
 *           hard   nproc        1024000
EOF

# set max service processes

cat >> /etc/systemd/system.conf << EOF
DefaultLimitNOFILE=1024000
DefaultLimitNPROC=1024000
EOF

#set max user processes
#sed -i 's/4096/1024000/' /etc/security/limits.d/20-nproc.conf
#set ssh
sed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_config
sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config
#sed -i 's/#PermitRootLogin yes/#PermitRootLogin no/' /etc/ssh/sshd_config
service sshd restart
#set sysctl
true > /etc/sysctl.conf
cat >> /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=256
EOF
/sbin/sysctl -p
echo "sysctl set OK!!"
sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
#set profile
cat >> /etc/profile << EOF
ulimit -d unlimited
ulimit -m unlimited
ulimit -s unlimited
ulimit -v unlimited
ulimit -t unlimited
ulimit -c unlimited
EOF
chmod +x /etc/rc.local
systemctl stop firewalld.service
rm -rf /root/*.cfg
rm -rf /root/*.log
rm -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
# 设置网卡名字为ethx
cobbler profile edit --name=CentOS-8-1905-x86_64 --kopts='net.ifnames=0 biosdevname=0'
# 同步cobbler
cobbler sync

测试

使用cobbler 安装CentOS8

# 等等安装完成
#进入系统
[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> 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 forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> 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 -a
Linux 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-release
CentOS Linux release 8.0.1905 (Core)
[root@localhost ~]# ulimit -a
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 31148
max locked memory       (kbytes, -l) 16384
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024000
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) unlimited
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1024000
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
# 系统已经安装完成
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI