设为首页 收藏本站
查看: 724|回复: 0

[经验分享] Cobbler无人值守全自动安装部署Linux系统

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-5-11 08:56:42 | 显示全部楼层 |阅读模式
注意事项:使用VMware Workstation实验时,注意网卡的模式,NAT模式下关闭默认的DHCP服务器!
[iyunv@~]# cat /etc/redhat-release
CentOS release 6.7 (Final)
[iyunv@~]# wget http://dl.fedoraproject.org/pub/ ... ease-6-8.noarch.rpm
[iyunv@~]# yum install cobbler cobbler-web dhcp cman pykickstart debmirror python-ctypes -y
[iyunv@~]# yum install pykickstart debmirror python-ctypes -y
[iyunv@~]# vim /etc/httpd/conf/httpd.conf  #编辑修改http配置文件
ServerName localhost:80
[iyunv@~]# cat /etc/xinetd.d/rsync |grep disable
        disable        = no
[iyunv@~]# cat /etc/xinetd.d/tftp |grep disable
    disable                 = no


[iyunv@~]# service httpd start
[iyunv@~]# service xinetd start
[iyunv@~]# service cobblerd start
[iyunv@~]# cobbler get-loaders # 首次执行会报错,重新启动cobbler再次执行即可
[iyunv@~]# service cobblerd restart
[iyunv@~]# cobbler get-loaders  #再次执行,等待下载完成即可[需要联网]


[iyunv@~]# sed -i 's@next_server: 127.0.0.1@next_server: 192.168.1.10@g' /etc/cobbler/settings
[iyunv@~]# sed -i 's@server: 127.0.0.1@server: 192.168.1.10@g' /etc/cobbler/settings
[iyunv@~]# sed -i 's$@arches="i386"$#@arches="i386"$g' /etc/debmirror.conf
[iyunv@~]# sed  -i 's$@dists="sid"$#@dists="sid"$g' /etc/debmirror.conf
[iyunv@~]# openssl passwd -1 -salt 'random-phrase-here' 'yangjie'
[iyunv@~]# $1$random-p$LVezyn3LDLBs0eno3kbbN/
[iyunv@~]# vim /etc/cobbler/settings  #修改密码   
default_password_crypted: "$1$random-p$LVezyn3LDLBs0eno3kbbN/"


[iyunv@~]# cobbler check    #检查配置,根据提示修改对应的参数即可


[iyunv@~]# cp /etc/cobbler/dhcp.template /etc/dhcp/dhcpd.conf
[iyunv@~]# vim /etc/dhcp/dhcpd.conf
[iyunv@~]# cat /etc/dhcp/dhcpd.conf
ddns-update-style interim;
allow booting;
allow bootp;
ignore client-updates;
set vendorclass = option vendor-class-identifier;
option pxe-system-type code 93 = unsigned integer 16;
subnet 192.168.1.0 netmask 255.255.255.0 {
     option routers             192.168.1.10;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.1.100 192.168.1.254;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                192.168.1.10;
     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";
          }
     }
}
[iyunv@~]# mount /dev/sr0 /media
[iyunv@~]# cobbler import --path=/media/ --name=Centos6.7 #添加镜像文件
[iyunv@~]# cobbler list
[iyunv@~]# cobber distro list
[iyunv@~]# cobbler profile report
#添加镜像文件时默认关联cfg文件,文件路径为/var/lib/cobbler/kickstart/sample_end.cfg
#可以直接使用默认文件进行安装!此处修改关联ks文件,
[iyunv@~]# cobbler profile edit --name=Centos6.7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos6.cfg

[iyunv@~]# cobbler sync    #每次修改设置后执行同步操作生效
[iyunv@~]# service httpd restart
[iyunv@~]# service xinetd restart
[iyunv@~]# service dhcpd restart
[iyunv@~]# service cobblerd restart



安装kickstart程序可以自定义自己需要的ks文件:
[iyunv@~]# yum install -y system-config-kickstart


kickstart文件示例 for Centos6.7:
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url=http://192.168.1.10/cblr/links/Centos6.7-x86_64
# Root password
rootpw --iscrypted $1$fAEc8og0$FUo010cL80ub9ko5lQcjO0
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# System keyboard
keyboard us
# System language
lang zh_CN
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone  Asia/Shanghai
# Network information
network  --bootproto=dhcp --device=eth0 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all  
# Disk partitioning information
part /boot --fstype="ext4" --size=100
part swap --fstype="swap" --size=2000
part / --fstype="ext4" --grow --size=1


%post
useradd admin
sed -i '100 i admin ALL=(ALL)   ALL' /etc/sudoers
echo -e "net.core.netdev_max_backlog = 262144" >> /etc/sysctl.conf
echo -e "net.core.wmem_default = 8388608" >> /etc/sysctl.conf
echo -e "net.core.rmem_default = 8388608" >> /etc/sysctl.conf
echo -e "net.core.rmem_max = 16777216" >> /etc/sysctl.conf
echo -e "net.core.wmem_max = 16777216" >> /etc/sysctl.conf
echo -e "net.ipv4.route.gc_timeout = 20" >> /etc/sysctl.conf
echo -e "net.ipv4.ip_local_port_range = 10024 65535" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_retries2 = 5" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_fin_timeout = 30" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_syn_retries = 1" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_synack_retries = 1" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_timestamps = 0" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_tw_recycle = 1" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_tw_reuse = 1" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_keepalive_time = 120" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_keepalive_probes = 3" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_keepalive_intvl = 15" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_max_tw_buckets = 36000" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_max_orphans = 3276800" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_max_syn_backlog = 262144" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_wmem = 8192 131072 16777216" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_rmem = 32768 131072 16777216" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_mem = 94500000 915000000 927000000" >> /etc/sysctl.conf
#/etc/security/limits.conf
echo -e "* soft nproc unlimited" >> /etc/security/limits.conf
echo -e "* hard nproc unlimited" >> /etc/security/limits.conf
echo -e "* soft nofile 655350" >> /etc/security/limits.conf
echo -e "* hard nofile 655350" >> /etc/security/limits.conf
#/etc/proflie
echo -e "ulimit -SHn 655350" >> /etc/profile
echo -e "ulimit -SHu unlimited" >> /etc/profile
echo -e "ulimit -SHd unlimited" >> /etc/profile
echo -e "ulimit -SHm unlimited" >> /etc/profile
echo -e "ulimit -SHs unlimited" >> /etc/profile
echo -e "ulimit -SHt unlimited" >> /etc/profile
echo -e "ulimit -SHv unlimited" >> /etc/profile
source /etc/profile
sysctl -p


%end


%packages
@additional-devel
@base
@compat-libraries
@desktop-platform-devel
@development
@server-platform-devel


%end



###############################################
Centos7.* 7.1:
[iyunv@~]# cobbler import --path=/Centos7/ --name=Centos7.1
[iyunv@~]# chmod 655 /var/lib/cobbler/kickstarts/Centos7.cfg
[iyunv@~]# cobbler profile edit --name=Centos7.1-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos7.cfg
[iyunv@~]# cobbler profile edit --name=Centos7.1-x86_64 --kopts='net.ifnames=0 biosdevname=0'
[iyunv@~]# cobbler profile report --name=Centos7.1-x86_64
[iyunv@~]# cobbler sync


Centos7.cfg 文件示例:
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Reboot after installation
reboot
# Root password
rootpw --iscrypted $1$vrLoecRB$SEfZU7opkIKzYMU9b8Uhi0
# System timezone
timezone Asia/Shanghai
# Use network installation
url --url=$tree
# System language
lang zh_CN
# Firewall configuration
firewall --disabled
# Network information
$SNIPPET('network_config')
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# SELinux configuration
selinux --disabled


# 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=100
part swap --fstype="swap" --size=2000
part / --fstype="xfs" --grow --size=1


%packages
@base
@compat-libraries
@development
%end


%addon com_redhat_kdump --disable --reserve-mb='auto'
%end



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-215373-1-1.html 上篇帖子: bash嵌套expect实现交换机的交互式登录实例 下篇帖子: CentOS 下配置Django项目运行环境 Linux
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表