就是说不需要安装系统,直接用光盘来引导机器,实现web集群,对于快速部署或者测试有极大的便利。因为是看了原文,然后自己加了些注释,所以一般注释都在一段E文之后,请注意阅读顺序。 先看看市场适用性: Quote:
集群架构 Quote:
Load-balancing hardware or software. For hardware, we can use F5 BIG-IP or anything of this kind. This hardware can handle HTTP connections and route them to the correct server. It also knows many tricks and can cache HTTPS. Also, I like it because it runs BSD OS as a managing OS. I'll call it lb01. There are a lot of different load-balancing systems. As a rule they are high configurable but it's usually easy to understand their syntax and write your own configuration. Our example needs to cache SSL and forward plain HTTP to our servers. It should choose the server with the least load and should remove broken ones from the list. All modern load balancers know how to do this well. Data storage. Personally, I like the NetApp NFS server from Network Appliance. It runs BSD, supports the NFS protocol, and works very well. I'll call it as nfs01. Diskless workstations, equipped only with network adapters and CD-ROM drives. Since we'll only use them for web services, I'll call them web01-10. They will run the Apache Web Server and whatever else needed. 架设流程 Quote:
Let's start from the FreeSBIE building process. To build a FreeSBIE LiveCD, we need a FreeBSD station. Preferably, it should run the same hardware configuration as all our cluster machines. In my case, this is an AMD Duron 1200 CPU with 128 MB of RAM. The build station also has a Maxtor 6Y120P0 UDMA 100 hard drive. Our cluster machines do not need this. Finally, the build station also needs a CD-RW or DVD-RW disk drive to burn our CD ISO image, after we build a system, and spare, blank CD-R disks. (CD-RW may be better until you're familiar with the building and burning processes). FreeSBIE has a FreeBSD port at /usr/ports/sysutils/freesbie. I used the version from 7 February 2004, freesbie-20040207.tar.bz2, with a size of 151,799 bytes. The FreeSBIE port is "a collection of scripts that help a user create CDs/DVDs containing a complete operating system based on FreeBSD. It is used as 'live-CD' and boots straight from CD." FreeSBIE uses compression to store a lot of software on the LiveFS file system. The FreeSBIE site has pre-built LiveCD ISO images. When I wrote this article they had the following: Latest ISO: FreeSBIE-1.0-i386 FreeSBIE-1.0-i386.iso ISO image 565,504 Kb 02/27/2004 12:22:00 If the default functions and configuration is OK for you, you can use these images. For our configuration we'll need to customize the defaults. ::以上是官方现成的ISO,如果配置和你的机器差不多,可以用现成的。 The first step is to build an ISO image to burn to a blank CD-R or CD-RW disk. The install process requires the following files: freesbie-20040207.tar.bz2 151,799 bytes The collection of scripts. ::自己制作需要的几个文件 Installation is as simple as: $ cd /usr/ports/sysutils/freesbie ::安装freebie The main part of this package is the collection of scripts that live under /usr/local/share/freesbie. The README suggests to run a user interface for the scripts, built using Savio Lam's dialog program. Let's run that ./freesbie. Start it from /usr/local/share/freesbie, since all the scripts use relative, not absolute, paths. ::包的主要部分在/usr/local/share/freesbie,有一个图形界面便于设置,因为所有的脚本是相对路径的,所以进入/usr/local/share/freesbie执行./freesbie The first run of the script, shown in Figure 1, proposes a startup configuration.
We need to set paths and file names about the LiveFS file system to create. Let's put it in /usr/local/livefs. If the directory doesn't exist, the installer will prompt you to create it: ATTENTION PLEASE! The path you have entered does not seems a valid path or the directory does not Do you wish to create it? [ Yes ] No ::设置LiveFS的路径和文件名 We also need to set FreeSBIE's home directory, where the installer will create the kernel configuration file used to build a system. Use the current directory, /usr/local/share/freesbie. ::使用当前目录作为freebie根目录,主要用来生成内核配置文件 Next, set the path to the ISO image to create. The default is /usr/local/share/freesbie/FreeSBIE.iso. I personally would rather not build a custom system in the system-wide directories, though. This will lead you to the main menu, shown in Figure 2. ::设置ISO生成目录
::FreeBIE设置主目录 The first section, Configure, we have already passed in the previous block. So we can move forward. Unfortunately, if you need a help system and press F1 as it advises at the bottom of the screen, it'll take you to a shell. You probably don't need the help, but beware. Let's tackle the menu options in order. Rmdir - Clean the FreeSBIE FS ::清除LiveFS系统文件目录 Mkdir - Create a New FreeSBIE FS ::生成LiveFS系统文件目录 This options starts the 1.mkdir.sh script, which tries to create a directory structure for the new file system. After this happens, the /usr/local/livecd directory will resemble: drwxr-xr-x 2 root wheel 512 23 Feb 17:44 cdrom ./mnt contains the directory structure for the various supported file systems: drwxr-xr-x 2 root wheel 512 23 Feb 17:44 dos.1 The whole directory structure takes about 94 Kbytes now. ::生成的文件系统大概占用94K World - BuildWorld - Create a New World This step runs the 2.buildworld.sh script. It requires that you've installed the src-all package (FreeBSD sources for everything). I suggest that you perform a full upgrade for the whole system through CVSup. It can save you a lot of time and nerves instead of spending hours figuring out why something is not compiling. After the world building has finished, you can look at the results in the default /usr/obj/usr/src directory. In our case it takes up about 419 Mbytes of space. ::编译world目标,这个升级过freebsd的人,应该比较熟悉 Install - InstallWorld - Install New World ::安装生成的系统文件到指定的光盘目录 This option runs the 3.installworld.sh script to install the freshly built world. This step will take less time than the build process. The /usr/local/livefs will then resemble: -rw-r--r-- 2 root wheel 802 23 Feb 19:41 .cshrc Kernel - Build & Install Kernel - Create and Install Kernel ::编译和安装内核 This option runs the 4.kernel.sh script to compile and install a kernel to our LiveFS file system. The default FreeSBIE kernel configuration file is /usr/local/share/freesbie/FREESBIE. [默认内核配置文件]It's based on the GENERIC kernel configuration file with a lot of added options, so you should customize this file. If you're not familiar with the kernel configuration procedure, back up the original file as FREESBIE.orig[备份的默认内核配置文件]. The default configuration produces a kernel of about 5 Mbytes in size, which is definitely too much. After removing support for SCSI, RAID, missing network cards, and ISDN, my kernel size decreased to 2.2 Mbytes. You can do better. ::默认生成的内核大概5M左右,包括大部分驱动程序,是GENERIC加上FreeBIE自己的一些设置的结果。 I advise you to do a kernel compile and install using the /usr/local/share/freesbie/kernel.sh script, but not the visual dialog interface. If any errors appear during the compilation or installation it's hard to see because dialog clears all debug information too fast. ::建议手工使用/usr/local/share/freesbie/kernel.sh脚本来编译内核,因为图形界面下出错信息闪得太快。 After you've finished this step, copy the kernel to the /usr/local/livefs kernel directory. FIXIT - PatchFiles - Copy Cool and Useful Files ::使用5.patchfiles.sh安装补丁 This option runs 5.patchfiles.sh, which adds a lot of different scripts to the LiveFS file system, especially in the scripts/ directory: Patching files in /etc directory... Packages - Packages - Choose Packages to Install ::软件包安装 This options runs the 6.packages.sh script to install additional packages to your LiveFS file system. Figure 3 shows the menu of packages to choose.
The script generates this package list with information from pkg_info. In other words, LiveFS can install only those packages already installed on your build system. If you have installed some of your software manually without using the ports or pkg_add utility, you won't see it in the generated list. As Figure 4 shows, this operation is very similar to using the /stand/sysinstall utility for tuning your FreeBSD installation. ::只能安装已经安装的软件包,安装界面非常类似sysinstall
While choosing necessary packages, keep in mind that you're limited by the space of your storage medium. A CD-R or CD-RW normally holds between 650 and 800 Mbytes. If you use a DVD, you'll have much more room for your software. ::根据cd-r和dvd的空间限制,适当地选择软件包 User - Custom User - Install Shell Script Files and Others ::用户配置.其他软件配置文件 Installing customized files... This is not very useful for server configuration. ::以上步骤是FreeBIE的建议配置,和集群配置关系不大 Build - Build ISO - Create .iso File ::生成ISO文件 There are two different ways to customize the build. The first way is to edit all files in the /usr/local/share/freesbie directory before starting ./freesbie. The second way is to create a LiveFS file structure and then edit necessary files. Certainly, you can combine both of them, but I find the second approach much more sensible. Customizing the System ::讲了半天,还是生成一个LiveCD,下面是自定义集群方法 First, we need to customize the /etc directory on the LiveFS. The /etc/rc.conf file holds hostname and interface configuration. We have no easy way to keep this file on an NFS drive, except for patching the startup scripts. Hopefully GUFI, the main Italian FreeBSD User Group developing FreeSBIE, will simplify this eventually. We can either prepare a different configuration for each server in web01-10 or edit the scripts to mount /etc/rc.conf from nfs01. You can also try to follow the /usr/share/examples/diskless/clone_root instructions of cloning a diskless configuration, although I believe it'll also require a lot of hacking. I have not looked at it closely, but it seemed more oriented to diskless configurations. ::主机名和网卡的设置,没有很简单的方法。需要配置的文件是rc.conf,要么为几台做集群的服务器的每个ISO做不同的设置,要么手工修改启动脚本,另外可以尝试/usr/share/examples/diskless/clone_root做无盘配置,不过对于正式应用,第一种还是最简单的,而且cdr和dvd也不贵。 Once we've set a system hostname and have connected to the network, we must start our services. ::编译fstab,挂载nfs卷 This means we'll need to edit /etc/fstab: nfs01:/startup/usr/local/etc/rc.d/cluster The /usr/local/etc/rc.d/cluster directory holds a startup script for local services. FreeBSD's /etc/rc script mounts NFS file systems before it starts local software, so we won't need any hacks there. ::/startup/usr/local/etc/rc.d/cluster目录包含需要启动的当地服务,freebsd的rc脚本会先加载nfs卷,然后启动这些服务。 Also we need to mount a data directory and software configuration, too: nfs01:/storage/var/web /var/web nfs Ro 0 0 The /var/web directory holds data for our web services. This could be a directory with a complex file structure. Though we shouldn't normally make changes there, we can do this if we mount it in rw mode. nfs01:/startup/usr/local/etc /usr/local/etc nfs ro 0 0 ::以上的配置是分别挂载web数据目录和服务的配置目录,如果需要,可以把etc目录挂载成可读写 To crown it all, nfs01 must store: /startup/usr/local/etc ::nfs服务器上所需要的目录结构,作者吹嘘了一下自己的NetApp NFS server :cool: When we've finished customizing our system, we can prepare an ISO image to burn. It took me no more than two hours to reach this point from the very beginning. I hope it normally would take no more than four or five hours for any professional familiar with FreeBSD to prepare a completely new, highly customized cluster system. You can now burn the ISO image to disk using any operating system or software you like. Under FreeBSD I like the burncd one and on the Windows platform I use Ahead Nero. Here's how to burn the system on a CD-RW disc under FreeBSD: # burncd -s max -f /dev/acd0a blank # burncd -s max -f /dev/acd0a /usr/local/share/freesbie/FreeSBIE.iso fixate ::写ISO到盘 Updates It's also worth mentioning how to keep your systems up-to-date. It's both easy and difficult. I believe that the most correct way to stay current is to keep your build system updated. As a rule, your production system needs infrequent updates — only when FreeBSD has important changes. So, while your build system is up-to-date, you can pass through the build process from the very beginning to create an image for the most recent version. ::关于升级的考虑,无非是重做光盘 Conclusion Now you can take a freshly burned CD disk and put it into the CD-ROM drive of you cluster machines. Boot it, then share your happiness at using such an easy and cost-effective solution with others! |
|||


最新评论
2 周 5 天 前
18 周 13 小时 前
19 周 1 天 前
37 周 1 天 前
37 周 1 天 前
48 周 2 天 前
1 年 7 周 前
1 年 8 周 前
1 年 11 周 前
1 年 12 周 前