免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 12553 | 回复: 12
打印 上一主题 下一主题

[系统管理] PXE+httpd+dhcp+kickstart自动安装系统(window和Linux双平台) [复制链接]

论坛徽章:
7
双子座
日期:2013-09-09 15:55:31CU大牛徽章
日期:2013-09-18 15:22:06CU大牛徽章
日期:2013-09-18 15:22:20CU大牛徽章
日期:2013-09-18 15:22:26CU大牛徽章
日期:2013-09-18 15:22:31CU大牛徽章
日期:2013-09-18 15:22:37CU大牛徽章
日期:2013-09-18 15:22:46
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-07-05 16:01 |只看该作者 |倒序浏览
本帖最后由 milujite 于 2012-07-05 17:57 编辑

一项目利旧了几台2950,没DVD,想装RHEL5.动手照着教程弄了个自动安装,在虚拟机上测试了下,可行
Linux平台
  1. 1、配置本地源并安装软件包将安装介质复制到/var/www/html目录,新建rhel-local.repo文件创建一个本地repo
  2. [root@PXEBoot ~]#vi /etc/yum.repo.d/rhel-local.repo
  3. [rhel-Server]
  4. name=Red Hat Enterprise Linux $releasever - Server
  5. baseurl=file:///var/www/html/Server
  6. enabled=1
  7. gpgcheck=0
  8. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
  9. [rhel-VT]
  10. name=Red Hat Enterprise Linux $releasever - VT
  11. baseurl=file:///var/www/html/VT
  12. enabled=1
  13. gpgcheck=0
  14. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
  15. [rhel-Cluster]
  16. name=Red Hat Enterprise Linux $releasever - Cluster
  17. baseurl=file:///var/www/html/Cluster
  18. enabled=1
  19. gpgcheck=0
  20. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
  21. [rhel-ClusterStorage]
  22. name=Red Hat Enterprise Linux $releasever - ClusterStorage
  23. baseurl=file:///var/www/html/ClusterStorage
  24. enabled=1
  25. gpgcheck=0
  26. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

  27. 2、安装软件包
  28. [root@PXEBoot ~]#yum install httpd
  29. [root@PXEBoot ~]#yum install dhcp
  30. 如果想用图形界面来写kickstart规则和配置网络启动,可以安装以下两个工具
  31. [root@PXEBoot ~]#yum install system-config-kickstart
  32. [root@PXEBoot ~]#yum install system-config-netboot

  33. 3、配置启动dhcp服务器,这里我的安装网络是172.16.100.0,tftp服务器是本机172.16.100.254,bootloader是pxelinux.0
  34. [root@PXEBoot ~]#vi /etc/dhcpd.conf
  35. ddns-update-style interim;

  36. subnet 172.16.100.0 netmask 255.255.255.0 {

  37. # --- default gateway
  38.      option routers               172.16.100.1;
  39.      option subnet-mask          255.255.255.0;

  40.      option time-offset          -18000;     # Eastern Standard Time
  41.    
  42. #     option ntp-servers          192.168.1.1;
  43. #     option netbios-name-servers     192.168.1.1;
  44. # --- Selects point-to-point node (default is hybrid). Don't change this unless
  45. # -- you understand Netbios very well
  46. #     option netbios-node-type 2;

  47.      next-server 172.16.100.254;
  48.      filename "pxelinux.0";
  49.      range dynamic-bootp 172.16.100.10 172.16.100.250;
  50.      default-lease-time 21600;
  51.      max-lease-time 43200;

  52.      # we want the nameserver to appear at a fixed address
  53.      #host ns {
  54.      #     next-server marvin.redhat.com;
  55.      #     hardware ethernet 12:34:56:78:AB:CD;
  56.      #     fixed-address 207.175.42.254;
  57.      #}
  58. }
  59. [root@PXEBoot ~]# /etc/init.d/dhcpd restart

  60. 4、配置tftp服务器
  61. [root@PXEBoot ~]# vi /etc/xinetd.d/tftp
  62. # default: off
  63. # description: The tftp server serves files using the trivial file transfer \
  64. #     protocol.  The tftp protocol is often used to boot diskless \
  65. #     workstations, download configuration files to network-aware printers, \
  66. #     and to start the installation process for some operating systems.
  67. service tftp
  68. {
  69.      socket_type          = dgram
  70.      protocol          = udp
  71.      wait               = yes
  72.      user               = root
  73.      server               = /usr/sbin/in.tftpd
  74.      server_args          = -s /tftpboot
  75.      disable               = no
  76.      per_source          = 11
  77.      cps               = 100 2
  78.      flags               = IPv4
  79. }
  80. [root@PXEBoot ~]#/etc/init.d/xinetd restart

  81. 5、配置httpd服务器,注释welcome.conf配置
  82. [root@PXEBoot ~]# vi /etc/httpd/conf.d/welcome.conf
  83. #<LocationMatch "^/+$">
  84. #    Options -Indexes
  85. #    ErrorDocument 403 /error/noindex.html
  86. #</LocationMatch>
  87. [root@PXEBoot ~]# /etc/init.d/httpd restart

  88. 6、在/tftpboot目录下建立以下目录结构,从/var/www/html/isolinux目录复制boot.msg,general.msg,param.msg,rescue.msg到pxelinux.cfg目录下,并且复制isolinux.cfg文件为default文件;复制initrd.img,vmlinuz到rhel5.7目录下;从/usr/lib/syslinux目录复制pxelinux.0到/tftpboot目录。
  89. /tftpboot/
  90. |-- pxelinux.0
  91. |-- pxelinux.cfg
  92. |     |-- boot.msg
  93. |     |-- general.msg
  94. |     |-- options.msg
  95. |     |-- param.msg
  96. |     |-- rescue.msg
  97. |     `-- default
  98. `-- rhel5.7
  99.       |-- initrd.img
  100.       `-- vmlinuz

  101. 7、修改default配置文件
  102. [root@PXEBoot ~]# vi /tftpboot/pxelinux.cfg/default
  103. default web
  104. prompt 1
  105. timeout 100
  106. display boot.msg
  107. F1 boot.msg
  108. F2 options.msg
  109. F3 general.msg
  110. F4 param.msg
  111. F5 rescue.msg
  112. label web
  113.   kernel rhel5.7/vmlinuz
  114.   append initrd=rhel5.7/initrd.img ks=http://172.16.100.254/ks/web.cfg
  115. label db
  116.   kernel rhel5.7/vmlinuz
  117.   append initrd=rhel5.7/initrd.img ks=http://172.16.100.254/ks/db.cfg
  118. label text
  119.   kernel rhel5.7/vmlinuz
  120.   append initrd=rhel5.7/initrd.img text
  121. label ks
  122.   kernel rhel5.7/vmlinuz
  123.   append ks initrd=rhel5.7/initrd.img
  124. label local
  125.   localboot 1
  126. label memtest86
  127.   kernel rhel5.7/memtest
  128.   append -

  129. 8、生成kickstart配置文件
  130. kickstart可以从已经安装的系统anaconda-ks.cfg文件复制而来,也可以使用system-config-kickstart程序来生成,建议使用后者生成,再进行修改。由于需要kickstart文件能被http访问到,因此讲kickstart文件放在/var/www/html/ks目录下,内容大致如下,配置中的分区信息等可以根据需要进行修改:
  131. [root@PXEBoot ~]# vi /var/www/html/ks/web.cfg
  132. #platform=x86, AMD64, or Intel EM64T
  133. #skip input subscribe number
  134. key --skip
  135. # System authorization information
  136. auth  --useshadow  --enablemd5
  137. # System bootloader configuration
  138. bootloader --append="rhgb quiet" --location=mbr --driveorder=sda
  139. # Clear the Master Boot Record
  140. zerombr
  141. # Partition clearing information
  142. clearpart --all --initlabel
  143. # Use graphical install
  144. graphical
  145. # Firewall configuration
  146. firewall --disabled
  147. # Run the Setup Agent on first boot
  148. firstboot --disable
  149. # System keyboard
  150. keyboard us
  151. # System language
  152. lang en_US
  153. # Installation logging level
  154. logging --level=info
  155. # Use network installation
  156. url --url=http://172.16.100.254/
  157. # Network information
  158. network --bootproto=dhcp --device=eth0 --onboot=on
  159. # Reboot after installation
  160. reboot
  161. #Root password
  162. rootpw --iscrypted xxxxxxxxxxxxxxxxxxxxxxxxxxx

  163. # SELinux configuration
  164. selinux --disabled
  165. # System timezone
  166. timezone  Asia/Shanghai
  167. # Install OS instead of upgrade
  168. install
  169. # X Window System configuration information
  170. # Disk partitioning information
  171. part /boot --asprimary --bytes-per-inode=4096 --fstype="ext3" --size=200
  172. part / --asprimary --bytes-per-inode=4096 --fstype="ext3" --size=4096
  173. part swap --asprimary --bytes-per-inode=4096 --fstype="swap" --size=512
  174. part pv.0 --size=100 --grow --asprimary
  175. volgroup redhatvg --pesize=32768 pv.0
  176. logvol /var --fstype ext3 --name=varlv --vgname=redhatvg --size=1024
  177. logvol /home --fstype ext3 --name=homelv --vgname=redhatvg --size=1024

  178. %packages
  179. @base
  180. @core
  181. @development-tools
  182. @base-x
  183. @x-software-development
  184. @gnome-desktop
  185. @admin-tools
  186. @gnome-software-development
  187. @development-libs
  188. @legacy-software-development
  189. @legacy-software-support
  190. @system-tools
  191. @editors
  192. @java-development
  193. @java
  194. @text-internet
  195. @graphical-internet
  196. kexec-tools
  197. iscsi-initiator-utils
  198. fipscheck
  199. device-mapper-multipath
  200. sgpio
  201. python-dmidecode
  202. imake
  203. emacs
  204. audit
  205. mesa-libGLU-devel
  206. xorg-x11-utils
  207. xorg-x11-server-Xnest
  208. xorg-x11-server-Xvfb
  209. -nspluginwrapper

  210. 9、这样一个完整的自动PXE网络安装RHEL环境就完成了,在同个局域网中从网络启动一个虚拟机
  211. 超时时间过后,或者手动输入需要安装的设置,如web/db等,系统将进入系统安装界面。
复制代码
windows平台
没Linux的童鞋可以使用windows的tftpd32软件配合filezilla server搞一个,tftpd32的配置手册很详细,只需要修改几个参数,修改kickstart配置文件的url,default配置文件的ks文件位置url就可以了。
  1. 本机IP地址172.16.100.1,tftp服务器地址172.16.100.1,tftproot是D:\boottftp\pxe,ftp服务器也是172.16.100.1,帐号ftp,密码ftp,ftp的root目录为d:\boottftp\rhel,目录结构如下:
  2. D:\boottftp
  3.       |--filezilla ftp服务器软件
  4.       |--pxe   pxeroot所在位置
  5.       |     |--pxelinux.cfg   存放pxelinux配置文件
  6.       |     |      |--default   pxe配置文件
  7.       |     |--rhel5.7   存放内核和initrd文件
  8.       |     |      |--initrd.img  启动用的initrd文件
  9.       |     |      |--vmlinuz   内核文件
  10.       |     |--pxelinux.0   pxeboot loader文件          
  11.       |--rhel  rhel的iso解压路径
  12.       |     |--ks   存放kickstart文件
  13.       |          |--web.cfg   web服务器的kickstart安装配置文件
  14.       |          |--db.cfg    数据库服务器的kickstart安装配置文件
  15.       |     |--RHEL ISO解出来的文件
  16.       |--tftpd64 tftpd32的64位版本,系统不支持64就用tftpd32吧。从这个网页下载http://tftpd32.jounin.net/tftpd32_download.html-server-Xvfb

  17. web.cfg内容
  18. #platform=x86, AMD64, or Intel EM64T
  19. #skip input subscribe number
  20. key --skip
  21. # System authorization information
  22. auth  --useshadow  --enablemd5
  23. # System bootloader configuration
  24. bootloader --append="rhgb quiet" --location=mbr --driveorder=sda
  25. # Clear the Master Boot Record
  26. zerombr
  27. # Partition clearing information
  28. clearpart --all --initlabel
  29. # Use graphical install
  30. graphical
  31. # Firewall configuration
  32. firewall --disabled
  33. # Run the Setup Agent on first boot
  34. firstboot --disable
  35. # System keyboard
  36. keyboard us
  37. # System language
  38. lang en_US
  39. # Installation logging level
  40. logging --level=info
  41. # Use network installation
  42. url --url=ftp://ftp:ftp@172.16.100.1/
  43. # Network information
  44. network --bootproto=dhcp --device=eth0 --onboot=on
  45. # Reboot after installation
  46. reboot
  47. #Root password
  48. rootpw --iscrypted $1$y1mdu23U$rD7iEgyLLbadfGviGpD460

  49. # SELinux configuration
  50. selinux --disabled
  51. # System timezone
  52. timezone  Asia/Shanghai
  53. # Install OS instead of upgrade
  54. install
  55. # X Window System configuration information
  56. # Disk partitioning information
  57. part /boot --asprimary --bytes-per-inode=4096 --fstype="ext3" --size=200
  58. part / --asprimary --bytes-per-inode=4096 --fstype="ext3" --size=4096
  59. part swap --asprimary --bytes-per-inode=4096 --fstype="swap" --size=512
  60. part pv.0 --size=100 --grow --asprimary
  61. volgroup redhatvg --pesize=32768 pv.0
  62. logvol /var --fstype ext3 --name=varlv --vgname=redhatvg --size=1024
  63. logvol /home --fstype ext3 --name=homelv --vgname=redhatvg --size=1024

  64. %packages
  65. @base
  66. @core
  67. @development-tools
  68. @base-x
  69. @x-software-development
  70. @gnome-desktop
  71. @admin-tools
  72. @gnome-software-development
  73. @development-libs
  74. @legacy-software-development
  75. @legacy-software-support
  76. @system-tools
  77. @editors
  78. @java-development
  79. @java
  80. @text-internet
  81. @graphical-internet
  82. kexec-tools
  83. iscsi-initiator-utils
  84. fipscheck
  85. device-mapper-multipath
  86. sgpio
  87. python-dmidecode
  88. imake
  89. emacs
  90. audit
  91. mesa-libGLU-devel
  92. xorg-x11-utils
  93. xorg-x11-server-Xnest
  94. xorg-x11-server-Xvfb
  95. -nspluginwrapper


  96. default文件内容:
  97. default web
  98. prompt 1
  99. timeout 100
  100. display boot.msg
  101. F1 boot.msg
  102. F2 options.msg
  103. F3 general.msg
  104. F4 param.msg
  105. F5 rescue.msg
  106. label web
  107.   kernel rhel5.7/vmlinuz
  108.   append initrd=rhel5.7/initrd.img ks=ftp://ftp:ftp@172.16.100.1/ks/web.cfg
  109. label db
  110.   kernel rhel5.7/vmlinuz
  111.   append initrd=rhel5.7/initrd.img ks=ftp://ftp:ftp@172.16.100.1/ks/db.cfg
  112. label text
  113.   kernel rhel5.7/vmlinuz
  114.   append initrd=rhel5.7/initrd.img text
  115. label ks
  116.   kernel rhel5.7/vmlinuz
  117.   append ks initrd=rhel5.7/initrd.img
  118. label local
  119.   localboot 1
  120. label memtest86
  121.   kernel rhel5.7/memtest
  122.   append -
复制代码
tftpd32的配置就看下图了。

论坛徽章:
0
2 [报告]
发表于 2012-07-05 17:22 |只看该作者
好贴,mark下~

论坛徽章:
13
15-16赛季CBA联赛之同曦
日期:2016-01-28 19:52:032015亚冠之北京国安
日期:2015-10-07 14:28:19NBA常规赛纪念章
日期:2015-05-04 22:32:03处女座
日期:2015-01-15 19:45:44卯兔
日期:2014-10-28 16:17:14白羊座
日期:2014-05-24 15:10:46寅虎
日期:2014-05-10 09:50:35白羊座
日期:2014-03-12 20:52:17午马
日期:2014-03-01 08:37:27射手座
日期:2014-02-19 19:26:54子鼠
日期:2013-11-30 09:03:56狮子座
日期:2013-09-08 08:37:52
3 [报告]
发表于 2012-07-05 17:22 |只看该作者
不错 感谢分享 精华帖 ^_^

论坛徽章:
0
4 [报告]
发表于 2012-07-06 10:04 |只看该作者
感谢分享 yum 源的这句我从来没写过 是不是就是解决软件少KEY的办法啊
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

论坛徽章:
7
双子座
日期:2013-09-09 15:55:31CU大牛徽章
日期:2013-09-18 15:22:06CU大牛徽章
日期:2013-09-18 15:22:20CU大牛徽章
日期:2013-09-18 15:22:26CU大牛徽章
日期:2013-09-18 15:22:31CU大牛徽章
日期:2013-09-18 15:22:37CU大牛徽章
日期:2013-09-18 15:22:46
5 [报告]
发表于 2012-07-06 12:00 |只看该作者
boke19880201 发表于 2012-07-06 10:04
感谢分享 yum 源的这句我从来没写过 是不是就是解决软件少KEY的办法啊
gpgkey=file:///etc/pki/rpm-gpg/RP ...
这句其实用本地源无所谓的,直接把gpgcheck关掉就好了

论坛徽章:
0
6 [报告]
发表于 2012-08-20 18:00 |只看该作者
好贴,顶起

论坛徽章:
0
7 [报告]
发表于 2012-08-21 15:39 |只看该作者
好贴
绝对收藏了

论坛徽章:
0
8 [报告]
发表于 2012-11-16 12:33 |只看该作者
这个方法好,试试看。

论坛徽章:
0
9 [报告]
发表于 2014-06-05 15:44 |只看该作者
暮然回首。。。

论坛徽章:
0
10 [报告]
发表于 2014-06-05 15:46 |只看该作者
cu高人特别多。。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP