码迷,mamicode.com
首页 > 系统相关 > 详细

Cobbler无人值守全自动安装部署Linux系统

时间:2016-05-10 18:56:36      阅读:366      评论:0      收藏:0      [点我收藏+]

标签:linux   网卡   cobbler   kickstart   

注意事项:使用VMware Workstation实验时,注意网卡的模式,NAT模式下关闭默认的DHCP服务器!

[root@~]# cat /etc/redhat-release 

CentOS release 6.7 (Final)

[root@~]# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

[root@~]# yum install cobbler cobbler-web dhcp cman pykickstart debmirror python-ctypes -y

[root@~]# yum install pykickstart debmirror python-ctypes -y

[root@~]# vim /etc/httpd/conf/httpd.conf  #编辑修改http配置文件

ServerName localhost:80

[root@~]# cat /etc/xinetd.d/rsync |grep disable

disable = no

[root@~]# cat /etc/xinetd.d/tftp |grep disable

    disable                 = no


[root@~]# service httpd start

[root@~]# service xinetd start

[root@~]# service cobblerd start 

[root@~]# cobbler get-loaders # 首次执行会报错,重新启动cobbler再次执行即可

[root@~]# service cobblerd restart

[root@~]# cobbler get-loaders  #再次执行,等待下载完成即可[需要联网]


[root@~]# sed -i ‘s@next_server: 127.0.0.1@next_server: 192.168.1.10@g‘ /etc/cobbler/settings

[root@~]# sed -i ‘s@server: 127.0.0.1@server: 192.168.1.10@g‘ /etc/cobbler/settings

[root@~]# sed -i ‘s$@arches="i386"$#@arches="i386"$g‘ /etc/debmirror.conf

[root@~]# sed  -i ‘s$@dists="sid"$#@dists="sid"$g‘ /etc/debmirror.conf

[root@~]# openssl passwd -1 -salt ‘random-phrase-here‘ ‘yangjie‘

[root@~]# $1$random-p$LVezyn3LDLBs0eno3kbbN/

[root@~]# vim /etc/cobbler/settings  #修改密码    

default_password_crypted: "$1$random-p$LVezyn3LDLBs0eno3kbbN/"


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


[root@~]# cp /etc/cobbler/dhcp.template /etc/dhcp/dhcpd.conf

[root@~]# vim /etc/dhcp/dhcpd.conf

[root@~]# 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";

          }

     }

}

[root@~]# mount /dev/sr0 /media

[root@~]# cobbler import --path=/media/ --name=Centos6.7 #添加镜像文件

[root@~]# cobbler list

[root@~]# cobber distro list

[root@~]# cobbler profile report

#添加镜像文件时默认关联cfg文件,文件路径为/var/lib/cobbler/kickstart/sample_end.cfg

#可以直接使用默认文件进行安装!此处修改关联ks文件,

[root@~]# cobbler profile edit --name=Centos6.7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos6.cfg 

[root@~]# cobbler sync    #每次修改设置后执行同步操作生效

[root@~]# service httpd restart

[root@~]# service xinetd restart

[root@~]# service dhcpd restart

[root@~]# service cobblerd restart



安装kickstart程序可以自定义自己需要的ks文件:

[root@~]# 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:

[root@~]# cobbler import --path=/Centos7/ --name=Centos7.1

[root@~]# chmod 655 /var/lib/cobbler/kickstarts/Centos7.cfg

[root@~]# cobbler profile edit --name=Centos7.1-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos7.cfg 

[root@~]# cobbler profile edit --name=Centos7.1-x86_64 --kopts=‘net.ifnames=0 biosdevname=0‘

[root@~]# cobbler profile report --name=Centos7.1-x86_64

[root@~]# 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


本文出自 “筱枫网络” 博客,请务必保留此出处http://jie1215.blog.51cto.com/2183736/1771878

Cobbler无人值守全自动安装部署Linux系统

标签:linux   网卡   cobbler   kickstart   

原文地址:http://jie1215.blog.51cto.com/2183736/1771878

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!