Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1604704
  • 博文数量: 184
  • 博客积分: 3044
  • 博客等级: 中校
  • 技术积分: 2467
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-25 15:04
文章分类

全部博文(184)

文章存档

2022年(4)

2021年(3)

2020年(1)

2019年(5)

2018年(13)

2017年(6)

2016年(10)

2015年(11)

2014年(11)

2013年(13)

2012年(23)

2011年(25)

2010年(2)

2008年(1)

2007年(5)

2006年(51)

分类: 系统运维

2014-01-07 16:22:42

由于最期对一家业务进行Centos安装时出现一些不安定原因:安装文件过大,Centos6.4的ISO文件近4.4G,不方便拷贝与交换,为此研究了一下Centos安装光盘的制作,有些所得记录下来:
1:每一安装好的Centos在/root下都有几个文件:anaconda-ks.cfg  install.log 
anaconda-ks.cfg是系统生成的安装自动应答文件,以此作为后续ks.cfg的基础进行修改增减
install.log文件则是安装了什么文件

以下都是在已经安装好的Centos下操作:
工具安装:yum install createrepo mkisofs rsync
首先把下载的原Centos6.4的ISO文件挂载到/mnt上
新建一个系统制作目录: /kingdee/sky/OS

同步除了Packages的文件到/kingdee/sky/OS下
rsync -a --exclude=Packages /mnt/* /kingdee/sky/OS/

然后根据 install.log文件找出需要安装的文件并把这些文件放到/kingdee/sky/OS/Packages目录下
cprpm.sh脚本:
#!/bin/bash
cd /root
awk '/安装/ {print $2}' install.log|sed 's/^[0-9]*://' >/root/package.txt
DVD='/mnt/Packages'    
PACKDIR='/root/package.txt'     
NEW_DVD='/kingdee/sky/OS/Packages/'
if [ ! -d $NEW_DVD ];then
     mkdir -p $NEW_DVD
fi
while read LINE
do
cp ${DVD}/${LINE}*.rpm  /${NEW_DVD} || echo "$LINE don't cp......."
done < package.txt
rm -f package.txt
#
注意:在光盘中没有的rpm文件,如haproxy的安装文件,在使用yum安装时,如果把yum.conf的keepcache=0修改成keepcache=1时,yum的安装文件就会保存
在yum.conf指定的目录下,默认是在/var/cache/yum/目录下。 把需要的rpm包拷贝到/kingdee/sky/OS/Packages/下,在ks.cfg指定时就可以正常安装!


生成安装的关系文件
##repo.sh

#####################

点击(此处)折叠或打开

  1. #!/bin/bash
  2. ISO_DIR=/kingdee/sky/OS
  3. copsname=`ls ${ISO_DIR}/repodata/*-comps.xml`
  4. cd ${ISO_DIR}/repodata && mv ${copsname} comps.xml
  5. echo "cd ${ISO_DIR}/repodata && mv ${copsname} comps.xml"


  6. #mv *-comps.xml comps.xml
  7. #删除除comps.xml的所有文件
  8. cd ${ISO_DIR}/repodata && ls .|grep -vx "comps.xml"|xargs -i rm -f {}
  9. echo "cd ${ISO_DIR}/repodata && ls .|grep -vx "comps.xml"|xargs -i rm -f {}"
  10. #回到/disk根目录,就可以重新开始生成comps.xml文件了。
  11. cd ${ISO_DIR}
  12. cp -a /mnt/.discinfo ./
  13. createrepo -g repodata/comps.xml ${ISO_DIR}
  14. echo "createrepo -g repodata/comps.xml ${ISO_DIR}"
  15. declare -x discinfo=`head -1 .discinfo`
  16. echo $discinfo
  17. cd ${ISO_DIR}
  18. copsname=`ls ${ISO_DIR}/repodata/*-comps.xml`
  19. echo $copsname
  20. cd ${ISO_DIR}/repodata && mv ${copsname} comps.xml


  21. createrepo -u "media://$discinfo" -g repodata/comps.xml ${ISO_DIR}
#修改isolinux/isolinux.cfg
label linux
append  ks=cdrom:/ks.cfg  initrd=initrd.img



#制作ISO文件
mkisofs -o  /root/CentOS6.4.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4  -boot-info-table -R -J -v -V "KDweibo Centos6.4 Install DVD" -T  /kingdee/sky/OS/ 


附ks.cfg

点击(此处)折叠或打开

  1. # Kickstart file automatically generated by anaconda.

  2. #version=DEVEL
  3. install
  4. cdrom
  5. lang zh_CN.UTF-8
  6. keyboard us
  7. #network --onboot yes --device eth0 --bootproto static --ip 192.168.227.111 --netmask 255.255.255.0 --gateway 192.168.227.1 --noipv6 --nameserver 8.8.8.8 --hostname db1
  8. network --onboot no --device eth0 --bootproto dhcp --noipv6
  9. rootpw --iscrypted $6$C1ssKNqR4GgcGdhR$10QJcAJ1AM0wXemvQJxm5CKILmO64uGpS83p7FoMvJLeaUzL8V/dQinRDLPJmX7LAMBv/7z2fH7PZC6iKpEA2/
  10. firewall --service=ssh
  11. authconfig --enableshadow --passalgo=sha512
  12. selinux --enforcing
  13. timezone --utc Asia/Shanghai
  14. bootloader --location=mbr
  15. zerombr
  16. # The following is the partition information you requested
  17. # Note that any partitions you deleted are not expressed
  18. # here so unless you clear all partitions first, this is
  19. # not guaranteed to work
  20. #clearpart --linux --drives=sda
  21. clearpart --all --initlabel
  22. part pv.008002 --grow --size=1
  23. volgroup VolGroup --pesize=4096 pv.008002
  24. logvol / --fstype=ext4 --name=lv_root --vgname=VolGroup --grow --size=1024 --maxsize=51200
  25. logvol swap --name=lv_swap --vgname=VolGroup --grow --size=1568 --maxsize=1568

  26. part /boot --fstype=ext4 --size=500


  27. #repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100
  28. %post --interpreter=/usr/bin/env bash
  29. cat >> /etc/security/limits.conf <<EOF
  30. * soft nofile 10240
  31. * hard nofile 10240
  32. root soft nproc 65535
  33. root hard nproc 65535
  34. EOF
  35. cat >>/etc/sysctl.conf <<EOF
  36. #sky added
  37. net.ipv4.conf.lo.arp_ignore = 1
  38. net.ipv4.conf.lo.arp_announce = 2
  39. net.ipv4.conf.all.arp_ignore = 1
  40. net.ipv4.conf.all.arp_announce = 2
  41.  
  42. net.core.rmem_max=16777216
  43. net.core.wmem_max=16777216
  44. net.ipv4.tcp_rmem=4096 87380 16777216
  45. net.ipv4.tcp_wmem=4096 16384 16777216
  46. net.core.somaxconn=4096
  47. net.core.netdev_max_backlog=16384
  48. net.ipv4.tcp_max_syn_backlog=8192
  49. net.ipv4.tcp_syncookies=1
  50. net.ipv4.ip_local_port_range=1024 65535
  51. net.ipv4.tcp_tw_recycle=1
  52. net.ipv4.tcp_congestion_control=cubic
  53. #************************************
  54. EOF
  55. echo "nameserver 8.8.8.8" >/etc/resolv.conf
  56. %end
  57. %packages
  58. @chinese-support
  59. @core
  60. @server-policy
  61. gcc
  62. memcached
  63. make
  64. ncurses-devel
  65. libxml2-devel
  66. gd
  67. gd-devel
  68. autoconf
  69. make
  70. ncurses-devel
  71. yum-priorities
  72. vim
  73. haproxy
  74. openssh-clients
  75. wget
  76. nc
  77. ImageMagick
  78. libxslt
  79. zip
  80. unzip
  81. xmlto
  82. pcre-devel
  83. openssl
  84. %end












阅读(2320) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~