Cobbler是什么?
- [root@server1 ~]# wget http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
- [root@server1 ~]# rpm -ivh epel-release-5-4.noarch.rpm
- warning: epel-release-5-4.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6
- Preparing... ########################################### [100%]
- 1:epel-release ########################################### [100%]
- [root@server1 ~]#
- [root@server1 ~]# yum -y install cobbler httpd rsync tftp-server xinetd dhcp python-ctypes pykickstart cman
- ...
- cobbler-2.2.2-1.el5.rf.noarch from rpmforge has depsolving problems
- --> Missing Dependency: python-netaddr is needed by package cobbler-2.2.2-1.el5.rf.noarch (rpmforge)
- cobbler-2.2.2-1.el5.rf.noarch from rpmforge has depsolving problems
- --> Missing Dependency: mod_wsgi is needed by package cobbler-2.2.2-1.el5.rf.noarch (rpmforge)
- Error: Missing Dependency: python-netaddr is needed by package cobbler-2.2.2-1.el5.rf.noarch (rpmforge)
- Error: Missing Dependency: mod_wsgi is needed by package cobbler-2.2.2-1.el5.rf.noarch (rpmforge)
- You could try using --skip-broken to work around the problem
- You could try running: package-cleanup --problems
- package-cleanup --dupes
- rpm -Va --nofiles --nodigest
- [root@server1 ~]# wget ftp://rpmfind.net/linux/epel/5/i386/python-netaddr-0.5.2-1.el5.noarch.rpm
- [root@server1 ~]# rpm -ivh python-netaddr-0.5.2-1.el5.noarch.rpm
- warning: python-netaddr-0.5.2-1.el5.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6
- Preparing... ########################################### [100%]
- 1:python-netaddr ########################################### [100%]
- [root@server1 ~]# wget ftp://rpmfind.net/linux/epel/5/i386/mod_wsgi-3.2-2.el5.i386.rpm
- [root@server1 ~]# rpm -ivh mod_wsgi-3.2-2.el5.i386.rpm
- warning: mod_wsgi-3.2-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6
- Preparing... ########################################### [100%]
- 1:mod_wsgi ########################################### [100%]
- [root@server1 ~]# yum -y install cobbler httpd rsync tftp-server xinetd dhcp python-ctypes pykickstart cman
- ...中间省略
- [root@server1 ~]# chkconfig httpd on
- [root@server1 ~]# chkconfig cobblerd on
- [root@server1 ~]# chkconfig dhcpd on
- [root@server1 ~]# chkconfig xinetd on
- [root@server1 ~]#/etc/init.d/iptables stop
- [root@server1 ~]#chkconfig --level 35 iptables off
- [root@server1 ~]#chmod +x /etc/init.d/cobbler_all
- 用法:/etc/init.d/cobbler_all start|stop|startus|sync
- #!/bin/bash
- case $1 in
- start)
- /etc/init.d/httpd start
- /etc/init.d/xinetd start
- /etc/init.d/dhcpd start
- /etc/init.d/cobblerd start
- ;;
- stop)
- /etc/init.d/httpd stop
- /etc/init.d/xinetd stop
- /etc/init.d/dhcpd stop
- /etc/init.d/cobblerd stop
- ;;
- status)
- /etc/init.d/httpd status
- /etc/init.d/xinetd status
- /etc/init.d/dhcpd status
- /etc/init.d/cobblerd status
- ;;
- sync)
- cobbler sync
- ;;
- *)
- echo "Input error,please in put 'start|stop|status|sync'!";
- exit 2>&1 >/dev/null &
- ;;
- esac
- [root@server1 ~]# vim /etc/cobbler/settings
- next_server: 127.0.0.1 修改为:next_server: 192.168.0.45(是cobbler服务器的地址)
- server: 127.0.0.1 修改为: server: 192.168.0.45(是cobbler服务器的地址)
- manage_dhcp: 0 修改为 manage_dhcp: 1 (1意思就是由cobbler自动管理dhcpd)
- manage_rsync: 0 修改为 manage_rsync: 1 (1意思就是由cobbler自动管理rsync)
- [root@server1 ~]# vim /etc/httpd/conf/httpd.conf 在LoadModule附近 添加以下行
- LoadModule suexec_module modules/mod_suexec.so
- LoadModule disk_cache_module modules/mod_disk_cache.so
- LoadModule file_cache_module modules/mod_file_cache.so
- LoadModule mem_cache_module modules/mod_mem_cache.so
- LoadModule cgi_module modules/mod_cgi.so
- LoadModule version_module modules/mod_version.so
- LoadModule wsgi_module modules/mod_wsgi.so <- 在这里添加这行
- [root@server1 ~]# service httpd start
- 启动 httpd: [确定]
- [root@server1 ~]# service cobblerd start
- Starting cobbler daemon: [确定]
- [root@server1 ~]#
- [root@server1 ~]# vim /etc/xinetd.d/rsync
- service rsync
- {
- disable = no 修改yes 为 no(就是启用)
- socket_type = stream
- wait = no
- user = root
- server = /usr/bin/rsync
- server_args = --daemon
- log_on_failure += USERID
- }
- [root@server1 ~]# vim /etc/xinetd.d/tftp
- service tftp
- {
- socket_type = dgram
- protocol = udp
- wait = yes
- user = root
- server = /usr/sbin/in.tftpd
- server_args = -s /tftpboot
- disable = no 修改yes 为 no(就是启用)
- per_source = 11
- cps = 100 2
- flags = IPv4
- }
- [root@server1 ~]# vim /etc/cobbler/dhcp.template
- ddns-update-style interim;
- allow booting;
- allow bootp;
- ignore client-updates;
- set vendorclass = option vendor-class-identifier;
- subnet 192.168.0.0 netmask 255.255.255.0 {
- option routers 192.168.0.1;
- option domain-name-servers 192.168.0.1;
- option subnet-mask 255.255.255.0;
- range dynamic-bootp 192.168.0.10 192.168.0.20;
- filename "/pxelinux.0";
- default-lease-time 21600;
- max-lease-time 43200;
- next-server $next_server;
- }
- [root@server1 ~]# cobbler check
- The following are potential configuration items that you may want to fix:
- 1 : some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely. Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
- 2 : debmirror package is not installed, it will be required to manage debian deployments and repositories
- 3 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
- Restart cobblerd and then run 'cobbler sync' to apply changes.
- [root@server1 ~]# cobbler get-loaders
- task started: 2012-12-09_055900_get_loaders
- task started (id=Download Bootloader Content, time=Sun Dec 9 05:59:00 2012)
- downloading http://dgoodwin.fedorapeople.org/loaders/README to /var/lib/cobbler/loaders/README
- downloading http://dgoodwin.fedorapeople.org/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
- downloading http://dgoodwin.fedorapeople.org/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
- downloading http://dgoodwin.fedorapeople.org/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
- downloading http://dgoodwin.fedorapeople.org/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
- downloading http://dgoodwin.fedorapeople.org/loaders/yaboot-1.3.14-12 to /var/lib/cobbler/loaders/yaboot
- downloading http://dgoodwin.fedorapeople.org/loaders/pxelinux.0-3.61 to /var/lib/cobbler/loaders/pxelinux.0
- downloading http://dgoodwin.fedorapeople.org/loaders/menu.c32-3.61 to /var/lib/cobbler/loaders/menu.c32
- downloading http://dgoodwin.fedorapeople.org/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
- downloading http://dgoodwin.fedorapeople.org/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
- *** TASK COMPLETE *** <-看到这就代表成功完成
- [root@server1 ~]# openssl passwd -1 -salt 'thinkpad' '123456'
- $1$thinkpad$NIq68XbeN51UgdtXiSOAE.
- default_password_crypted: "$1$thinkpad$NIq68XbeN51UgdtXiSOAE."
- [root@server1 log]# mkdir /mnt/centos5.6
- [root@server1 log]# mount /dev/cdrom /mnt/centos5.6/
- mount: block device /dev/cdrom is write-protected, mounting read-only
- [root@server1 log]# cobbler import --path=/mnt/centos5.6/ --name=centos5.6-i386 这个进行的时间比较长
- task started: 2012-12-09_064244_import
- task started (id=Media import, time=Sun Dec 9 06:42:44 2012)
- Found a redhat compatible signature: CentOS
- adding distros
- creating new distro: centos5.6-xen-i386
- creating new profile: centos5.6-xen-i386
- creating new distro: centos5.6-i386
- creating new profile: centos5.6-i386
- associating repos
- traversing distro centos5.6-xen-i386
- descent into /var/www/cobbler/ks_mirror/centos5.6-i386
- processing repo at : /var/www/cobbler/ks_mirror/centos5.6-i386
- need to process repo/comps: /var/www/cobbler/ks_mirror/centos5.6-i386
- looking for /var/www/cobbler/ks_mirror/centos5.6-i386/repodata/*comps*.xml
- running: createrepo -c cache -s sha --groupfile /var/www/cobbler/ks_mirror/centos5.6-i386/repodata/comps.xml /var/www/cobbler/ks_mirror/centos5.6-i386
- 2644/2644 - CentOS/boost-doc-1.33.1-10.el5.i386.rpm pm86.rpm
- Saving Primary metadata
- Saving file lists metadata
- Saving other metadata
- received on stderr: This option is deprecated
- traversing distro centos5.6-i386
- descent into /var/www/cobbler/ks_mirror/centos5.6-i386
- processing repo at : /var/www/cobbler/ks_mirror/centos5.6-i386
- need to process repo/comps: /var/www/cobbler/ks_mirror/centos5.6-i386
- looking for /var/www/cobbler/ks_mirror/centos5.6-i386/repodata/*comps*.xml
- running: createrepo -c cache -s sha --groupfile /var/www/cobbler/ks_mirror/centos5.6-i386/repodata/comps.xml /var/www/cobbler/ks_mirror/centos5.6-i386
- 2644/2644 - CentOS/boost-doc-1.33.1-10.el5.i386.rpm pm86.rpm
- Saving Primary metadata
- Saving file lists metadata
- Saving other metadata
- received on stderr: This option is deprecated
- associating kickstarts
- *** TASK COMPLETE *** <-看到这就代表成功完成
- [root@server1 ~]# service cobblerd restart
- Stopping cobbler daemon: [确定]
- Starting cobbler daemon: [确定]
- [root@server1 ~]# cobbler sync
- task started: 2012-12-09_070816_sync
- task started (id=Sync, time=Sun Dec 9 07:08:16 2012)
- running pre-sync triggers
- cleaning trees
- removing: /var/www/cobbler/images/centos5.6-i386
- removing: /var/www/cobbler/images/centos5.6-xen-i386
- removing: /tftpboot/pxelinux.cfg/default
- removing: /tftpboot/grub/efidefault
- removing: /tftpboot/grub/grub-x86_64.efi
- removing: /tftpboot/grub/images
- removing: /tftpboot/grub/grub-x86.efi
- removing: /tftpboot/s390x/profile_list
- copying bootloaders
- trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /tftpboot/grub/grub-x86_64.efi
- trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /tftpboot/grub/grub-x86.efi
- copying distros to tftpboot
- copying files for distro: centos5.6-xen-i386
- trying hardlink /var/www/cobbler/ks_mirror/centos5.6-i386/images/xen/vmlinuz -> /tftpboot/images/centos5.6-xen-i386/vmlinuz
- trying hardlink /var/www/cobbler/ks_mirror/centos5.6-i386/images/xen/initrd.img -> /tftpboot/images/centos5.6-xen-i386/initrd.img
- copying files for distro: centos5.6-i386
- trying hardlink /var/www/cobbler/ks_mirror/centos5.6-i386/images/pxeboot/vmlinuz -> /tftpboot/images/centos5.6-i386/vmlinuz
- trying hardlink /var/www/cobbler/ks_mirror/centos5.6-i386/images/pxeboot/initrd.img -> /tftpboot/images/centos5.6-i386/initrd.img
- copying images
- generating PXE configuration files
- generating PXE menu structure
- copying files for distro: centos5.6-xen-i386
- trying hardlink /var/www/cobbler/ks_mirror/centos5.6-i386/images/xen/vmlinuz -> /var/www/cobbler/images/centos5.6-xen-i386/vmlinuz
- trying hardlink /var/www/cobbler/ks_mirror/centos5.6-i386/images/xen/initrd.img -> /var/www/cobbler/images/centos5.6-xen-i386/initrd.img
- copying files for distro: centos5.6-i386
- trying hardlink /var/www/cobbler/ks_mirror/centos5.6-i386/images/pxeboot/vmlinuz -> /var/www/cobbler/images/centos5.6-i386/vmlinuz
- trying hardlink /var/www/cobbler/ks_mirror/centos5.6-i386/images/pxeboot/initrd.img -> /var/www/cobbler/images/centos5.6-i386/initrd.img
- rendering DHCP files
- generating /etc/dhcpd.conf
- rendering TFTPD files
- generating /etc/xinetd.d/tftp
- cleaning link caches
- rendering Rsync files
- running post-sync triggers
- running python triggers from /var/lib/cobbler/triggers/sync/post/*
- running python trigger cobbler.modules.sync_post_restart_services
- running: dhcpd -t -q
- received on stdout:
- received on stderr:
- running: service dhcpd restart
- received on stdout: 关闭 dhcpd:[确定]
- 启动 dhcpd:[确定]
- received on stderr:
- running shell triggers from /var/lib/cobbler/triggers/sync/post/*
- running python triggers from /var/lib/cobbler/triggers/change/*
- running python trigger cobbler.modules.scm_track
- running shell triggers from /var/lib/cobbler/triggers/change/*
- *** TASK COMPLETE *** <-看到这就代表成功完成
- [root@server1 ~]# cobbler profile edit --name=centos5.6-i386 --distro=centos5.6-i386 --kickstart=/var/lib/cobbler/kickstarts/centos5.6-i386.ks
- #platform=x86, AMD64, or Intel EM64T
- # System authorization information
- auth --useshadow --enablemd5
- # System bootloader configuration
- bootloader --location=mbr
- # Partition clearing information
- clearpart --all --initlabel
- # Use text mode install
- text
- # Firewall configuration
- firewall --disable
- # Run the Setup Agent on first boot
- firstboot --disable
- # System keyboard
- keyboard us
- # System language
- lang zh_CN.UTF-8
- # Use network installation
- url --url=$tree
- # If any cobbler repo definitions were referenced in the kickstart profile, include them here.
- $yum_repo_stanza
- # Network information
- $SNIPPET('network_config')
- # Reboot after installation
- reboot
- #Root password
- rootpw --iscrypted $default_password_crypted
- # SELinux configuration
- selinux --disabled
- # Do not configure the X Window System
- skipx
- # System timezone
- timezone Asia/Shanghai
- # Install OS instead of upgrade
- install
- # Clear the Master Boot Record
- zerombr
- # Allow anaconda to partition the system as needed
- # autopart
- #NO LVM 这里的分区没有配置LVM
- part /boot --bytes-per-inode=4096 --fstype="ext3" --size=200
- part swap --bytes-per-inode=4096 --fstype="swap" --size=800
- part / --bytes-per-inode=4096 --fstype="ext3" --size=5000
- part /data --bytes-per-inode=4096 --fstype="ext3" --grow --size=1
- #LVM Setting 这的分区有配置LVM
- #part /boot --bytes-per-inode=4096 --fstype="ext3" --size=200
- #part swap --bytes-per-inode=4096 --fstype="swap" --size=800
- #part pv.01 --size=1 --grow
- #volgroup myvg pv.01
- #logvol / --vgname=myvg --size=5000 --name=rootvol --bytes-per-inode=4096 --fstype="ext3"
- #logvol /data --vgname=myvg --size=1 --grow --name=datavol --bytes-per-inode=4096 --fstype="ext3"
- # network configure
- network --bootproto=dhcp --device=eth0 --noipv6 --onboot=on --hostname=test.com
- # network --bootproto=static --device=eth1 --ip=192.168.1.2 --netmask=255.255.255.0 --gateway=192.168.1.1 --noipv6 --onboot=on
- %pre
- $SNIPPET('log_ks_pre')
- $SNIPPET('kickstart_start')
- $SNIPPET('pre_install_network_config')
- # Enable installation monitoring
- $SNIPPET('pre_anamon')
- %packages
- #$SNIPPET('func_install_if_enabled')
- #$SNIPPET('puppet_install_if_enabled')
- @base
- @editors
- @development-libs
- @development-tools
- @x-software-development
- @system-tools
- @text-internet
- @chinese-support
- imake
- expect
- %post
- $SNIPPET('log_ks_post')
- # Start yum configuration
- $yum_config_stanza
- # End yum configuration
- $SNIPPET('post_install_kernel_options')
- $SNIPPET('post_install_network_config')
- $SNIPPET('func_register_if_enabled')
- $SNIPPET('puppet_register_if_enabled')
- $SNIPPET('download_config_files')
- $SNIPPET('koan_environment')
- $SNIPPET('redhat_register')
- $SNIPPET('cobbler_register')
- # Enable post-install boot notification
- $SNIPPET('post_anamon')
- # Start final steps
- $SNIPPET('kickstart_done')
- # End final steps
- %post
- echo "ulimit -SHn 102400" >> /etc/rc.local
- sed -i 's/HISTSIZE\=1000/HISTSIZE\=50/' /etc/profile
- sed -i "s/ca::ctrlaltdel:\/sbin\/shutdown -t3 -r now/#ca::ctrlaltdel:\/sbin\/shutdown -t3 -r now/" /etc/inittab
- sed -i '48,50 s/^/#/' /etc/inittab
- /sbin/init q
- sed -i "8 s/^/alias vi='vim'/" /root/.bashrc
- cat >> /root/.vimrc << EOF
- syntax on
- set number
- set autoindent
- set shiftwidth=4
- set encoding=utf-8 fileencodings=ucs-bom,utf-8,cp936
- EOF
- sed -i -e '74 s/^/#/' -i -e '76 s/^/#/' /etc/ssh/sshd_config
- sed -i "s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config
- sed -i -e '44 s/^/#/' -i -e '48 s/^/#/' /etc/ssh/sshd_config
- for i in `ls /etc/rc3.d/S*`
- do
- CURSRV=`echo $i|cut -c 15-`
- echo $CURSRV
- case $CURSRV in
- crond | irqbalance | microcode_ctl | network | random | sshd | syslog | local )
- echo "Base services, Skip!"
- ;;
- *)
- echo "change $CURSRV to off"
- chkconfig --level 235 $CURSRV off
- service $CURSRV stop
- ;;
- esac
- done
- true > /etc/sysctl.conf
- cat >> /etc/sysctl.conf << EOF
- kernel.sysrq = 0
- kernel.core_uses_pid = 1
- kernel.msgmnb = 65536
- kernel.msgmax = 65536
- kernel.shmmax = 68719476736
- kernel.shmall = 4294967296
- 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 = 262144
- net.core.somaxconn = 262144
- net.ipv4.ip_forward = 0
- net.ipv4.conf.default.rp_filter = 1
- net.ipv4.conf.default.accept_source_route = 0
- net.ipv4.tcp_syncookies = 1
- net.ipv4.tcp_max_tw_buckets = 6000
- net.ipv4.tcp_sack = 1
- net.ipv4.tcp_window_scaling = 1
- net.ipv4.tcp_rmem = 4096 87380 4194304
- net.ipv4.tcp_wmem = 4096 16384 4194304
- net.ipv4.tcp_max_orphans = 3276800
- net.ipv4.tcp_max_syn_backlog = 262144
- net.ipv4.tcp_timestamps = 0
- net.ipv4.tcp_synack_retries = 1
- net.ipv4.tcp_syn_retries = 1
- net.ipv4.tcp_tw_recycle = 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 = 1200
- net.ipv4.ip_local_port_range = 1024 65535
- EOF
- /sbin/sysctl -p